@@ -14,7 +14,7 @@ |
||
| 14 | 14 | /** |
| 15 | 15 | * Get SQL query part for filter used |
| 16 | 16 | * @param Array $filter the filter |
| 17 | - * @return Array the SQL part |
|
| 17 | + * @return string the SQL part |
|
| 18 | 18 | */ |
| 19 | 19 | public function getFilter($filter = array(),$where = false,$and = false) { |
| 20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
@@ -10,10 +10,10 @@ discard block |
||
| 10 | 10 | } |
| 11 | 11 | |
| 12 | 12 | /** |
| 13 | - * Get SQL query part for filter used |
|
| 14 | - * @param Array $filter the filter |
|
| 15 | - * @return Array the SQL part |
|
| 16 | - */ |
|
| 13 | + * Get SQL query part for filter used |
|
| 14 | + * @param Array $filter the filter |
|
| 15 | + * @return Array the SQL part |
|
| 16 | + */ |
|
| 17 | 17 | public function getFilter($filter = array(),$where = false,$and = false) { |
| 18 | 18 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
| 19 | 19 | $filters = array(); |
@@ -151,44 +151,44 @@ discard block |
||
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | |
| 154 | - /** |
|
| 155 | - * Gets all the spotter information based on a particular callsign |
|
| 156 | - * |
|
| 157 | - * @return Array the spotter information |
|
| 158 | - * |
|
| 159 | - */ |
|
| 160 | - public function getLastArchiveSpotterDataByIdent($ident) |
|
| 161 | - { |
|
| 154 | + /** |
|
| 155 | + * Gets all the spotter information based on a particular callsign |
|
| 156 | + * |
|
| 157 | + * @return Array the spotter information |
|
| 158 | + * |
|
| 159 | + */ |
|
| 160 | + public function getLastArchiveSpotterDataByIdent($ident) |
|
| 161 | + { |
|
| 162 | 162 | $Spotter = new Spotter($this->db); |
| 163 | - date_default_timezone_set('UTC'); |
|
| 163 | + date_default_timezone_set('UTC'); |
|
| 164 | 164 | |
| 165 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 166 | - //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
| 167 | - $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
| 165 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 166 | + //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
| 167 | + $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
| 168 | 168 | |
| 169 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident)); |
|
| 169 | + $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident)); |
|
| 170 | 170 | |
| 171 | - return $spotter_array; |
|
| 172 | - } |
|
| 171 | + return $spotter_array; |
|
| 172 | + } |
|
| 173 | 173 | |
| 174 | 174 | |
| 175 | - /** |
|
| 176 | - * Gets last the spotter information based on a particular id |
|
| 177 | - * |
|
| 178 | - * @return Array the spotter information |
|
| 179 | - * |
|
| 180 | - */ |
|
| 181 | - public function getLastArchiveSpotterDataById($id) |
|
| 182 | - { |
|
| 183 | - $Spotter = new Spotter($this->db); |
|
| 184 | - date_default_timezone_set('UTC'); |
|
| 185 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 186 | - //$query = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id"; |
|
| 187 | - //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
| 188 | - $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
| 175 | + /** |
|
| 176 | + * Gets last the spotter information based on a particular id |
|
| 177 | + * |
|
| 178 | + * @return Array the spotter information |
|
| 179 | + * |
|
| 180 | + */ |
|
| 181 | + public function getLastArchiveSpotterDataById($id) |
|
| 182 | + { |
|
| 183 | + $Spotter = new Spotter($this->db); |
|
| 184 | + date_default_timezone_set('UTC'); |
|
| 185 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 186 | + //$query = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id"; |
|
| 187 | + //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
| 188 | + $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
| 189 | 189 | |
| 190 | 190 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
| 191 | - /* |
|
| 191 | + /* |
|
| 192 | 192 | try { |
| 193 | 193 | $Connection = new Connection(); |
| 194 | 194 | $sth = Connection->$db->prepare($query); |
@@ -198,122 +198,122 @@ discard block |
||
| 198 | 198 | } |
| 199 | 199 | $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC); |
| 200 | 200 | */ |
| 201 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id)); |
|
| 202 | - |
|
| 203 | - return $spotter_array; |
|
| 204 | - } |
|
| 205 | - |
|
| 206 | - /** |
|
| 207 | - * Gets all the spotter information based on a particular id |
|
| 208 | - * |
|
| 209 | - * @return Array the spotter information |
|
| 210 | - * |
|
| 211 | - */ |
|
| 212 | - public function getAllArchiveSpotterDataById($id) |
|
| 201 | + $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id)); |
|
| 202 | + |
|
| 203 | + return $spotter_array; |
|
| 204 | + } |
|
| 205 | + |
|
| 206 | + /** |
|
| 207 | + * Gets all the spotter information based on a particular id |
|
| 208 | + * |
|
| 209 | + * @return Array the spotter information |
|
| 210 | + * |
|
| 211 | + */ |
|
| 212 | + public function getAllArchiveSpotterDataById($id) |
|
| 213 | 213 | { |
| 214 | - date_default_timezone_set('UTC'); |
|
| 215 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 216 | - $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
| 214 | + date_default_timezone_set('UTC'); |
|
| 215 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 216 | + $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
| 217 | 217 | |
| 218 | 218 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
| 219 | 219 | |
| 220 | - try { |
|
| 221 | - $sth = $this->db->prepare($query); |
|
| 222 | - $sth->execute(array(':id' => $id)); |
|
| 223 | - } catch(PDOException $e) { |
|
| 224 | - echo $e->getMessage(); |
|
| 225 | - die; |
|
| 226 | - } |
|
| 227 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 228 | - |
|
| 229 | - return $spotter_array; |
|
| 230 | - } |
|
| 231 | - |
|
| 232 | - /** |
|
| 233 | - * Gets coordinate & time spotter information based on a particular id |
|
| 234 | - * |
|
| 235 | - * @return Array the spotter information |
|
| 236 | - * |
|
| 237 | - */ |
|
| 238 | - public function getCoordArchiveSpotterDataById($id) |
|
| 239 | - { |
|
| 240 | - date_default_timezone_set('UTC'); |
|
| 241 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 242 | - $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
| 220 | + try { |
|
| 221 | + $sth = $this->db->prepare($query); |
|
| 222 | + $sth->execute(array(':id' => $id)); |
|
| 223 | + } catch(PDOException $e) { |
|
| 224 | + echo $e->getMessage(); |
|
| 225 | + die; |
|
| 226 | + } |
|
| 227 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 228 | + |
|
| 229 | + return $spotter_array; |
|
| 230 | + } |
|
| 231 | + |
|
| 232 | + /** |
|
| 233 | + * Gets coordinate & time spotter information based on a particular id |
|
| 234 | + * |
|
| 235 | + * @return Array the spotter information |
|
| 236 | + * |
|
| 237 | + */ |
|
| 238 | + public function getCoordArchiveSpotterDataById($id) |
|
| 239 | + { |
|
| 240 | + date_default_timezone_set('UTC'); |
|
| 241 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 242 | + $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
| 243 | 243 | |
| 244 | 244 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
| 245 | 245 | |
| 246 | - try { |
|
| 247 | - $sth = $this->db->prepare($query); |
|
| 248 | - $sth->execute(array(':id' => $id)); |
|
| 249 | - } catch(PDOException $e) { |
|
| 250 | - echo $e->getMessage(); |
|
| 251 | - die; |
|
| 252 | - } |
|
| 253 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 246 | + try { |
|
| 247 | + $sth = $this->db->prepare($query); |
|
| 248 | + $sth->execute(array(':id' => $id)); |
|
| 249 | + } catch(PDOException $e) { |
|
| 250 | + echo $e->getMessage(); |
|
| 251 | + die; |
|
| 252 | + } |
|
| 253 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 254 | 254 | |
| 255 | - return $spotter_array; |
|
| 256 | - } |
|
| 255 | + return $spotter_array; |
|
| 256 | + } |
|
| 257 | 257 | |
| 258 | 258 | |
| 259 | - /** |
|
| 260 | - * Gets altitude information based on a particular callsign |
|
| 261 | - * |
|
| 262 | - * @return Array the spotter information |
|
| 263 | - * |
|
| 264 | - */ |
|
| 265 | - public function getAltitudeArchiveSpotterDataByIdent($ident) |
|
| 266 | - { |
|
| 259 | + /** |
|
| 260 | + * Gets altitude information based on a particular callsign |
|
| 261 | + * |
|
| 262 | + * @return Array the spotter information |
|
| 263 | + * |
|
| 264 | + */ |
|
| 265 | + public function getAltitudeArchiveSpotterDataByIdent($ident) |
|
| 266 | + { |
|
| 267 | 267 | |
| 268 | - date_default_timezone_set('UTC'); |
|
| 268 | + date_default_timezone_set('UTC'); |
|
| 269 | 269 | |
| 270 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 271 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
| 270 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 271 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
| 272 | 272 | |
| 273 | - try { |
|
| 274 | - $sth = $this->db->prepare($query); |
|
| 275 | - $sth->execute(array(':ident' => $ident)); |
|
| 276 | - } catch(PDOException $e) { |
|
| 277 | - echo $e->getMessage(); |
|
| 278 | - die; |
|
| 279 | - } |
|
| 280 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 273 | + try { |
|
| 274 | + $sth = $this->db->prepare($query); |
|
| 275 | + $sth->execute(array(':ident' => $ident)); |
|
| 276 | + } catch(PDOException $e) { |
|
| 277 | + echo $e->getMessage(); |
|
| 278 | + die; |
|
| 279 | + } |
|
| 280 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 281 | 281 | |
| 282 | - return $spotter_array; |
|
| 283 | - } |
|
| 282 | + return $spotter_array; |
|
| 283 | + } |
|
| 284 | 284 | |
| 285 | - /** |
|
| 286 | - * Gets altitude information based on a particular id |
|
| 287 | - * |
|
| 288 | - * @return Array the spotter information |
|
| 289 | - * |
|
| 290 | - */ |
|
| 291 | - public function getAltitudeArchiveSpotterDataById($id) |
|
| 292 | - { |
|
| 285 | + /** |
|
| 286 | + * Gets altitude information based on a particular id |
|
| 287 | + * |
|
| 288 | + * @return Array the spotter information |
|
| 289 | + * |
|
| 290 | + */ |
|
| 291 | + public function getAltitudeArchiveSpotterDataById($id) |
|
| 292 | + { |
|
| 293 | 293 | |
| 294 | - date_default_timezone_set('UTC'); |
|
| 294 | + date_default_timezone_set('UTC'); |
|
| 295 | 295 | |
| 296 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 297 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
| 296 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 297 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
| 298 | 298 | |
| 299 | - try { |
|
| 300 | - $sth = $this->db->prepare($query); |
|
| 301 | - $sth->execute(array(':id' => $id)); |
|
| 302 | - } catch(PDOException $e) { |
|
| 303 | - echo $e->getMessage(); |
|
| 304 | - die; |
|
| 305 | - } |
|
| 306 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 299 | + try { |
|
| 300 | + $sth = $this->db->prepare($query); |
|
| 301 | + $sth->execute(array(':id' => $id)); |
|
| 302 | + } catch(PDOException $e) { |
|
| 303 | + echo $e->getMessage(); |
|
| 304 | + die; |
|
| 305 | + } |
|
| 306 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 307 | 307 | |
| 308 | - return $spotter_array; |
|
| 309 | - } |
|
| 308 | + return $spotter_array; |
|
| 309 | + } |
|
| 310 | 310 | |
| 311 | - /** |
|
| 312 | - * Gets altitude & speed information based on a particular id |
|
| 313 | - * |
|
| 314 | - * @return Array the spotter information |
|
| 315 | - * |
|
| 316 | - */ |
|
| 311 | + /** |
|
| 312 | + * Gets altitude & speed information based on a particular id |
|
| 313 | + * |
|
| 314 | + * @return Array the spotter information |
|
| 315 | + * |
|
| 316 | + */ |
|
| 317 | 317 | public function getAltitudeSpeedArchiveSpotterDataById($id) |
| 318 | 318 | { |
| 319 | 319 | date_default_timezone_set('UTC'); |
@@ -330,12 +330,12 @@ discard block |
||
| 330 | 330 | return $spotter_array; |
| 331 | 331 | } |
| 332 | 332 | |
| 333 | - /** |
|
| 334 | - * Gets altitude information based on a particular callsign |
|
| 335 | - * |
|
| 336 | - * @return Array the spotter information |
|
| 337 | - * |
|
| 338 | - */ |
|
| 333 | + /** |
|
| 334 | + * Gets altitude information based on a particular callsign |
|
| 335 | + * |
|
| 336 | + * @return Array the spotter information |
|
| 337 | + * |
|
| 338 | + */ |
|
| 339 | 339 | public function getLastAltitudeArchiveSpotterDataByIdent($ident) |
| 340 | 340 | { |
| 341 | 341 | date_default_timezone_set('UTC'); |
@@ -355,12 +355,12 @@ discard block |
||
| 355 | 355 | |
| 356 | 356 | |
| 357 | 357 | |
| 358 | - /** |
|
| 359 | - * Gets all the archive spotter information |
|
| 360 | - * |
|
| 361 | - * @return Array the spotter information |
|
| 362 | - * |
|
| 363 | - */ |
|
| 358 | + /** |
|
| 359 | + * Gets all the archive spotter information |
|
| 360 | + * |
|
| 361 | + * @return Array the spotter information |
|
| 362 | + * |
|
| 363 | + */ |
|
| 364 | 364 | public function getSpotterArchiveData($ident,$flightaware_id,$date) |
| 365 | 365 | { |
| 366 | 366 | $Spotter = new Spotter($this->db); |
@@ -388,34 +388,34 @@ discard block |
||
| 388 | 388 | } |
| 389 | 389 | |
| 390 | 390 | /** |
| 391 | - * Gets Minimal Live Spotter data |
|
| 392 | - * |
|
| 393 | - * @return Array the spotter information |
|
| 394 | - * |
|
| 395 | - */ |
|
| 396 | - public function getMinLiveSpotterData($begindate,$enddate,$filter = array()) |
|
| 397 | - { |
|
| 398 | - global $globalDBdriver, $globalLiveInterval; |
|
| 399 | - date_default_timezone_set('UTC'); |
|
| 400 | - |
|
| 401 | - $filter_query = ''; |
|
| 402 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 403 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 404 | - } |
|
| 405 | - // Use spotter_output also ? |
|
| 406 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 407 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 408 | - } |
|
| 409 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 410 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
| 411 | - } |
|
| 412 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 413 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 414 | - } |
|
| 391 | + * Gets Minimal Live Spotter data |
|
| 392 | + * |
|
| 393 | + * @return Array the spotter information |
|
| 394 | + * |
|
| 395 | + */ |
|
| 396 | + public function getMinLiveSpotterData($begindate,$enddate,$filter = array()) |
|
| 397 | + { |
|
| 398 | + global $globalDBdriver, $globalLiveInterval; |
|
| 399 | + date_default_timezone_set('UTC'); |
|
| 400 | + |
|
| 401 | + $filter_query = ''; |
|
| 402 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 403 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 404 | + } |
|
| 405 | + // Use spotter_output also ? |
|
| 406 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 407 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 408 | + } |
|
| 409 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 410 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
| 411 | + } |
|
| 412 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 413 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 414 | + } |
|
| 415 | 415 | |
| 416 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 417 | - if ($globalDBdriver == 'mysql') { |
|
| 418 | - /* |
|
| 416 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 417 | + if ($globalDBdriver == 'mysql') { |
|
| 418 | + /* |
|
| 419 | 419 | $query = 'SELECT a.aircraft_shadow, spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk |
| 420 | 420 | FROM spotter_archive |
| 421 | 421 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao'; |
@@ -434,56 +434,56 @@ discard block |
||
| 434 | 434 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao |
| 435 | 435 | WHERE spotter_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' |
| 436 | 436 | '.$filter_query.' ORDER BY flightaware_id'; |
| 437 | - } else { |
|
| 438 | - //$query = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao'; |
|
| 439 | - $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 437 | + } else { |
|
| 438 | + //$query = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao'; |
|
| 439 | + $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 440 | 440 | FROM spotter_archive |
| 441 | 441 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao |
| 442 | 442 | WHERE spotter_archive.date >= '."'".$begindate."'".' AND spotter_archive.date <= '."'".$enddate."'".' |
| 443 | 443 | '.$filter_query.' ORDER BY flightaware_id'; |
| 444 | - } |
|
| 445 | - //echo $query; |
|
| 446 | - try { |
|
| 447 | - $sth = $this->db->prepare($query); |
|
| 448 | - $sth->execute(); |
|
| 449 | - } catch(PDOException $e) { |
|
| 450 | - echo $e->getMessage(); |
|
| 451 | - die; |
|
| 452 | - } |
|
| 453 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 444 | + } |
|
| 445 | + //echo $query; |
|
| 446 | + try { |
|
| 447 | + $sth = $this->db->prepare($query); |
|
| 448 | + $sth->execute(); |
|
| 449 | + } catch(PDOException $e) { |
|
| 450 | + echo $e->getMessage(); |
|
| 451 | + die; |
|
| 452 | + } |
|
| 453 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 454 | 454 | |
| 455 | - return $spotter_array; |
|
| 456 | - } |
|
| 455 | + return $spotter_array; |
|
| 456 | + } |
|
| 457 | 457 | |
| 458 | 458 | /** |
| 459 | - * Gets Minimal Live Spotter data |
|
| 460 | - * |
|
| 461 | - * @return Array the spotter information |
|
| 462 | - * |
|
| 463 | - */ |
|
| 464 | - public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array()) |
|
| 465 | - { |
|
| 466 | - global $globalDBdriver, $globalLiveInterval; |
|
| 467 | - date_default_timezone_set('UTC'); |
|
| 468 | - |
|
| 469 | - $filter_query = ''; |
|
| 470 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 471 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 472 | - } |
|
| 473 | - // Should use spotter_output also ? |
|
| 474 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 475 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 476 | - } |
|
| 477 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 478 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
| 479 | - } |
|
| 480 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 481 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 482 | - } |
|
| 459 | + * Gets Minimal Live Spotter data |
|
| 460 | + * |
|
| 461 | + * @return Array the spotter information |
|
| 462 | + * |
|
| 463 | + */ |
|
| 464 | + public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array()) |
|
| 465 | + { |
|
| 466 | + global $globalDBdriver, $globalLiveInterval; |
|
| 467 | + date_default_timezone_set('UTC'); |
|
| 468 | + |
|
| 469 | + $filter_query = ''; |
|
| 470 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 471 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 472 | + } |
|
| 473 | + // Should use spotter_output also ? |
|
| 474 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 475 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 476 | + } |
|
| 477 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 478 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
| 479 | + } |
|
| 480 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 481 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 482 | + } |
|
| 483 | 483 | |
| 484 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 485 | - if ($globalDBdriver == 'mysql') { |
|
| 486 | - /* |
|
| 484 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 485 | + if ($globalDBdriver == 'mysql') { |
|
| 486 | + /* |
|
| 487 | 487 | $query = 'SELECT a.aircraft_shadow, spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk |
| 488 | 488 | FROM spotter_archive |
| 489 | 489 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao'; |
@@ -494,95 +494,95 @@ discard block |
||
| 494 | 494 | WHERE (spotter_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
| 495 | 495 | '.$filter_query.' GROUP BY spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao, spotter_archive_output.arrival_airport_icao, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow'; |
| 496 | 496 | |
| 497 | - } else { |
|
| 498 | - //$query = 'SELECT spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow FROM spotter_archive_output INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive_output.flightaware_id = s.flightaware_id AND spotter_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao'; |
|
| 499 | - /* |
|
| 497 | + } else { |
|
| 498 | + //$query = 'SELECT spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow FROM spotter_archive_output INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive_output.flightaware_id = s.flightaware_id AND spotter_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao'; |
|
| 499 | + /* |
|
| 500 | 500 | $query = 'SELECT spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow |
| 501 | 501 | FROM spotter_archive_output |
| 502 | 502 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao |
| 503 | 503 | WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".' |
| 504 | 504 | '.$filter_query.' GROUP BY spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao, spotter_archive_output.arrival_airport_icao, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow'; |
| 505 | 505 | */ |
| 506 | - $query = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow |
|
| 506 | + $query = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow |
|
| 507 | 507 | FROM spotter_archive_output |
| 508 | 508 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao |
| 509 | 509 | WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".' |
| 510 | 510 | '.$filter_query.' LIMIT 200 OFFSET 0'; |
| 511 | 511 | // .' GROUP BY spotter_output.flightaware_id, spotter_output.ident, spotter_output.aircraft_icao, spotter_output.departure_airport_icao, spotter_output.arrival_airport_icao, spotter_output.latitude, spotter_output.longitude, spotter_output.altitude, spotter_output.heading, spotter_output.ground_speed, spotter_output.squawk, a.aircraft_shadow'; |
| 512 | 512 | |
| 513 | - } |
|
| 514 | - //echo $query; |
|
| 515 | - try { |
|
| 516 | - $sth = $this->db->prepare($query); |
|
| 517 | - $sth->execute(); |
|
| 518 | - } catch(PDOException $e) { |
|
| 519 | - echo $e->getMessage(); |
|
| 520 | - die; |
|
| 521 | - } |
|
| 522 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 513 | + } |
|
| 514 | + //echo $query; |
|
| 515 | + try { |
|
| 516 | + $sth = $this->db->prepare($query); |
|
| 517 | + $sth->execute(); |
|
| 518 | + } catch(PDOException $e) { |
|
| 519 | + echo $e->getMessage(); |
|
| 520 | + die; |
|
| 521 | + } |
|
| 522 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 523 | 523 | |
| 524 | - return $spotter_array; |
|
| 525 | - } |
|
| 524 | + return $spotter_array; |
|
| 525 | + } |
|
| 526 | 526 | |
| 527 | 527 | /** |
| 528 | - * Gets count Live Spotter data |
|
| 529 | - * |
|
| 530 | - * @return Array the spotter information |
|
| 531 | - * |
|
| 532 | - */ |
|
| 533 | - public function getLiveSpotterCount($begindate,$enddate,$filter = array()) |
|
| 534 | - { |
|
| 535 | - global $globalDBdriver, $globalLiveInterval; |
|
| 536 | - date_default_timezone_set('UTC'); |
|
| 537 | - |
|
| 538 | - $filter_query = ''; |
|
| 539 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 540 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 541 | - } |
|
| 542 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 543 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 544 | - } |
|
| 545 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 546 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
| 547 | - } |
|
| 548 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 549 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 550 | - } |
|
| 528 | + * Gets count Live Spotter data |
|
| 529 | + * |
|
| 530 | + * @return Array the spotter information |
|
| 531 | + * |
|
| 532 | + */ |
|
| 533 | + public function getLiveSpotterCount($begindate,$enddate,$filter = array()) |
|
| 534 | + { |
|
| 535 | + global $globalDBdriver, $globalLiveInterval; |
|
| 536 | + date_default_timezone_set('UTC'); |
|
| 551 | 537 | |
| 552 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 553 | - if ($globalDBdriver == 'mysql') { |
|
| 538 | + $filter_query = ''; |
|
| 539 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 540 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 541 | + } |
|
| 542 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 543 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 544 | + } |
|
| 545 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 546 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
| 547 | + } |
|
| 548 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 549 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 550 | + } |
|
| 551 | + |
|
| 552 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 553 | + if ($globalDBdriver == 'mysql') { |
|
| 554 | 554 | $query = 'SELECT COUNT(DISTINCT flightaware_id) as nb |
| 555 | 555 | FROM spotter_archive l |
| 556 | 556 | WHERE (l.date BETWEEN DATE_SUB('."'".$begindate."'".',INTERVAL '.$globalLiveInterval.' SECOND) AND '."'".$begindate."'".')'.$filter_query; |
| 557 | - } else { |
|
| 557 | + } else { |
|
| 558 | 558 | $query = 'SELECT COUNT(DISTINCT flightaware_id) as nb FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."' - INTERVAL '".$globalLiveInterval." SECONDS' AND "."'".$enddate."'".')'.$filter_query; |
| 559 | - } |
|
| 560 | - //echo $query; |
|
| 561 | - try { |
|
| 562 | - $sth = $this->db->prepare($query); |
|
| 563 | - $sth->execute(); |
|
| 564 | - } catch(PDOException $e) { |
|
| 565 | - echo $e->getMessage(); |
|
| 566 | - die; |
|
| 567 | - } |
|
| 559 | + } |
|
| 560 | + //echo $query; |
|
| 561 | + try { |
|
| 562 | + $sth = $this->db->prepare($query); |
|
| 563 | + $sth->execute(); |
|
| 564 | + } catch(PDOException $e) { |
|
| 565 | + echo $e->getMessage(); |
|
| 566 | + die; |
|
| 567 | + } |
|
| 568 | 568 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
| 569 | 569 | $sth->closeCursor(); |
| 570 | - return $result['nb']; |
|
| 570 | + return $result['nb']; |
|
| 571 | 571 | |
| 572 | - } |
|
| 572 | + } |
|
| 573 | 573 | |
| 574 | 574 | |
| 575 | 575 | |
| 576 | 576 | // Spotter_Archive_output |
| 577 | 577 | |
| 578 | - /** |
|
| 579 | - * Gets all the spotter information |
|
| 580 | - * |
|
| 581 | - * @return Array the spotter information |
|
| 582 | - * |
|
| 583 | - */ |
|
| 584 | - public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array()) |
|
| 585 | - { |
|
| 578 | + /** |
|
| 579 | + * Gets all the spotter information |
|
| 580 | + * |
|
| 581 | + * @return Array the spotter information |
|
| 582 | + * |
|
| 583 | + */ |
|
| 584 | + public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array()) |
|
| 585 | + { |
|
| 586 | 586 | global $globalTimezone, $globalDBdriver; |
| 587 | 587 | require_once(dirname(__FILE__).'/class.Translation.php'); |
| 588 | 588 | $Translation = new Translation($this->db); |
@@ -596,159 +596,159 @@ discard block |
||
| 596 | 596 | $filter_query = $this->getFilter($filters); |
| 597 | 597 | if ($q != "") |
| 598 | 598 | { |
| 599 | - if (!is_string($q)) |
|
| 600 | - { |
|
| 599 | + if (!is_string($q)) |
|
| 600 | + { |
|
| 601 | 601 | return false; |
| 602 | - } else { |
|
| 602 | + } else { |
|
| 603 | 603 | |
| 604 | 604 | $q_array = explode(" ", $q); |
| 605 | 605 | |
| 606 | 606 | foreach ($q_array as $q_item){ |
| 607 | - $additional_query .= " AND ("; |
|
| 608 | - $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
| 609 | - $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
| 610 | - $additional_query .= "(spotter_archive_output.aircraft_name like '%".$q_item."%') OR "; |
|
| 611 | - $additional_query .= "(spotter_archive_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
|
| 612 | - $additional_query .= "(spotter_archive_output.airline_icao like '%".$q_item."%') OR "; |
|
| 613 | - $additional_query .= "(spotter_archive_output.airline_name like '%".$q_item."%') OR "; |
|
| 614 | - $additional_query .= "(spotter_archive_output.airline_country like '%".$q_item."%') OR "; |
|
| 615 | - $additional_query .= "(spotter_archive_output.departure_airport_icao like '%".$q_item."%') OR "; |
|
| 616 | - $additional_query .= "(spotter_archive_output.departure_airport_name like '%".$q_item."%') OR "; |
|
| 617 | - $additional_query .= "(spotter_archive_output.departure_airport_city like '%".$q_item."%') OR "; |
|
| 618 | - $additional_query .= "(spotter_archive_output.departure_airport_country like '%".$q_item."%') OR "; |
|
| 619 | - $additional_query .= "(spotter_archive_output.arrival_airport_icao like '%".$q_item."%') OR "; |
|
| 620 | - $additional_query .= "(spotter_archive_output.arrival_airport_name like '%".$q_item."%') OR "; |
|
| 621 | - $additional_query .= "(spotter_archive_output.arrival_airport_city like '%".$q_item."%') OR "; |
|
| 622 | - $additional_query .= "(spotter_archive_output.arrival_airport_country like '%".$q_item."%') OR "; |
|
| 623 | - $additional_query .= "(spotter_archive_output.registration like '%".$q_item."%') OR "; |
|
| 624 | - $additional_query .= "(spotter_archive_output.owner_name like '%".$q_item."%') OR "; |
|
| 625 | - $additional_query .= "(spotter_archive_output.pilot_id like '%".$q_item."%') OR "; |
|
| 626 | - $additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR "; |
|
| 627 | - $additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR "; |
|
| 628 | - $translate = $Translation->ident2icao($q_item); |
|
| 629 | - if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR "; |
|
| 630 | - $additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')"; |
|
| 631 | - $additional_query .= ")"; |
|
| 607 | + $additional_query .= " AND ("; |
|
| 608 | + $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
| 609 | + $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
| 610 | + $additional_query .= "(spotter_archive_output.aircraft_name like '%".$q_item."%') OR "; |
|
| 611 | + $additional_query .= "(spotter_archive_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
|
| 612 | + $additional_query .= "(spotter_archive_output.airline_icao like '%".$q_item."%') OR "; |
|
| 613 | + $additional_query .= "(spotter_archive_output.airline_name like '%".$q_item."%') OR "; |
|
| 614 | + $additional_query .= "(spotter_archive_output.airline_country like '%".$q_item."%') OR "; |
|
| 615 | + $additional_query .= "(spotter_archive_output.departure_airport_icao like '%".$q_item."%') OR "; |
|
| 616 | + $additional_query .= "(spotter_archive_output.departure_airport_name like '%".$q_item."%') OR "; |
|
| 617 | + $additional_query .= "(spotter_archive_output.departure_airport_city like '%".$q_item."%') OR "; |
|
| 618 | + $additional_query .= "(spotter_archive_output.departure_airport_country like '%".$q_item."%') OR "; |
|
| 619 | + $additional_query .= "(spotter_archive_output.arrival_airport_icao like '%".$q_item."%') OR "; |
|
| 620 | + $additional_query .= "(spotter_archive_output.arrival_airport_name like '%".$q_item."%') OR "; |
|
| 621 | + $additional_query .= "(spotter_archive_output.arrival_airport_city like '%".$q_item."%') OR "; |
|
| 622 | + $additional_query .= "(spotter_archive_output.arrival_airport_country like '%".$q_item."%') OR "; |
|
| 623 | + $additional_query .= "(spotter_archive_output.registration like '%".$q_item."%') OR "; |
|
| 624 | + $additional_query .= "(spotter_archive_output.owner_name like '%".$q_item."%') OR "; |
|
| 625 | + $additional_query .= "(spotter_archive_output.pilot_id like '%".$q_item."%') OR "; |
|
| 626 | + $additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR "; |
|
| 627 | + $additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR "; |
|
| 628 | + $translate = $Translation->ident2icao($q_item); |
|
| 629 | + if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR "; |
|
| 630 | + $additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')"; |
|
| 631 | + $additional_query .= ")"; |
|
| 632 | + } |
|
| 632 | 633 | } |
| 633 | - } |
|
| 634 | 634 | } |
| 635 | 635 | |
| 636 | 636 | if ($registration != "") |
| 637 | 637 | { |
| 638 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 639 | - if (!is_string($registration)) |
|
| 640 | - { |
|
| 638 | + $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 639 | + if (!is_string($registration)) |
|
| 640 | + { |
|
| 641 | 641 | return false; |
| 642 | - } else { |
|
| 642 | + } else { |
|
| 643 | 643 | $additional_query .= " AND (spotter_archive_output.registration = '".$registration."')"; |
| 644 | - } |
|
| 644 | + } |
|
| 645 | 645 | } |
| 646 | 646 | |
| 647 | 647 | if ($aircraft_icao != "") |
| 648 | 648 | { |
| 649 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 650 | - if (!is_string($aircraft_icao)) |
|
| 651 | - { |
|
| 649 | + $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 650 | + if (!is_string($aircraft_icao)) |
|
| 651 | + { |
|
| 652 | 652 | return false; |
| 653 | - } else { |
|
| 653 | + } else { |
|
| 654 | 654 | $additional_query .= " AND (spotter_archive_output.aircraft_icao = '".$aircraft_icao."')"; |
| 655 | - } |
|
| 655 | + } |
|
| 656 | 656 | } |
| 657 | 657 | |
| 658 | 658 | if ($aircraft_manufacturer != "") |
| 659 | 659 | { |
| 660 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
| 661 | - if (!is_string($aircraft_manufacturer)) |
|
| 662 | - { |
|
| 660 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
| 661 | + if (!is_string($aircraft_manufacturer)) |
|
| 662 | + { |
|
| 663 | 663 | return false; |
| 664 | - } else { |
|
| 664 | + } else { |
|
| 665 | 665 | $additional_query .= " AND (spotter_archive_output.aircraft_manufacturer = '".$aircraft_manufacturer."')"; |
| 666 | - } |
|
| 666 | + } |
|
| 667 | 667 | } |
| 668 | 668 | |
| 669 | 669 | if ($highlights == "true") |
| 670 | 670 | { |
| 671 | - if (!is_string($highlights)) |
|
| 672 | - { |
|
| 671 | + if (!is_string($highlights)) |
|
| 672 | + { |
|
| 673 | 673 | return false; |
| 674 | - } else { |
|
| 674 | + } else { |
|
| 675 | 675 | $additional_query .= " AND (spotter_archive_output.highlight <> '')"; |
| 676 | - } |
|
| 676 | + } |
|
| 677 | 677 | } |
| 678 | 678 | |
| 679 | 679 | if ($airline_icao != "") |
| 680 | 680 | { |
| 681 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
| 682 | - if (!is_string($airline_icao)) |
|
| 683 | - { |
|
| 681 | + $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
| 682 | + if (!is_string($airline_icao)) |
|
| 683 | + { |
|
| 684 | 684 | return false; |
| 685 | - } else { |
|
| 685 | + } else { |
|
| 686 | 686 | $additional_query .= " AND (spotter_archive_output.airline_icao = '".$airline_icao."')"; |
| 687 | - } |
|
| 687 | + } |
|
| 688 | 688 | } |
| 689 | 689 | |
| 690 | 690 | if ($airline_country != "") |
| 691 | 691 | { |
| 692 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
| 693 | - if (!is_string($airline_country)) |
|
| 694 | - { |
|
| 692 | + $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
| 693 | + if (!is_string($airline_country)) |
|
| 694 | + { |
|
| 695 | 695 | return false; |
| 696 | - } else { |
|
| 696 | + } else { |
|
| 697 | 697 | $additional_query .= " AND (spotter_archive_output.airline_country = '".$airline_country."')"; |
| 698 | - } |
|
| 698 | + } |
|
| 699 | 699 | } |
| 700 | 700 | |
| 701 | 701 | if ($airline_type != "") |
| 702 | 702 | { |
| 703 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
| 704 | - if (!is_string($airline_type)) |
|
| 705 | - { |
|
| 703 | + $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
| 704 | + if (!is_string($airline_type)) |
|
| 705 | + { |
|
| 706 | 706 | return false; |
| 707 | - } else { |
|
| 707 | + } else { |
|
| 708 | 708 | if ($airline_type == "passenger") |
| 709 | 709 | { |
| 710 | - $additional_query .= " AND (spotter_archive_output.airline_type = 'passenger')"; |
|
| 710 | + $additional_query .= " AND (spotter_archive_output.airline_type = 'passenger')"; |
|
| 711 | 711 | } |
| 712 | 712 | if ($airline_type == "cargo") |
| 713 | 713 | { |
| 714 | - $additional_query .= " AND (spotter_archive_output.airline_type = 'cargo')"; |
|
| 714 | + $additional_query .= " AND (spotter_archive_output.airline_type = 'cargo')"; |
|
| 715 | 715 | } |
| 716 | 716 | if ($airline_type == "military") |
| 717 | 717 | { |
| 718 | - $additional_query .= " AND (spotter_archive_output.airline_type = 'military')"; |
|
| 718 | + $additional_query .= " AND (spotter_archive_output.airline_type = 'military')"; |
|
| 719 | + } |
|
| 719 | 720 | } |
| 720 | - } |
|
| 721 | 721 | } |
| 722 | 722 | |
| 723 | 723 | if ($airport != "") |
| 724 | 724 | { |
| 725 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
| 726 | - if (!is_string($airport)) |
|
| 727 | - { |
|
| 725 | + $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
| 726 | + if (!is_string($airport)) |
|
| 727 | + { |
|
| 728 | 728 | return false; |
| 729 | - } else { |
|
| 729 | + } else { |
|
| 730 | 730 | $additional_query .= " AND ((spotter_archive_output.departure_airport_icao = '".$airport."') OR (spotter_archive_output.arrival_airport_icao = '".$airport."'))"; |
| 731 | - } |
|
| 731 | + } |
|
| 732 | 732 | } |
| 733 | 733 | |
| 734 | 734 | if ($airport_country != "") |
| 735 | 735 | { |
| 736 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
| 737 | - if (!is_string($airport_country)) |
|
| 738 | - { |
|
| 736 | + $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
| 737 | + if (!is_string($airport_country)) |
|
| 738 | + { |
|
| 739 | 739 | return false; |
| 740 | - } else { |
|
| 740 | + } else { |
|
| 741 | 741 | $additional_query .= " AND ((spotter_archive_output.departure_airport_country = '".$airport_country."') OR (spotter_archive_output.arrival_airport_country = '".$airport_country."'))"; |
| 742 | - } |
|
| 742 | + } |
|
| 743 | 743 | } |
| 744 | 744 | |
| 745 | 745 | if ($callsign != "") |
| 746 | 746 | { |
| 747 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 748 | - if (!is_string($callsign)) |
|
| 749 | - { |
|
| 747 | + $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 748 | + if (!is_string($callsign)) |
|
| 749 | + { |
|
| 750 | 750 | return false; |
| 751 | - } else { |
|
| 751 | + } else { |
|
| 752 | 752 | $translate = $Translation->ident2icao($callsign); |
| 753 | 753 | if ($translate != $callsign) { |
| 754 | 754 | $additional_query .= " AND (spotter_archive_output.ident = :callsign OR spotter_archive_output.ident = :translate)"; |
@@ -756,81 +756,81 @@ discard block |
||
| 756 | 756 | } else { |
| 757 | 757 | $additional_query .= " AND (spotter_archive_output.ident = '".$callsign."')"; |
| 758 | 758 | } |
| 759 | - } |
|
| 759 | + } |
|
| 760 | 760 | } |
| 761 | 761 | |
| 762 | 762 | if ($owner != "") |
| 763 | 763 | { |
| 764 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 765 | - if (!is_string($owner)) |
|
| 766 | - { |
|
| 764 | + $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 765 | + if (!is_string($owner)) |
|
| 766 | + { |
|
| 767 | 767 | return false; |
| 768 | - } else { |
|
| 768 | + } else { |
|
| 769 | 769 | $additional_query .= " AND (spotter_archive_output.owner_name = '".$owner."')"; |
| 770 | - } |
|
| 770 | + } |
|
| 771 | 771 | } |
| 772 | 772 | |
| 773 | 773 | if ($pilot_name != "") |
| 774 | 774 | { |
| 775 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
| 776 | - if (!is_string($pilot_name)) |
|
| 777 | - { |
|
| 775 | + $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
| 776 | + if (!is_string($pilot_name)) |
|
| 777 | + { |
|
| 778 | 778 | return false; |
| 779 | - } else { |
|
| 779 | + } else { |
|
| 780 | 780 | $additional_query .= " AND (spotter_archive_output.pilot_name = '".$pilot_name."')"; |
| 781 | - } |
|
| 781 | + } |
|
| 782 | 782 | } |
| 783 | 783 | |
| 784 | 784 | if ($pilot_id != "") |
| 785 | 785 | { |
| 786 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
| 787 | - if (!is_string($pilot_id)) |
|
| 788 | - { |
|
| 786 | + $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
| 787 | + if (!is_string($pilot_id)) |
|
| 788 | + { |
|
| 789 | 789 | return false; |
| 790 | - } else { |
|
| 790 | + } else { |
|
| 791 | 791 | $additional_query .= " AND (spotter_archive_output.pilot_id = '".$pilot_id."')"; |
| 792 | - } |
|
| 792 | + } |
|
| 793 | 793 | } |
| 794 | 794 | |
| 795 | 795 | if ($departure_airport_route != "") |
| 796 | 796 | { |
| 797 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
| 798 | - if (!is_string($departure_airport_route)) |
|
| 799 | - { |
|
| 797 | + $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
| 798 | + if (!is_string($departure_airport_route)) |
|
| 799 | + { |
|
| 800 | 800 | return false; |
| 801 | - } else { |
|
| 801 | + } else { |
|
| 802 | 802 | $additional_query .= " AND (spotter_archive_output.departure_airport_icao = '".$departure_airport_route."')"; |
| 803 | - } |
|
| 803 | + } |
|
| 804 | 804 | } |
| 805 | 805 | |
| 806 | 806 | if ($arrival_airport_route != "") |
| 807 | 807 | { |
| 808 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
| 809 | - if (!is_string($arrival_airport_route)) |
|
| 810 | - { |
|
| 808 | + $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
| 809 | + if (!is_string($arrival_airport_route)) |
|
| 810 | + { |
|
| 811 | 811 | return false; |
| 812 | - } else { |
|
| 812 | + } else { |
|
| 813 | 813 | $additional_query .= " AND (spotter_archive_output.arrival_airport_icao = '".$arrival_airport_route."')"; |
| 814 | - } |
|
| 814 | + } |
|
| 815 | 815 | } |
| 816 | 816 | |
| 817 | 817 | if ($altitude != "") |
| 818 | 818 | { |
| 819 | - $altitude_array = explode(",", $altitude); |
|
| 819 | + $altitude_array = explode(",", $altitude); |
|
| 820 | 820 | |
| 821 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 822 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 821 | + $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 822 | + $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 823 | 823 | |
| 824 | 824 | |
| 825 | - if ($altitude_array[1] != "") |
|
| 826 | - { |
|
| 825 | + if ($altitude_array[1] != "") |
|
| 826 | + { |
|
| 827 | 827 | $altitude_array[0] = substr($altitude_array[0], 0, -2); |
| 828 | 828 | $altitude_array[1] = substr($altitude_array[1], 0, -2); |
| 829 | 829 | $additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' "; |
| 830 | - } else { |
|
| 830 | + } else { |
|
| 831 | 831 | $altitude_array[0] = substr($altitude_array[0], 0, -2); |
| 832 | 832 | $additional_query .= " AND altitude <= '".$altitude_array[0]."' "; |
| 833 | - } |
|
| 833 | + } |
|
| 834 | 834 | } |
| 835 | 835 | |
| 836 | 836 | if ($date_posted != "") |
@@ -915,14 +915,14 @@ discard block |
||
| 915 | 915 | } |
| 916 | 916 | } |
| 917 | 917 | |
| 918 | - /** |
|
| 919 | - * Gets all the spotter information based on the callsign |
|
| 920 | - * |
|
| 921 | - * @return Array the spotter information |
|
| 922 | - * |
|
| 923 | - */ |
|
| 924 | - public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '') |
|
| 925 | - { |
|
| 918 | + /** |
|
| 919 | + * Gets all the spotter information based on the callsign |
|
| 920 | + * |
|
| 921 | + * @return Array the spotter information |
|
| 922 | + * |
|
| 923 | + */ |
|
| 924 | + public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '') |
|
| 925 | + { |
|
| 926 | 926 | $global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output"; |
| 927 | 927 | |
| 928 | 928 | date_default_timezone_set('UTC'); |
@@ -934,35 +934,35 @@ discard block |
||
| 934 | 934 | |
| 935 | 935 | if ($ident != "") |
| 936 | 936 | { |
| 937 | - if (!is_string($ident)) |
|
| 938 | - { |
|
| 937 | + if (!is_string($ident)) |
|
| 938 | + { |
|
| 939 | 939 | return false; |
| 940 | - } else { |
|
| 940 | + } else { |
|
| 941 | 941 | $additional_query = " AND (spotter_archive_output.ident = :ident)"; |
| 942 | 942 | $query_values = array(':ident' => $ident); |
| 943 | - } |
|
| 943 | + } |
|
| 944 | 944 | } |
| 945 | 945 | |
| 946 | 946 | if ($limit != "") |
| 947 | 947 | { |
| 948 | - $limit_array = explode(",", $limit); |
|
| 948 | + $limit_array = explode(",", $limit); |
|
| 949 | 949 | |
| 950 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 951 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 950 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 951 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 952 | 952 | |
| 953 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 954 | - { |
|
| 953 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 954 | + { |
|
| 955 | 955 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 956 | 956 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 957 | - } |
|
| 957 | + } |
|
| 958 | 958 | } |
| 959 | 959 | |
| 960 | 960 | if ($sort != "") |
| 961 | 961 | { |
| 962 | - $search_orderby_array = $Spotter->getOrderBy(); |
|
| 963 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 962 | + $search_orderby_array = $Spotter->getOrderBy(); |
|
| 963 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 964 | 964 | } else { |
| 965 | - $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
| 965 | + $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
| 966 | 966 | } |
| 967 | 967 | |
| 968 | 968 | $query = $global_query." WHERE spotter_archive_output.ident <> '' ".$additional_query." ".$orderby_query; |
@@ -970,17 +970,17 @@ discard block |
||
| 970 | 970 | $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
| 971 | 971 | |
| 972 | 972 | return $spotter_array; |
| 973 | - } |
|
| 973 | + } |
|
| 974 | 974 | |
| 975 | 975 | |
| 976 | - /** |
|
| 977 | - * Gets all the spotter information based on the owner |
|
| 978 | - * |
|
| 979 | - * @return Array the spotter information |
|
| 980 | - * |
|
| 981 | - */ |
|
| 982 | - public function getSpotterDataByOwner($owner = '', $limit = '', $sort = '', $filter = array()) |
|
| 983 | - { |
|
| 976 | + /** |
|
| 977 | + * Gets all the spotter information based on the owner |
|
| 978 | + * |
|
| 979 | + * @return Array the spotter information |
|
| 980 | + * |
|
| 981 | + */ |
|
| 982 | + public function getSpotterDataByOwner($owner = '', $limit = '', $sort = '', $filter = array()) |
|
| 983 | + { |
|
| 984 | 984 | $global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output"; |
| 985 | 985 | |
| 986 | 986 | date_default_timezone_set('UTC'); |
@@ -993,35 +993,35 @@ discard block |
||
| 993 | 993 | |
| 994 | 994 | if ($owner != "") |
| 995 | 995 | { |
| 996 | - if (!is_string($owner)) |
|
| 997 | - { |
|
| 996 | + if (!is_string($owner)) |
|
| 997 | + { |
|
| 998 | 998 | return false; |
| 999 | - } else { |
|
| 999 | + } else { |
|
| 1000 | 1000 | $additional_query = " AND (spotter_archive_output.owner_name = :owner)"; |
| 1001 | 1001 | $query_values = array(':owner' => $owner); |
| 1002 | - } |
|
| 1002 | + } |
|
| 1003 | 1003 | } |
| 1004 | 1004 | |
| 1005 | 1005 | if ($limit != "") |
| 1006 | 1006 | { |
| 1007 | - $limit_array = explode(",", $limit); |
|
| 1007 | + $limit_array = explode(",", $limit); |
|
| 1008 | 1008 | |
| 1009 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1010 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1009 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1010 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1011 | 1011 | |
| 1012 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1013 | - { |
|
| 1012 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1013 | + { |
|
| 1014 | 1014 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 1015 | 1015 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 1016 | - } |
|
| 1016 | + } |
|
| 1017 | 1017 | } |
| 1018 | 1018 | |
| 1019 | 1019 | if ($sort != "") |
| 1020 | 1020 | { |
| 1021 | - $search_orderby_array = $Spotter->getOrderBy(); |
|
| 1022 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1021 | + $search_orderby_array = $Spotter->getOrderBy(); |
|
| 1022 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1023 | 1023 | } else { |
| 1024 | - $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
| 1024 | + $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
| 1025 | 1025 | } |
| 1026 | 1026 | |
| 1027 | 1027 | $query = $global_query.$filter_query." spotter_archive_output.owner_name <> '' ".$additional_query." ".$orderby_query; |
@@ -1029,16 +1029,16 @@ discard block |
||
| 1029 | 1029 | $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
| 1030 | 1030 | |
| 1031 | 1031 | return $spotter_array; |
| 1032 | - } |
|
| 1033 | - |
|
| 1034 | - /** |
|
| 1035 | - * Gets all the spotter information based on the pilot |
|
| 1036 | - * |
|
| 1037 | - * @return Array the spotter information |
|
| 1038 | - * |
|
| 1039 | - */ |
|
| 1040 | - public function getSpotterDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array()) |
|
| 1041 | - { |
|
| 1032 | + } |
|
| 1033 | + |
|
| 1034 | + /** |
|
| 1035 | + * Gets all the spotter information based on the pilot |
|
| 1036 | + * |
|
| 1037 | + * @return Array the spotter information |
|
| 1038 | + * |
|
| 1039 | + */ |
|
| 1040 | + public function getSpotterDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array()) |
|
| 1041 | + { |
|
| 1042 | 1042 | $global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output"; |
| 1043 | 1043 | |
| 1044 | 1044 | date_default_timezone_set('UTC'); |
@@ -1057,24 +1057,24 @@ discard block |
||
| 1057 | 1057 | |
| 1058 | 1058 | if ($limit != "") |
| 1059 | 1059 | { |
| 1060 | - $limit_array = explode(",", $limit); |
|
| 1060 | + $limit_array = explode(",", $limit); |
|
| 1061 | 1061 | |
| 1062 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1063 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1062 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1063 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1064 | 1064 | |
| 1065 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1066 | - { |
|
| 1065 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1066 | + { |
|
| 1067 | 1067 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 1068 | 1068 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 1069 | - } |
|
| 1069 | + } |
|
| 1070 | 1070 | } |
| 1071 | 1071 | |
| 1072 | 1072 | if ($sort != "") |
| 1073 | 1073 | { |
| 1074 | - $search_orderby_array = $Spotter->getOrderBy(); |
|
| 1075 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1074 | + $search_orderby_array = $Spotter->getOrderBy(); |
|
| 1075 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1076 | 1076 | } else { |
| 1077 | - $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
| 1077 | + $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
| 1078 | 1078 | } |
| 1079 | 1079 | |
| 1080 | 1080 | $query = $global_query.$filter_query." spotter_archive_output.pilot_name <> '' ".$additional_query." ".$orderby_query; |
@@ -1082,16 +1082,16 @@ discard block |
||
| 1082 | 1082 | $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
| 1083 | 1083 | |
| 1084 | 1084 | return $spotter_array; |
| 1085 | - } |
|
| 1086 | - |
|
| 1087 | - /** |
|
| 1088 | - * Gets all number of flight over countries |
|
| 1089 | - * |
|
| 1090 | - * @return Array the airline country list |
|
| 1091 | - * |
|
| 1092 | - */ |
|
| 1093 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1094 | - { |
|
| 1085 | + } |
|
| 1086 | + |
|
| 1087 | + /** |
|
| 1088 | + * Gets all number of flight over countries |
|
| 1089 | + * |
|
| 1090 | + * @return Array the airline country list |
|
| 1091 | + * |
|
| 1092 | + */ |
|
| 1093 | + public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1094 | + { |
|
| 1095 | 1095 | global $globalDBdriver; |
| 1096 | 1096 | /* |
| 1097 | 1097 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
@@ -1101,14 +1101,14 @@ discard block |
||
| 1101 | 1101 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
| 1102 | 1102 | FROM countries c, spotter_archive s |
| 1103 | 1103 | WHERE c.iso2 = s.over_country "; |
| 1104 | - if ($olderthanmonths > 0) { |
|
| 1105 | - if ($globalDBdriver == 'mysql') { |
|
| 1104 | + if ($olderthanmonths > 0) { |
|
| 1105 | + if ($globalDBdriver == 'mysql') { |
|
| 1106 | 1106 | $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
| 1107 | 1107 | } else { |
| 1108 | 1108 | $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
| 1109 | 1109 | } |
| 1110 | 1110 | } |
| 1111 | - if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
| 1111 | + if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
| 1112 | 1112 | $query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
| 1113 | 1113 | if ($limit) $query .= " LIMIT 0,10"; |
| 1114 | 1114 | |
@@ -1121,23 +1121,23 @@ discard block |
||
| 1121 | 1121 | |
| 1122 | 1122 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
| 1123 | 1123 | { |
| 1124 | - $temp_array['flight_count'] = $row['nb']; |
|
| 1125 | - $temp_array['flight_country'] = $row['name']; |
|
| 1126 | - $temp_array['flight_country_iso3'] = $row['iso3']; |
|
| 1127 | - $temp_array['flight_country_iso2'] = $row['iso2']; |
|
| 1128 | - $flight_array[] = $temp_array; |
|
| 1124 | + $temp_array['flight_count'] = $row['nb']; |
|
| 1125 | + $temp_array['flight_country'] = $row['name']; |
|
| 1126 | + $temp_array['flight_country_iso3'] = $row['iso3']; |
|
| 1127 | + $temp_array['flight_country_iso2'] = $row['iso2']; |
|
| 1128 | + $flight_array[] = $temp_array; |
|
| 1129 | 1129 | } |
| 1130 | 1130 | return $flight_array; |
| 1131 | - } |
|
| 1132 | - |
|
| 1133 | - /** |
|
| 1134 | - * Gets all number of flight over countries |
|
| 1135 | - * |
|
| 1136 | - * @return Array the airline country list |
|
| 1137 | - * |
|
| 1138 | - */ |
|
| 1139 | - public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1140 | - { |
|
| 1131 | + } |
|
| 1132 | + |
|
| 1133 | + /** |
|
| 1134 | + * Gets all number of flight over countries |
|
| 1135 | + * |
|
| 1136 | + * @return Array the airline country list |
|
| 1137 | + * |
|
| 1138 | + */ |
|
| 1139 | + public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1140 | + { |
|
| 1141 | 1141 | global $globalDBdriver; |
| 1142 | 1142 | /* |
| 1143 | 1143 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
@@ -1147,14 +1147,14 @@ discard block |
||
| 1147 | 1147 | $query = "SELECT o.airline_icao,c.name, c.iso3, c.iso2, count(c.name) as nb |
| 1148 | 1148 | FROM countries c, spotter_archive s, spotter_output o |
| 1149 | 1149 | WHERE c.iso2 = s.over_country AND o.airline_icao <> '' AND o.flightaware_id = s.flightaware_id "; |
| 1150 | - if ($olderthanmonths > 0) { |
|
| 1151 | - if ($globalDBdriver == 'mysql') { |
|
| 1150 | + if ($olderthanmonths > 0) { |
|
| 1151 | + if ($globalDBdriver == 'mysql') { |
|
| 1152 | 1152 | $query .= 'AND s.date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
| 1153 | 1153 | } else { |
| 1154 | 1154 | $query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
| 1155 | 1155 | } |
| 1156 | 1156 | } |
| 1157 | - if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
| 1157 | + if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
| 1158 | 1158 | $query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
| 1159 | 1159 | if ($limit) $query .= " LIMIT 0,10"; |
| 1160 | 1160 | |
@@ -1167,24 +1167,24 @@ discard block |
||
| 1167 | 1167 | |
| 1168 | 1168 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
| 1169 | 1169 | { |
| 1170 | - $temp_array['airline_icao'] = $row['airline_icao']; |
|
| 1171 | - $temp_array['flight_count'] = $row['nb']; |
|
| 1172 | - $temp_array['flight_country'] = $row['name']; |
|
| 1173 | - $temp_array['flight_country_iso3'] = $row['iso3']; |
|
| 1174 | - $temp_array['flight_country_iso2'] = $row['iso2']; |
|
| 1175 | - $flight_array[] = $temp_array; |
|
| 1170 | + $temp_array['airline_icao'] = $row['airline_icao']; |
|
| 1171 | + $temp_array['flight_count'] = $row['nb']; |
|
| 1172 | + $temp_array['flight_country'] = $row['name']; |
|
| 1173 | + $temp_array['flight_country_iso3'] = $row['iso3']; |
|
| 1174 | + $temp_array['flight_country_iso2'] = $row['iso2']; |
|
| 1175 | + $flight_array[] = $temp_array; |
|
| 1176 | 1176 | } |
| 1177 | 1177 | return $flight_array; |
| 1178 | - } |
|
| 1179 | - |
|
| 1180 | - /** |
|
| 1181 | - * Gets last spotter information based on a particular callsign |
|
| 1182 | - * |
|
| 1183 | - * @return Array the spotter information |
|
| 1184 | - * |
|
| 1185 | - */ |
|
| 1186 | - public function getDateArchiveSpotterDataById($id,$date) |
|
| 1187 | - { |
|
| 1178 | + } |
|
| 1179 | + |
|
| 1180 | + /** |
|
| 1181 | + * Gets last spotter information based on a particular callsign |
|
| 1182 | + * |
|
| 1183 | + * @return Array the spotter information |
|
| 1184 | + * |
|
| 1185 | + */ |
|
| 1186 | + public function getDateArchiveSpotterDataById($id,$date) |
|
| 1187 | + { |
|
| 1188 | 1188 | $Spotter = new Spotter($this->db); |
| 1189 | 1189 | date_default_timezone_set('UTC'); |
| 1190 | 1190 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
@@ -1192,16 +1192,16 @@ discard block |
||
| 1192 | 1192 | $date = date('c',$date); |
| 1193 | 1193 | $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
| 1194 | 1194 | return $spotter_array; |
| 1195 | - } |
|
| 1196 | - |
|
| 1197 | - /** |
|
| 1198 | - * Gets all the spotter information based on a particular callsign |
|
| 1199 | - * |
|
| 1200 | - * @return Array the spotter information |
|
| 1201 | - * |
|
| 1202 | - */ |
|
| 1203 | - public function getDateArchiveSpotterDataByIdent($ident,$date) |
|
| 1204 | - { |
|
| 1195 | + } |
|
| 1196 | + |
|
| 1197 | + /** |
|
| 1198 | + * Gets all the spotter information based on a particular callsign |
|
| 1199 | + * |
|
| 1200 | + * @return Array the spotter information |
|
| 1201 | + * |
|
| 1202 | + */ |
|
| 1203 | + public function getDateArchiveSpotterDataByIdent($ident,$date) |
|
| 1204 | + { |
|
| 1205 | 1205 | $Spotter = new Spotter($this->db); |
| 1206 | 1206 | date_default_timezone_set('UTC'); |
| 1207 | 1207 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
@@ -1209,16 +1209,16 @@ discard block |
||
| 1209 | 1209 | $date = date('c',$date); |
| 1210 | 1210 | $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
| 1211 | 1211 | return $spotter_array; |
| 1212 | - } |
|
| 1213 | - |
|
| 1214 | - /** |
|
| 1215 | - * Gets all the spotter information based on the airport |
|
| 1216 | - * |
|
| 1217 | - * @return Array the spotter information |
|
| 1218 | - * |
|
| 1219 | - */ |
|
| 1220 | - public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
| 1221 | - { |
|
| 1212 | + } |
|
| 1213 | + |
|
| 1214 | + /** |
|
| 1215 | + * Gets all the spotter information based on the airport |
|
| 1216 | + * |
|
| 1217 | + * @return Array the spotter information |
|
| 1218 | + * |
|
| 1219 | + */ |
|
| 1220 | + public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
| 1221 | + { |
|
| 1222 | 1222 | global $global_query; |
| 1223 | 1223 | $Spotter = new Spotter($this->db); |
| 1224 | 1224 | date_default_timezone_set('UTC'); |
@@ -1229,35 +1229,35 @@ discard block |
||
| 1229 | 1229 | |
| 1230 | 1230 | if ($airport != "") |
| 1231 | 1231 | { |
| 1232 | - if (!is_string($airport)) |
|
| 1233 | - { |
|
| 1232 | + if (!is_string($airport)) |
|
| 1233 | + { |
|
| 1234 | 1234 | return false; |
| 1235 | - } else { |
|
| 1235 | + } else { |
|
| 1236 | 1236 | $additional_query .= " AND ((spotter_archive_output.departure_airport_icao = :airport) OR (spotter_archive_output.arrival_airport_icao = :airport))"; |
| 1237 | 1237 | $query_values = array(':airport' => $airport); |
| 1238 | - } |
|
| 1238 | + } |
|
| 1239 | 1239 | } |
| 1240 | 1240 | |
| 1241 | 1241 | if ($limit != "") |
| 1242 | 1242 | { |
| 1243 | - $limit_array = explode(",", $limit); |
|
| 1243 | + $limit_array = explode(",", $limit); |
|
| 1244 | 1244 | |
| 1245 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1246 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1245 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1246 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1247 | 1247 | |
| 1248 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1249 | - { |
|
| 1248 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1249 | + { |
|
| 1250 | 1250 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 1251 | 1251 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 1252 | - } |
|
| 1252 | + } |
|
| 1253 | 1253 | } |
| 1254 | 1254 | |
| 1255 | 1255 | if ($sort != "") |
| 1256 | 1256 | { |
| 1257 | - $search_orderby_array = $Spotter->getOrderBy(); |
|
| 1258 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1257 | + $search_orderby_array = $Spotter->getOrderBy(); |
|
| 1258 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1259 | 1259 | } else { |
| 1260 | - $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
| 1260 | + $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
| 1261 | 1261 | } |
| 1262 | 1262 | |
| 1263 | 1263 | $query = $global_query.$filter_query." spotter_archive_output.ident <> '' ".$additional_query." AND ((spotter_archive_output.departure_airport_icao <> 'NA') AND (spotter_archive_output.arrival_airport_icao <> 'NA')) ".$orderby_query; |
@@ -1265,6 +1265,6 @@ discard block |
||
| 1265 | 1265 | $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
| 1266 | 1266 | |
| 1267 | 1267 | return $spotter_array; |
| 1268 | - } |
|
| 1268 | + } |
|
| 1269 | 1269 | } |
| 1270 | 1270 | ?> |
| 1271 | 1271 | \ No newline at end of file |
@@ -14,78 +14,78 @@ discard block |
||
| 14 | 14 | * @param Array $filter the filter |
| 15 | 15 | * @return Array the SQL part |
| 16 | 16 | */ |
| 17 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
| 17 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
| 18 | 18 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
| 19 | 19 | $filters = array(); |
| 20 | 20 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
| 21 | 21 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
| 22 | 22 | $filters = $globalStatsFilters[$globalFilterName]; |
| 23 | 23 | } else { |
| 24 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
| 24 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
| 25 | 25 | } |
| 26 | 26 | } |
| 27 | 27 | if (isset($filter[0]['source'])) { |
| 28 | - $filters = array_merge($filters,$filter); |
|
| 28 | + $filters = array_merge($filters, $filter); |
|
| 29 | 29 | } |
| 30 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 30 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
| 31 | 31 | $filter_query_join = ''; |
| 32 | 32 | $filter_query_where = ''; |
| 33 | - foreach($filters as $flt) { |
|
| 33 | + foreach ($filters as $flt) { |
|
| 34 | 34 | if (isset($flt['airlines']) && !empty($flt['airlines'])) { |
| 35 | 35 | if ($flt['airlines'][0] != '') { |
| 36 | 36 | if (isset($flt['source'])) { |
| 37 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 37 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $flt['airlines'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 38 | 38 | } else { |
| 39 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 39 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $flt['airlines'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 40 | 40 | } |
| 41 | 41 | } |
| 42 | 42 | } |
| 43 | 43 | if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) { |
| 44 | 44 | if (isset($flt['source'])) { |
| 45 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 45 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 46 | 46 | } else { |
| 47 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 47 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 48 | 48 | } |
| 49 | 49 | } |
| 50 | 50 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
| 51 | 51 | if (isset($flt['source'])) { |
| 52 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 52 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 53 | 53 | } else { |
| 54 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 54 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','", $flt['idents'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 55 | 55 | } |
| 56 | 56 | } |
| 57 | 57 | if (isset($flt['registrations']) && !empty($flt['registrations'])) { |
| 58 | 58 | if (isset($flt['source'])) { |
| 59 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 59 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','", $flt['registrations'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 60 | 60 | } else { |
| 61 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 61 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','", $flt['registrations'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 62 | 62 | } |
| 63 | 63 | } |
| 64 | 64 | if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id']) && isset($flt['idents']) && empty($flt['idents']) && isset($flt['registrations']) && empty($flt['registrations'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']) && !isset($flt['idents']) && !isset($flt['registrations']))) { |
| 65 | 65 | if (isset($flt['source'])) { |
| 66 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) saa ON saa.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 66 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.format_source IN ('".implode("','", $flt['source'])."')) saa ON saa.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 67 | 67 | } |
| 68 | 68 | } |
| 69 | 69 | } |
| 70 | 70 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 71 | 71 | if ($filter['airlines'][0] != '') { |
| 72 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) saf ON saf.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 72 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) saf ON saf.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 73 | 73 | } |
| 74 | 74 | } |
| 75 | 75 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
| 76 | 76 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive_output.flightaware_id "; |
| 77 | 77 | } |
| 78 | 78 | if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) { |
| 79 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 79 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','", $filter['pilots_id'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 80 | 80 | } |
| 81 | 81 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 82 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
| 82 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
| 83 | 83 | } |
| 84 | 84 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
| 85 | 85 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
| 86 | 86 | } |
| 87 | 87 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 88 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 88 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 89 | 89 | } |
| 90 | 90 | if ((isset($filter['year']) && $filter['year'] != '') || (isset($filter['month']) && $filter['month'] != '') || (isset($filter['day']) && $filter['day'] != '')) { |
| 91 | 91 | $filter_query_date = ''; |
@@ -110,41 +110,41 @@ discard block |
||
| 110 | 110 | $filter_query_date .= " AND EXTRACT(DAY FROM spotter_archive_output.date) = '".$filter['day']."'"; |
| 111 | 111 | } |
| 112 | 112 | } |
| 113 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 113 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 114 | 114 | } |
| 115 | 115 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
| 116 | 116 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
| 117 | 117 | if ($filter_query_where != '') { |
| 118 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
| 118 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
| 119 | 119 | } |
| 120 | 120 | $filter_query = $filter_query_join.$filter_query_where; |
| 121 | 121 | return $filter_query; |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | // Spotter_archive |
| 125 | - public function addSpotterArchiveData($flightaware_id = '', $ident = '', $registration = '', $airline_name = '', $airline_icao = '', $airline_country = '', $airline_type = '', $aircraft_icao = '', $aircraft_shadow = '', $aircraft_name = '', $aircraft_manufacturer = '', $departure_airport_icao = '', $departure_airport_name = '', $departure_airport_city = '', $departure_airport_country = '', $departure_airport_time = '',$arrival_airport_icao = '', $arrival_airport_name = '', $arrival_airport_city ='', $arrival_airport_country = '', $arrival_airport_time = '', $route_stop = '', $date = '',$latitude = '', $longitude = '', $waypoints = '', $altitude = '', $real_altitude = '',$heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '',$verticalrate = '',$format_source = '', $source_name = '', $over_country = '') { |
|
| 125 | + public function addSpotterArchiveData($flightaware_id = '', $ident = '', $registration = '', $airline_name = '', $airline_icao = '', $airline_country = '', $airline_type = '', $aircraft_icao = '', $aircraft_shadow = '', $aircraft_name = '', $aircraft_manufacturer = '', $departure_airport_icao = '', $departure_airport_name = '', $departure_airport_city = '', $departure_airport_country = '', $departure_airport_time = '', $arrival_airport_icao = '', $arrival_airport_name = '', $arrival_airport_city = '', $arrival_airport_country = '', $arrival_airport_time = '', $route_stop = '', $date = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $real_altitude = '', $heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '', $verticalrate = '', $format_source = '', $source_name = '', $over_country = '') { |
|
| 126 | 126 | require_once(dirname(__FILE__).'/class.Spotter.php'); |
| 127 | 127 | if ($over_country == '') { |
| 128 | 128 | $Spotter = new Spotter($this->db); |
| 129 | - $data_country = $Spotter->getCountryFromLatitudeLongitude($latitude,$longitude); |
|
| 129 | + $data_country = $Spotter->getCountryFromLatitudeLongitude($latitude, $longitude); |
|
| 130 | 130 | if (!empty($data_country)) $country = $data_country['iso2']; |
| 131 | 131 | else $country = ''; |
| 132 | 132 | } else $country = $over_country; |
| 133 | - if ($airline_type === NULL) $airline_type =''; |
|
| 133 | + if ($airline_type === NULL) $airline_type = ''; |
|
| 134 | 134 | |
| 135 | 135 | //if ($country == '') echo "\n".'************ UNKNOW COUNTRY ****************'."\n"; |
| 136 | 136 | //else echo "\n".'*/*/*/*/*/*/*/ Country : '.$country.' */*/*/*/*/*/*/*/*/'."\n"; |
| 137 | 137 | |
| 138 | 138 | // Route is not added in spotter_archive |
| 139 | - $query = "INSERT INTO spotter_archive (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, departure_airport_time,arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, arrival_airport_time, route_stop, date,latitude, longitude, waypoints, altitude, heading, ground_speed, squawk, ModeS, pilot_id, pilot_name, verticalrate,format_source,over_country,source_name,real_altitude) |
|
| 139 | + $query = "INSERT INTO spotter_archive (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, departure_airport_time,arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, arrival_airport_time, route_stop, date,latitude, longitude, waypoints, altitude, heading, ground_speed, squawk, ModeS, pilot_id, pilot_name, verticalrate,format_source,over_country,source_name,real_altitude) |
|
| 140 | 140 | VALUES (:flightaware_id, :ident, :registration, :airline_name, :airline_icao, :airline_country, :airline_type, :aircraft_icao, :aircraft_shadow, :aircraft_name, :aircraft_manufacturer, :departure_airport_icao, :departure_airport_name, :departure_airport_city, :departure_airport_country, :departure_airport_time,:arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :arrival_airport_time, :route_stop, :date,:latitude, :longitude, :waypoints, :altitude, :heading, :ground_speed, :squawk, :ModeS, :pilot_id, :pilot_name, :verticalrate, :format_source, :over_country, :source_name,:real_altitude)"; |
| 141 | 141 | |
| 142 | - $query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':registration' => $registration, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type, ':aircraft_icao' => $aircraft_icao, ':aircraft_shadow' => $aircraft_shadow, ':aircraft_name' => $aircraft_name, ':aircraft_manufacturer' => $aircraft_manufacturer, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_name' => $departure_airport_name, ':departure_airport_city' => $departure_airport_city, ':departure_airport_country' => $departure_airport_country, ':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':arrival_airport_time' => $arrival_airport_time, ':route_stop' => $route_stop, ':date' => $date,':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':ground_speed' => $ground_speed, ':squawk' => $squawk, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':over_country' => $country, ':source_name' => $source_name,':real_altitude' => $real_altitude); |
|
| 142 | + $query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':registration' => $registration, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type, ':aircraft_icao' => $aircraft_icao, ':aircraft_shadow' => $aircraft_shadow, ':aircraft_name' => $aircraft_name, ':aircraft_manufacturer' => $aircraft_manufacturer, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_name' => $departure_airport_name, ':departure_airport_city' => $departure_airport_city, ':departure_airport_country' => $departure_airport_country, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':arrival_airport_time' => $arrival_airport_time, ':route_stop' => $route_stop, ':date' => $date, ':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':ground_speed' => $ground_speed, ':squawk' => $squawk, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':over_country' => $country, ':source_name' => $source_name, ':real_altitude' => $real_altitude); |
|
| 143 | 143 | try { |
| 144 | 144 | $sth = $this->db->prepare($query); |
| 145 | 145 | $sth->execute($query_values); |
| 146 | 146 | $sth->closeCursor(); |
| 147 | - } catch(PDOException $e) { |
|
| 147 | + } catch (PDOException $e) { |
|
| 148 | 148 | return "error : ".$e->getMessage(); |
| 149 | 149 | } |
| 150 | 150 | return "success"; |
@@ -164,9 +164,9 @@ discard block |
||
| 164 | 164 | |
| 165 | 165 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 166 | 166 | //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
| 167 | - $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
| 167 | + $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
| 168 | 168 | |
| 169 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident)); |
|
| 169 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident)); |
|
| 170 | 170 | |
| 171 | 171 | return $spotter_array; |
| 172 | 172 | } |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 186 | 186 | //$query = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id"; |
| 187 | 187 | //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
| 188 | - $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
| 188 | + $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
| 189 | 189 | |
| 190 | 190 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
| 191 | 191 | /* |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | } |
| 199 | 199 | $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC); |
| 200 | 200 | */ |
| 201 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id)); |
|
| 201 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id)); |
|
| 202 | 202 | |
| 203 | 203 | return $spotter_array; |
| 204 | 204 | } |
@@ -213,14 +213,14 @@ discard block |
||
| 213 | 213 | { |
| 214 | 214 | date_default_timezone_set('UTC'); |
| 215 | 215 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 216 | - $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
| 216 | + $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
| 217 | 217 | |
| 218 | 218 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
| 219 | 219 | |
| 220 | 220 | try { |
| 221 | 221 | $sth = $this->db->prepare($query); |
| 222 | 222 | $sth->execute(array(':id' => $id)); |
| 223 | - } catch(PDOException $e) { |
|
| 223 | + } catch (PDOException $e) { |
|
| 224 | 224 | echo $e->getMessage(); |
| 225 | 225 | die; |
| 226 | 226 | } |
@@ -239,14 +239,14 @@ discard block |
||
| 239 | 239 | { |
| 240 | 240 | date_default_timezone_set('UTC'); |
| 241 | 241 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 242 | - $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
| 242 | + $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
| 243 | 243 | |
| 244 | 244 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
| 245 | 245 | |
| 246 | 246 | try { |
| 247 | 247 | $sth = $this->db->prepare($query); |
| 248 | 248 | $sth->execute(array(':id' => $id)); |
| 249 | - } catch(PDOException $e) { |
|
| 249 | + } catch (PDOException $e) { |
|
| 250 | 250 | echo $e->getMessage(); |
| 251 | 251 | die; |
| 252 | 252 | } |
@@ -268,12 +268,12 @@ discard block |
||
| 268 | 268 | date_default_timezone_set('UTC'); |
| 269 | 269 | |
| 270 | 270 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 271 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
| 271 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
| 272 | 272 | |
| 273 | 273 | try { |
| 274 | 274 | $sth = $this->db->prepare($query); |
| 275 | 275 | $sth->execute(array(':ident' => $ident)); |
| 276 | - } catch(PDOException $e) { |
|
| 276 | + } catch (PDOException $e) { |
|
| 277 | 277 | echo $e->getMessage(); |
| 278 | 278 | die; |
| 279 | 279 | } |
@@ -294,12 +294,12 @@ discard block |
||
| 294 | 294 | date_default_timezone_set('UTC'); |
| 295 | 295 | |
| 296 | 296 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 297 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
| 297 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
| 298 | 298 | |
| 299 | 299 | try { |
| 300 | 300 | $sth = $this->db->prepare($query); |
| 301 | 301 | $sth->execute(array(':id' => $id)); |
| 302 | - } catch(PDOException $e) { |
|
| 302 | + } catch (PDOException $e) { |
|
| 303 | 303 | echo $e->getMessage(); |
| 304 | 304 | die; |
| 305 | 305 | } |
@@ -318,11 +318,11 @@ discard block |
||
| 318 | 318 | { |
| 319 | 319 | date_default_timezone_set('UTC'); |
| 320 | 320 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 321 | - $query = "SELECT spotter_archive.altitude, spotter_archive.real_altitude,spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
| 321 | + $query = "SELECT spotter_archive.altitude, spotter_archive.real_altitude,spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
| 322 | 322 | try { |
| 323 | 323 | $sth = $this->db->prepare($query); |
| 324 | 324 | $sth->execute(array(':id' => $id)); |
| 325 | - } catch(PDOException $e) { |
|
| 325 | + } catch (PDOException $e) { |
|
| 326 | 326 | echo $e->getMessage(); |
| 327 | 327 | die; |
| 328 | 328 | } |
@@ -340,12 +340,12 @@ discard block |
||
| 340 | 340 | { |
| 341 | 341 | date_default_timezone_set('UTC'); |
| 342 | 342 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 343 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
| 343 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
| 344 | 344 | // $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident"; |
| 345 | 345 | try { |
| 346 | 346 | $sth = $this->db->prepare($query); |
| 347 | 347 | $sth->execute(array(':ident' => $ident)); |
| 348 | - } catch(PDOException $e) { |
|
| 348 | + } catch (PDOException $e) { |
|
| 349 | 349 | echo $e->getMessage(); |
| 350 | 350 | die; |
| 351 | 351 | } |
@@ -361,12 +361,12 @@ discard block |
||
| 361 | 361 | * @return Array the spotter information |
| 362 | 362 | * |
| 363 | 363 | */ |
| 364 | - public function getSpotterArchiveData($ident,$flightaware_id,$date) |
|
| 364 | + public function getSpotterArchiveData($ident, $flightaware_id, $date) |
|
| 365 | 365 | { |
| 366 | 366 | $Spotter = new Spotter($this->db); |
| 367 | 367 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 368 | - $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate"; |
|
| 369 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%')); |
|
| 368 | + $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate"; |
|
| 369 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':flightaware_id' => $flightaware_id, ':date' => $date.'%')); |
|
| 370 | 370 | return $spotter_array; |
| 371 | 371 | } |
| 372 | 372 | |
@@ -381,7 +381,7 @@ discard block |
||
| 381 | 381 | try { |
| 382 | 382 | $sth = $this->db->prepare($query); |
| 383 | 383 | $sth->execute(); |
| 384 | - } catch(PDOException $e) { |
|
| 384 | + } catch (PDOException $e) { |
|
| 385 | 385 | echo $e->getMessage(); |
| 386 | 386 | die; |
| 387 | 387 | } |
@@ -393,24 +393,24 @@ discard block |
||
| 393 | 393 | * @return Array the spotter information |
| 394 | 394 | * |
| 395 | 395 | */ |
| 396 | - public function getMinLiveSpotterData($begindate,$enddate,$filter = array()) |
|
| 396 | + public function getMinLiveSpotterData($begindate, $enddate, $filter = array()) |
|
| 397 | 397 | { |
| 398 | 398 | global $globalDBdriver, $globalLiveInterval; |
| 399 | 399 | date_default_timezone_set('UTC'); |
| 400 | 400 | |
| 401 | 401 | $filter_query = ''; |
| 402 | 402 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 403 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 403 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
| 404 | 404 | } |
| 405 | 405 | // Use spotter_output also ? |
| 406 | 406 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 407 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 407 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 408 | 408 | } |
| 409 | 409 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
| 410 | 410 | $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
| 411 | 411 | } |
| 412 | 412 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 413 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 413 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 414 | 414 | } |
| 415 | 415 | |
| 416 | 416 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -429,14 +429,14 @@ discard block |
||
| 429 | 429 | GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id |
| 430 | 430 | AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao'; |
| 431 | 431 | */ |
| 432 | - $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 432 | + $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 433 | 433 | FROM spotter_archive |
| 434 | 434 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao |
| 435 | 435 | WHERE spotter_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' |
| 436 | 436 | '.$filter_query.' ORDER BY flightaware_id'; |
| 437 | 437 | } else { |
| 438 | 438 | //$query = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao'; |
| 439 | - $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 439 | + $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 440 | 440 | FROM spotter_archive |
| 441 | 441 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao |
| 442 | 442 | WHERE spotter_archive.date >= '."'".$begindate."'".' AND spotter_archive.date <= '."'".$enddate."'".' |
@@ -446,7 +446,7 @@ discard block |
||
| 446 | 446 | try { |
| 447 | 447 | $sth = $this->db->prepare($query); |
| 448 | 448 | $sth->execute(); |
| 449 | - } catch(PDOException $e) { |
|
| 449 | + } catch (PDOException $e) { |
|
| 450 | 450 | echo $e->getMessage(); |
| 451 | 451 | die; |
| 452 | 452 | } |
@@ -461,24 +461,24 @@ discard block |
||
| 461 | 461 | * @return Array the spotter information |
| 462 | 462 | * |
| 463 | 463 | */ |
| 464 | - public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array()) |
|
| 464 | + public function getMinLiveSpotterDataPlayback($begindate, $enddate, $filter = array()) |
|
| 465 | 465 | { |
| 466 | 466 | global $globalDBdriver, $globalLiveInterval; |
| 467 | 467 | date_default_timezone_set('UTC'); |
| 468 | 468 | |
| 469 | 469 | $filter_query = ''; |
| 470 | 470 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 471 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 471 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
| 472 | 472 | } |
| 473 | 473 | // Should use spotter_output also ? |
| 474 | 474 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 475 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 475 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 476 | 476 | } |
| 477 | 477 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
| 478 | 478 | $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
| 479 | 479 | } |
| 480 | 480 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 481 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 481 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 482 | 482 | } |
| 483 | 483 | |
| 484 | 484 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -488,7 +488,7 @@ discard block |
||
| 488 | 488 | FROM spotter_archive |
| 489 | 489 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao'; |
| 490 | 490 | */ |
| 491 | - $query = 'SELECT a.aircraft_shadow, spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk |
|
| 491 | + $query = 'SELECT a.aircraft_shadow, spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk |
|
| 492 | 492 | FROM spotter_archive_output |
| 493 | 493 | LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive_output.aircraft_icao = a.icao |
| 494 | 494 | WHERE (spotter_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
@@ -503,7 +503,7 @@ discard block |
||
| 503 | 503 | WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".' |
| 504 | 504 | '.$filter_query.' GROUP BY spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao, spotter_archive_output.arrival_airport_icao, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow'; |
| 505 | 505 | */ |
| 506 | - $query = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow |
|
| 506 | + $query = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow |
|
| 507 | 507 | FROM spotter_archive_output |
| 508 | 508 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao |
| 509 | 509 | WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".' |
@@ -515,7 +515,7 @@ discard block |
||
| 515 | 515 | try { |
| 516 | 516 | $sth = $this->db->prepare($query); |
| 517 | 517 | $sth->execute(); |
| 518 | - } catch(PDOException $e) { |
|
| 518 | + } catch (PDOException $e) { |
|
| 519 | 519 | echo $e->getMessage(); |
| 520 | 520 | die; |
| 521 | 521 | } |
@@ -530,23 +530,23 @@ discard block |
||
| 530 | 530 | * @return Array the spotter information |
| 531 | 531 | * |
| 532 | 532 | */ |
| 533 | - public function getLiveSpotterCount($begindate,$enddate,$filter = array()) |
|
| 533 | + public function getLiveSpotterCount($begindate, $enddate, $filter = array()) |
|
| 534 | 534 | { |
| 535 | 535 | global $globalDBdriver, $globalLiveInterval; |
| 536 | 536 | date_default_timezone_set('UTC'); |
| 537 | 537 | |
| 538 | 538 | $filter_query = ''; |
| 539 | 539 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 540 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 540 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
| 541 | 541 | } |
| 542 | 542 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 543 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 543 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 544 | 544 | } |
| 545 | 545 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
| 546 | 546 | $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
| 547 | 547 | } |
| 548 | 548 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 549 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 549 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 550 | 550 | } |
| 551 | 551 | |
| 552 | 552 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -561,7 +561,7 @@ discard block |
||
| 561 | 561 | try { |
| 562 | 562 | $sth = $this->db->prepare($query); |
| 563 | 563 | $sth->execute(); |
| 564 | - } catch(PDOException $e) { |
|
| 564 | + } catch (PDOException $e) { |
|
| 565 | 565 | echo $e->getMessage(); |
| 566 | 566 | die; |
| 567 | 567 | } |
@@ -581,7 +581,7 @@ discard block |
||
| 581 | 581 | * @return Array the spotter information |
| 582 | 582 | * |
| 583 | 583 | */ |
| 584 | - public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array()) |
|
| 584 | + public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '', $pilot_id = '', $pilot_name = '', $altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $filters = array()) |
|
| 585 | 585 | { |
| 586 | 586 | global $globalTimezone, $globalDBdriver; |
| 587 | 587 | require_once(dirname(__FILE__).'/class.Translation.php'); |
@@ -603,7 +603,7 @@ discard block |
||
| 603 | 603 | |
| 604 | 604 | $q_array = explode(" ", $q); |
| 605 | 605 | |
| 606 | - foreach ($q_array as $q_item){ |
|
| 606 | + foreach ($q_array as $q_item) { |
|
| 607 | 607 | $additional_query .= " AND ("; |
| 608 | 608 | $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR "; |
| 609 | 609 | $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
@@ -635,7 +635,7 @@ discard block |
||
| 635 | 635 | |
| 636 | 636 | if ($registration != "") |
| 637 | 637 | { |
| 638 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 638 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
| 639 | 639 | if (!is_string($registration)) |
| 640 | 640 | { |
| 641 | 641 | return false; |
@@ -646,7 +646,7 @@ discard block |
||
| 646 | 646 | |
| 647 | 647 | if ($aircraft_icao != "") |
| 648 | 648 | { |
| 649 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 649 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
| 650 | 650 | if (!is_string($aircraft_icao)) |
| 651 | 651 | { |
| 652 | 652 | return false; |
@@ -657,7 +657,7 @@ discard block |
||
| 657 | 657 | |
| 658 | 658 | if ($aircraft_manufacturer != "") |
| 659 | 659 | { |
| 660 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
| 660 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING); |
|
| 661 | 661 | if (!is_string($aircraft_manufacturer)) |
| 662 | 662 | { |
| 663 | 663 | return false; |
@@ -678,7 +678,7 @@ discard block |
||
| 678 | 678 | |
| 679 | 679 | if ($airline_icao != "") |
| 680 | 680 | { |
| 681 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
| 681 | + $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING); |
|
| 682 | 682 | if (!is_string($airline_icao)) |
| 683 | 683 | { |
| 684 | 684 | return false; |
@@ -689,7 +689,7 @@ discard block |
||
| 689 | 689 | |
| 690 | 690 | if ($airline_country != "") |
| 691 | 691 | { |
| 692 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
| 692 | + $airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING); |
|
| 693 | 693 | if (!is_string($airline_country)) |
| 694 | 694 | { |
| 695 | 695 | return false; |
@@ -700,7 +700,7 @@ discard block |
||
| 700 | 700 | |
| 701 | 701 | if ($airline_type != "") |
| 702 | 702 | { |
| 703 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
| 703 | + $airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING); |
|
| 704 | 704 | if (!is_string($airline_type)) |
| 705 | 705 | { |
| 706 | 706 | return false; |
@@ -722,7 +722,7 @@ discard block |
||
| 722 | 722 | |
| 723 | 723 | if ($airport != "") |
| 724 | 724 | { |
| 725 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
| 725 | + $airport = filter_var($airport, FILTER_SANITIZE_STRING); |
|
| 726 | 726 | if (!is_string($airport)) |
| 727 | 727 | { |
| 728 | 728 | return false; |
@@ -733,7 +733,7 @@ discard block |
||
| 733 | 733 | |
| 734 | 734 | if ($airport_country != "") |
| 735 | 735 | { |
| 736 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
| 736 | + $airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING); |
|
| 737 | 737 | if (!is_string($airport_country)) |
| 738 | 738 | { |
| 739 | 739 | return false; |
@@ -744,7 +744,7 @@ discard block |
||
| 744 | 744 | |
| 745 | 745 | if ($callsign != "") |
| 746 | 746 | { |
| 747 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 747 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
| 748 | 748 | if (!is_string($callsign)) |
| 749 | 749 | { |
| 750 | 750 | return false; |
@@ -752,7 +752,7 @@ discard block |
||
| 752 | 752 | $translate = $Translation->ident2icao($callsign); |
| 753 | 753 | if ($translate != $callsign) { |
| 754 | 754 | $additional_query .= " AND (spotter_archive_output.ident = :callsign OR spotter_archive_output.ident = :translate)"; |
| 755 | - $query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate)); |
|
| 755 | + $query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate)); |
|
| 756 | 756 | } else { |
| 757 | 757 | $additional_query .= " AND (spotter_archive_output.ident = '".$callsign."')"; |
| 758 | 758 | } |
@@ -761,7 +761,7 @@ discard block |
||
| 761 | 761 | |
| 762 | 762 | if ($owner != "") |
| 763 | 763 | { |
| 764 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 764 | + $owner = filter_var($owner, FILTER_SANITIZE_STRING); |
|
| 765 | 765 | if (!is_string($owner)) |
| 766 | 766 | { |
| 767 | 767 | return false; |
@@ -772,7 +772,7 @@ discard block |
||
| 772 | 772 | |
| 773 | 773 | if ($pilot_name != "") |
| 774 | 774 | { |
| 775 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
| 775 | + $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING); |
|
| 776 | 776 | if (!is_string($pilot_name)) |
| 777 | 777 | { |
| 778 | 778 | return false; |
@@ -783,7 +783,7 @@ discard block |
||
| 783 | 783 | |
| 784 | 784 | if ($pilot_id != "") |
| 785 | 785 | { |
| 786 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
| 786 | + $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT); |
|
| 787 | 787 | if (!is_string($pilot_id)) |
| 788 | 788 | { |
| 789 | 789 | return false; |
@@ -794,7 +794,7 @@ discard block |
||
| 794 | 794 | |
| 795 | 795 | if ($departure_airport_route != "") |
| 796 | 796 | { |
| 797 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
| 797 | + $departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING); |
|
| 798 | 798 | if (!is_string($departure_airport_route)) |
| 799 | 799 | { |
| 800 | 800 | return false; |
@@ -805,7 +805,7 @@ discard block |
||
| 805 | 805 | |
| 806 | 806 | if ($arrival_airport_route != "") |
| 807 | 807 | { |
| 808 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
| 808 | + $arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING); |
|
| 809 | 809 | if (!is_string($arrival_airport_route)) |
| 810 | 810 | { |
| 811 | 811 | return false; |
@@ -818,8 +818,8 @@ discard block |
||
| 818 | 818 | { |
| 819 | 819 | $altitude_array = explode(",", $altitude); |
| 820 | 820 | |
| 821 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 822 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 821 | + $altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 822 | + $altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 823 | 823 | |
| 824 | 824 | |
| 825 | 825 | if ($altitude_array[1] != "") |
@@ -836,8 +836,8 @@ discard block |
||
| 836 | 836 | if ($date_posted != "") |
| 837 | 837 | { |
| 838 | 838 | $date_array = explode(",", $date_posted); |
| 839 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
| 840 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
| 839 | + $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING); |
|
| 840 | + $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING); |
|
| 841 | 841 | if ($globalTimezone != '') { |
| 842 | 842 | date_default_timezone_set($globalTimezone); |
| 843 | 843 | $datetime = new DateTime(); |
@@ -864,8 +864,8 @@ discard block |
||
| 864 | 864 | if ($limit != "") |
| 865 | 865 | { |
| 866 | 866 | $limit_array = explode(",", $limit); |
| 867 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 868 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 867 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 868 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 869 | 869 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 870 | 870 | { |
| 871 | 871 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
@@ -873,8 +873,8 @@ discard block |
||
| 873 | 873 | } |
| 874 | 874 | } |
| 875 | 875 | if ($origLat != "" && $origLon != "" && $dist != "") { |
| 876 | - $dist = number_format($dist*0.621371,2,'.',''); |
|
| 877 | - $query="SELECT spotter_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
| 876 | + $dist = number_format($dist*0.621371, 2, '.', ''); |
|
| 877 | + $query = "SELECT spotter_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
| 878 | 878 | FROM spotter_archive_output, spotter_archive WHERE spotter_output_archive.flightaware_id = spotter_archive.flightaware_id AND spotter_output.ident <> '' ".$additional_query."AND CAST(spotter_archive.longitude as double precision) between ($origLon-$dist/ABS(cos(radians($origLat))*69)) and ($origLon+$dist/ABS(cos(radians($origLat))*69)) and CAST(spotter_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) |
| 879 | 879 | AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query." ORDER BY distance"; |
| 880 | 880 | } else { |
@@ -890,12 +890,12 @@ discard block |
||
| 890 | 890 | $additional_query .= " AND (spotter_archive_output.waypoints <> '')"; |
| 891 | 891 | } |
| 892 | 892 | |
| 893 | - $query = "SELECT spotter_archive_output.* FROM spotter_archive_output |
|
| 893 | + $query = "SELECT spotter_archive_output.* FROM spotter_archive_output |
|
| 894 | 894 | WHERE spotter_archive_output.ident <> '' |
| 895 | 895 | ".$additional_query." |
| 896 | 896 | ".$filter_query.$orderby_query; |
| 897 | 897 | } |
| 898 | - $spotter_array = $Spotter->getDataFromDB($query, $query_values,$limit_query); |
|
| 898 | + $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
|
| 899 | 899 | return $spotter_array; |
| 900 | 900 | } |
| 901 | 901 | |
@@ -910,7 +910,7 @@ discard block |
||
| 910 | 910 | try { |
| 911 | 911 | $sth = $this->db->prepare($query); |
| 912 | 912 | $sth->execute(); |
| 913 | - } catch(PDOException $e) { |
|
| 913 | + } catch (PDOException $e) { |
|
| 914 | 914 | return "error"; |
| 915 | 915 | } |
| 916 | 916 | } |
@@ -947,8 +947,8 @@ discard block |
||
| 947 | 947 | { |
| 948 | 948 | $limit_array = explode(",", $limit); |
| 949 | 949 | |
| 950 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 951 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 950 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 951 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 952 | 952 | |
| 953 | 953 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 954 | 954 | { |
@@ -989,7 +989,7 @@ discard block |
||
| 989 | 989 | $query_values = array(); |
| 990 | 990 | $limit_query = ''; |
| 991 | 991 | $additional_query = ''; |
| 992 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 992 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 993 | 993 | |
| 994 | 994 | if ($owner != "") |
| 995 | 995 | { |
@@ -1006,8 +1006,8 @@ discard block |
||
| 1006 | 1006 | { |
| 1007 | 1007 | $limit_array = explode(",", $limit); |
| 1008 | 1008 | |
| 1009 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1010 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1009 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1010 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1011 | 1011 | |
| 1012 | 1012 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1013 | 1013 | { |
@@ -1047,7 +1047,7 @@ discard block |
||
| 1047 | 1047 | $query_values = array(); |
| 1048 | 1048 | $limit_query = ''; |
| 1049 | 1049 | $additional_query = ''; |
| 1050 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 1050 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 1051 | 1051 | |
| 1052 | 1052 | if ($pilot != "") |
| 1053 | 1053 | { |
@@ -1059,8 +1059,8 @@ discard block |
||
| 1059 | 1059 | { |
| 1060 | 1060 | $limit_array = explode(",", $limit); |
| 1061 | 1061 | |
| 1062 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1063 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1062 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1063 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1064 | 1064 | |
| 1065 | 1065 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1066 | 1066 | { |
@@ -1090,7 +1090,7 @@ discard block |
||
| 1090 | 1090 | * @return Array the airline country list |
| 1091 | 1091 | * |
| 1092 | 1092 | */ |
| 1093 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1093 | + public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
| 1094 | 1094 | { |
| 1095 | 1095 | global $globalDBdriver; |
| 1096 | 1096 | /* |
@@ -1119,7 +1119,7 @@ discard block |
||
| 1119 | 1119 | $flight_array = array(); |
| 1120 | 1120 | $temp_array = array(); |
| 1121 | 1121 | |
| 1122 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1122 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1123 | 1123 | { |
| 1124 | 1124 | $temp_array['flight_count'] = $row['nb']; |
| 1125 | 1125 | $temp_array['flight_country'] = $row['name']; |
@@ -1136,7 +1136,7 @@ discard block |
||
| 1136 | 1136 | * @return Array the airline country list |
| 1137 | 1137 | * |
| 1138 | 1138 | */ |
| 1139 | - public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1139 | + public function countAllFlightOverCountriesByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
| 1140 | 1140 | { |
| 1141 | 1141 | global $globalDBdriver; |
| 1142 | 1142 | /* |
@@ -1165,7 +1165,7 @@ discard block |
||
| 1165 | 1165 | $flight_array = array(); |
| 1166 | 1166 | $temp_array = array(); |
| 1167 | 1167 | |
| 1168 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1168 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1169 | 1169 | { |
| 1170 | 1170 | $temp_array['airline_icao'] = $row['airline_icao']; |
| 1171 | 1171 | $temp_array['flight_count'] = $row['nb']; |
@@ -1183,14 +1183,14 @@ discard block |
||
| 1183 | 1183 | * @return Array the spotter information |
| 1184 | 1184 | * |
| 1185 | 1185 | */ |
| 1186 | - public function getDateArchiveSpotterDataById($id,$date) |
|
| 1186 | + public function getDateArchiveSpotterDataById($id, $date) |
|
| 1187 | 1187 | { |
| 1188 | 1188 | $Spotter = new Spotter($this->db); |
| 1189 | 1189 | date_default_timezone_set('UTC'); |
| 1190 | 1190 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 1191 | - $query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC'; |
|
| 1192 | - $date = date('c',$date); |
|
| 1193 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
|
| 1191 | + $query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC'; |
|
| 1192 | + $date = date('c', $date); |
|
| 1193 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date)); |
|
| 1194 | 1194 | return $spotter_array; |
| 1195 | 1195 | } |
| 1196 | 1196 | |
@@ -1200,14 +1200,14 @@ discard block |
||
| 1200 | 1200 | * @return Array the spotter information |
| 1201 | 1201 | * |
| 1202 | 1202 | */ |
| 1203 | - public function getDateArchiveSpotterDataByIdent($ident,$date) |
|
| 1203 | + public function getDateArchiveSpotterDataByIdent($ident, $date) |
|
| 1204 | 1204 | { |
| 1205 | 1205 | $Spotter = new Spotter($this->db); |
| 1206 | 1206 | date_default_timezone_set('UTC'); |
| 1207 | 1207 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 1208 | - $query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC'; |
|
| 1209 | - $date = date('c',$date); |
|
| 1210 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
| 1208 | + $query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC'; |
|
| 1209 | + $date = date('c', $date); |
|
| 1210 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
| 1211 | 1211 | return $spotter_array; |
| 1212 | 1212 | } |
| 1213 | 1213 | |
@@ -1217,7 +1217,7 @@ discard block |
||
| 1217 | 1217 | * @return Array the spotter information |
| 1218 | 1218 | * |
| 1219 | 1219 | */ |
| 1220 | - public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
| 1220 | + public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '', $filters = array()) |
|
| 1221 | 1221 | { |
| 1222 | 1222 | global $global_query; |
| 1223 | 1223 | $Spotter = new Spotter($this->db); |
@@ -1225,7 +1225,7 @@ discard block |
||
| 1225 | 1225 | $query_values = array(); |
| 1226 | 1226 | $limit_query = ''; |
| 1227 | 1227 | $additional_query = ''; |
| 1228 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1228 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1229 | 1229 | |
| 1230 | 1230 | if ($airport != "") |
| 1231 | 1231 | { |
@@ -1242,8 +1242,8 @@ discard block |
||
| 1242 | 1242 | { |
| 1243 | 1243 | $limit_array = explode(",", $limit); |
| 1244 | 1244 | |
| 1245 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1246 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1245 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1246 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1247 | 1247 | |
| 1248 | 1248 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1249 | 1249 | { |
@@ -6,7 +6,9 @@ discard block |
||
| 6 | 6 | public function __construct($dbc = null) { |
| 7 | 7 | $Connection = new Connection($dbc); |
| 8 | 8 | $this->db = $Connection->db; |
| 9 | - if ($this->db === null) die('Error: No DB connection.'); |
|
| 9 | + if ($this->db === null) { |
|
| 10 | + die('Error: No DB connection.'); |
|
| 11 | + } |
|
| 10 | 12 | } |
| 11 | 13 | |
| 12 | 14 | /** |
@@ -27,7 +29,9 @@ discard block |
||
| 27 | 29 | if (isset($filter[0]['source'])) { |
| 28 | 30 | $filters = array_merge($filters,$filter); |
| 29 | 31 | } |
| 30 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 32 | + if (is_array($globalFilter)) { |
|
| 33 | + $filter = array_merge($filter,$globalFilter); |
|
| 34 | + } |
|
| 31 | 35 | $filter_query_join = ''; |
| 32 | 36 | $filter_query_where = ''; |
| 33 | 37 | foreach($filters as $flt) { |
@@ -112,8 +116,11 @@ discard block |
||
| 112 | 116 | } |
| 113 | 117 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id"; |
| 114 | 118 | } |
| 115 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
| 116 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
| 119 | + if ($filter_query_where == '' && $where) { |
|
| 120 | + $filter_query_where = ' WHERE'; |
|
| 121 | + } elseif ($filter_query_where != '' && $and) { |
|
| 122 | + $filter_query_where .= ' AND'; |
|
| 123 | + } |
|
| 117 | 124 | if ($filter_query_where != '') { |
| 118 | 125 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
| 119 | 126 | } |
@@ -127,10 +134,17 @@ discard block |
||
| 127 | 134 | if ($over_country == '') { |
| 128 | 135 | $Spotter = new Spotter($this->db); |
| 129 | 136 | $data_country = $Spotter->getCountryFromLatitudeLongitude($latitude,$longitude); |
| 130 | - if (!empty($data_country)) $country = $data_country['iso2']; |
|
| 131 | - else $country = ''; |
|
| 132 | - } else $country = $over_country; |
|
| 133 | - if ($airline_type === NULL) $airline_type =''; |
|
| 137 | + if (!empty($data_country)) { |
|
| 138 | + $country = $data_country['iso2']; |
|
| 139 | + } else { |
|
| 140 | + $country = ''; |
|
| 141 | + } |
|
| 142 | + } else { |
|
| 143 | + $country = $over_country; |
|
| 144 | + } |
|
| 145 | + if ($airline_type === NULL) { |
|
| 146 | + $airline_type =''; |
|
| 147 | + } |
|
| 134 | 148 | |
| 135 | 149 | //if ($country == '') echo "\n".'************ UNKNOW COUNTRY ****************'."\n"; |
| 136 | 150 | //else echo "\n".'*/*/*/*/*/*/*/ Country : '.$country.' */*/*/*/*/*/*/*/*/'."\n"; |
@@ -626,7 +640,9 @@ discard block |
||
| 626 | 640 | $additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR "; |
| 627 | 641 | $additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR "; |
| 628 | 642 | $translate = $Translation->ident2icao($q_item); |
| 629 | - if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR "; |
|
| 643 | + if ($translate != $q_item) { |
|
| 644 | + $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR "; |
|
| 645 | + } |
|
| 630 | 646 | $additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')"; |
| 631 | 647 | $additional_query .= ")"; |
| 632 | 648 | } |
@@ -842,7 +858,9 @@ discard block |
||
| 842 | 858 | date_default_timezone_set($globalTimezone); |
| 843 | 859 | $datetime = new DateTime(); |
| 844 | 860 | $offset = $datetime->format('P'); |
| 845 | - } else $offset = '+00:00'; |
|
| 861 | + } else { |
|
| 862 | + $offset = '+00:00'; |
|
| 863 | + } |
|
| 846 | 864 | if ($date_array[1] != "") |
| 847 | 865 | { |
| 848 | 866 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
@@ -1108,9 +1126,13 @@ discard block |
||
| 1108 | 1126 | $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
| 1109 | 1127 | } |
| 1110 | 1128 | } |
| 1111 | - if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
| 1129 | + if ($sincedate != '') { |
|
| 1130 | + $query .= "AND date > '".$sincedate."' "; |
|
| 1131 | + } |
|
| 1112 | 1132 | $query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
| 1113 | - if ($limit) $query .= " LIMIT 0,10"; |
|
| 1133 | + if ($limit) { |
|
| 1134 | + $query .= " LIMIT 0,10"; |
|
| 1135 | + } |
|
| 1114 | 1136 | |
| 1115 | 1137 | |
| 1116 | 1138 | $sth = $this->db->prepare($query); |
@@ -1154,9 +1176,13 @@ discard block |
||
| 1154 | 1176 | $query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
| 1155 | 1177 | } |
| 1156 | 1178 | } |
| 1157 | - if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
| 1179 | + if ($sincedate != '') { |
|
| 1180 | + $query .= "AND s.date > '".$sincedate."' "; |
|
| 1181 | + } |
|
| 1158 | 1182 | $query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
| 1159 | - if ($limit) $query .= " LIMIT 0,10"; |
|
| 1183 | + if ($limit) { |
|
| 1184 | + $query .= " LIMIT 0,10"; |
|
| 1185 | + } |
|
| 1160 | 1186 | |
| 1161 | 1187 | |
| 1162 | 1188 | $sth = $this->db->prepare($query); |
@@ -405,17 +405,17 @@ discard block |
||
| 405 | 405 | } |
| 406 | 406 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 407 | 407 | } else $all = array(); |
| 408 | - if (empty($all)) { |
|
| 409 | - $Spotter = new Spotter($this->db); |
|
| 410 | - $filters = array(); |
|
| 408 | + if (empty($all)) { |
|
| 409 | + $Spotter = new Spotter($this->db); |
|
| 410 | + $filters = array(); |
|
| 411 | 411 | $filters = array('year' => $year,'month' => $month); |
| 412 | - if ($filter_name != '') { |
|
| 413 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 412 | + if ($filter_name != '') { |
|
| 413 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 414 | 414 | } |
| 415 | 415 | //$all = $Spotter->countAllAirlines($limit,0,'',$filters,$year,$month); |
| 416 | - $all = $Spotter->countAllAirlines($limit,0,'',$filters); |
|
| 417 | - } |
|
| 418 | - return $all; |
|
| 416 | + $all = $Spotter->countAllAirlines($limit,0,'',$filters); |
|
| 417 | + } |
|
| 418 | + return $all; |
|
| 419 | 419 | } |
| 420 | 420 | public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
| 421 | 421 | global $globalStatsFilters; |
@@ -1612,7 +1612,7 @@ discard block |
||
| 1612 | 1612 | return "error : ".$e->getMessage(); |
| 1613 | 1613 | } |
| 1614 | 1614 | } |
| 1615 | - /* |
|
| 1615 | + /* |
|
| 1616 | 1616 | public function getStatsSource($date,$stats_type = '') { |
| 1617 | 1617 | if ($stats_type == '') { |
| 1618 | 1618 | $query = "SELECT * FROM stats_source WHERE stats_date = :date ORDER BY source_name"; |
@@ -2574,8 +2574,8 @@ discard block |
||
| 2574 | 2574 | } |
| 2575 | 2575 | if ($globalDebug) echo 'Count all aircrafts by months...'."\n"; |
| 2576 | 2576 | $alldata = $Spotter->countAllMonthsAircrafts($filter); |
| 2577 | - foreach ($alldata as $number) { |
|
| 2578 | - $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); |
|
| 2577 | + foreach ($alldata as $number) { |
|
| 2578 | + $this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name); |
|
| 2579 | 2579 | } |
| 2580 | 2580 | if ($globalDebug) echo 'Count all real arrivals by months...'."\n"; |
| 2581 | 2581 | $alldata = $Spotter->countAllMonthsRealArrivals($filter); |
@@ -19,14 +19,14 @@ discard block |
||
| 19 | 19 | if ($this->db === null) die('Error: No DB connection.'); |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | - public function addLastStatsUpdate($type,$stats_date) { |
|
| 22 | + public function addLastStatsUpdate($type, $stats_date) { |
|
| 23 | 23 | $query = "DELETE FROM config WHERE name = :type; |
| 24 | 24 | INSERT INTO config (name,value) VALUES (:type,:stats_date);"; |
| 25 | - $query_values = array('type' => $type,':stats_date' => $stats_date); |
|
| 25 | + $query_values = array('type' => $type, ':stats_date' => $stats_date); |
|
| 26 | 26 | try { |
| 27 | 27 | $sth = $this->db->prepare($query); |
| 28 | 28 | $sth->execute($query_values); |
| 29 | - } catch(PDOException $e) { |
|
| 29 | + } catch (PDOException $e) { |
|
| 30 | 30 | return "error : ".$e->getMessage(); |
| 31 | 31 | } |
| 32 | 32 | } |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | try { |
| 37 | 37 | $sth = $this->db->prepare($query); |
| 38 | 38 | $sth->execute(array(':type' => $type)); |
| 39 | - } catch(PDOException $e) { |
|
| 39 | + } catch (PDOException $e) { |
|
| 40 | 40 | echo "error : ".$e->getMessage(); |
| 41 | 41 | } |
| 42 | 42 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | try { |
| 58 | 58 | $sth = $this->db->prepare($query); |
| 59 | 59 | $sth->execute(array(':filter_name' => $filter_name)); |
| 60 | - } catch(PDOException $e) { |
|
| 60 | + } catch (PDOException $e) { |
|
| 61 | 61 | return "error : ".$e->getMessage(); |
| 62 | 62 | } |
| 63 | 63 | } |
@@ -70,14 +70,14 @@ discard block |
||
| 70 | 70 | try { |
| 71 | 71 | $sth = $this->db->prepare($query); |
| 72 | 72 | $sth->execute(); |
| 73 | - } catch(PDOException $e) { |
|
| 73 | + } catch (PDOException $e) { |
|
| 74 | 74 | return "error : ".$e->getMessage(); |
| 75 | 75 | } |
| 76 | 76 | $query = "DELETE FROM stats_aircraft WHERE filter_name = :filter_name;DELETE FROM stats_airline WHERE filter_name = :filter_name;DELETE FROM stats_callsign WHERE filter_name = :filter_name;DELETE FROM stats_country WHERE filter_name = :filter_name;DELETE FROM stats_owner WHERE filter_name = :filter_name;DELETE FROM stats_pilot WHERE filter_name = :filter_name;DELETE FROM stats_registration WHERE filter_name = :filter_name;"; |
| 77 | 77 | try { |
| 78 | 78 | $sth = $this->db->prepare($query); |
| 79 | 79 | $sth->execute(array(':filter_name' => $filter_name)); |
| 80 | - } catch(PDOException $e) { |
|
| 80 | + } catch (PDOException $e) { |
|
| 81 | 81 | return "error : ".$e->getMessage(); |
| 82 | 82 | } |
| 83 | 83 | } |
@@ -89,77 +89,77 @@ discard block |
||
| 89 | 89 | try { |
| 90 | 90 | $sth = $this->db->prepare($query); |
| 91 | 91 | $sth->execute(array(':filter_name' => $filter_name)); |
| 92 | - } catch(PDOException $e) { |
|
| 92 | + } catch (PDOException $e) { |
|
| 93 | 93 | echo "error : ".$e->getMessage(); |
| 94 | 94 | } |
| 95 | 95 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 96 | 96 | if (empty($all)) { |
| 97 | 97 | $filters = array(); |
| 98 | 98 | if ($filter_name != '') { |
| 99 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 99 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 100 | 100 | } |
| 101 | 101 | $Spotter = new Spotter($this->db); |
| 102 | - $all = $Spotter->getAllAirlineNames('',NULL,$filters); |
|
| 102 | + $all = $Spotter->getAllAirlineNames('', NULL, $filters); |
|
| 103 | 103 | } |
| 104 | 104 | return $all; |
| 105 | 105 | } |
| 106 | - public function getAllAircraftTypes($stats_airline = '',$filter_name = '') { |
|
| 106 | + public function getAllAircraftTypes($stats_airline = '', $filter_name = '') { |
|
| 107 | 107 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 108 | 108 | $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC"; |
| 109 | 109 | try { |
| 110 | 110 | $sth = $this->db->prepare($query); |
| 111 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 112 | - } catch(PDOException $e) { |
|
| 111 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 112 | + } catch (PDOException $e) { |
|
| 113 | 113 | echo "error : ".$e->getMessage(); |
| 114 | 114 | } |
| 115 | 115 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 116 | 116 | return $all; |
| 117 | 117 | } |
| 118 | - public function getAllManufacturers($stats_airline = '',$filter_name = '') { |
|
| 118 | + public function getAllManufacturers($stats_airline = '', $filter_name = '') { |
|
| 119 | 119 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 120 | 120 | $query = "SELECT DISTINCT(aircraft_manufacturer) FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND aircraft_manufacturer <> '' ORDER BY aircraft_manufacturer ASC"; |
| 121 | 121 | try { |
| 122 | 122 | $sth = $this->db->prepare($query); |
| 123 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 124 | - } catch(PDOException $e) { |
|
| 123 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 124 | + } catch (PDOException $e) { |
|
| 125 | 125 | echo "error : ".$e->getMessage(); |
| 126 | 126 | } |
| 127 | 127 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 128 | 128 | return $all; |
| 129 | 129 | } |
| 130 | - public function getAllAirportNames($stats_airline = '',$filter_name = '') { |
|
| 130 | + public function getAllAirportNames($stats_airline = '', $filter_name = '') { |
|
| 131 | 131 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 132 | 132 | $query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND stats_type = 'daily' GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC"; |
| 133 | 133 | try { |
| 134 | 134 | $sth = $this->db->prepare($query); |
| 135 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 136 | - } catch(PDOException $e) { |
|
| 135 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 136 | + } catch (PDOException $e) { |
|
| 137 | 137 | echo "error : ".$e->getMessage(); |
| 138 | 138 | } |
| 139 | 139 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 140 | 140 | return $all; |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | - public function getAllOwnerNames($stats_airline = '',$filter_name = '') { |
|
| 143 | + public function getAllOwnerNames($stats_airline = '', $filter_name = '') { |
|
| 144 | 144 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 145 | 145 | $query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC"; |
| 146 | 146 | try { |
| 147 | 147 | $sth = $this->db->prepare($query); |
| 148 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 149 | - } catch(PDOException $e) { |
|
| 148 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 149 | + } catch (PDOException $e) { |
|
| 150 | 150 | echo "error : ".$e->getMessage(); |
| 151 | 151 | } |
| 152 | 152 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 153 | 153 | return $all; |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | - public function getAllPilotNames($stats_airline = '',$filter_name = '') { |
|
| 156 | + public function getAllPilotNames($stats_airline = '', $filter_name = '') { |
|
| 157 | 157 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 158 | 158 | $query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC"; |
| 159 | 159 | try { |
| 160 | 160 | $sth = $this->db->prepare($query); |
| 161 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 162 | - } catch(PDOException $e) { |
|
| 161 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 162 | + } catch (PDOException $e) { |
|
| 163 | 163 | echo "error : ".$e->getMessage(); |
| 164 | 164 | } |
| 165 | 165 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -167,23 +167,23 @@ discard block |
||
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | |
| 170 | - public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') { |
|
| 170 | + public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
| 171 | 171 | global $globalStatsFilters; |
| 172 | 172 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 173 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 173 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 174 | 174 | $Spotter = new Spotter($this->db); |
| 175 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 175 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 176 | 176 | $alliance_airlines = array(); |
| 177 | 177 | foreach ($airlines as $airline) { |
| 178 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 178 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 179 | 179 | } |
| 180 | 180 | if ($year == '' && $month == '') { |
| 181 | - if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 182 | - else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
|
| 181 | + if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 182 | + else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
|
| 183 | 183 | try { |
| 184 | 184 | $sth = $this->db->prepare($query); |
| 185 | 185 | $sth->execute(array(':filter_name' => $filter_name)); |
| 186 | - } catch(PDOException $e) { |
|
| 186 | + } catch (PDOException $e) { |
|
| 187 | 187 | echo "error : ".$e->getMessage(); |
| 188 | 188 | } |
| 189 | 189 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -194,29 +194,29 @@ discard block |
||
| 194 | 194 | else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
| 195 | 195 | try { |
| 196 | 196 | $sth = $this->db->prepare($query); |
| 197 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 198 | - } catch(PDOException $e) { |
|
| 197 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 198 | + } catch (PDOException $e) { |
|
| 199 | 199 | echo "error : ".$e->getMessage(); |
| 200 | 200 | } |
| 201 | 201 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 202 | 202 | } else $all = array(); |
| 203 | 203 | } |
| 204 | 204 | if (empty($all)) { |
| 205 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 206 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month); |
|
| 205 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 206 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month); |
|
| 207 | 207 | } else { |
| 208 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
| 208 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
| 209 | 209 | } |
| 210 | 210 | if ($filter_name != '') { |
| 211 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 211 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 212 | 212 | } |
| 213 | 213 | $Spotter = new Spotter($this->db); |
| 214 | 214 | //$all = $Spotter->countAllAircraftTypes($limit,0,'',$filters,$year,$month); |
| 215 | - $all = $Spotter->countAllAircraftTypes($limit,0,'',$filters); |
|
| 215 | + $all = $Spotter->countAllAircraftTypes($limit, 0, '', $filters); |
|
| 216 | 216 | } |
| 217 | 217 | return $all; |
| 218 | 218 | } |
| 219 | - public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') { |
|
| 219 | + public function countAllAirlineCountries($limit = true, $filter_name = '', $year = '', $month = '') { |
|
| 220 | 220 | global $globalStatsFilters; |
| 221 | 221 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 222 | 222 | if ($year == '' && $month == '') { |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | try { |
| 226 | 226 | $sth = $this->db->prepare($query); |
| 227 | 227 | $sth->execute(array(':filter_name' => $filter_name)); |
| 228 | - } catch(PDOException $e) { |
|
| 228 | + } catch (PDOException $e) { |
|
| 229 | 229 | echo "error : ".$e->getMessage(); |
| 230 | 230 | } |
| 231 | 231 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -233,32 +233,32 @@ discard block |
||
| 233 | 233 | if (empty($all)) { |
| 234 | 234 | $Spotter = new Spotter($this->db); |
| 235 | 235 | $filters = array(); |
| 236 | - $filters = array('year' => $year,'month' => $month); |
|
| 236 | + $filters = array('year' => $year, 'month' => $month); |
|
| 237 | 237 | if ($filter_name != '') { |
| 238 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 238 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 239 | 239 | } |
| 240 | 240 | //$all = $Spotter->countAllAirlineCountries($limit,$filters,$year,$month); |
| 241 | - $all = $Spotter->countAllAirlineCountries($limit,$filters); |
|
| 241 | + $all = $Spotter->countAllAirlineCountries($limit, $filters); |
|
| 242 | 242 | } |
| 243 | 243 | return $all; |
| 244 | 244 | } |
| 245 | - public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') { |
|
| 245 | + public function countAllAircraftManufacturers($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
| 246 | 246 | global $globalStatsFilters; |
| 247 | 247 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 248 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 248 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 249 | 249 | $Spotter = new Spotter($this->db); |
| 250 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 250 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 251 | 251 | $alliance_airlines = array(); |
| 252 | 252 | foreach ($airlines as $airline) { |
| 253 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 253 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 254 | 254 | } |
| 255 | 255 | if ($year == '' && $month == '') { |
| 256 | - if ($limit) $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0"; |
|
| 257 | - else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC"; |
|
| 256 | + if ($limit) $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0"; |
|
| 257 | + else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC"; |
|
| 258 | 258 | try { |
| 259 | 259 | $sth = $this->db->prepare($query); |
| 260 | 260 | $sth->execute(array(':filter_name' => $filter_name)); |
| 261 | - } catch(PDOException $e) { |
|
| 261 | + } catch (PDOException $e) { |
|
| 262 | 262 | echo "error : ".$e->getMessage(); |
| 263 | 263 | } |
| 264 | 264 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -269,21 +269,21 @@ discard block |
||
| 269 | 269 | else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC"; |
| 270 | 270 | try { |
| 271 | 271 | $sth = $this->db->prepare($query); |
| 272 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 273 | - } catch(PDOException $e) { |
|
| 272 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 273 | + } catch (PDOException $e) { |
|
| 274 | 274 | echo "error : ".$e->getMessage(); |
| 275 | 275 | } |
| 276 | 276 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 277 | 277 | } else $all = array(); |
| 278 | 278 | } |
| 279 | 279 | if (empty($all)) { |
| 280 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 281 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month); |
|
| 280 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 281 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month); |
|
| 282 | 282 | } else { |
| 283 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
| 283 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
| 284 | 284 | } |
| 285 | 285 | if ($filter_name != '') { |
| 286 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 286 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 287 | 287 | } |
| 288 | 288 | $Spotter = new Spotter($this->db); |
| 289 | 289 | //$all = $Spotter->countAllAircraftManufacturers($filters,$year,$month); |
@@ -292,23 +292,23 @@ discard block |
||
| 292 | 292 | return $all; |
| 293 | 293 | } |
| 294 | 294 | |
| 295 | - public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') { |
|
| 295 | + public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
| 296 | 296 | global $globalStatsFilters; |
| 297 | 297 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 298 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 298 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 299 | 299 | $Spotter = new Spotter($this->db); |
| 300 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 300 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 301 | 301 | $alliance_airlines = array(); |
| 302 | 302 | foreach ($airlines as $airline) { |
| 303 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 303 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 304 | 304 | } |
| 305 | 305 | if ($year == '' && $month == '') { |
| 306 | - if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 307 | - else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC"; |
|
| 306 | + if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 307 | + else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC"; |
|
| 308 | 308 | try { |
| 309 | 309 | $sth = $this->db->prepare($query); |
| 310 | 310 | $sth->execute(array(':filter_name' => $filter_name)); |
| 311 | - } catch(PDOException $e) { |
|
| 311 | + } catch (PDOException $e) { |
|
| 312 | 312 | echo "error : ".$e->getMessage(); |
| 313 | 313 | } |
| 314 | 314 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -319,61 +319,61 @@ discard block |
||
| 319 | 319 | else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC"; |
| 320 | 320 | try { |
| 321 | 321 | $sth = $this->db->prepare($query); |
| 322 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 323 | - } catch(PDOException $e) { |
|
| 322 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 323 | + } catch (PDOException $e) { |
|
| 324 | 324 | echo "error : ".$e->getMessage(); |
| 325 | 325 | } |
| 326 | 326 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 327 | 327 | } else $all = array(); |
| 328 | 328 | } |
| 329 | 329 | if (empty($all)) { |
| 330 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 331 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month); |
|
| 330 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 331 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month); |
|
| 332 | 332 | } else { |
| 333 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
| 333 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
| 334 | 334 | } |
| 335 | 335 | if ($filter_name != '') { |
| 336 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 336 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 337 | 337 | } |
| 338 | 338 | $Spotter = new Spotter($this->db); |
| 339 | 339 | //$all = $Spotter->countAllArrivalCountries($limit,$filters,$year,$month); |
| 340 | - $all = $Spotter->countAllArrivalCountries($limit,$filters); |
|
| 340 | + $all = $Spotter->countAllArrivalCountries($limit, $filters); |
|
| 341 | 341 | } |
| 342 | 342 | return $all; |
| 343 | 343 | } |
| 344 | 344 | public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
| 345 | 345 | global $globalStatsFilters; |
| 346 | 346 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 347 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 347 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 348 | 348 | $Spotter = new Spotter($this->db); |
| 349 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 349 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 350 | 350 | $alliance_airlines = array(); |
| 351 | 351 | foreach ($airlines as $airline) { |
| 352 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 352 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 353 | 353 | } |
| 354 | - if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 355 | - else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC"; |
|
| 354 | + if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 355 | + else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC"; |
|
| 356 | 356 | $query_values = array(':filter_name' => $filter_name); |
| 357 | 357 | } else { |
| 358 | 358 | if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0"; |
| 359 | 359 | else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC"; |
| 360 | - $query_values = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
| 360 | + $query_values = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
| 361 | 361 | } |
| 362 | 362 | try { |
| 363 | 363 | $sth = $this->db->prepare($query); |
| 364 | 364 | $sth->execute($query_values); |
| 365 | - } catch(PDOException $e) { |
|
| 365 | + } catch (PDOException $e) { |
|
| 366 | 366 | echo "error : ".$e->getMessage(); |
| 367 | 367 | } |
| 368 | 368 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 369 | 369 | if (empty($all)) { |
| 370 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 371 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month); |
|
| 370 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 371 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month); |
|
| 372 | 372 | } else { |
| 373 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
| 373 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
| 374 | 374 | } |
| 375 | 375 | if ($filter_name != '') { |
| 376 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 376 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 377 | 377 | } |
| 378 | 378 | $Spotter = new Spotter($this->db); |
| 379 | 379 | //$all = $Spotter->countAllDepartureCountries($filters,$year,$month); |
@@ -382,7 +382,7 @@ discard block |
||
| 382 | 382 | return $all; |
| 383 | 383 | } |
| 384 | 384 | |
| 385 | - public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') { |
|
| 385 | + public function countAllAirlines($limit = true, $filter_name = '', $year = '', $month = '') { |
|
| 386 | 386 | global $globalStatsFilters, $globalVATSIM, $globalIVAO; |
| 387 | 387 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 388 | 388 | if ($year == '' && $month == '') { |
@@ -391,7 +391,7 @@ discard block |
||
| 391 | 391 | if (isset($forsource)) { |
| 392 | 392 | if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
| 393 | 393 | else $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC"; |
| 394 | - $query_values = array(':filter_name' => $filter_name,':forsource' => $forsource); |
|
| 394 | + $query_values = array(':filter_name' => $filter_name, ':forsource' => $forsource); |
|
| 395 | 395 | } else { |
| 396 | 396 | if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
| 397 | 397 | else $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC"; |
@@ -400,7 +400,7 @@ discard block |
||
| 400 | 400 | try { |
| 401 | 401 | $sth = $this->db->prepare($query); |
| 402 | 402 | $sth->execute($query_values); |
| 403 | - } catch(PDOException $e) { |
|
| 403 | + } catch (PDOException $e) { |
|
| 404 | 404 | echo "error : ".$e->getMessage(); |
| 405 | 405 | } |
| 406 | 406 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -408,32 +408,32 @@ discard block |
||
| 408 | 408 | if (empty($all)) { |
| 409 | 409 | $Spotter = new Spotter($this->db); |
| 410 | 410 | $filters = array(); |
| 411 | - $filters = array('year' => $year,'month' => $month); |
|
| 411 | + $filters = array('year' => $year, 'month' => $month); |
|
| 412 | 412 | if ($filter_name != '') { |
| 413 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 413 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 414 | 414 | } |
| 415 | 415 | //$all = $Spotter->countAllAirlines($limit,0,'',$filters,$year,$month); |
| 416 | - $all = $Spotter->countAllAirlines($limit,0,'',$filters); |
|
| 416 | + $all = $Spotter->countAllAirlines($limit, 0, '', $filters); |
|
| 417 | 417 | } |
| 418 | 418 | return $all; |
| 419 | 419 | } |
| 420 | - public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
|
| 420 | + public function countAllAircraftRegistrations($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
| 421 | 421 | global $globalStatsFilters; |
| 422 | 422 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 423 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 423 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 424 | 424 | $Spotter = new Spotter($this->db); |
| 425 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 425 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 426 | 426 | $alliance_airlines = array(); |
| 427 | 427 | foreach ($airlines as $airline) { |
| 428 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 428 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 429 | 429 | } |
| 430 | 430 | if ($year == '' && $month == '') { |
| 431 | - if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0"; |
|
| 432 | - else $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC"; |
|
| 431 | + if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0"; |
|
| 432 | + else $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC"; |
|
| 433 | 433 | try { |
| 434 | 434 | $sth = $this->db->prepare($query); |
| 435 | 435 | $sth->execute(array(':filter_name' => $filter_name)); |
| 436 | - } catch(PDOException $e) { |
|
| 436 | + } catch (PDOException $e) { |
|
| 437 | 437 | echo "error : ".$e->getMessage(); |
| 438 | 438 | } |
| 439 | 439 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -444,45 +444,45 @@ discard block |
||
| 444 | 444 | else $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC"; |
| 445 | 445 | try { |
| 446 | 446 | $sth = $this->db->prepare($query); |
| 447 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 448 | - } catch(PDOException $e) { |
|
| 447 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 448 | + } catch (PDOException $e) { |
|
| 449 | 449 | echo "error : ".$e->getMessage(); |
| 450 | 450 | } |
| 451 | 451 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 452 | 452 | } else $all = array(); |
| 453 | 453 | } |
| 454 | 454 | if (empty($all)) { |
| 455 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 456 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month); |
|
| 455 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 456 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month); |
|
| 457 | 457 | } else { |
| 458 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
| 458 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
| 459 | 459 | } |
| 460 | 460 | if ($filter_name != '') { |
| 461 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 461 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 462 | 462 | } |
| 463 | 463 | $Spotter = new Spotter($this->db); |
| 464 | 464 | //$all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters,$year,$month); |
| 465 | - $all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters); |
|
| 465 | + $all = $Spotter->countAllAircraftRegistrations($limit, 0, '', $filters); |
|
| 466 | 466 | } |
| 467 | 467 | return $all; |
| 468 | 468 | } |
| 469 | - public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
|
| 469 | + public function countAllCallsigns($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
| 470 | 470 | global $globalStatsFilters; |
| 471 | 471 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 472 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 472 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 473 | 473 | $Spotter = new Spotter($this->db); |
| 474 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 474 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 475 | 475 | $alliance_airlines = array(); |
| 476 | 476 | foreach ($airlines as $airline) { |
| 477 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 477 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 478 | 478 | } |
| 479 | 479 | if ($year == '' && $month == '') { |
| 480 | - if ($limit) $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 481 | - else $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC"; |
|
| 480 | + if ($limit) $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 481 | + else $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC"; |
|
| 482 | 482 | try { |
| 483 | 483 | $sth = $this->db->prepare($query); |
| 484 | 484 | $sth->execute(array(':filter_name' => $filter_name)); |
| 485 | - } catch(PDOException $e) { |
|
| 485 | + } catch (PDOException $e) { |
|
| 486 | 486 | echo "error : ".$e->getMessage(); |
| 487 | 487 | } |
| 488 | 488 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -493,46 +493,46 @@ discard block |
||
| 493 | 493 | else $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC"; |
| 494 | 494 | try { |
| 495 | 495 | $sth = $this->db->prepare($query); |
| 496 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 497 | - } catch(PDOException $e) { |
|
| 496 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 497 | + } catch (PDOException $e) { |
|
| 498 | 498 | echo "error : ".$e->getMessage(); |
| 499 | 499 | } |
| 500 | 500 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 501 | 501 | } else $all = array(); |
| 502 | 502 | } |
| 503 | 503 | if (empty($all)) { |
| 504 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 505 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month); |
|
| 504 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 505 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month); |
|
| 506 | 506 | } else { |
| 507 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
| 507 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
| 508 | 508 | } |
| 509 | 509 | if ($filter_name != '') { |
| 510 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 510 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 511 | 511 | } |
| 512 | 512 | $Spotter = new Spotter($this->db); |
| 513 | 513 | //$all = $Spotter->countAllCallsigns($limit,0,'',$filters,$year,$month); |
| 514 | - $all = $Spotter->countAllCallsigns($limit,0,'',$filters); |
|
| 514 | + $all = $Spotter->countAllCallsigns($limit, 0, '', $filters); |
|
| 515 | 515 | } |
| 516 | 516 | return $all; |
| 517 | 517 | } |
| 518 | - public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '',$year = '',$month = '') { |
|
| 518 | + public function countAllFlightOverCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
| 519 | 519 | $Connection = new Connection($this->db); |
| 520 | 520 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 521 | 521 | if ($Connection->tableExists('countries')) { |
| 522 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 522 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 523 | 523 | $Spotter = new Spotter($this->db); |
| 524 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 524 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 525 | 525 | if ($year == '' && $month == '') { |
| 526 | 526 | $alliance_airlines = array(); |
| 527 | 527 | foreach ($airlines as $airline) { |
| 528 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 528 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 529 | 529 | } |
| 530 | - if ($limit) $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0"; |
|
| 531 | - else $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC"; |
|
| 530 | + if ($limit) $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0"; |
|
| 531 | + else $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC"; |
|
| 532 | 532 | try { |
| 533 | 533 | $sth = $this->db->prepare($query); |
| 534 | 534 | $sth->execute(array(':filter_name' => $filter_name)); |
| 535 | - } catch(PDOException $e) { |
|
| 535 | + } catch (PDOException $e) { |
|
| 536 | 536 | echo "error : ".$e->getMessage(); |
| 537 | 537 | } |
| 538 | 538 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -544,8 +544,8 @@ discard block |
||
| 544 | 544 | else $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC"; |
| 545 | 545 | try { |
| 546 | 546 | $sth = $this->db->prepare($query); |
| 547 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 548 | - } catch(PDOException $e) { |
|
| 547 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 548 | + } catch (PDOException $e) { |
|
| 549 | 549 | echo "error : ".$e->getMessage(); |
| 550 | 550 | } |
| 551 | 551 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -562,7 +562,7 @@ discard block |
||
| 562 | 562 | return array(); |
| 563 | 563 | } |
| 564 | 564 | } |
| 565 | - public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '', $year = '',$month = '') { |
|
| 565 | + public function countAllPilots($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
| 566 | 566 | global $globalStatsFilters; |
| 567 | 567 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 568 | 568 | if ($year == '' && $month == '') { |
@@ -570,41 +570,41 @@ discard block |
||
| 570 | 570 | else $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC"; |
| 571 | 571 | try { |
| 572 | 572 | $sth = $this->db->prepare($query); |
| 573 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 574 | - } catch(PDOException $e) { |
|
| 573 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 574 | + } catch (PDOException $e) { |
|
| 575 | 575 | echo "error : ".$e->getMessage(); |
| 576 | 576 | } |
| 577 | 577 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 578 | 578 | } else $all = array(); |
| 579 | 579 | if (empty($all)) { |
| 580 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
| 580 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
| 581 | 581 | if ($filter_name != '') { |
| 582 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 582 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 583 | 583 | } |
| 584 | 584 | $Spotter = new Spotter($this->db); |
| 585 | 585 | //$all = $Spotter->countAllPilots($limit,0,'',$filters,$year,$month); |
| 586 | - $all = $Spotter->countAllPilots($limit,0,'',$filters); |
|
| 586 | + $all = $Spotter->countAllPilots($limit, 0, '', $filters); |
|
| 587 | 587 | } |
| 588 | 588 | return $all; |
| 589 | 589 | } |
| 590 | 590 | |
| 591 | - public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '',$year = '',$month = '') { |
|
| 591 | + public function countAllOwners($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
| 592 | 592 | global $globalStatsFilters; |
| 593 | 593 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 594 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 594 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 595 | 595 | $Spotter = new Spotter($this->db); |
| 596 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 596 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 597 | 597 | if ($year == '' && $month == '') { |
| 598 | 598 | $alliance_airlines = array(); |
| 599 | 599 | foreach ($airlines as $airline) { |
| 600 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 600 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 601 | 601 | } |
| 602 | - if ($limit) $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0"; |
|
| 603 | - else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC"; |
|
| 602 | + if ($limit) $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0"; |
|
| 603 | + else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC"; |
|
| 604 | 604 | try { |
| 605 | 605 | $sth = $this->db->prepare($query); |
| 606 | 606 | $sth->execute(array(':filter_name' => $filter_name)); |
| 607 | - } catch(PDOException $e) { |
|
| 607 | + } catch (PDOException $e) { |
|
| 608 | 608 | echo "error : ".$e->getMessage(); |
| 609 | 609 | } |
| 610 | 610 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -615,45 +615,45 @@ discard block |
||
| 615 | 615 | else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC"; |
| 616 | 616 | try { |
| 617 | 617 | $sth = $this->db->prepare($query); |
| 618 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 619 | - } catch(PDOException $e) { |
|
| 618 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 619 | + } catch (PDOException $e) { |
|
| 620 | 620 | echo "error : ".$e->getMessage(); |
| 621 | 621 | } |
| 622 | 622 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 623 | 623 | } else $all = array(); |
| 624 | 624 | } |
| 625 | 625 | if (empty($all)) { |
| 626 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 627 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month); |
|
| 626 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 627 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month); |
|
| 628 | 628 | } else { |
| 629 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
| 629 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
| 630 | 630 | } |
| 631 | 631 | if ($filter_name != '') { |
| 632 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 632 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 633 | 633 | } |
| 634 | 634 | $Spotter = new Spotter($this->db); |
| 635 | 635 | //$all = $Spotter->countAllOwners($limit,0,'',$filters,$year,$month); |
| 636 | - $all = $Spotter->countAllOwners($limit,0,'',$filters); |
|
| 636 | + $all = $Spotter->countAllOwners($limit, 0, '', $filters); |
|
| 637 | 637 | } |
| 638 | 638 | return $all; |
| 639 | 639 | } |
| 640 | - public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
|
| 640 | + public function countAllDepartureAirports($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
| 641 | 641 | global $globalStatsFilters; |
| 642 | 642 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 643 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 643 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 644 | 644 | $Spotter = new Spotter($this->db); |
| 645 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 645 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 646 | 646 | if ($year == '' && $month == '') { |
| 647 | 647 | $alliance_airlines = array(); |
| 648 | 648 | foreach ($airlines as $airline) { |
| 649 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 649 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 650 | 650 | } |
| 651 | - if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 652 | - else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
|
| 651 | + if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 652 | + else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
|
| 653 | 653 | try { |
| 654 | 654 | $sth = $this->db->prepare($query); |
| 655 | 655 | $sth->execute(array(':filter_name' => $filter_name)); |
| 656 | - } catch(PDOException $e) { |
|
| 656 | + } catch (PDOException $e) { |
|
| 657 | 657 | echo "error : ".$e->getMessage(); |
| 658 | 658 | } |
| 659 | 659 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -664,27 +664,27 @@ discard block |
||
| 664 | 664 | else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
| 665 | 665 | try { |
| 666 | 666 | $sth = $this->db->prepare($query); |
| 667 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 668 | - } catch(PDOException $e) { |
|
| 667 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 668 | + } catch (PDOException $e) { |
|
| 669 | 669 | echo "error : ".$e->getMessage(); |
| 670 | 670 | } |
| 671 | 671 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 672 | 672 | } else $all = array(); |
| 673 | 673 | } |
| 674 | 674 | if (empty($all)) { |
| 675 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 676 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month); |
|
| 675 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 676 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month); |
|
| 677 | 677 | } else { |
| 678 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
| 678 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
| 679 | 679 | } |
| 680 | 680 | if ($filter_name != '') { |
| 681 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 681 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 682 | 682 | } |
| 683 | 683 | $Spotter = new Spotter($this->db); |
| 684 | 684 | // $pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters,$year,$month); |
| 685 | 685 | // $dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters,$year,$month); |
| 686 | - $pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters); |
|
| 687 | - $dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters); |
|
| 686 | + $pall = $Spotter->countAllDepartureAirports($limit, 0, '', $filters); |
|
| 687 | + $dall = $Spotter->countAllDetectedDepartureAirports($limit, 0, '', $filters); |
|
| 688 | 688 | $all = array(); |
| 689 | 689 | foreach ($pall as $value) { |
| 690 | 690 | $icao = $value['airport_departure_icao']; |
@@ -700,27 +700,27 @@ discard block |
||
| 700 | 700 | foreach ($all as $key => $row) { |
| 701 | 701 | $count[$key] = $row['airport_departure_icao_count']; |
| 702 | 702 | } |
| 703 | - array_multisort($count,SORT_DESC,$all); |
|
| 703 | + array_multisort($count, SORT_DESC, $all); |
|
| 704 | 704 | } |
| 705 | 705 | return $all; |
| 706 | 706 | } |
| 707 | - public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
|
| 707 | + public function countAllArrivalAirports($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
| 708 | 708 | global $globalStatsFilters; |
| 709 | 709 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 710 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 710 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 711 | 711 | $Spotter = new Spotter($this->db); |
| 712 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 712 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 713 | 713 | if ($year == '' && $month == '') { |
| 714 | 714 | $alliance_airlines = array(); |
| 715 | 715 | foreach ($airlines as $airline) { |
| 716 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 716 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 717 | 717 | } |
| 718 | - if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 719 | - else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
|
| 718 | + if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 719 | + else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
|
| 720 | 720 | try { |
| 721 | 721 | $sth = $this->db->prepare($query); |
| 722 | 722 | $sth->execute(array(':filter_name' => $filter_name)); |
| 723 | - } catch(PDOException $e) { |
|
| 723 | + } catch (PDOException $e) { |
|
| 724 | 724 | echo "error : ".$e->getMessage(); |
| 725 | 725 | } |
| 726 | 726 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -731,27 +731,27 @@ discard block |
||
| 731 | 731 | else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
| 732 | 732 | try { |
| 733 | 733 | $sth = $this->db->prepare($query); |
| 734 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 735 | - } catch(PDOException $e) { |
|
| 734 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 735 | + } catch (PDOException $e) { |
|
| 736 | 736 | echo "error : ".$e->getMessage(); |
| 737 | 737 | } |
| 738 | 738 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 739 | 739 | } else $all = array(); |
| 740 | 740 | } |
| 741 | 741 | if (empty($all)) { |
| 742 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 743 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month); |
|
| 742 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 743 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month); |
|
| 744 | 744 | } else { |
| 745 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
| 745 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
| 746 | 746 | } |
| 747 | 747 | if ($filter_name != '') { |
| 748 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 748 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 749 | 749 | } |
| 750 | 750 | $Spotter = new Spotter($this->db); |
| 751 | 751 | // $pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters,$year,$month); |
| 752 | 752 | // $dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters,$year,$month); |
| 753 | - $pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters); |
|
| 754 | - $dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters); |
|
| 753 | + $pall = $Spotter->countAllArrivalAirports($limit, 0, '', false, $filters); |
|
| 754 | + $dall = $Spotter->countAllDetectedArrivalAirports($limit, 0, '', false, $filters); |
|
| 755 | 755 | $all = array(); |
| 756 | 756 | foreach ($pall as $value) { |
| 757 | 757 | $icao = $value['airport_arrival_icao']; |
@@ -767,26 +767,26 @@ discard block |
||
| 767 | 767 | foreach ($all as $key => $row) { |
| 768 | 768 | $count[$key] = $row['airport_arrival_icao_count']; |
| 769 | 769 | } |
| 770 | - array_multisort($count,SORT_DESC,$all); |
|
| 770 | + array_multisort($count, SORT_DESC, $all); |
|
| 771 | 771 | } |
| 772 | 772 | return $all; |
| 773 | 773 | } |
| 774 | - public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') { |
|
| 774 | + public function countAllMonthsLastYear($limit = true, $stats_airline = '', $filter_name = '') { |
|
| 775 | 775 | global $globalDBdriver, $globalStatsFilters; |
| 776 | 776 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 777 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 777 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 778 | 778 | $Spotter = new Spotter($this->db); |
| 779 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 779 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 780 | 780 | $alliance_airlines = array(); |
| 781 | 781 | foreach ($airlines as $airline) { |
| 782 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 782 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 783 | 783 | } |
| 784 | 784 | if ($globalDBdriver == 'mysql') { |
| 785 | - if ($limit) $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
| 786 | - else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
| 785 | + if ($limit) $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
| 786 | + else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
| 787 | 787 | } else { |
| 788 | - if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
| 789 | - else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
| 788 | + if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
| 789 | + else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
| 790 | 790 | } |
| 791 | 791 | $query_data = array(':filter_name' => $filter_name); |
| 792 | 792 | } else { |
@@ -797,23 +797,23 @@ discard block |
||
| 797 | 797 | if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
| 798 | 798 | else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
| 799 | 799 | } |
| 800 | - $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
| 800 | + $query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
| 801 | 801 | } |
| 802 | 802 | try { |
| 803 | 803 | $sth = $this->db->prepare($query); |
| 804 | 804 | $sth->execute($query_data); |
| 805 | - } catch(PDOException $e) { |
|
| 805 | + } catch (PDOException $e) { |
|
| 806 | 806 | echo "error : ".$e->getMessage(); |
| 807 | 807 | } |
| 808 | 808 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 809 | 809 | if (empty($all)) { |
| 810 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 811 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 810 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 811 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 812 | 812 | } else { |
| 813 | 813 | $filters = array('airlines' => array($stats_airline)); |
| 814 | 814 | } |
| 815 | 815 | if ($filter_name != '') { |
| 816 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 816 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 817 | 817 | } |
| 818 | 818 | $Spotter = new Spotter($this->db); |
| 819 | 819 | $all = $Spotter->countAllMonthsLastYear($filters); |
@@ -821,57 +821,57 @@ discard block |
||
| 821 | 821 | return $all; |
| 822 | 822 | } |
| 823 | 823 | |
| 824 | - public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') { |
|
| 824 | + public function countAllDatesLastMonth($stats_airline = '', $filter_name = '') { |
|
| 825 | 825 | global $globalStatsFilters; |
| 826 | 826 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 827 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 827 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 828 | 828 | $Spotter = new Spotter($this->db); |
| 829 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 829 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 830 | 830 | $alliance_airlines = array(); |
| 831 | 831 | foreach ($airlines as $airline) { |
| 832 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 832 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 833 | 833 | } |
| 834 | - $query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'month' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
| 834 | + $query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'month' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
| 835 | 835 | $query_data = array(':filter_name' => $filter_name); |
| 836 | 836 | } else { |
| 837 | 837 | $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"; |
| 838 | - $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
| 838 | + $query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
| 839 | 839 | } |
| 840 | 840 | try { |
| 841 | 841 | $sth = $this->db->prepare($query); |
| 842 | 842 | $sth->execute($query_data); |
| 843 | - } catch(PDOException $e) { |
|
| 843 | + } catch (PDOException $e) { |
|
| 844 | 844 | echo "error : ".$e->getMessage(); |
| 845 | 845 | } |
| 846 | 846 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 847 | 847 | if (empty($all)) { |
| 848 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 849 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 848 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 849 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 850 | 850 | } else { |
| 851 | 851 | $filters = array('airlines' => array($stats_airline)); |
| 852 | 852 | } |
| 853 | 853 | if ($filter_name != '') { |
| 854 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 854 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 855 | 855 | } |
| 856 | 856 | $Spotter = new Spotter($this->db); |
| 857 | 857 | $all = $Spotter->countAllDatesLastMonth($filters); |
| 858 | 858 | } |
| 859 | 859 | return $all; |
| 860 | 860 | } |
| 861 | - public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') { |
|
| 861 | + public function countAllDatesLast7Days($stats_airline = '', $filter_name = '') { |
|
| 862 | 862 | global $globalDBdriver, $globalStatsFilters; |
| 863 | 863 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 864 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 864 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 865 | 865 | $Spotter = new Spotter($this->db); |
| 866 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 866 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 867 | 867 | $alliance_airlines = array(); |
| 868 | 868 | foreach ($airlines as $airline) { |
| 869 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 869 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 870 | 870 | } |
| 871 | 871 | if ($globalDBdriver == 'mysql') { |
| 872 | - $query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY) AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
| 872 | + $query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY) AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
| 873 | 873 | } else { |
| 874 | - $query = "SELECT flight_date as date_name, SUM(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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
| 874 | + $query = "SELECT flight_date as date_name, SUM(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 IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
| 875 | 875 | } |
| 876 | 876 | $query_data = array(':filter_name' => $filter_name); |
| 877 | 877 | } else { |
@@ -880,60 +880,60 @@ discard block |
||
| 880 | 880 | } else { |
| 881 | 881 | $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"; |
| 882 | 882 | } |
| 883 | - $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
| 883 | + $query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
| 884 | 884 | } |
| 885 | 885 | try { |
| 886 | 886 | $sth = $this->db->prepare($query); |
| 887 | 887 | $sth->execute($query_data); |
| 888 | - } catch(PDOException $e) { |
|
| 888 | + } catch (PDOException $e) { |
|
| 889 | 889 | echo "error : ".$e->getMessage(); |
| 890 | 890 | } |
| 891 | 891 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 892 | 892 | if (empty($all)) { |
| 893 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 894 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 893 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 894 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 895 | 895 | } else { |
| 896 | 896 | $filters = array('airlines' => array($stats_airline)); |
| 897 | 897 | } |
| 898 | 898 | if ($filter_name != '') { |
| 899 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 899 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 900 | 900 | } |
| 901 | 901 | $Spotter = new Spotter($this->db); |
| 902 | 902 | $all = $Spotter->countAllDatesLast7Days($filters); |
| 903 | 903 | } |
| 904 | 904 | return $all; |
| 905 | 905 | } |
| 906 | - public function countAllDates($stats_airline = '',$filter_name = '') { |
|
| 906 | + public function countAllDates($stats_airline = '', $filter_name = '') { |
|
| 907 | 907 | global $globalStatsFilters; |
| 908 | 908 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 909 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 909 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 910 | 910 | $Spotter = new Spotter($this->db); |
| 911 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 911 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 912 | 912 | $alliance_airlines = array(); |
| 913 | 913 | foreach ($airlines as $airline) { |
| 914 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 914 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 915 | 915 | } |
| 916 | - $query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'date' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date ORDER BY date_count DESC"; |
|
| 916 | + $query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'date' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date ORDER BY date_count DESC"; |
|
| 917 | 917 | $query_data = array(':filter_name' => $filter_name); |
| 918 | 918 | } else { |
| 919 | 919 | $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 ORDER BY date_count DESC"; |
| 920 | - $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
| 920 | + $query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
| 921 | 921 | } |
| 922 | 922 | try { |
| 923 | 923 | $sth = $this->db->prepare($query); |
| 924 | 924 | $sth->execute($query_data); |
| 925 | - } catch(PDOException $e) { |
|
| 925 | + } catch (PDOException $e) { |
|
| 926 | 926 | echo "error : ".$e->getMessage(); |
| 927 | 927 | } |
| 928 | 928 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 929 | 929 | if (empty($all)) { |
| 930 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 931 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 930 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 931 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 932 | 932 | } else { |
| 933 | 933 | $filters = array('airlines' => array($stats_airline)); |
| 934 | 934 | } |
| 935 | 935 | if ($filter_name != '') { |
| 936 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 936 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 937 | 937 | } |
| 938 | 938 | $Spotter = new Spotter($this->db); |
| 939 | 939 | $all = $Spotter->countAllDates($filters); |
@@ -948,34 +948,34 @@ discard block |
||
| 948 | 948 | try { |
| 949 | 949 | $sth = $this->db->prepare($query); |
| 950 | 950 | $sth->execute($query_data); |
| 951 | - } catch(PDOException $e) { |
|
| 951 | + } catch (PDOException $e) { |
|
| 952 | 952 | echo "error : ".$e->getMessage(); |
| 953 | 953 | } |
| 954 | 954 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 955 | 955 | if (empty($all)) { |
| 956 | 956 | $filters = array(); |
| 957 | 957 | if ($filter_name != '') { |
| 958 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 958 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 959 | 959 | } |
| 960 | 960 | $Spotter = new Spotter($this->db); |
| 961 | 961 | $all = $Spotter->countAllDatesByAirlines($filters); |
| 962 | 962 | } |
| 963 | 963 | return $all; |
| 964 | 964 | } |
| 965 | - public function countAllMonths($stats_airline = '',$filter_name = '') { |
|
| 965 | + public function countAllMonths($stats_airline = '', $filter_name = '') { |
|
| 966 | 966 | global $globalStatsFilters, $globalDBdriver; |
| 967 | 967 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 968 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 968 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 969 | 969 | $Spotter = new Spotter($this->db); |
| 970 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 970 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 971 | 971 | $alliance_airlines = array(); |
| 972 | 972 | foreach ($airlines as $airline) { |
| 973 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 973 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 974 | 974 | } |
| 975 | 975 | if ($globalDBdriver == 'mysql') { |
| 976 | - $query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date ORDER BY date_count DESC"; |
|
| 976 | + $query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date ORDER BY date_count DESC"; |
|
| 977 | 977 | } else { |
| 978 | - $query = "SELECT EXTRACT(YEAR FROM stats_date) AS year_name,EXTRACT(MONTH FROM stats_date) AS month_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date ORDER BY date_count DESC"; |
|
| 978 | + $query = "SELECT EXTRACT(YEAR FROM stats_date) AS year_name,EXTRACT(MONTH FROM stats_date) AS month_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date ORDER BY date_count DESC"; |
|
| 979 | 979 | } |
| 980 | 980 | $query_data = array(':filter_name' => $filter_name); |
| 981 | 981 | } else { |
@@ -989,18 +989,18 @@ discard block |
||
| 989 | 989 | try { |
| 990 | 990 | $sth = $this->db->prepare($query); |
| 991 | 991 | $sth->execute($query_data); |
| 992 | - } catch(PDOException $e) { |
|
| 992 | + } catch (PDOException $e) { |
|
| 993 | 993 | echo "error : ".$e->getMessage(); |
| 994 | 994 | } |
| 995 | 995 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 996 | 996 | if (empty($all)) { |
| 997 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 998 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 997 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 998 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 999 | 999 | } else { |
| 1000 | 1000 | $filters = array('airlines' => array($stats_airline)); |
| 1001 | 1001 | } |
| 1002 | 1002 | if ($filter_name != '') { |
| 1003 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 1003 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 1004 | 1004 | } |
| 1005 | 1005 | $Spotter = new Spotter($this->db); |
| 1006 | 1006 | $all = $Spotter->countAllMonths($filters); |
@@ -1017,7 +1017,7 @@ discard block |
||
| 1017 | 1017 | try { |
| 1018 | 1018 | $sth = $this->db->prepare($query); |
| 1019 | 1019 | $sth->execute(); |
| 1020 | - } catch(PDOException $e) { |
|
| 1020 | + } catch (PDOException $e) { |
|
| 1021 | 1021 | echo "error : ".$e->getMessage(); |
| 1022 | 1022 | } |
| 1023 | 1023 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1037,7 +1037,7 @@ discard block |
||
| 1037 | 1037 | try { |
| 1038 | 1038 | $sth = $this->db->prepare($query); |
| 1039 | 1039 | $sth->execute(); |
| 1040 | - } catch(PDOException $e) { |
|
| 1040 | + } catch (PDOException $e) { |
|
| 1041 | 1041 | echo "error : ".$e->getMessage(); |
| 1042 | 1042 | } |
| 1043 | 1043 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1054,32 +1054,32 @@ discard block |
||
| 1054 | 1054 | try { |
| 1055 | 1055 | $sth = $this->db->prepare($query); |
| 1056 | 1056 | $sth->execute(array(':filter_name' => $filter_name)); |
| 1057 | - } catch(PDOException $e) { |
|
| 1057 | + } catch (PDOException $e) { |
|
| 1058 | 1058 | echo "error : ".$e->getMessage(); |
| 1059 | 1059 | } |
| 1060 | 1060 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1061 | 1061 | if (empty($all)) { |
| 1062 | 1062 | $filters = array(); |
| 1063 | 1063 | if ($filter_name != '') { |
| 1064 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 1064 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 1065 | 1065 | } |
| 1066 | 1066 | $Spotter = new Spotter($this->db); |
| 1067 | 1067 | $all = $Spotter->countAllMilitaryMonths($filters); |
| 1068 | 1068 | } |
| 1069 | 1069 | return $all; |
| 1070 | 1070 | } |
| 1071 | - public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') { |
|
| 1071 | + public function countAllHours($orderby = 'hour', $limit = true, $stats_airline = '', $filter_name = '') { |
|
| 1072 | 1072 | global $globalTimezone, $globalDBdriver, $globalStatsFilters; |
| 1073 | 1073 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1074 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 1074 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 1075 | 1075 | $Spotter = new Spotter($this->db); |
| 1076 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 1076 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 1077 | 1077 | $alliance_airlines = array(); |
| 1078 | 1078 | foreach ($airlines as $airline) { |
| 1079 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 1079 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 1080 | 1080 | } |
| 1081 | - if ($limit) $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
| 1082 | - else $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
| 1081 | + if ($limit) $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
| 1082 | + else $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
| 1083 | 1083 | $query_data = array(':filter_name' => $filter_name); |
| 1084 | 1084 | } else { |
| 1085 | 1085 | if ($limit) $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
@@ -1097,37 +1097,37 @@ discard block |
||
| 1097 | 1097 | try { |
| 1098 | 1098 | $sth = $this->db->prepare($query); |
| 1099 | 1099 | $sth->execute($query_data); |
| 1100 | - } catch(PDOException $e) { |
|
| 1100 | + } catch (PDOException $e) { |
|
| 1101 | 1101 | echo "error : ".$e->getMessage(); |
| 1102 | 1102 | } |
| 1103 | 1103 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1104 | 1104 | if (empty($all)) { |
| 1105 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 1106 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 1105 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 1106 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 1107 | 1107 | } else { |
| 1108 | 1108 | $filters = array('airlines' => array($stats_airline)); |
| 1109 | 1109 | } |
| 1110 | 1110 | if ($filter_name != '') { |
| 1111 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 1111 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 1112 | 1112 | } |
| 1113 | 1113 | $Spotter = new Spotter($this->db); |
| 1114 | - $all = $Spotter->countAllHours($orderby,$filters); |
|
| 1114 | + $all = $Spotter->countAllHours($orderby, $filters); |
|
| 1115 | 1115 | } |
| 1116 | 1116 | return $all; |
| 1117 | 1117 | } |
| 1118 | - public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') { |
|
| 1118 | + public function countOverallFlights($stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
| 1119 | 1119 | global $globalStatsFilters; |
| 1120 | 1120 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1121 | 1121 | if ($year == '') $year = date('Y'); |
| 1122 | - $all = $this->getSumStats('flights_bymonth',$year,$stats_airline,$filter_name,$month); |
|
| 1122 | + $all = $this->getSumStats('flights_bymonth', $year, $stats_airline, $filter_name, $month); |
|
| 1123 | 1123 | if (empty($all)) { |
| 1124 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 1125 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month); |
|
| 1124 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 1125 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month); |
|
| 1126 | 1126 | } else { |
| 1127 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
| 1127 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
| 1128 | 1128 | } |
| 1129 | 1129 | if ($filter_name != '') { |
| 1130 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 1130 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 1131 | 1131 | } |
| 1132 | 1132 | $Spotter = new Spotter($this->db); |
| 1133 | 1133 | //$all = $Spotter->countOverallFlights($filters,$year,$month); |
@@ -1135,16 +1135,16 @@ discard block |
||
| 1135 | 1135 | } |
| 1136 | 1136 | return $all; |
| 1137 | 1137 | } |
| 1138 | - public function countOverallMilitaryFlights($filter_name = '',$year = '', $month = '') { |
|
| 1138 | + public function countOverallMilitaryFlights($filter_name = '', $year = '', $month = '') { |
|
| 1139 | 1139 | global $globalStatsFilters; |
| 1140 | 1140 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1141 | 1141 | if ($year == '') $year = date('Y'); |
| 1142 | - $all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month); |
|
| 1142 | + $all = $this->getSumStats('military_flights_bymonth', $year, '', $filter_name, $month); |
|
| 1143 | 1143 | if (empty($all)) { |
| 1144 | 1144 | $filters = array(); |
| 1145 | - $filters = array('year' => $year,'month' => $month); |
|
| 1145 | + $filters = array('year' => $year, 'month' => $month); |
|
| 1146 | 1146 | if ($filter_name != '') { |
| 1147 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 1147 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 1148 | 1148 | } |
| 1149 | 1149 | $Spotter = new Spotter($this->db); |
| 1150 | 1150 | //$all = $Spotter->countOverallMilitaryFlights($filters,$year,$month); |
@@ -1152,19 +1152,19 @@ discard block |
||
| 1152 | 1152 | } |
| 1153 | 1153 | return $all; |
| 1154 | 1154 | } |
| 1155 | - public function countOverallArrival($stats_airline = '',$filter_name = '', $year = '', $month = '') { |
|
| 1155 | + public function countOverallArrival($stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
| 1156 | 1156 | global $globalStatsFilters; |
| 1157 | 1157 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1158 | 1158 | if ($year == '') $year = date('Y'); |
| 1159 | - $all = $this->getSumStats('realarrivals_bymonth',$year,$stats_airline,$filter_name,$month); |
|
| 1159 | + $all = $this->getSumStats('realarrivals_bymonth', $year, $stats_airline, $filter_name, $month); |
|
| 1160 | 1160 | if (empty($all)) { |
| 1161 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 1162 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month); |
|
| 1161 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 1162 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month); |
|
| 1163 | 1163 | } else { |
| 1164 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
| 1164 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
| 1165 | 1165 | } |
| 1166 | 1166 | if ($filter_name != '') { |
| 1167 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 1167 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 1168 | 1168 | } |
| 1169 | 1169 | $Spotter = new Spotter($this->db); |
| 1170 | 1170 | //$all = $Spotter->countOverallArrival($filters,$year,$month); |
@@ -1172,48 +1172,48 @@ discard block |
||
| 1172 | 1172 | } |
| 1173 | 1173 | return $all; |
| 1174 | 1174 | } |
| 1175 | - public function countOverallAircrafts($stats_airline = '',$filter_name = '',$year = '', $month = '') { |
|
| 1175 | + public function countOverallAircrafts($stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
| 1176 | 1176 | global $globalStatsFilters; |
| 1177 | 1177 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1178 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 1178 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 1179 | 1179 | $Spotter = new Spotter($this->db); |
| 1180 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 1180 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 1181 | 1181 | if ($year == '' && $month == '') { |
| 1182 | 1182 | $alliance_airlines = array(); |
| 1183 | 1183 | foreach ($airlines as $airline) { |
| 1184 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 1184 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 1185 | 1185 | } |
| 1186 | - $query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name"; |
|
| 1186 | + $query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name"; |
|
| 1187 | 1187 | try { |
| 1188 | 1188 | $sth = $this->db->prepare($query); |
| 1189 | 1189 | $sth->execute(array(':filter_name' => $filter_name)); |
| 1190 | - } catch(PDOException $e) { |
|
| 1190 | + } catch (PDOException $e) { |
|
| 1191 | 1191 | echo "error : ".$e->getMessage(); |
| 1192 | 1192 | } |
| 1193 | 1193 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1194 | 1194 | $all = $result[0]['nb']; |
| 1195 | - } else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month); |
|
| 1195 | + } else $all = $this->getSumStats('aircrafts_bymonth', $year, $stats_airline, $filter_name, $month); |
|
| 1196 | 1196 | } else { |
| 1197 | 1197 | if ($year == '' && $month == '') { |
| 1198 | 1198 | $query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
| 1199 | 1199 | try { |
| 1200 | 1200 | $sth = $this->db->prepare($query); |
| 1201 | - $sth->execute(array(':filter_name' => $filter_name,':stats_airline' => $stats_airline)); |
|
| 1202 | - } catch(PDOException $e) { |
|
| 1201 | + $sth->execute(array(':filter_name' => $filter_name, ':stats_airline' => $stats_airline)); |
|
| 1202 | + } catch (PDOException $e) { |
|
| 1203 | 1203 | echo "error : ".$e->getMessage(); |
| 1204 | 1204 | } |
| 1205 | 1205 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1206 | 1206 | $all = $result[0]['nb']; |
| 1207 | - } else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month); |
|
| 1207 | + } else $all = $this->getSumStats('aircrafts_bymonth', $year, $stats_airline, $filter_name, $month); |
|
| 1208 | 1208 | } |
| 1209 | 1209 | if (empty($all)) { |
| 1210 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 1211 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month); |
|
| 1210 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 1211 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month); |
|
| 1212 | 1212 | } else { |
| 1213 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
| 1213 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
| 1214 | 1214 | } |
| 1215 | 1215 | if ($filter_name != '') { |
| 1216 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 1216 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 1217 | 1217 | } |
| 1218 | 1218 | $Spotter = new Spotter($this->db); |
| 1219 | 1219 | //$all = $Spotter->countOverallAircrafts($filters,$year,$month); |
@@ -1221,7 +1221,7 @@ discard block |
||
| 1221 | 1221 | } |
| 1222 | 1222 | return $all; |
| 1223 | 1223 | } |
| 1224 | - public function countOverallAirlines($filter_name = '',$year = '',$month = '') { |
|
| 1224 | + public function countOverallAirlines($filter_name = '', $year = '', $month = '') { |
|
| 1225 | 1225 | global $globalStatsFilters; |
| 1226 | 1226 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1227 | 1227 | if ($year == '' && $month == '') { |
@@ -1229,17 +1229,17 @@ discard block |
||
| 1229 | 1229 | try { |
| 1230 | 1230 | $sth = $this->db->prepare($query); |
| 1231 | 1231 | $sth->execute(array(':filter_name' => $filter_name)); |
| 1232 | - } catch(PDOException $e) { |
|
| 1232 | + } catch (PDOException $e) { |
|
| 1233 | 1233 | echo "error : ".$e->getMessage(); |
| 1234 | 1234 | } |
| 1235 | 1235 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1236 | 1236 | $all = $result[0]['nb_airline']; |
| 1237 | - } else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month); |
|
| 1237 | + } else $all = $this->getSumStats('airlines_bymonth', $year, '', $filter_name, $month); |
|
| 1238 | 1238 | if (empty($all)) { |
| 1239 | 1239 | $filters = array(); |
| 1240 | - $filters = array('year' => $year,'month' => $month); |
|
| 1240 | + $filters = array('year' => $year, 'month' => $month); |
|
| 1241 | 1241 | if ($filter_name != '') { |
| 1242 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 1242 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 1243 | 1243 | } |
| 1244 | 1244 | $Spotter = new Spotter($this->db); |
| 1245 | 1245 | //$all = $Spotter->countOverallAirlines($filters,$year,$month); |
@@ -1247,29 +1247,29 @@ discard block |
||
| 1247 | 1247 | } |
| 1248 | 1248 | return $all; |
| 1249 | 1249 | } |
| 1250 | - public function countOverallOwners($stats_airline = '',$filter_name = '',$year = '', $month = '') { |
|
| 1250 | + public function countOverallOwners($stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
| 1251 | 1251 | global $globalStatsFilters; |
| 1252 | 1252 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1253 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 1253 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 1254 | 1254 | $Spotter = new Spotter($this->db); |
| 1255 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 1255 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 1256 | 1256 | if ($year == '' && $month == '') { |
| 1257 | 1257 | $alliance_airlines = array(); |
| 1258 | 1258 | foreach ($airlines as $airline) { |
| 1259 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 1259 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 1260 | 1260 | } |
| 1261 | - $query = "SELECT count(*) as nb FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name"; |
|
| 1261 | + $query = "SELECT count(*) as nb FROM stats_owner WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name"; |
|
| 1262 | 1262 | $query_values = array(':filter_name' => $filter_name); |
| 1263 | 1263 | try { |
| 1264 | 1264 | $sth = $this->db->prepare($query); |
| 1265 | 1265 | $sth->execute($query_values); |
| 1266 | - } catch(PDOException $e) { |
|
| 1266 | + } catch (PDOException $e) { |
|
| 1267 | 1267 | echo "error : ".$e->getMessage(); |
| 1268 | 1268 | } |
| 1269 | 1269 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1270 | 1270 | $all = $result[0]['nb']; |
| 1271 | 1271 | } else { |
| 1272 | - $all = $this->getSumStats('owners_bymonth',$year,$stats_airline,$filter_name,$month); |
|
| 1272 | + $all = $this->getSumStats('owners_bymonth', $year, $stats_airline, $filter_name, $month); |
|
| 1273 | 1273 | } |
| 1274 | 1274 | } else { |
| 1275 | 1275 | if ($year == '' && $month == '') { |
@@ -1278,23 +1278,23 @@ discard block |
||
| 1278 | 1278 | try { |
| 1279 | 1279 | $sth = $this->db->prepare($query); |
| 1280 | 1280 | $sth->execute($query_values); |
| 1281 | - } catch(PDOException $e) { |
|
| 1281 | + } catch (PDOException $e) { |
|
| 1282 | 1282 | echo "error : ".$e->getMessage(); |
| 1283 | 1283 | } |
| 1284 | 1284 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1285 | 1285 | $all = $result[0]['nb']; |
| 1286 | 1286 | } else { |
| 1287 | - $all = $this->getSumStats('owners_bymonth',$year,$stats_airline,$filter_name,$month); |
|
| 1287 | + $all = $this->getSumStats('owners_bymonth', $year, $stats_airline, $filter_name, $month); |
|
| 1288 | 1288 | } |
| 1289 | 1289 | } |
| 1290 | 1290 | if (empty($all)) { |
| 1291 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 1292 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month); |
|
| 1291 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 1292 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month); |
|
| 1293 | 1293 | } else { |
| 1294 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
| 1294 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
| 1295 | 1295 | } |
| 1296 | 1296 | if ($filter_name != '') { |
| 1297 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 1297 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 1298 | 1298 | } |
| 1299 | 1299 | $Spotter = new Spotter($this->db); |
| 1300 | 1300 | //$all = $Spotter->countOverallOwners($filters,$year,$month); |
@@ -1302,7 +1302,7 @@ discard block |
||
| 1302 | 1302 | } |
| 1303 | 1303 | return $all; |
| 1304 | 1304 | } |
| 1305 | - public function countOverallPilots($stats_airline = '',$filter_name = '',$year = '',$month = '') { |
|
| 1305 | + public function countOverallPilots($stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
| 1306 | 1306 | global $globalStatsFilters; |
| 1307 | 1307 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1308 | 1308 | //if ($year == '') $year = date('Y'); |
@@ -1312,18 +1312,18 @@ discard block |
||
| 1312 | 1312 | try { |
| 1313 | 1313 | $sth = $this->db->prepare($query); |
| 1314 | 1314 | $sth->execute($query_values); |
| 1315 | - } catch(PDOException $e) { |
|
| 1315 | + } catch (PDOException $e) { |
|
| 1316 | 1316 | echo "error : ".$e->getMessage(); |
| 1317 | 1317 | } |
| 1318 | 1318 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1319 | 1319 | $all = $result[0]['nb']; |
| 1320 | 1320 | } else { |
| 1321 | - $all = $this->getSumStats('pilots_bymonth',$year,$stats_airline,$filter_name,$month); |
|
| 1321 | + $all = $this->getSumStats('pilots_bymonth', $year, $stats_airline, $filter_name, $month); |
|
| 1322 | 1322 | } |
| 1323 | 1323 | if (empty($all)) { |
| 1324 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
| 1324 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
| 1325 | 1325 | if ($filter_name != '') { |
| 1326 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 1326 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 1327 | 1327 | } |
| 1328 | 1328 | $Spotter = new Spotter($this->db); |
| 1329 | 1329 | //$all = $Spotter->countOverallPilots($filters,$year,$month); |
@@ -1332,104 +1332,104 @@ discard block |
||
| 1332 | 1332 | return $all; |
| 1333 | 1333 | } |
| 1334 | 1334 | |
| 1335 | - public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') { |
|
| 1335 | + public function getLast7DaysAirports($airport_icao = '', $stats_airline = '', $filter_name = '') { |
|
| 1336 | 1336 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1337 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 1337 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 1338 | 1338 | $Spotter = new Spotter($this->db); |
| 1339 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 1339 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 1340 | 1340 | $alliance_airlines = array(); |
| 1341 | 1341 | foreach ($airlines as $airline) { |
| 1342 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 1342 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 1343 | 1343 | } |
| 1344 | - $query = "SELECT * FROM stats_airport WHERE stats_type = 'daily' AND airport_icao = :airport_icao AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY date"; |
|
| 1345 | - $query_values = array(':airport_icao' => $airport_icao,':filter_name' => $filter_name); |
|
| 1344 | + $query = "SELECT * FROM stats_airport WHERE stats_type = 'daily' AND airport_icao = :airport_icao AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY date"; |
|
| 1345 | + $query_values = array(':airport_icao' => $airport_icao, ':filter_name' => $filter_name); |
|
| 1346 | 1346 | } else { |
| 1347 | 1347 | $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"; |
| 1348 | - $query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
| 1348 | + $query_values = array(':airport_icao' => $airport_icao, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
| 1349 | 1349 | } |
| 1350 | 1350 | try { |
| 1351 | 1351 | $sth = $this->db->prepare($query); |
| 1352 | 1352 | $sth->execute($query_values); |
| 1353 | - } catch(PDOException $e) { |
|
| 1353 | + } catch (PDOException $e) { |
|
| 1354 | 1354 | echo "error : ".$e->getMessage(); |
| 1355 | 1355 | } |
| 1356 | 1356 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1357 | 1357 | return $all; |
| 1358 | 1358 | } |
| 1359 | - public function getStats($type,$stats_airline = '', $filter_name = '') { |
|
| 1359 | + public function getStats($type, $stats_airline = '', $filter_name = '') { |
|
| 1360 | 1360 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1361 | 1361 | $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date"; |
| 1362 | - $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
| 1362 | + $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
| 1363 | 1363 | try { |
| 1364 | 1364 | $sth = $this->db->prepare($query); |
| 1365 | 1365 | $sth->execute($query_values); |
| 1366 | - } catch(PDOException $e) { |
|
| 1366 | + } catch (PDOException $e) { |
|
| 1367 | 1367 | echo "error : ".$e->getMessage(); |
| 1368 | 1368 | } |
| 1369 | 1369 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1370 | 1370 | return $all; |
| 1371 | 1371 | } |
| 1372 | - public function deleteStatsByType($type,$stats_airline = '', $filter_name = '') { |
|
| 1372 | + public function deleteStatsByType($type, $stats_airline = '', $filter_name = '') { |
|
| 1373 | 1373 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1374 | 1374 | $query = "DELETE FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
| 1375 | - $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
| 1375 | + $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
| 1376 | 1376 | try { |
| 1377 | 1377 | $sth = $this->db->prepare($query); |
| 1378 | 1378 | $sth->execute($query_values); |
| 1379 | - } catch(PDOException $e) { |
|
| 1379 | + } catch (PDOException $e) { |
|
| 1380 | 1380 | echo "error : ".$e->getMessage(); |
| 1381 | 1381 | } |
| 1382 | 1382 | } |
| 1383 | - public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') { |
|
| 1383 | + public function getSumStats($type, $year, $stats_airline = '', $filter_name = '', $month = '') { |
|
| 1384 | 1384 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1385 | 1385 | global $globalArchiveMonths, $globalDBdriver; |
| 1386 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 1386 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 1387 | 1387 | $Spotter = new Spotter($this->db); |
| 1388 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 1388 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 1389 | 1389 | $alliance_airlines = array(); |
| 1390 | 1390 | foreach ($airlines as $airline) { |
| 1391 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 1391 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 1392 | 1392 | } |
| 1393 | 1393 | if ($globalDBdriver == 'mysql') { |
| 1394 | 1394 | if ($month == '') { |
| 1395 | - $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name"; |
|
| 1395 | + $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name"; |
|
| 1396 | 1396 | $query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name); |
| 1397 | 1397 | } else { |
| 1398 | - $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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name"; |
|
| 1399 | - $query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name,':month' => $month); |
|
| 1398 | + $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 IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name"; |
|
| 1399 | + $query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name, ':month' => $month); |
|
| 1400 | 1400 | } |
| 1401 | 1401 | } else { |
| 1402 | 1402 | if ($month == '') { |
| 1403 | - $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name"; |
|
| 1403 | + $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name"; |
|
| 1404 | 1404 | $query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name); |
| 1405 | 1405 | } else { |
| 1406 | - $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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name"; |
|
| 1407 | - $query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name,':month' => $month); |
|
| 1406 | + $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 IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name"; |
|
| 1407 | + $query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name, ':month' => $month); |
|
| 1408 | 1408 | } |
| 1409 | 1409 | } |
| 1410 | 1410 | } else { |
| 1411 | 1411 | if ($globalDBdriver == 'mysql') { |
| 1412 | 1412 | if ($month == '') { |
| 1413 | 1413 | $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"; |
| 1414 | - $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
| 1414 | + $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
| 1415 | 1415 | } else { |
| 1416 | 1416 | $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"; |
| 1417 | - $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name,':month' => $month); |
|
| 1417 | + $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':month' => $month); |
|
| 1418 | 1418 | } |
| 1419 | 1419 | } else { |
| 1420 | 1420 | if ($month == '') { |
| 1421 | 1421 | $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"; |
| 1422 | - $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
| 1422 | + $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
| 1423 | 1423 | } else { |
| 1424 | 1424 | $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"; |
| 1425 | - $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name,':month' => $month); |
|
| 1425 | + $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':month' => $month); |
|
| 1426 | 1426 | } |
| 1427 | 1427 | } |
| 1428 | 1428 | } |
| 1429 | 1429 | try { |
| 1430 | 1430 | $sth = $this->db->prepare($query); |
| 1431 | 1431 | $sth->execute($query_values); |
| 1432 | - } catch(PDOException $e) { |
|
| 1432 | + } catch (PDOException $e) { |
|
| 1433 | 1433 | echo "error : ".$e->getMessage(); |
| 1434 | 1434 | } |
| 1435 | 1435 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1438,17 +1438,17 @@ discard block |
||
| 1438 | 1438 | public function getStatsTotal($type, $stats_airline = '', $filter_name = '') { |
| 1439 | 1439 | global $globalArchiveMonths, $globalDBdriver; |
| 1440 | 1440 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1441 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 1441 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 1442 | 1442 | $Spotter = new Spotter($this->db); |
| 1443 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 1443 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 1444 | 1444 | $alliance_airlines = array(); |
| 1445 | 1445 | foreach ($airlines as $airline) { |
| 1446 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 1446 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 1447 | 1447 | } |
| 1448 | 1448 | if ($globalDBdriver == 'mysql') { |
| 1449 | - $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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name"; |
|
| 1449 | + $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 IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name"; |
|
| 1450 | 1450 | } else { |
| 1451 | - $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveMonths." MONTHS' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name"; |
|
| 1451 | + $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveMonths." MONTHS' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name"; |
|
| 1452 | 1452 | } |
| 1453 | 1453 | $query_values = array(':type' => $type, ':filter_name' => $filter_name); |
| 1454 | 1454 | } else { |
@@ -1462,7 +1462,7 @@ discard block |
||
| 1462 | 1462 | try { |
| 1463 | 1463 | $sth = $this->db->prepare($query); |
| 1464 | 1464 | $sth->execute($query_values); |
| 1465 | - } catch(PDOException $e) { |
|
| 1465 | + } catch (PDOException $e) { |
|
| 1466 | 1466 | echo "error : ".$e->getMessage(); |
| 1467 | 1467 | } |
| 1468 | 1468 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1471,17 +1471,17 @@ discard block |
||
| 1471 | 1471 | public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') { |
| 1472 | 1472 | global $globalArchiveMonths, $globalDBdriver; |
| 1473 | 1473 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1474 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 1474 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 1475 | 1475 | $Spotter = new Spotter($this->db); |
| 1476 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 1476 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 1477 | 1477 | $alliance_airlines = array(); |
| 1478 | 1478 | foreach ($airlines as $airline) { |
| 1479 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 1479 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 1480 | 1480 | } |
| 1481 | 1481 | if ($globalDBdriver == 'mysql') { |
| 1482 | - $query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name"; |
|
| 1482 | + $query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name"; |
|
| 1483 | 1483 | } else { |
| 1484 | - $query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name"; |
|
| 1484 | + $query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name"; |
|
| 1485 | 1485 | } |
| 1486 | 1486 | } else { |
| 1487 | 1487 | if ($globalDBdriver == 'mysql') { |
@@ -1493,7 +1493,7 @@ discard block |
||
| 1493 | 1493 | try { |
| 1494 | 1494 | $sth = $this->db->prepare($query); |
| 1495 | 1495 | $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
| 1496 | - } catch(PDOException $e) { |
|
| 1496 | + } catch (PDOException $e) { |
|
| 1497 | 1497 | echo "error : ".$e->getMessage(); |
| 1498 | 1498 | } |
| 1499 | 1499 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1510,7 +1510,7 @@ discard block |
||
| 1510 | 1510 | try { |
| 1511 | 1511 | $sth = $this->db->prepare($query); |
| 1512 | 1512 | $sth->execute(array(':filter_name' => $filter_name)); |
| 1513 | - } catch(PDOException $e) { |
|
| 1513 | + } catch (PDOException $e) { |
|
| 1514 | 1514 | echo "error : ".$e->getMessage(); |
| 1515 | 1515 | } |
| 1516 | 1516 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1527,20 +1527,20 @@ discard block |
||
| 1527 | 1527 | try { |
| 1528 | 1528 | $sth = $this->db->prepare($query); |
| 1529 | 1529 | $sth->execute(array(':filter_name' => $filter_name)); |
| 1530 | - } catch(PDOException $e) { |
|
| 1530 | + } catch (PDOException $e) { |
|
| 1531 | 1531 | echo "error : ".$e->getMessage(); |
| 1532 | 1532 | } |
| 1533 | 1533 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1534 | 1534 | return $all[0]['total']; |
| 1535 | 1535 | } |
| 1536 | - public function getStatsOwner($owner_name,$filter_name = '') { |
|
| 1536 | + public function getStatsOwner($owner_name, $filter_name = '') { |
|
| 1537 | 1537 | global $globalArchiveMonths, $globalDBdriver; |
| 1538 | 1538 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1539 | 1539 | $query = "SELECT cnt FROM stats_owner WHERE filter_name = :filter_name AND owner_name = :owner_name"; |
| 1540 | 1540 | try { |
| 1541 | 1541 | $sth = $this->db->prepare($query); |
| 1542 | - $sth->execute(array(':filter_name' => $filter_name,':owner_name' => $owner_name)); |
|
| 1543 | - } catch(PDOException $e) { |
|
| 1542 | + $sth->execute(array(':filter_name' => $filter_name, ':owner_name' => $owner_name)); |
|
| 1543 | + } catch (PDOException $e) { |
|
| 1544 | 1544 | echo "error : ".$e->getMessage(); |
| 1545 | 1545 | } |
| 1546 | 1546 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1558,20 +1558,20 @@ discard block |
||
| 1558 | 1558 | try { |
| 1559 | 1559 | $sth = $this->db->prepare($query); |
| 1560 | 1560 | $sth->execute(array(':filter_name' => $filter_name)); |
| 1561 | - } catch(PDOException $e) { |
|
| 1561 | + } catch (PDOException $e) { |
|
| 1562 | 1562 | echo "error : ".$e->getMessage(); |
| 1563 | 1563 | } |
| 1564 | 1564 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1565 | 1565 | return $all[0]['total']; |
| 1566 | 1566 | } |
| 1567 | - public function getStatsPilot($pilot,$filter_name = '') { |
|
| 1567 | + public function getStatsPilot($pilot, $filter_name = '') { |
|
| 1568 | 1568 | global $globalArchiveMonths, $globalDBdriver; |
| 1569 | 1569 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1570 | 1570 | $query = "SELECT cnt FROM stats_pilot WHERE filter_name = :filter_name AND (pilot_name = :pilot OR pilot_id = :pilot)"; |
| 1571 | 1571 | try { |
| 1572 | 1572 | $sth = $this->db->prepare($query); |
| 1573 | - $sth->execute(array(':filter_name' => $filter_name,':pilot' => $pilot)); |
|
| 1574 | - } catch(PDOException $e) { |
|
| 1573 | + $sth->execute(array(':filter_name' => $filter_name, ':pilot' => $pilot)); |
|
| 1574 | + } catch (PDOException $e) { |
|
| 1575 | 1575 | echo "error : ".$e->getMessage(); |
| 1576 | 1576 | } |
| 1577 | 1577 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1579,7 +1579,7 @@ discard block |
||
| 1579 | 1579 | else return 0; |
| 1580 | 1580 | } |
| 1581 | 1581 | |
| 1582 | - public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
|
| 1582 | + public function addStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') { |
|
| 1583 | 1583 | global $globalDBdriver; |
| 1584 | 1584 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1585 | 1585 | if ($globalDBdriver == 'mysql') { |
@@ -1587,15 +1587,15 @@ discard block |
||
| 1587 | 1587 | } else { |
| 1588 | 1588 | $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);"; |
| 1589 | 1589 | } |
| 1590 | - $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
| 1590 | + $query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
| 1591 | 1591 | try { |
| 1592 | 1592 | $sth = $this->db->prepare($query); |
| 1593 | 1593 | $sth->execute($query_values); |
| 1594 | - } catch(PDOException $e) { |
|
| 1594 | + } catch (PDOException $e) { |
|
| 1595 | 1595 | return "error : ".$e->getMessage(); |
| 1596 | 1596 | } |
| 1597 | 1597 | } |
| 1598 | - public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
|
| 1598 | + public function updateStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') { |
|
| 1599 | 1599 | global $globalDBdriver; |
| 1600 | 1600 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1601 | 1601 | if ($globalDBdriver == 'mysql') { |
@@ -1604,11 +1604,11 @@ discard block |
||
| 1604 | 1604 | //$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date"; |
| 1605 | 1605 | $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);"; |
| 1606 | 1606 | } |
| 1607 | - $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
| 1607 | + $query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
| 1608 | 1608 | try { |
| 1609 | 1609 | $sth = $this->db->prepare($query); |
| 1610 | 1610 | $sth->execute($query_values); |
| 1611 | - } catch(PDOException $e) { |
|
| 1611 | + } catch (PDOException $e) { |
|
| 1612 | 1612 | return "error : ".$e->getMessage(); |
| 1613 | 1613 | } |
| 1614 | 1614 | } |
@@ -1632,75 +1632,75 @@ discard block |
||
| 1632 | 1632 | } |
| 1633 | 1633 | */ |
| 1634 | 1634 | |
| 1635 | - public function getStatsSource($stats_type,$year = '',$month = '',$day = '') { |
|
| 1635 | + public function getStatsSource($stats_type, $year = '', $month = '', $day = '') { |
|
| 1636 | 1636 | global $globalDBdriver; |
| 1637 | 1637 | $query = "SELECT * FROM stats_source WHERE stats_type = :stats_type"; |
| 1638 | 1638 | $query_values = array(); |
| 1639 | 1639 | if ($globalDBdriver == 'mysql') { |
| 1640 | 1640 | if ($year != '') { |
| 1641 | 1641 | $query .= ' AND YEAR(stats_date) = :year'; |
| 1642 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 1642 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 1643 | 1643 | } |
| 1644 | 1644 | if ($month != '') { |
| 1645 | 1645 | $query .= ' AND MONTH(stats_date) = :month'; |
| 1646 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 1646 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 1647 | 1647 | } |
| 1648 | 1648 | if ($day != '') { |
| 1649 | 1649 | $query .= ' AND DAY(stats_date) = :day'; |
| 1650 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 1650 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 1651 | 1651 | } |
| 1652 | 1652 | } else { |
| 1653 | 1653 | if ($year != '') { |
| 1654 | 1654 | $query .= ' AND EXTRACT(YEAR FROM stats_date) = :year'; |
| 1655 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 1655 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 1656 | 1656 | } |
| 1657 | 1657 | if ($month != '') { |
| 1658 | 1658 | $query .= ' AND EXTRACT(MONTH FROM stats_date) = :month'; |
| 1659 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 1659 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 1660 | 1660 | } |
| 1661 | 1661 | if ($day != '') { |
| 1662 | 1662 | $query .= ' AND EXTRACT(DAY FROM stats_date) = :day'; |
| 1663 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 1663 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 1664 | 1664 | } |
| 1665 | 1665 | } |
| 1666 | 1666 | $query .= " ORDER BY source_name"; |
| 1667 | - $query_values = array_merge($query_values,array(':stats_type' => $stats_type)); |
|
| 1667 | + $query_values = array_merge($query_values, array(':stats_type' => $stats_type)); |
|
| 1668 | 1668 | try { |
| 1669 | 1669 | $sth = $this->db->prepare($query); |
| 1670 | 1670 | $sth->execute($query_values); |
| 1671 | - } catch(PDOException $e) { |
|
| 1671 | + } catch (PDOException $e) { |
|
| 1672 | 1672 | echo "error : ".$e->getMessage(); |
| 1673 | 1673 | } |
| 1674 | 1674 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1675 | 1675 | return $all; |
| 1676 | 1676 | } |
| 1677 | 1677 | |
| 1678 | - public function addStatSource($data,$source_name,$stats_type,$date) { |
|
| 1678 | + public function addStatSource($data, $source_name, $stats_type, $date) { |
|
| 1679 | 1679 | global $globalDBdriver; |
| 1680 | 1680 | if ($globalDBdriver == 'mysql') { |
| 1681 | 1681 | $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"; |
| 1682 | 1682 | } else { |
| 1683 | 1683 | $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);"; |
| 1684 | 1684 | } |
| 1685 | - $query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type); |
|
| 1685 | + $query_values = array(':data' => $data, ':stats_date' => $date, ':source_name' => $source_name, ':stats_type' => $stats_type); |
|
| 1686 | 1686 | try { |
| 1687 | 1687 | $sth = $this->db->prepare($query); |
| 1688 | 1688 | $sth->execute($query_values); |
| 1689 | - } catch(PDOException $e) { |
|
| 1689 | + } catch (PDOException $e) { |
|
| 1690 | 1690 | return "error : ".$e->getMessage(); |
| 1691 | 1691 | } |
| 1692 | 1692 | } |
| 1693 | - public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') { |
|
| 1693 | + public function addStatFlight($type, $date_name, $cnt, $stats_airline = '', $filter_name = '') { |
|
| 1694 | 1694 | $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)"; |
| 1695 | - $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
| 1695 | + $query_values = array(':type' => $type, ':flight_date' => $date_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
| 1696 | 1696 | try { |
| 1697 | 1697 | $sth = $this->db->prepare($query); |
| 1698 | 1698 | $sth->execute($query_values); |
| 1699 | - } catch(PDOException $e) { |
|
| 1699 | + } catch (PDOException $e) { |
|
| 1700 | 1700 | return "error : ".$e->getMessage(); |
| 1701 | 1701 | } |
| 1702 | 1702 | } |
| 1703 | - public function addStatAircraftRegistration($registration,$cnt,$aircraft_icao = '',$airline_icao = '',$filter_name = '',$reset = false) { |
|
| 1703 | + public function addStatAircraftRegistration($registration, $cnt, $aircraft_icao = '', $airline_icao = '', $filter_name = '', $reset = false) { |
|
| 1704 | 1704 | global $globalDBdriver; |
| 1705 | 1705 | if ($globalDBdriver == 'mysql') { |
| 1706 | 1706 | if ($reset) { |
@@ -1715,15 +1715,15 @@ discard block |
||
| 1715 | 1715 | $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);"; |
| 1716 | 1716 | } |
| 1717 | 1717 | } |
| 1718 | - $query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
| 1718 | + $query_values = array(':aircraft_icao' => $aircraft_icao, ':registration' => $registration, ':cnt' => $cnt, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
| 1719 | 1719 | try { |
| 1720 | 1720 | $sth = $this->db->prepare($query); |
| 1721 | 1721 | $sth->execute($query_values); |
| 1722 | - } catch(PDOException $e) { |
|
| 1722 | + } catch (PDOException $e) { |
|
| 1723 | 1723 | return "error : ".$e->getMessage(); |
| 1724 | 1724 | } |
| 1725 | 1725 | } |
| 1726 | - public function addStatCallsign($callsign_icao,$cnt,$airline_icao = '', $filter_name = '', $reset = false) { |
|
| 1726 | + public function addStatCallsign($callsign_icao, $cnt, $airline_icao = '', $filter_name = '', $reset = false) { |
|
| 1727 | 1727 | global $globalDBdriver; |
| 1728 | 1728 | if ($globalDBdriver == 'mysql') { |
| 1729 | 1729 | if ($reset) { |
@@ -1738,15 +1738,15 @@ discard block |
||
| 1738 | 1738 | $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);"; |
| 1739 | 1739 | } |
| 1740 | 1740 | } |
| 1741 | - $query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name); |
|
| 1741 | + $query_values = array(':callsign_icao' => $callsign_icao, ':airline_icao' => $airline_icao, ':cnt' => $cnt, ':filter_name' => $filter_name); |
|
| 1742 | 1742 | try { |
| 1743 | 1743 | $sth = $this->db->prepare($query); |
| 1744 | 1744 | $sth->execute($query_values); |
| 1745 | - } catch(PDOException $e) { |
|
| 1745 | + } catch (PDOException $e) { |
|
| 1746 | 1746 | return "error : ".$e->getMessage(); |
| 1747 | 1747 | } |
| 1748 | 1748 | } |
| 1749 | - public function addStatCountry($iso2,$iso3,$name,$cnt,$airline_icao = '',$filter_name = '',$reset = false) { |
|
| 1749 | + public function addStatCountry($iso2, $iso3, $name, $cnt, $airline_icao = '', $filter_name = '', $reset = false) { |
|
| 1750 | 1750 | global $globalDBdriver; |
| 1751 | 1751 | if ($globalDBdriver == 'mysql') { |
| 1752 | 1752 | if ($reset) { |
@@ -1761,15 +1761,15 @@ discard block |
||
| 1761 | 1761 | $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);"; |
| 1762 | 1762 | } |
| 1763 | 1763 | } |
| 1764 | - $query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name,':airline' => $airline_icao); |
|
| 1764 | + $query_values = array(':iso2' => $iso2, ':iso3' => $iso3, ':name' => $name, ':cnt' => $cnt, ':filter_name' => $filter_name, ':airline' => $airline_icao); |
|
| 1765 | 1765 | try { |
| 1766 | 1766 | $sth = $this->db->prepare($query); |
| 1767 | 1767 | $sth->execute($query_values); |
| 1768 | - } catch(PDOException $e) { |
|
| 1768 | + } catch (PDOException $e) { |
|
| 1769 | 1769 | return "error : ".$e->getMessage(); |
| 1770 | 1770 | } |
| 1771 | 1771 | } |
| 1772 | - public function addStatAircraft($aircraft_icao,$cnt,$aircraft_name = '',$aircraft_manufacturer = '', $airline_icao = '', $filter_name = '', $reset = false) { |
|
| 1772 | + public function addStatAircraft($aircraft_icao, $cnt, $aircraft_name = '', $aircraft_manufacturer = '', $airline_icao = '', $filter_name = '', $reset = false) { |
|
| 1773 | 1773 | global $globalDBdriver; |
| 1774 | 1774 | if ($globalDBdriver == 'mysql') { |
| 1775 | 1775 | if ($reset) { |
@@ -1784,15 +1784,15 @@ discard block |
||
| 1784 | 1784 | $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);"; |
| 1785 | 1785 | } |
| 1786 | 1786 | } |
| 1787 | - $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); |
|
| 1787 | + $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); |
|
| 1788 | 1788 | try { |
| 1789 | 1789 | $sth = $this->db->prepare($query); |
| 1790 | 1790 | $sth->execute($query_values); |
| 1791 | - } catch(PDOException $e) { |
|
| 1791 | + } catch (PDOException $e) { |
|
| 1792 | 1792 | return "error : ".$e->getMessage(); |
| 1793 | 1793 | } |
| 1794 | 1794 | } |
| 1795 | - public function addStatAirline($airline_icao,$cnt,$airline_name = '',$filter_name = '', $reset = false) { |
|
| 1795 | + public function addStatAirline($airline_icao, $cnt, $airline_name = '', $filter_name = '', $reset = false) { |
|
| 1796 | 1796 | global $globalDBdriver; |
| 1797 | 1797 | if ($globalDBdriver == 'mysql') { |
| 1798 | 1798 | if ($reset) { |
@@ -1807,15 +1807,15 @@ discard block |
||
| 1807 | 1807 | $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);"; |
| 1808 | 1808 | } |
| 1809 | 1809 | } |
| 1810 | - $query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name); |
|
| 1810 | + $query_values = array(':airline_icao' => $airline_icao, ':airline_name' => $airline_name, ':cnt' => $cnt, ':filter_name' => $filter_name); |
|
| 1811 | 1811 | try { |
| 1812 | 1812 | $sth = $this->db->prepare($query); |
| 1813 | 1813 | $sth->execute($query_values); |
| 1814 | - } catch(PDOException $e) { |
|
| 1814 | + } catch (PDOException $e) { |
|
| 1815 | 1815 | return "error : ".$e->getMessage(); |
| 1816 | 1816 | } |
| 1817 | 1817 | } |
| 1818 | - public function addStatOwner($owner_name,$cnt,$stats_airline = '', $filter_name = '', $reset = false) { |
|
| 1818 | + public function addStatOwner($owner_name, $cnt, $stats_airline = '', $filter_name = '', $reset = false) { |
|
| 1819 | 1819 | global $globalDBdriver; |
| 1820 | 1820 | if ($globalDBdriver == 'mysql') { |
| 1821 | 1821 | if ($reset) { |
@@ -1830,15 +1830,15 @@ discard block |
||
| 1830 | 1830 | $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);"; |
| 1831 | 1831 | } |
| 1832 | 1832 | } |
| 1833 | - $query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
| 1833 | + $query_values = array(':owner_name' => $owner_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
| 1834 | 1834 | try { |
| 1835 | 1835 | $sth = $this->db->prepare($query); |
| 1836 | 1836 | $sth->execute($query_values); |
| 1837 | - } catch(PDOException $e) { |
|
| 1837 | + } catch (PDOException $e) { |
|
| 1838 | 1838 | return "error : ".$e->getMessage(); |
| 1839 | 1839 | } |
| 1840 | 1840 | } |
| 1841 | - public function addStatPilot($pilot_id,$cnt,$pilot_name,$stats_airline = '',$filter_name = '',$format_source = '',$reset = false) { |
|
| 1841 | + public function addStatPilot($pilot_id, $cnt, $pilot_name, $stats_airline = '', $filter_name = '', $format_source = '', $reset = false) { |
|
| 1842 | 1842 | global $globalDBdriver; |
| 1843 | 1843 | if ($globalDBdriver == 'mysql') { |
| 1844 | 1844 | if ($reset) { |
@@ -1853,15 +1853,15 @@ discard block |
||
| 1853 | 1853 | $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);"; |
| 1854 | 1854 | } |
| 1855 | 1855 | } |
| 1856 | - $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); |
|
| 1856 | + $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); |
|
| 1857 | 1857 | try { |
| 1858 | 1858 | $sth = $this->db->prepare($query); |
| 1859 | 1859 | $sth->execute($query_values); |
| 1860 | - } catch(PDOException $e) { |
|
| 1860 | + } catch (PDOException $e) { |
|
| 1861 | 1861 | return "error : ".$e->getMessage(); |
| 1862 | 1862 | } |
| 1863 | 1863 | } |
| 1864 | - public function addStatDepartureAirports($airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '',$reset = false) { |
|
| 1864 | + public function addStatDepartureAirports($airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '', $reset = false) { |
|
| 1865 | 1865 | global $globalDBdriver; |
| 1866 | 1866 | if ($airport_icao != '') { |
| 1867 | 1867 | if ($globalDBdriver == 'mysql') { |
@@ -1877,16 +1877,16 @@ discard block |
||
| 1877 | 1877 | $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);"; |
| 1878 | 1878 | } |
| 1879 | 1879 | } |
| 1880 | - $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); |
|
| 1880 | + $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); |
|
| 1881 | 1881 | try { |
| 1882 | 1882 | $sth = $this->db->prepare($query); |
| 1883 | 1883 | $sth->execute($query_values); |
| 1884 | - } catch(PDOException $e) { |
|
| 1884 | + } catch (PDOException $e) { |
|
| 1885 | 1885 | return "error : ".$e->getMessage(); |
| 1886 | 1886 | } |
| 1887 | 1887 | } |
| 1888 | 1888 | } |
| 1889 | - public function addStatDepartureAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') { |
|
| 1889 | + public function addStatDepartureAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '') { |
|
| 1890 | 1890 | global $globalDBdriver; |
| 1891 | 1891 | if ($airport_icao != '') { |
| 1892 | 1892 | if ($globalDBdriver == 'mysql') { |
@@ -1894,16 +1894,16 @@ discard block |
||
| 1894 | 1894 | } else { |
| 1895 | 1895 | $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);"; |
| 1896 | 1896 | } |
| 1897 | - $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); |
|
| 1897 | + $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); |
|
| 1898 | 1898 | try { |
| 1899 | 1899 | $sth = $this->db->prepare($query); |
| 1900 | 1900 | $sth->execute($query_values); |
| 1901 | - } catch(PDOException $e) { |
|
| 1901 | + } catch (PDOException $e) { |
|
| 1902 | 1902 | return "error : ".$e->getMessage(); |
| 1903 | 1903 | } |
| 1904 | 1904 | } |
| 1905 | 1905 | } |
| 1906 | - public function addStatArrivalAirports($airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '',$reset = false) { |
|
| 1906 | + public function addStatArrivalAirports($airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '', $reset = false) { |
|
| 1907 | 1907 | global $globalDBdriver; |
| 1908 | 1908 | if ($airport_icao != '') { |
| 1909 | 1909 | if ($globalDBdriver == 'mysql') { |
@@ -1919,16 +1919,16 @@ discard block |
||
| 1919 | 1919 | $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);"; |
| 1920 | 1920 | } |
| 1921 | 1921 | } |
| 1922 | - $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); |
|
| 1922 | + $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); |
|
| 1923 | 1923 | try { |
| 1924 | 1924 | $sth = $this->db->prepare($query); |
| 1925 | 1925 | $sth->execute($query_values); |
| 1926 | - } catch(PDOException $e) { |
|
| 1926 | + } catch (PDOException $e) { |
|
| 1927 | 1927 | return "error : ".$e->getMessage(); |
| 1928 | 1928 | } |
| 1929 | 1929 | } |
| 1930 | 1930 | } |
| 1931 | - public function addStatArrivalAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') { |
|
| 1931 | + public function addStatArrivalAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '') { |
|
| 1932 | 1932 | global $globalDBdriver; |
| 1933 | 1933 | if ($airport_icao != '') { |
| 1934 | 1934 | if ($globalDBdriver == 'mysql') { |
@@ -1936,11 +1936,11 @@ discard block |
||
| 1936 | 1936 | } else { |
| 1937 | 1937 | $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);"; |
| 1938 | 1938 | } |
| 1939 | - $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); |
|
| 1939 | + $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); |
|
| 1940 | 1940 | try { |
| 1941 | 1941 | $sth = $this->db->prepare($query); |
| 1942 | 1942 | $sth->execute($query_values); |
| 1943 | - } catch(PDOException $e) { |
|
| 1943 | + } catch (PDOException $e) { |
|
| 1944 | 1944 | return "error : ".$e->getMessage(); |
| 1945 | 1945 | } |
| 1946 | 1946 | } |
@@ -1952,7 +1952,7 @@ discard block |
||
| 1952 | 1952 | try { |
| 1953 | 1953 | $sth = $this->db->prepare($query); |
| 1954 | 1954 | $sth->execute($query_values); |
| 1955 | - } catch(PDOException $e) { |
|
| 1955 | + } catch (PDOException $e) { |
|
| 1956 | 1956 | return "error : ".$e->getMessage(); |
| 1957 | 1957 | } |
| 1958 | 1958 | } |
@@ -1962,7 +1962,7 @@ discard block |
||
| 1962 | 1962 | try { |
| 1963 | 1963 | $sth = $this->db->prepare($query); |
| 1964 | 1964 | $sth->execute($query_values); |
| 1965 | - } catch(PDOException $e) { |
|
| 1965 | + } catch (PDOException $e) { |
|
| 1966 | 1966 | return "error : ".$e->getMessage(); |
| 1967 | 1967 | } |
| 1968 | 1968 | } |
@@ -1972,13 +1972,13 @@ discard block |
||
| 1972 | 1972 | try { |
| 1973 | 1973 | $sth = $this->db->prepare($query); |
| 1974 | 1974 | $sth->execute($query_values); |
| 1975 | - } catch(PDOException $e) { |
|
| 1975 | + } catch (PDOException $e) { |
|
| 1976 | 1976 | return "error : ".$e->getMessage(); |
| 1977 | 1977 | } |
| 1978 | 1978 | } |
| 1979 | 1979 | |
| 1980 | 1980 | public function addOldStats() { |
| 1981 | - global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters,$globalDeleteLastYearStats,$globalStatsReset,$globalStatsResetYear, $globalAccidents; |
|
| 1981 | + global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters, $globalDeleteLastYearStats, $globalStatsReset, $globalStatsResetYear, $globalAccidents; |
|
| 1982 | 1982 | $Common = new Common(); |
| 1983 | 1983 | $Connection = new Connection($this->db); |
| 1984 | 1984 | date_default_timezone_set('UTC'); |
@@ -1996,41 +1996,41 @@ discard block |
||
| 1996 | 1996 | $Spotter = new Spotter($this->db); |
| 1997 | 1997 | |
| 1998 | 1998 | if ($globalDebug) echo 'Count all aircraft types...'."\n"; |
| 1999 | - $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day); |
|
| 1999 | + $alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day); |
|
| 2000 | 2000 | foreach ($alldata as $number) { |
| 2001 | - $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'','',$reset); |
|
| 2001 | + $this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], '', '', $reset); |
|
| 2002 | 2002 | } |
| 2003 | 2003 | if ($globalDebug) echo 'Count all airlines...'."\n"; |
| 2004 | - $alldata = $Spotter->countAllAirlines(false,0,$last_update_day); |
|
| 2004 | + $alldata = $Spotter->countAllAirlines(false, 0, $last_update_day); |
|
| 2005 | 2005 | foreach ($alldata as $number) { |
| 2006 | - $this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],'',$reset); |
|
| 2006 | + $this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name'], '', $reset); |
|
| 2007 | 2007 | } |
| 2008 | 2008 | if ($globalDebug) echo 'Count all registrations...'."\n"; |
| 2009 | - $alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day); |
|
| 2009 | + $alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day); |
|
| 2010 | 2010 | foreach ($alldata as $number) { |
| 2011 | - $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'','',$reset); |
|
| 2011 | + $this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], '', '', $reset); |
|
| 2012 | 2012 | } |
| 2013 | 2013 | if ($globalDebug) echo 'Count all callsigns...'."\n"; |
| 2014 | - $alldata = $Spotter->countAllCallsigns(false,0,$last_update_day); |
|
| 2014 | + $alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day); |
|
| 2015 | 2015 | foreach ($alldata as $number) { |
| 2016 | - $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset); |
|
| 2016 | + $this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao'], '', $reset); |
|
| 2017 | 2017 | } |
| 2018 | 2018 | if ($globalDebug) echo 'Count all owners...'."\n"; |
| 2019 | - $alldata = $Spotter->countAllOwners(false,0,$last_update_day); |
|
| 2019 | + $alldata = $Spotter->countAllOwners(false, 0, $last_update_day); |
|
| 2020 | 2020 | foreach ($alldata as $number) { |
| 2021 | - $this->addStatOwner($number['owner_name'],$number['owner_count'],'','',$reset); |
|
| 2021 | + $this->addStatOwner($number['owner_name'], $number['owner_count'], '', '', $reset); |
|
| 2022 | 2022 | } |
| 2023 | 2023 | if ($globalDebug) echo 'Count all pilots...'."\n"; |
| 2024 | - $alldata = $Spotter->countAllPilots(false,0,$last_update_day); |
|
| 2024 | + $alldata = $Spotter->countAllPilots(false, 0, $last_update_day); |
|
| 2025 | 2025 | foreach ($alldata as $number) { |
| 2026 | 2026 | if ($number['pilot_id'] == 0 || $number['pilot_id'] == '') $number['pilot_id'] = $number['pilot_name']; |
| 2027 | - $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source'],$reset); |
|
| 2027 | + $this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], '', '', $number['format_source'], $reset); |
|
| 2028 | 2028 | } |
| 2029 | 2029 | |
| 2030 | 2030 | if ($globalDebug) echo 'Count all departure airports...'."\n"; |
| 2031 | - $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day); |
|
| 2031 | + $pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day); |
|
| 2032 | 2032 | if ($globalDebug) echo 'Count all detected departure airports...'."\n"; |
| 2033 | - $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day); |
|
| 2033 | + $dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day); |
|
| 2034 | 2034 | if ($globalDebug) echo 'Order departure airports...'."\n"; |
| 2035 | 2035 | $alldata = array(); |
| 2036 | 2036 | foreach ($pall as $value) { |
@@ -2047,14 +2047,14 @@ discard block |
||
| 2047 | 2047 | foreach ($alldata as $key => $row) { |
| 2048 | 2048 | $count[$key] = $row['airport_departure_icao_count']; |
| 2049 | 2049 | } |
| 2050 | - array_multisort($count,SORT_DESC,$alldata); |
|
| 2050 | + array_multisort($count, SORT_DESC, $alldata); |
|
| 2051 | 2051 | foreach ($alldata as $number) { |
| 2052 | - 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); |
|
| 2052 | + echo $this->addStatDepartureAirports($number['airport_departure_icao'], $number['airport_departure_name'], $number['airport_departure_city'], $number['airport_departure_country'], $number['airport_departure_icao_count'], '', '', $reset); |
|
| 2053 | 2053 | } |
| 2054 | 2054 | if ($globalDebug) echo 'Count all arrival airports...'."\n"; |
| 2055 | - $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day); |
|
| 2055 | + $pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day); |
|
| 2056 | 2056 | if ($globalDebug) echo 'Count all detected arrival airports...'."\n"; |
| 2057 | - $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day); |
|
| 2057 | + $dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day); |
|
| 2058 | 2058 | if ($globalDebug) echo 'Order arrival airports...'."\n"; |
| 2059 | 2059 | $alldata = array(); |
| 2060 | 2060 | foreach ($pall as $value) { |
@@ -2071,18 +2071,18 @@ discard block |
||
| 2071 | 2071 | foreach ($alldata as $key => $row) { |
| 2072 | 2072 | $count[$key] = $row['airport_arrival_icao_count']; |
| 2073 | 2073 | } |
| 2074 | - array_multisort($count,SORT_DESC,$alldata); |
|
| 2074 | + array_multisort($count, SORT_DESC, $alldata); |
|
| 2075 | 2075 | foreach ($alldata as $number) { |
| 2076 | - 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); |
|
| 2076 | + echo $this->addStatArrivalAirports($number['airport_arrival_icao'], $number['airport_arrival_name'], $number['airport_arrival_city'], $number['airport_arrival_country'], $number['airport_arrival_icao_count'], '', '', $reset); |
|
| 2077 | 2077 | } |
| 2078 | 2078 | if ($Connection->tableExists('countries')) { |
| 2079 | 2079 | if ($globalDebug) echo 'Count all flights by countries...'."\n"; |
| 2080 | 2080 | //$SpotterArchive = new SpotterArchive(); |
| 2081 | 2081 | //$alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day); |
| 2082 | 2082 | $Spotter = new Spotter($this->db); |
| 2083 | - $alldata = $Spotter->countAllFlightOverCountries(false,0,$last_update_day); |
|
| 2083 | + $alldata = $Spotter->countAllFlightOverCountries(false, 0, $last_update_day); |
|
| 2084 | 2084 | foreach ($alldata as $number) { |
| 2085 | - $this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],'','',$reset); |
|
| 2085 | + $this->addStatCountry($number['flight_country_iso2'], $number['flight_country_iso3'], $number['flight_country'], $number['flight_count'], '', '', $reset); |
|
| 2086 | 2086 | } |
| 2087 | 2087 | } |
| 2088 | 2088 | |
@@ -2092,12 +2092,12 @@ discard block |
||
| 2092 | 2092 | $this->deleteStatsByType('fatalities_byyear'); |
| 2093 | 2093 | $alldata = $Accident->countFatalitiesByYear(); |
| 2094 | 2094 | foreach ($alldata as $number) { |
| 2095 | - $this->addStat('fatalities_byyear',$number['count'],date('Y-m-d H:i:s',mktime(0,0,0,1,1,$number['year']))); |
|
| 2095 | + $this->addStat('fatalities_byyear', $number['count'], date('Y-m-d H:i:s', mktime(0, 0, 0, 1, 1, $number['year']))); |
|
| 2096 | 2096 | } |
| 2097 | 2097 | $this->deleteStatsByType('fatalities_bymonth'); |
| 2098 | 2098 | $alldata = $Accident->countFatalitiesLast12Months(); |
| 2099 | 2099 | foreach ($alldata as $number) { |
| 2100 | - $this->addStat('fatalities_bymonth',$number['count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month'],1,$number['year']))); |
|
| 2100 | + $this->addStat('fatalities_bymonth', $number['count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month'], 1, $number['year']))); |
|
| 2101 | 2101 | } |
| 2102 | 2102 | } |
| 2103 | 2103 | |
@@ -2111,37 +2111,37 @@ discard block |
||
| 2111 | 2111 | $lastyear = false; |
| 2112 | 2112 | foreach ($alldata as $number) { |
| 2113 | 2113 | if ($number['year_name'] != date('Y')) $lastyear = true; |
| 2114 | - $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']))); |
|
| 2114 | + $this->addStat('flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name']))); |
|
| 2115 | 2115 | } |
| 2116 | 2116 | if ($globalDebug) echo 'Count all military flights by months...'."\n"; |
| 2117 | 2117 | $alldata = $Spotter->countAllMilitaryMonths($filter_last_month); |
| 2118 | 2118 | foreach ($alldata as $number) { |
| 2119 | - $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']))); |
|
| 2119 | + $this->addStat('military_flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name']))); |
|
| 2120 | 2120 | } |
| 2121 | 2121 | if ($globalDebug) echo 'Count all owners by months...'."\n"; |
| 2122 | 2122 | $alldata = $Spotter->countAllMonthsOwners($filter_last_month); |
| 2123 | 2123 | foreach ($alldata as $number) { |
| 2124 | - $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']))); |
|
| 2124 | + $this->addStat('owners_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name']))); |
|
| 2125 | 2125 | } |
| 2126 | 2126 | if ($globalDebug) echo 'Count all pilots by months...'."\n"; |
| 2127 | 2127 | $alldata = $Spotter->countAllMonthsPilots($filter_last_month); |
| 2128 | 2128 | foreach ($alldata as $number) { |
| 2129 | - $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']))); |
|
| 2129 | + $this->addStat('pilots_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name']))); |
|
| 2130 | 2130 | } |
| 2131 | 2131 | if ($globalDebug) echo 'Count all airlines by months...'."\n"; |
| 2132 | 2132 | $alldata = $Spotter->countAllMonthsAirlines($filter_last_month); |
| 2133 | 2133 | foreach ($alldata as $number) { |
| 2134 | - $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']))); |
|
| 2134 | + $this->addStat('airlines_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name']))); |
|
| 2135 | 2135 | } |
| 2136 | 2136 | if ($globalDebug) echo 'Count all aircrafts by months...'."\n"; |
| 2137 | 2137 | $alldata = $Spotter->countAllMonthsAircrafts($filter_last_month); |
| 2138 | 2138 | foreach ($alldata as $number) { |
| 2139 | - $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']))); |
|
| 2139 | + $this->addStat('aircrafts_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name']))); |
|
| 2140 | 2140 | } |
| 2141 | 2141 | if ($globalDebug) echo 'Count all real arrivals by months...'."\n"; |
| 2142 | 2142 | $alldata = $Spotter->countAllMonthsRealArrivals($filter_last_month); |
| 2143 | 2143 | foreach ($alldata as $number) { |
| 2144 | - $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']))); |
|
| 2144 | + $this->addStat('realarrivals_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name']))); |
|
| 2145 | 2145 | } |
| 2146 | 2146 | if ($globalDebug) echo 'Airports data...'."\n"; |
| 2147 | 2147 | if ($globalDebug) echo '...Departure'."\n"; |
@@ -2186,7 +2186,7 @@ discard block |
||
| 2186 | 2186 | } |
| 2187 | 2187 | $alldata = $pall; |
| 2188 | 2188 | foreach ($alldata as $number) { |
| 2189 | - $this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count']); |
|
| 2189 | + $this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count']); |
|
| 2190 | 2190 | } |
| 2191 | 2191 | echo '...Arrival'."\n"; |
| 2192 | 2192 | $pall = $Spotter->getLast7DaysAirportsArrival(); |
@@ -2227,7 +2227,7 @@ discard block |
||
| 2227 | 2227 | } |
| 2228 | 2228 | $alldata = $pall; |
| 2229 | 2229 | foreach ($alldata as $number) { |
| 2230 | - $this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count']); |
|
| 2230 | + $this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count']); |
|
| 2231 | 2231 | } |
| 2232 | 2232 | |
| 2233 | 2233 | echo 'Flights data...'."\n"; |
@@ -2235,28 +2235,28 @@ discard block |
||
| 2235 | 2235 | echo '-> countAllDatesLastMonth...'."\n"; |
| 2236 | 2236 | $alldata = $Spotter->countAllDatesLastMonth($filter_last_month); |
| 2237 | 2237 | foreach ($alldata as $number) { |
| 2238 | - $this->addStatFlight('month',$number['date_name'],$number['date_count']); |
|
| 2238 | + $this->addStatFlight('month', $number['date_name'], $number['date_count']); |
|
| 2239 | 2239 | } |
| 2240 | 2240 | echo '-> countAllDates...'."\n"; |
| 2241 | 2241 | $previousdata = $this->countAllDates(); |
| 2242 | 2242 | $previousdatabyairlines = $this->countAllDatesByAirlines(); |
| 2243 | 2243 | $this->deleteStatFlight('date'); |
| 2244 | - $alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates($filter_last_month)); |
|
| 2244 | + $alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates($filter_last_month)); |
|
| 2245 | 2245 | $values = array(); |
| 2246 | 2246 | foreach ($alldata as $cnt) { |
| 2247 | 2247 | $values[] = $cnt['date_count']; |
| 2248 | 2248 | } |
| 2249 | - array_multisort($values,SORT_DESC,$alldata); |
|
| 2250 | - array_splice($alldata,11); |
|
| 2249 | + array_multisort($values, SORT_DESC, $alldata); |
|
| 2250 | + array_splice($alldata, 11); |
|
| 2251 | 2251 | foreach ($alldata as $number) { |
| 2252 | - $this->addStatFlight('date',$number['date_name'],$number['date_count']); |
|
| 2252 | + $this->addStatFlight('date', $number['date_name'], $number['date_count']); |
|
| 2253 | 2253 | } |
| 2254 | 2254 | |
| 2255 | 2255 | $this->deleteStatFlight('hour'); |
| 2256 | 2256 | echo '-> countAllHours...'."\n"; |
| 2257 | - $alldata = $Spotter->countAllHours('hour',$filter_last_month); |
|
| 2257 | + $alldata = $Spotter->countAllHours('hour', $filter_last_month); |
|
| 2258 | 2258 | foreach ($alldata as $number) { |
| 2259 | - $this->addStatFlight('hour',$number['hour_name'],$number['hour_count']); |
|
| 2259 | + $this->addStatFlight('hour', $number['hour_name'], $number['hour_count']); |
|
| 2260 | 2260 | } |
| 2261 | 2261 | |
| 2262 | 2262 | // Count by airlines |
@@ -2265,42 +2265,42 @@ discard block |
||
| 2265 | 2265 | if ($globalDebug) echo 'Count all flights by countries by airlines...'."\n"; |
| 2266 | 2266 | $SpotterArchive = new SpotterArchive($this->db); |
| 2267 | 2267 | //$Spotter = new Spotter($this->db); |
| 2268 | - $alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false,0,$last_update_day); |
|
| 2268 | + $alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false, 0, $last_update_day); |
|
| 2269 | 2269 | //$alldata = $Spotter->countAllFlightOverCountriesByAirlines(false,0,$last_update_day); |
| 2270 | 2270 | foreach ($alldata as $number) { |
| 2271 | - $this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],$number['airline_icao'],'',$reset); |
|
| 2271 | + $this->addStatCountry($number['flight_country_iso2'], $number['flight_country_iso3'], $number['flight_country'], $number['flight_count'], $number['airline_icao'], '', $reset); |
|
| 2272 | 2272 | } |
| 2273 | 2273 | } |
| 2274 | 2274 | if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n"; |
| 2275 | 2275 | $Spotter = new Spotter($this->db); |
| 2276 | - $alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day); |
|
| 2276 | + $alldata = $Spotter->countAllAircraftTypesByAirlines(false, 0, $last_update_day); |
|
| 2277 | 2277 | foreach ($alldata as $number) { |
| 2278 | - $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao'],'',$reset); |
|
| 2278 | + $this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], $number['airline_icao'], '', $reset); |
|
| 2279 | 2279 | } |
| 2280 | 2280 | if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n"; |
| 2281 | - $alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day); |
|
| 2281 | + $alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false, 0, $last_update_day); |
|
| 2282 | 2282 | foreach ($alldata as $number) { |
| 2283 | - $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao'],'',$reset); |
|
| 2283 | + $this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], $number['airline_icao'], '', $reset); |
|
| 2284 | 2284 | } |
| 2285 | 2285 | if ($globalDebug) echo 'Count all callsigns by airlines...'."\n"; |
| 2286 | - $alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day); |
|
| 2286 | + $alldata = $Spotter->countAllCallsignsByAirlines(false, 0, $last_update_day); |
|
| 2287 | 2287 | foreach ($alldata as $number) { |
| 2288 | - $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset); |
|
| 2288 | + $this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao'], '', $reset); |
|
| 2289 | 2289 | } |
| 2290 | 2290 | if ($globalDebug) echo 'Count all owners by airlines...'."\n"; |
| 2291 | - $alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day); |
|
| 2291 | + $alldata = $Spotter->countAllOwnersByAirlines(false, 0, $last_update_day); |
|
| 2292 | 2292 | foreach ($alldata as $number) { |
| 2293 | - $this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao'],'',$reset); |
|
| 2293 | + $this->addStatOwner($number['owner_name'], $number['owner_count'], $number['airline_icao'], '', $reset); |
|
| 2294 | 2294 | } |
| 2295 | 2295 | if ($globalDebug) echo 'Count all pilots by airlines...'."\n"; |
| 2296 | - $alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day); |
|
| 2296 | + $alldata = $Spotter->countAllPilotsByAirlines(false, 0, $last_update_day); |
|
| 2297 | 2297 | foreach ($alldata as $number) { |
| 2298 | - $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source'],$reset); |
|
| 2298 | + $this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], $number['airline_icao'], '', $number['format_source'], $reset); |
|
| 2299 | 2299 | } |
| 2300 | 2300 | if ($globalDebug) echo 'Count all departure airports by airlines...'."\n"; |
| 2301 | - $pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day); |
|
| 2301 | + $pall = $Spotter->countAllDepartureAirportsByAirlines(false, 0, $last_update_day); |
|
| 2302 | 2302 | if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n"; |
| 2303 | - $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day); |
|
| 2303 | + $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false, 0, $last_update_day); |
|
| 2304 | 2304 | if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n"; |
| 2305 | 2305 | //$alldata = array(); |
| 2306 | 2306 | foreach ($dall as $value) { |
@@ -2320,12 +2320,12 @@ discard block |
||
| 2320 | 2320 | } |
| 2321 | 2321 | $alldata = $pall; |
| 2322 | 2322 | foreach ($alldata as $number) { |
| 2323 | - 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); |
|
| 2323 | + echo $this->addStatDepartureAirports($number['airport_departure_icao'], $number['airport_departure_name'], $number['airport_departure_city'], $number['airport_departure_country'], $number['airport_departure_icao_count'], $number['airline_icao'], '', $reset); |
|
| 2324 | 2324 | } |
| 2325 | 2325 | if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n"; |
| 2326 | - $pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day); |
|
| 2326 | + $pall = $Spotter->countAllArrivalAirportsByAirlines(false, 0, $last_update_day); |
|
| 2327 | 2327 | if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n"; |
| 2328 | - $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day); |
|
| 2328 | + $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false, 0, $last_update_day); |
|
| 2329 | 2329 | if ($globalDebug) echo 'Order arrival airports by airlines...'."\n"; |
| 2330 | 2330 | //$alldata = array(); |
| 2331 | 2331 | foreach ($dall as $value) { |
@@ -2345,7 +2345,7 @@ discard block |
||
| 2345 | 2345 | } |
| 2346 | 2346 | $alldata = $pall; |
| 2347 | 2347 | foreach ($alldata as $number) { |
| 2348 | - if ($number['airline_icao'] != '') echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],$number['airline_icao'],'',$reset); |
|
| 2348 | + if ($number['airline_icao'] != '') echo $this->addStatArrivalAirports($number['airport_arrival_icao'], $number['airport_arrival_name'], $number['airport_arrival_city'], $number['airport_arrival_country'], $number['airport_arrival_icao_count'], $number['airline_icao'], '', $reset); |
|
| 2349 | 2349 | } |
| 2350 | 2350 | if ($globalDebug) echo 'Count all flights by months by airlines...'."\n"; |
| 2351 | 2351 | $Spotter = new Spotter($this->db); |
@@ -2353,27 +2353,27 @@ discard block |
||
| 2353 | 2353 | $lastyear = false; |
| 2354 | 2354 | foreach ($alldata as $number) { |
| 2355 | 2355 | if ($number['year_name'] != date('Y')) $lastyear = true; |
| 2356 | - $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']); |
|
| 2356 | + $this->addStat('flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']); |
|
| 2357 | 2357 | } |
| 2358 | 2358 | if ($globalDebug) echo 'Count all owners by months by airlines...'."\n"; |
| 2359 | 2359 | $alldata = $Spotter->countAllMonthsOwnersByAirlines($filter_last_month); |
| 2360 | 2360 | foreach ($alldata as $number) { |
| 2361 | - $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']); |
|
| 2361 | + $this->addStat('owners_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']); |
|
| 2362 | 2362 | } |
| 2363 | 2363 | if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n"; |
| 2364 | 2364 | $alldata = $Spotter->countAllMonthsPilotsByAirlines($filter_last_month); |
| 2365 | 2365 | foreach ($alldata as $number) { |
| 2366 | - $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']); |
|
| 2366 | + $this->addStat('pilots_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']); |
|
| 2367 | 2367 | } |
| 2368 | 2368 | if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n"; |
| 2369 | 2369 | $alldata = $Spotter->countAllMonthsAircraftsByAirlines($filter_last_month); |
| 2370 | 2370 | foreach ($alldata as $number) { |
| 2371 | - $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']); |
|
| 2371 | + $this->addStat('aircrafts_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']); |
|
| 2372 | 2372 | } |
| 2373 | 2373 | if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n"; |
| 2374 | 2374 | $alldata = $Spotter->countAllMonthsRealArrivalsByAirlines($filter_last_month); |
| 2375 | 2375 | foreach ($alldata as $number) { |
| 2376 | - $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']); |
|
| 2376 | + $this->addStat('realarrivals_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']); |
|
| 2377 | 2377 | } |
| 2378 | 2378 | if ($globalDebug) echo '...Departure'."\n"; |
| 2379 | 2379 | $pall = $Spotter->getLast7DaysAirportsDepartureByAirlines(); |
@@ -2396,7 +2396,7 @@ discard block |
||
| 2396 | 2396 | } |
| 2397 | 2397 | $alldata = $pall; |
| 2398 | 2398 | foreach ($alldata as $number) { |
| 2399 | - $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']); |
|
| 2399 | + $this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count'], $number['airline_icao']); |
|
| 2400 | 2400 | } |
| 2401 | 2401 | if ($globalDebug) echo '...Arrival'."\n"; |
| 2402 | 2402 | $pall = $Spotter->getLast7DaysAirportsArrivalByAirlines(); |
@@ -2419,32 +2419,32 @@ discard block |
||
| 2419 | 2419 | } |
| 2420 | 2420 | $alldata = $pall; |
| 2421 | 2421 | foreach ($alldata as $number) { |
| 2422 | - $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']); |
|
| 2422 | + $this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count'], $number['airline_icao']); |
|
| 2423 | 2423 | } |
| 2424 | 2424 | |
| 2425 | 2425 | if ($globalDebug) echo 'Flights data...'."\n"; |
| 2426 | 2426 | if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n"; |
| 2427 | 2427 | $alldata = $Spotter->countAllDatesLastMonthByAirlines($filter_last_month); |
| 2428 | 2428 | foreach ($alldata as $number) { |
| 2429 | - $this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']); |
|
| 2429 | + $this->addStatFlight('month', $number['date_name'], $number['date_count'], $number['airline_icao']); |
|
| 2430 | 2430 | } |
| 2431 | 2431 | if ($globalDebug) echo '-> countAllDates...'."\n"; |
| 2432 | 2432 | //$previousdata = $this->countAllDatesByAirlines(); |
| 2433 | - $alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines($filter_last_month)); |
|
| 2433 | + $alldata = $Common->array_merge_noappend($previousdatabyairlines, $Spotter->countAllDatesByAirlines($filter_last_month)); |
|
| 2434 | 2434 | $values = array(); |
| 2435 | 2435 | foreach ($alldata as $cnt) { |
| 2436 | 2436 | $values[] = $cnt['date_count']; |
| 2437 | 2437 | } |
| 2438 | - array_multisort($values,SORT_DESC,$alldata); |
|
| 2439 | - array_splice($alldata,11); |
|
| 2438 | + array_multisort($values, SORT_DESC, $alldata); |
|
| 2439 | + array_splice($alldata, 11); |
|
| 2440 | 2440 | foreach ($alldata as $number) { |
| 2441 | - $this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']); |
|
| 2441 | + $this->addStatFlight('date', $number['date_name'], $number['date_count'], $number['airline_icao']); |
|
| 2442 | 2442 | } |
| 2443 | 2443 | |
| 2444 | 2444 | if ($globalDebug) echo '-> countAllHours...'."\n"; |
| 2445 | - $alldata = $Spotter->countAllHoursByAirlines('hour',$filter_last_month); |
|
| 2445 | + $alldata = $Spotter->countAllHoursByAirlines('hour', $filter_last_month); |
|
| 2446 | 2446 | foreach ($alldata as $number) { |
| 2447 | - $this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']); |
|
| 2447 | + $this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], $number['airline_icao']); |
|
| 2448 | 2448 | } |
| 2449 | 2449 | |
| 2450 | 2450 | // Stats by filters |
@@ -2468,7 +2468,7 @@ discard block |
||
| 2468 | 2468 | $last_update_day = date('Y').'-01-01 00:00:00'; |
| 2469 | 2469 | } |
| 2470 | 2470 | } |
| 2471 | - if (isset($filter['DeleteLastYearStats']) && date('Y',strtotime($last_update_day)) != date('Y')) { |
|
| 2471 | + if (isset($filter['DeleteLastYearStats']) && date('Y', strtotime($last_update_day)) != date('Y')) { |
|
| 2472 | 2472 | $last_update_day = date('Y').'-01-01 00:00:00'; |
| 2473 | 2473 | $reset = true; |
| 2474 | 2474 | } |
@@ -2476,38 +2476,38 @@ discard block |
||
| 2476 | 2476 | if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n"; |
| 2477 | 2477 | $Spotter = new Spotter($this->db); |
| 2478 | 2478 | if ($globalDebug) echo 'Count all aircraft types...'."\n"; |
| 2479 | - $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter); |
|
| 2479 | + $alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day, $filter); |
|
| 2480 | 2480 | foreach ($alldata as $number) { |
| 2481 | - $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'',$filter_name,$reset); |
|
| 2481 | + $this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], '', $filter_name, $reset); |
|
| 2482 | 2482 | } |
| 2483 | 2483 | if ($globalDebug) echo 'Count all airlines...'."\n"; |
| 2484 | - $alldata = $Spotter->countAllAirlines(false,0,$last_update_day,$filter); |
|
| 2484 | + $alldata = $Spotter->countAllAirlines(false, 0, $last_update_day, $filter); |
|
| 2485 | 2485 | foreach ($alldata as $number) { |
| 2486 | - $this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],$filter_name,$reset); |
|
| 2486 | + $this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name'], $filter_name, $reset); |
|
| 2487 | 2487 | } |
| 2488 | 2488 | if ($globalDebug) echo 'Count all aircraft registrations...'."\n"; |
| 2489 | - $alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day,$filter); |
|
| 2489 | + $alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day, $filter); |
|
| 2490 | 2490 | foreach ($alldata as $number) { |
| 2491 | - $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'',$filter_name,$reset); |
|
| 2491 | + $this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], '', $filter_name, $reset); |
|
| 2492 | 2492 | } |
| 2493 | 2493 | if ($globalDebug) echo 'Count all callsigns...'."\n"; |
| 2494 | - $alldata = $Spotter->countAllCallsigns(false,0,$last_update_day,$filter); |
|
| 2494 | + $alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day, $filter); |
|
| 2495 | 2495 | foreach ($alldata as $number) { |
| 2496 | - $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],'',$filter_name,$reset); |
|
| 2496 | + $this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], '', $filter_name, $reset); |
|
| 2497 | 2497 | } |
| 2498 | 2498 | if ($globalDebug) echo 'Count all owners...'."\n"; |
| 2499 | - $alldata = $Spotter->countAllOwners(false,0,$last_update_day,$filter); |
|
| 2499 | + $alldata = $Spotter->countAllOwners(false, 0, $last_update_day, $filter); |
|
| 2500 | 2500 | foreach ($alldata as $number) { |
| 2501 | - $this->addStatOwner($number['owner_name'],$number['owner_count'],'',$filter_name,$reset); |
|
| 2501 | + $this->addStatOwner($number['owner_name'], $number['owner_count'], '', $filter_name, $reset); |
|
| 2502 | 2502 | } |
| 2503 | 2503 | if ($globalDebug) echo 'Count all pilots...'."\n"; |
| 2504 | - $alldata = $Spotter->countAllPilots(false,0,$last_update_day,$filter); |
|
| 2504 | + $alldata = $Spotter->countAllPilots(false, 0, $last_update_day, $filter); |
|
| 2505 | 2505 | foreach ($alldata as $number) { |
| 2506 | - $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'',$filter_name,$number['format_source'],$reset); |
|
| 2506 | + $this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], '', $filter_name, $number['format_source'], $reset); |
|
| 2507 | 2507 | } |
| 2508 | 2508 | if ($globalDebug) echo 'Count departure airports...'."\n"; |
| 2509 | - $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter); |
|
| 2510 | - $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter); |
|
| 2509 | + $pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day, $filter); |
|
| 2510 | + $dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day, $filter); |
|
| 2511 | 2511 | $alldata = array(); |
| 2512 | 2512 | foreach ($pall as $value) { |
| 2513 | 2513 | $icao = $value['airport_departure_icao']; |
@@ -2523,13 +2523,13 @@ discard block |
||
| 2523 | 2523 | foreach ($alldata as $key => $row) { |
| 2524 | 2524 | $count[$key] = $row['airport_departure_icao_count']; |
| 2525 | 2525 | } |
| 2526 | - array_multisort($count,SORT_DESC,$alldata); |
|
| 2526 | + array_multisort($count, SORT_DESC, $alldata); |
|
| 2527 | 2527 | foreach ($alldata as $number) { |
| 2528 | - 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); |
|
| 2528 | + echo $this->addStatDepartureAirports($number['airport_departure_icao'], $number['airport_departure_name'], $number['airport_departure_city'], $number['airport_departure_country'], $number['airport_departure_icao_count'], '', $filter_name, $reset); |
|
| 2529 | 2529 | } |
| 2530 | 2530 | if ($globalDebug) echo 'Count all arrival airports...'."\n"; |
| 2531 | - $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,false,$filter); |
|
| 2532 | - $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter); |
|
| 2531 | + $pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day, false, $filter); |
|
| 2532 | + $dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day, false, $filter); |
|
| 2533 | 2533 | $alldata = array(); |
| 2534 | 2534 | foreach ($pall as $value) { |
| 2535 | 2535 | $icao = $value['airport_arrival_icao']; |
@@ -2545,9 +2545,9 @@ discard block |
||
| 2545 | 2545 | foreach ($alldata as $key => $row) { |
| 2546 | 2546 | $count[$key] = $row['airport_arrival_icao_count']; |
| 2547 | 2547 | } |
| 2548 | - array_multisort($count,SORT_DESC,$alldata); |
|
| 2548 | + array_multisort($count, SORT_DESC, $alldata); |
|
| 2549 | 2549 | foreach ($alldata as $number) { |
| 2550 | - 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); |
|
| 2550 | + echo $this->addStatArrivalAirports($number['airport_arrival_icao'], $number['airport_arrival_name'], $number['airport_arrival_city'], $number['airport_arrival_country'], $number['airport_arrival_icao_count'], '', $filter_name, $reset); |
|
| 2551 | 2551 | } |
| 2552 | 2552 | if ($globalDebug) echo 'Count all months...'."\n"; |
| 2553 | 2553 | $Spotter = new Spotter($this->db); |
@@ -2555,36 +2555,36 @@ discard block |
||
| 2555 | 2555 | $lastyear = false; |
| 2556 | 2556 | foreach ($alldata as $number) { |
| 2557 | 2557 | if ($number['year_name'] != date('Y')) $lastyear = true; |
| 2558 | - $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); |
|
| 2558 | + $this->addStat('flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name); |
|
| 2559 | 2559 | } |
| 2560 | 2560 | if ($globalDebug) echo 'Count all owners by months...'."\n"; |
| 2561 | 2561 | $alldata = $Spotter->countAllMonthsOwners($filter); |
| 2562 | 2562 | foreach ($alldata as $number) { |
| 2563 | - $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); |
|
| 2563 | + $this->addStat('owners_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name); |
|
| 2564 | 2564 | } |
| 2565 | 2565 | if ($globalDebug) echo 'Count all pilots by months...'."\n"; |
| 2566 | 2566 | $alldata = $Spotter->countAllMonthsPilots($filter); |
| 2567 | 2567 | foreach ($alldata as $number) { |
| 2568 | - $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); |
|
| 2568 | + $this->addStat('pilots_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name); |
|
| 2569 | 2569 | } |
| 2570 | 2570 | if ($globalDebug) echo 'Count all military by months...'."\n"; |
| 2571 | 2571 | $alldata = $Spotter->countAllMilitaryMonths($filter); |
| 2572 | 2572 | foreach ($alldata as $number) { |
| 2573 | - $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); |
|
| 2573 | + $this->addStat('military_flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name); |
|
| 2574 | 2574 | } |
| 2575 | 2575 | if ($globalDebug) echo 'Count all aircrafts by months...'."\n"; |
| 2576 | 2576 | $alldata = $Spotter->countAllMonthsAircrafts($filter); |
| 2577 | 2577 | foreach ($alldata as $number) { |
| 2578 | - $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); |
|
| 2578 | + $this->addStat('aircrafts_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name); |
|
| 2579 | 2579 | } |
| 2580 | 2580 | if ($globalDebug) echo 'Count all real arrivals by months...'."\n"; |
| 2581 | 2581 | $alldata = $Spotter->countAllMonthsRealArrivals($filter); |
| 2582 | 2582 | foreach ($alldata as $number) { |
| 2583 | - $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); |
|
| 2583 | + $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); |
|
| 2584 | 2584 | } |
| 2585 | 2585 | echo '...Departure'."\n"; |
| 2586 | - $pall = $Spotter->getLast7DaysAirportsDeparture('',$filter); |
|
| 2587 | - $dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter); |
|
| 2586 | + $pall = $Spotter->getLast7DaysAirportsDeparture('', $filter); |
|
| 2587 | + $dall = $Spotter->getLast7DaysDetectedAirportsDeparture('', $filter); |
|
| 2588 | 2588 | foreach ($dall as $value) { |
| 2589 | 2589 | $icao = $value['departure_airport_icao']; |
| 2590 | 2590 | $ddate = $value['date']; |
@@ -2602,11 +2602,11 @@ discard block |
||
| 2602 | 2602 | } |
| 2603 | 2603 | $alldata = $pall; |
| 2604 | 2604 | foreach ($alldata as $number) { |
| 2605 | - $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); |
|
| 2605 | + $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); |
|
| 2606 | 2606 | } |
| 2607 | 2607 | echo '...Arrival'."\n"; |
| 2608 | - $pall = $Spotter->getLast7DaysAirportsArrival('',$filter); |
|
| 2609 | - $dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter); |
|
| 2608 | + $pall = $Spotter->getLast7DaysAirportsArrival('', $filter); |
|
| 2609 | + $dall = $Spotter->getLast7DaysDetectedAirportsArrival('', $filter); |
|
| 2610 | 2610 | foreach ($dall as $value) { |
| 2611 | 2611 | $icao = $value['arrival_airport_icao']; |
| 2612 | 2612 | $ddate = $value['date']; |
@@ -2624,39 +2624,39 @@ discard block |
||
| 2624 | 2624 | } |
| 2625 | 2625 | $alldata = $pall; |
| 2626 | 2626 | foreach ($alldata as $number) { |
| 2627 | - $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); |
|
| 2627 | + $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); |
|
| 2628 | 2628 | } |
| 2629 | 2629 | echo 'Flights data...'."\n"; |
| 2630 | 2630 | echo '-> countAllDatesLastMonth...'."\n"; |
| 2631 | 2631 | $alldata = $Spotter->countAllDatesLastMonth($filter); |
| 2632 | 2632 | foreach ($alldata as $number) { |
| 2633 | - $this->addStatFlight('month',$number['date_name'],$number['date_count'], '',$filter_name); |
|
| 2633 | + $this->addStatFlight('month', $number['date_name'], $number['date_count'], '', $filter_name); |
|
| 2634 | 2634 | } |
| 2635 | 2635 | echo '-> countAllDates...'."\n"; |
| 2636 | - $previousdata = $this->countAllDates('',$filter_name); |
|
| 2637 | - $alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates($filter)); |
|
| 2636 | + $previousdata = $this->countAllDates('', $filter_name); |
|
| 2637 | + $alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates($filter)); |
|
| 2638 | 2638 | $values = array(); |
| 2639 | 2639 | foreach ($alldata as $cnt) { |
| 2640 | 2640 | $values[] = $cnt['date_count']; |
| 2641 | 2641 | } |
| 2642 | - array_multisort($values,SORT_DESC,$alldata); |
|
| 2643 | - array_splice($alldata,11); |
|
| 2642 | + array_multisort($values, SORT_DESC, $alldata); |
|
| 2643 | + array_splice($alldata, 11); |
|
| 2644 | 2644 | foreach ($alldata as $number) { |
| 2645 | - $this->addStatFlight('date',$number['date_name'],$number['date_count'],'',$filter_name); |
|
| 2645 | + $this->addStatFlight('date', $number['date_name'], $number['date_count'], '', $filter_name); |
|
| 2646 | 2646 | } |
| 2647 | 2647 | |
| 2648 | 2648 | echo '-> countAllHours...'."\n"; |
| 2649 | - $alldata = $Spotter->countAllHours('hour',$filter); |
|
| 2649 | + $alldata = $Spotter->countAllHours('hour', $filter); |
|
| 2650 | 2650 | foreach ($alldata as $number) { |
| 2651 | - $this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],'',$filter_name); |
|
| 2651 | + $this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], '', $filter_name); |
|
| 2652 | 2652 | } |
| 2653 | 2653 | echo 'Insert last stats update date...'."\n"; |
| 2654 | 2654 | date_default_timezone_set('UTC'); |
| 2655 | - $this->addLastStatsUpdate('last_update_stats_'.$filter_name,date('Y-m-d G:i:s')); |
|
| 2655 | + $this->addLastStatsUpdate('last_update_stats_'.$filter_name, date('Y-m-d G:i:s')); |
|
| 2656 | 2656 | if (isset($filter['DeleteLastYearStats']) && $filter['DeleteLastYearStats'] == true) { |
| 2657 | - if (date('Y',strtotime($last_update_day)) != date('Y')) { |
|
| 2657 | + if (date('Y', strtotime($last_update_day)) != date('Y')) { |
|
| 2658 | 2658 | $this->deleteOldStats($filter_name); |
| 2659 | - $this->addLastStatsUpdate('last_update_stats_'.$filter_name,date('Y').'-01-01 00:00:00'); |
|
| 2659 | + $this->addLastStatsUpdate('last_update_stats_'.$filter_name, date('Y').'-01-01 00:00:00'); |
|
| 2660 | 2660 | } |
| 2661 | 2661 | } |
| 2662 | 2662 | } |
@@ -2668,16 +2668,16 @@ discard block |
||
| 2668 | 2668 | // SUM all previous month to put as year |
| 2669 | 2669 | $previous_year = date('Y'); |
| 2670 | 2670 | $previous_year--; |
| 2671 | - $this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year),$previous_year.'-01-01 00:00:00'); |
|
| 2672 | - $this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year),$previous_year.'-01-01 00:00:00'); |
|
| 2673 | - $this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year),$previous_year.'-01-01 00:00:00'); |
|
| 2674 | - $this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year),$previous_year.'-01-01 00:00:00'); |
|
| 2671 | + $this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year), $previous_year.'-01-01 00:00:00'); |
|
| 2672 | + $this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year), $previous_year.'-01-01 00:00:00'); |
|
| 2673 | + $this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year), $previous_year.'-01-01 00:00:00'); |
|
| 2674 | + $this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year), $previous_year.'-01-01 00:00:00'); |
|
| 2675 | 2675 | $allairlines = $this->getAllAirlineNames(); |
| 2676 | 2676 | foreach ($allairlines as $data) { |
| 2677 | - $this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']); |
|
| 2678 | - $this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']); |
|
| 2679 | - $this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']); |
|
| 2680 | - $this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']); |
|
| 2677 | + $this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']); |
|
| 2678 | + $this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']); |
|
| 2679 | + $this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']); |
|
| 2680 | + $this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']); |
|
| 2681 | 2681 | } |
| 2682 | 2682 | |
| 2683 | 2683 | if (isset($globalArchiveYear) && $globalArchiveYear) { |
@@ -2686,7 +2686,7 @@ discard block |
||
| 2686 | 2686 | try { |
| 2687 | 2687 | $sth = $this->db->prepare($query); |
| 2688 | 2688 | $sth->execute(); |
| 2689 | - } catch(PDOException $e) { |
|
| 2689 | + } catch (PDOException $e) { |
|
| 2690 | 2690 | return "error : ".$e->getMessage().' - query : '.$query."\n"; |
| 2691 | 2691 | } |
| 2692 | 2692 | } |
@@ -2699,15 +2699,15 @@ discard block |
||
| 2699 | 2699 | try { |
| 2700 | 2700 | $sth = $this->db->prepare($query); |
| 2701 | 2701 | $sth->execute(); |
| 2702 | - } catch(PDOException $e) { |
|
| 2702 | + } catch (PDOException $e) { |
|
| 2703 | 2703 | return "error : ".$e->getMessage().' - query : '.$query."\n"; |
| 2704 | 2704 | } |
| 2705 | 2705 | } |
| 2706 | 2706 | if (isset($globalDeleteLastYearStats) && $globalDeleteLastYearStats) { |
| 2707 | 2707 | $last_update = $this->getLastStatsUpdate('last_update_stats'); |
| 2708 | - if (date('Y',strtotime($last_update[0]['value'])) != date('Y')) { |
|
| 2708 | + if (date('Y', strtotime($last_update[0]['value'])) != date('Y')) { |
|
| 2709 | 2709 | $this->deleteOldStats(); |
| 2710 | - $this->addLastStatsUpdate('last_update_stats',date('Y').'-01-01 00:00:00'); |
|
| 2710 | + $this->addLastStatsUpdate('last_update_stats', date('Y').'-01-01 00:00:00'); |
|
| 2711 | 2711 | $lastyearupdate = true; |
| 2712 | 2712 | } |
| 2713 | 2713 | } |
@@ -2729,7 +2729,7 @@ discard block |
||
| 2729 | 2729 | try { |
| 2730 | 2730 | $sth = $this->db->prepare($query); |
| 2731 | 2731 | $sth->execute(); |
| 2732 | - } catch(PDOException $e) { |
|
| 2732 | + } catch (PDOException $e) { |
|
| 2733 | 2733 | return "error : ".$e->getMessage(); |
| 2734 | 2734 | } |
| 2735 | 2735 | } |
@@ -2744,14 +2744,14 @@ discard block |
||
| 2744 | 2744 | try { |
| 2745 | 2745 | $sth = $this->db->prepare($query); |
| 2746 | 2746 | $sth->execute(); |
| 2747 | - } catch(PDOException $e) { |
|
| 2747 | + } catch (PDOException $e) { |
|
| 2748 | 2748 | return "error : ".$e->getMessage(); |
| 2749 | 2749 | } |
| 2750 | 2750 | } |
| 2751 | 2751 | if (!isset($lastyearupdate)) { |
| 2752 | 2752 | echo 'Insert last stats update date...'."\n"; |
| 2753 | 2753 | date_default_timezone_set('UTC'); |
| 2754 | - $this->addLastStatsUpdate('last_update_stats',date('Y-m-d G:i:s')); |
|
| 2754 | + $this->addLastStatsUpdate('last_update_stats', date('Y-m-d G:i:s')); |
|
| 2755 | 2755 | } |
| 2756 | 2756 | if ($globalStatsResetYear) { |
| 2757 | 2757 | require_once(dirname(__FILE__).'/../install/class.settings.php'); |
@@ -13,10 +13,14 @@ discard block |
||
| 13 | 13 | |
| 14 | 14 | public function __construct($dbc = null) { |
| 15 | 15 | global $globalFilterName; |
| 16 | - if (isset($globalFilterName)) $this->filter_name = $globalFilterName; |
|
| 16 | + if (isset($globalFilterName)) { |
|
| 17 | + $this->filter_name = $globalFilterName; |
|
| 18 | + } |
|
| 17 | 19 | $Connection = new Connection($dbc); |
| 18 | 20 | $this->db = $Connection->db(); |
| 19 | - if ($this->db === null) die('Error: No DB connection.'); |
|
| 21 | + if ($this->db === null) { |
|
| 22 | + die('Error: No DB connection.'); |
|
| 23 | + } |
|
| 20 | 24 | } |
| 21 | 25 | |
| 22 | 26 | public function addLastStatsUpdate($type,$stats_date) { |
@@ -84,7 +88,9 @@ discard block |
||
| 84 | 88 | |
| 85 | 89 | public function getAllAirlineNames($filter_name = '') { |
| 86 | 90 | global $globalStatsFilters; |
| 87 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 91 | + if ($filter_name == '') { |
|
| 92 | + $filter_name = $this->filter_name; |
|
| 93 | + } |
|
| 88 | 94 | $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC"; |
| 89 | 95 | try { |
| 90 | 96 | $sth = $this->db->prepare($query); |
@@ -104,7 +110,9 @@ discard block |
||
| 104 | 110 | return $all; |
| 105 | 111 | } |
| 106 | 112 | public function getAllAircraftTypes($stats_airline = '',$filter_name = '') { |
| 107 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 113 | + if ($filter_name == '') { |
|
| 114 | + $filter_name = $this->filter_name; |
|
| 115 | + } |
|
| 108 | 116 | $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC"; |
| 109 | 117 | try { |
| 110 | 118 | $sth = $this->db->prepare($query); |
@@ -116,7 +124,9 @@ discard block |
||
| 116 | 124 | return $all; |
| 117 | 125 | } |
| 118 | 126 | public function getAllManufacturers($stats_airline = '',$filter_name = '') { |
| 119 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 127 | + if ($filter_name == '') { |
|
| 128 | + $filter_name = $this->filter_name; |
|
| 129 | + } |
|
| 120 | 130 | $query = "SELECT DISTINCT(aircraft_manufacturer) FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND aircraft_manufacturer <> '' ORDER BY aircraft_manufacturer ASC"; |
| 121 | 131 | try { |
| 122 | 132 | $sth = $this->db->prepare($query); |
@@ -128,7 +138,9 @@ discard block |
||
| 128 | 138 | return $all; |
| 129 | 139 | } |
| 130 | 140 | public function getAllAirportNames($stats_airline = '',$filter_name = '') { |
| 131 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 141 | + if ($filter_name == '') { |
|
| 142 | + $filter_name = $this->filter_name; |
|
| 143 | + } |
|
| 132 | 144 | $query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND stats_type = 'daily' GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC"; |
| 133 | 145 | try { |
| 134 | 146 | $sth = $this->db->prepare($query); |
@@ -141,7 +153,9 @@ discard block |
||
| 141 | 153 | } |
| 142 | 154 | |
| 143 | 155 | public function getAllOwnerNames($stats_airline = '',$filter_name = '') { |
| 144 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 156 | + if ($filter_name == '') { |
|
| 157 | + $filter_name = $this->filter_name; |
|
| 158 | + } |
|
| 145 | 159 | $query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC"; |
| 146 | 160 | try { |
| 147 | 161 | $sth = $this->db->prepare($query); |
@@ -154,7 +168,9 @@ discard block |
||
| 154 | 168 | } |
| 155 | 169 | |
| 156 | 170 | public function getAllPilotNames($stats_airline = '',$filter_name = '') { |
| 157 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 171 | + if ($filter_name == '') { |
|
| 172 | + $filter_name = $this->filter_name; |
|
| 173 | + } |
|
| 158 | 174 | $query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC"; |
| 159 | 175 | try { |
| 160 | 176 | $sth = $this->db->prepare($query); |
@@ -169,7 +185,9 @@ discard block |
||
| 169 | 185 | |
| 170 | 186 | public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') { |
| 171 | 187 | global $globalStatsFilters; |
| 172 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 188 | + if ($filter_name == '') { |
|
| 189 | + $filter_name = $this->filter_name; |
|
| 190 | + } |
|
| 173 | 191 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 174 | 192 | $Spotter = new Spotter($this->db); |
| 175 | 193 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -178,8 +196,11 @@ discard block |
||
| 178 | 196 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
| 179 | 197 | } |
| 180 | 198 | if ($year == '' && $month == '') { |
| 181 | - if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 182 | - else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
|
| 199 | + if ($limit) { |
|
| 200 | + $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 201 | + } else { |
|
| 202 | + $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
|
| 203 | + } |
|
| 183 | 204 | try { |
| 184 | 205 | $sth = $this->db->prepare($query); |
| 185 | 206 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -187,11 +208,16 @@ discard block |
||
| 187 | 208 | echo "error : ".$e->getMessage(); |
| 188 | 209 | } |
| 189 | 210 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 190 | - } else $all = array(); |
|
| 211 | + } else { |
|
| 212 | + $all = array(); |
|
| 213 | + } |
|
| 191 | 214 | } else { |
| 192 | 215 | if ($year == '' && $month == '') { |
| 193 | - if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 194 | - else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
|
| 216 | + if ($limit) { |
|
| 217 | + $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 218 | + } else { |
|
| 219 | + $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
|
| 220 | + } |
|
| 195 | 221 | try { |
| 196 | 222 | $sth = $this->db->prepare($query); |
| 197 | 223 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -199,7 +225,9 @@ discard block |
||
| 199 | 225 | echo "error : ".$e->getMessage(); |
| 200 | 226 | } |
| 201 | 227 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 202 | - } else $all = array(); |
|
| 228 | + } else { |
|
| 229 | + $all = array(); |
|
| 230 | + } |
|
| 203 | 231 | } |
| 204 | 232 | if (empty($all)) { |
| 205 | 233 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -218,10 +246,15 @@ discard block |
||
| 218 | 246 | } |
| 219 | 247 | public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') { |
| 220 | 248 | global $globalStatsFilters; |
| 221 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 249 | + if ($filter_name == '') { |
|
| 250 | + $filter_name = $this->filter_name; |
|
| 251 | + } |
|
| 222 | 252 | if ($year == '' && $month == '') { |
| 223 | - if ($limit) $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 224 | - else $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC"; |
|
| 253 | + if ($limit) { |
|
| 254 | + $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 255 | + } else { |
|
| 256 | + $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC"; |
|
| 257 | + } |
|
| 225 | 258 | try { |
| 226 | 259 | $sth = $this->db->prepare($query); |
| 227 | 260 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -229,7 +262,9 @@ discard block |
||
| 229 | 262 | echo "error : ".$e->getMessage(); |
| 230 | 263 | } |
| 231 | 264 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 232 | - } else $all = array(); |
|
| 265 | + } else { |
|
| 266 | + $all = array(); |
|
| 267 | + } |
|
| 233 | 268 | if (empty($all)) { |
| 234 | 269 | $Spotter = new Spotter($this->db); |
| 235 | 270 | $filters = array(); |
@@ -244,7 +279,9 @@ discard block |
||
| 244 | 279 | } |
| 245 | 280 | public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') { |
| 246 | 281 | global $globalStatsFilters; |
| 247 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 282 | + if ($filter_name == '') { |
|
| 283 | + $filter_name = $this->filter_name; |
|
| 284 | + } |
|
| 248 | 285 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 249 | 286 | $Spotter = new Spotter($this->db); |
| 250 | 287 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -253,8 +290,11 @@ discard block |
||
| 253 | 290 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
| 254 | 291 | } |
| 255 | 292 | if ($year == '' && $month == '') { |
| 256 | - if ($limit) $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0"; |
|
| 257 | - else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC"; |
|
| 293 | + if ($limit) { |
|
| 294 | + $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0"; |
|
| 295 | + } else { |
|
| 296 | + $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC"; |
|
| 297 | + } |
|
| 258 | 298 | try { |
| 259 | 299 | $sth = $this->db->prepare($query); |
| 260 | 300 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -262,11 +302,16 @@ discard block |
||
| 262 | 302 | echo "error : ".$e->getMessage(); |
| 263 | 303 | } |
| 264 | 304 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 265 | - } else $all = array(); |
|
| 305 | + } else { |
|
| 306 | + $all = array(); |
|
| 307 | + } |
|
| 266 | 308 | } else { |
| 267 | 309 | if ($year == '' && $month == '') { |
| 268 | - if ($limit) $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0"; |
|
| 269 | - else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC"; |
|
| 310 | + if ($limit) { |
|
| 311 | + $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0"; |
|
| 312 | + } else { |
|
| 313 | + $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC"; |
|
| 314 | + } |
|
| 270 | 315 | try { |
| 271 | 316 | $sth = $this->db->prepare($query); |
| 272 | 317 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -274,7 +319,9 @@ discard block |
||
| 274 | 319 | echo "error : ".$e->getMessage(); |
| 275 | 320 | } |
| 276 | 321 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 277 | - } else $all = array(); |
|
| 322 | + } else { |
|
| 323 | + $all = array(); |
|
| 324 | + } |
|
| 278 | 325 | } |
| 279 | 326 | if (empty($all)) { |
| 280 | 327 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -294,7 +341,9 @@ discard block |
||
| 294 | 341 | |
| 295 | 342 | public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') { |
| 296 | 343 | global $globalStatsFilters; |
| 297 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 344 | + if ($filter_name == '') { |
|
| 345 | + $filter_name = $this->filter_name; |
|
| 346 | + } |
|
| 298 | 347 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 299 | 348 | $Spotter = new Spotter($this->db); |
| 300 | 349 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -303,8 +352,11 @@ discard block |
||
| 303 | 352 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
| 304 | 353 | } |
| 305 | 354 | if ($year == '' && $month == '') { |
| 306 | - if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 307 | - else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC"; |
|
| 355 | + if ($limit) { |
|
| 356 | + $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 357 | + } else { |
|
| 358 | + $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC"; |
|
| 359 | + } |
|
| 308 | 360 | try { |
| 309 | 361 | $sth = $this->db->prepare($query); |
| 310 | 362 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -312,11 +364,16 @@ discard block |
||
| 312 | 364 | echo "error : ".$e->getMessage(); |
| 313 | 365 | } |
| 314 | 366 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 315 | - } else $all = array(); |
|
| 367 | + } else { |
|
| 368 | + $all = array(); |
|
| 369 | + } |
|
| 316 | 370 | } else { |
| 317 | 371 | if ($year == '' && $month == '') { |
| 318 | - if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 319 | - else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC"; |
|
| 372 | + if ($limit) { |
|
| 373 | + $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 374 | + } else { |
|
| 375 | + $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC"; |
|
| 376 | + } |
|
| 320 | 377 | try { |
| 321 | 378 | $sth = $this->db->prepare($query); |
| 322 | 379 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -324,7 +381,9 @@ discard block |
||
| 324 | 381 | echo "error : ".$e->getMessage(); |
| 325 | 382 | } |
| 326 | 383 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 327 | - } else $all = array(); |
|
| 384 | + } else { |
|
| 385 | + $all = array(); |
|
| 386 | + } |
|
| 328 | 387 | } |
| 329 | 388 | if (empty($all)) { |
| 330 | 389 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -343,7 +402,9 @@ discard block |
||
| 343 | 402 | } |
| 344 | 403 | public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
| 345 | 404 | global $globalStatsFilters; |
| 346 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 405 | + if ($filter_name == '') { |
|
| 406 | + $filter_name = $this->filter_name; |
|
| 407 | + } |
|
| 347 | 408 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 348 | 409 | $Spotter = new Spotter($this->db); |
| 349 | 410 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -351,12 +412,18 @@ discard block |
||
| 351 | 412 | foreach ($airlines as $airline) { |
| 352 | 413 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
| 353 | 414 | } |
| 354 | - if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 355 | - else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC"; |
|
| 415 | + if ($limit) { |
|
| 416 | + $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 417 | + } else { |
|
| 418 | + $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC"; |
|
| 419 | + } |
|
| 356 | 420 | $query_values = array(':filter_name' => $filter_name); |
| 357 | 421 | } else { |
| 358 | - if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 359 | - else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC"; |
|
| 422 | + if ($limit) { |
|
| 423 | + $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 424 | + } else { |
|
| 425 | + $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC"; |
|
| 426 | + } |
|
| 360 | 427 | $query_values = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
| 361 | 428 | } |
| 362 | 429 | try { |
@@ -384,17 +451,29 @@ discard block |
||
| 384 | 451 | |
| 385 | 452 | public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') { |
| 386 | 453 | global $globalStatsFilters, $globalVATSIM, $globalIVAO; |
| 387 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 454 | + if ($filter_name == '') { |
|
| 455 | + $filter_name = $this->filter_name; |
|
| 456 | + } |
|
| 388 | 457 | if ($year == '' && $month == '') { |
| 389 | - if ($globalVATSIM) $forsource = 'vatsim'; |
|
| 390 | - if ($globalIVAO) $forsource = 'ivao'; |
|
| 458 | + if ($globalVATSIM) { |
|
| 459 | + $forsource = 'vatsim'; |
|
| 460 | + } |
|
| 461 | + if ($globalIVAO) { |
|
| 462 | + $forsource = 'ivao'; |
|
| 463 | + } |
|
| 391 | 464 | if (isset($forsource)) { |
| 392 | - if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
|
| 393 | - else $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC"; |
|
| 465 | + if ($limit) { |
|
| 466 | + $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
|
| 467 | + } else { |
|
| 468 | + $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC"; |
|
| 469 | + } |
|
| 394 | 470 | $query_values = array(':filter_name' => $filter_name,':forsource' => $forsource); |
| 395 | 471 | } else { |
| 396 | - if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
|
| 397 | - else $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC"; |
|
| 472 | + if ($limit) { |
|
| 473 | + $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
|
| 474 | + } else { |
|
| 475 | + $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC"; |
|
| 476 | + } |
|
| 398 | 477 | $query_values = array(':filter_name' => $filter_name); |
| 399 | 478 | } |
| 400 | 479 | try { |
@@ -404,7 +483,9 @@ discard block |
||
| 404 | 483 | echo "error : ".$e->getMessage(); |
| 405 | 484 | } |
| 406 | 485 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 407 | - } else $all = array(); |
|
| 486 | + } else { |
|
| 487 | + $all = array(); |
|
| 488 | + } |
|
| 408 | 489 | if (empty($all)) { |
| 409 | 490 | $Spotter = new Spotter($this->db); |
| 410 | 491 | $filters = array(); |
@@ -419,7 +500,9 @@ discard block |
||
| 419 | 500 | } |
| 420 | 501 | public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
| 421 | 502 | global $globalStatsFilters; |
| 422 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 503 | + if ($filter_name == '') { |
|
| 504 | + $filter_name = $this->filter_name; |
|
| 505 | + } |
|
| 423 | 506 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 424 | 507 | $Spotter = new Spotter($this->db); |
| 425 | 508 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -428,8 +511,11 @@ discard block |
||
| 428 | 511 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
| 429 | 512 | } |
| 430 | 513 | if ($year == '' && $month == '') { |
| 431 | - if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0"; |
|
| 432 | - else $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC"; |
|
| 514 | + if ($limit) { |
|
| 515 | + $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0"; |
|
| 516 | + } else { |
|
| 517 | + $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC"; |
|
| 518 | + } |
|
| 433 | 519 | try { |
| 434 | 520 | $sth = $this->db->prepare($query); |
| 435 | 521 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -437,11 +523,16 @@ discard block |
||
| 437 | 523 | echo "error : ".$e->getMessage(); |
| 438 | 524 | } |
| 439 | 525 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 440 | - } else $all = array(); |
|
| 526 | + } else { |
|
| 527 | + $all = array(); |
|
| 528 | + } |
|
| 441 | 529 | } else { |
| 442 | 530 | if ($year == '' && $month == '') { |
| 443 | - if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0"; |
|
| 444 | - else $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC"; |
|
| 531 | + if ($limit) { |
|
| 532 | + $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0"; |
|
| 533 | + } else { |
|
| 534 | + $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC"; |
|
| 535 | + } |
|
| 445 | 536 | try { |
| 446 | 537 | $sth = $this->db->prepare($query); |
| 447 | 538 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -449,7 +540,9 @@ discard block |
||
| 449 | 540 | echo "error : ".$e->getMessage(); |
| 450 | 541 | } |
| 451 | 542 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 452 | - } else $all = array(); |
|
| 543 | + } else { |
|
| 544 | + $all = array(); |
|
| 545 | + } |
|
| 453 | 546 | } |
| 454 | 547 | if (empty($all)) { |
| 455 | 548 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -468,7 +561,9 @@ discard block |
||
| 468 | 561 | } |
| 469 | 562 | public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
| 470 | 563 | global $globalStatsFilters; |
| 471 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 564 | + if ($filter_name == '') { |
|
| 565 | + $filter_name = $this->filter_name; |
|
| 566 | + } |
|
| 472 | 567 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 473 | 568 | $Spotter = new Spotter($this->db); |
| 474 | 569 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -477,8 +572,11 @@ discard block |
||
| 477 | 572 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
| 478 | 573 | } |
| 479 | 574 | if ($year == '' && $month == '') { |
| 480 | - if ($limit) $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 481 | - else $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC"; |
|
| 575 | + if ($limit) { |
|
| 576 | + $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 577 | + } else { |
|
| 578 | + $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC"; |
|
| 579 | + } |
|
| 482 | 580 | try { |
| 483 | 581 | $sth = $this->db->prepare($query); |
| 484 | 582 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -486,11 +584,16 @@ discard block |
||
| 486 | 584 | echo "error : ".$e->getMessage(); |
| 487 | 585 | } |
| 488 | 586 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 489 | - } else $all = array(); |
|
| 587 | + } else { |
|
| 588 | + $all = array(); |
|
| 589 | + } |
|
| 490 | 590 | } else { |
| 491 | 591 | if ($year == '' && $month == '') { |
| 492 | - if ($limit) $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 493 | - else $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC"; |
|
| 592 | + if ($limit) { |
|
| 593 | + $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 594 | + } else { |
|
| 595 | + $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC"; |
|
| 596 | + } |
|
| 494 | 597 | try { |
| 495 | 598 | $sth = $this->db->prepare($query); |
| 496 | 599 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -498,7 +601,9 @@ discard block |
||
| 498 | 601 | echo "error : ".$e->getMessage(); |
| 499 | 602 | } |
| 500 | 603 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 501 | - } else $all = array(); |
|
| 604 | + } else { |
|
| 605 | + $all = array(); |
|
| 606 | + } |
|
| 502 | 607 | } |
| 503 | 608 | if (empty($all)) { |
| 504 | 609 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -517,7 +622,9 @@ discard block |
||
| 517 | 622 | } |
| 518 | 623 | public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '',$year = '',$month = '') { |
| 519 | 624 | $Connection = new Connection($this->db); |
| 520 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 625 | + if ($filter_name == '') { |
|
| 626 | + $filter_name = $this->filter_name; |
|
| 627 | + } |
|
| 521 | 628 | if ($Connection->tableExists('countries')) { |
| 522 | 629 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 523 | 630 | $Spotter = new Spotter($this->db); |
@@ -527,8 +634,11 @@ discard block |
||
| 527 | 634 | foreach ($airlines as $airline) { |
| 528 | 635 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
| 529 | 636 | } |
| 530 | - if ($limit) $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0"; |
|
| 531 | - else $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC"; |
|
| 637 | + if ($limit) { |
|
| 638 | + $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0"; |
|
| 639 | + } else { |
|
| 640 | + $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC"; |
|
| 641 | + } |
|
| 532 | 642 | try { |
| 533 | 643 | $sth = $this->db->prepare($query); |
| 534 | 644 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -537,11 +647,16 @@ discard block |
||
| 537 | 647 | } |
| 538 | 648 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 539 | 649 | return $all; |
| 540 | - } else return array(); |
|
| 650 | + } else { |
|
| 651 | + return array(); |
|
| 652 | + } |
|
| 541 | 653 | } else { |
| 542 | 654 | if ($year == '' && $month == '') { |
| 543 | - if ($limit) $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0"; |
|
| 544 | - else $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC"; |
|
| 655 | + if ($limit) { |
|
| 656 | + $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0"; |
|
| 657 | + } else { |
|
| 658 | + $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC"; |
|
| 659 | + } |
|
| 545 | 660 | try { |
| 546 | 661 | $sth = $this->db->prepare($query); |
| 547 | 662 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -550,7 +665,9 @@ discard block |
||
| 550 | 665 | } |
| 551 | 666 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 552 | 667 | return $all; |
| 553 | - } else return array(); |
|
| 668 | + } else { |
|
| 669 | + return array(); |
|
| 670 | + } |
|
| 554 | 671 | } |
| 555 | 672 | } else { |
| 556 | 673 | /* |
@@ -564,10 +681,15 @@ discard block |
||
| 564 | 681 | } |
| 565 | 682 | public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '', $year = '',$month = '') { |
| 566 | 683 | global $globalStatsFilters; |
| 567 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 684 | + if ($filter_name == '') { |
|
| 685 | + $filter_name = $this->filter_name; |
|
| 686 | + } |
|
| 568 | 687 | if ($year == '' && $month == '') { |
| 569 | - if ($limit) $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC LIMIT 10 OFFSET 0"; |
|
| 570 | - else $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC"; |
|
| 688 | + if ($limit) { |
|
| 689 | + $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC LIMIT 10 OFFSET 0"; |
|
| 690 | + } else { |
|
| 691 | + $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC"; |
|
| 692 | + } |
|
| 571 | 693 | try { |
| 572 | 694 | $sth = $this->db->prepare($query); |
| 573 | 695 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -575,7 +697,9 @@ discard block |
||
| 575 | 697 | echo "error : ".$e->getMessage(); |
| 576 | 698 | } |
| 577 | 699 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 578 | - } else $all = array(); |
|
| 700 | + } else { |
|
| 701 | + $all = array(); |
|
| 702 | + } |
|
| 579 | 703 | if (empty($all)) { |
| 580 | 704 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
| 581 | 705 | if ($filter_name != '') { |
@@ -590,7 +714,9 @@ discard block |
||
| 590 | 714 | |
| 591 | 715 | public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '',$year = '',$month = '') { |
| 592 | 716 | global $globalStatsFilters; |
| 593 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 717 | + if ($filter_name == '') { |
|
| 718 | + $filter_name = $this->filter_name; |
|
| 719 | + } |
|
| 594 | 720 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 595 | 721 | $Spotter = new Spotter($this->db); |
| 596 | 722 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -599,8 +725,11 @@ discard block |
||
| 599 | 725 | foreach ($airlines as $airline) { |
| 600 | 726 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
| 601 | 727 | } |
| 602 | - if ($limit) $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0"; |
|
| 603 | - else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC"; |
|
| 728 | + if ($limit) { |
|
| 729 | + $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0"; |
|
| 730 | + } else { |
|
| 731 | + $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC"; |
|
| 732 | + } |
|
| 604 | 733 | try { |
| 605 | 734 | $sth = $this->db->prepare($query); |
| 606 | 735 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -608,11 +737,16 @@ discard block |
||
| 608 | 737 | echo "error : ".$e->getMessage(); |
| 609 | 738 | } |
| 610 | 739 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 611 | - } else $all = array(); |
|
| 740 | + } else { |
|
| 741 | + $all = array(); |
|
| 742 | + } |
|
| 612 | 743 | } else { |
| 613 | 744 | if ($year == '' && $month == '') { |
| 614 | - if ($limit) $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0"; |
|
| 615 | - else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC"; |
|
| 745 | + if ($limit) { |
|
| 746 | + $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0"; |
|
| 747 | + } else { |
|
| 748 | + $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC"; |
|
| 749 | + } |
|
| 616 | 750 | try { |
| 617 | 751 | $sth = $this->db->prepare($query); |
| 618 | 752 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -620,7 +754,9 @@ discard block |
||
| 620 | 754 | echo "error : ".$e->getMessage(); |
| 621 | 755 | } |
| 622 | 756 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 623 | - } else $all = array(); |
|
| 757 | + } else { |
|
| 758 | + $all = array(); |
|
| 759 | + } |
|
| 624 | 760 | } |
| 625 | 761 | if (empty($all)) { |
| 626 | 762 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -639,7 +775,9 @@ discard block |
||
| 639 | 775 | } |
| 640 | 776 | public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
| 641 | 777 | global $globalStatsFilters; |
| 642 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 778 | + if ($filter_name == '') { |
|
| 779 | + $filter_name = $this->filter_name; |
|
| 780 | + } |
|
| 643 | 781 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 644 | 782 | $Spotter = new Spotter($this->db); |
| 645 | 783 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -648,8 +786,11 @@ discard block |
||
| 648 | 786 | foreach ($airlines as $airline) { |
| 649 | 787 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
| 650 | 788 | } |
| 651 | - if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 652 | - else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
|
| 789 | + if ($limit) { |
|
| 790 | + $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 791 | + } else { |
|
| 792 | + $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
|
| 793 | + } |
|
| 653 | 794 | try { |
| 654 | 795 | $sth = $this->db->prepare($query); |
| 655 | 796 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -657,11 +798,16 @@ discard block |
||
| 657 | 798 | echo "error : ".$e->getMessage(); |
| 658 | 799 | } |
| 659 | 800 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 660 | - } else $all = array(); |
|
| 801 | + } else { |
|
| 802 | + $all = array(); |
|
| 803 | + } |
|
| 661 | 804 | } else { |
| 662 | 805 | if ($year == '' && $month == '') { |
| 663 | - if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 664 | - else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
|
| 806 | + if ($limit) { |
|
| 807 | + $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 808 | + } else { |
|
| 809 | + $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
|
| 810 | + } |
|
| 665 | 811 | try { |
| 666 | 812 | $sth = $this->db->prepare($query); |
| 667 | 813 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -669,7 +815,9 @@ discard block |
||
| 669 | 815 | echo "error : ".$e->getMessage(); |
| 670 | 816 | } |
| 671 | 817 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 672 | - } else $all = array(); |
|
| 818 | + } else { |
|
| 819 | + $all = array(); |
|
| 820 | + } |
|
| 673 | 821 | } |
| 674 | 822 | if (empty($all)) { |
| 675 | 823 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -694,7 +842,9 @@ discard block |
||
| 694 | 842 | $icao = $value['airport_departure_icao']; |
| 695 | 843 | if (isset($all[$icao])) { |
| 696 | 844 | $all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
| 697 | - } else $all[$icao] = $value; |
|
| 845 | + } else { |
|
| 846 | + $all[$icao] = $value; |
|
| 847 | + } |
|
| 698 | 848 | } |
| 699 | 849 | $count = array(); |
| 700 | 850 | foreach ($all as $key => $row) { |
@@ -706,7 +856,9 @@ discard block |
||
| 706 | 856 | } |
| 707 | 857 | public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
| 708 | 858 | global $globalStatsFilters; |
| 709 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 859 | + if ($filter_name == '') { |
|
| 860 | + $filter_name = $this->filter_name; |
|
| 861 | + } |
|
| 710 | 862 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 711 | 863 | $Spotter = new Spotter($this->db); |
| 712 | 864 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -715,8 +867,11 @@ discard block |
||
| 715 | 867 | foreach ($airlines as $airline) { |
| 716 | 868 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
| 717 | 869 | } |
| 718 | - if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 719 | - else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
|
| 870 | + if ($limit) { |
|
| 871 | + $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 872 | + } else { |
|
| 873 | + $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
|
| 874 | + } |
|
| 720 | 875 | try { |
| 721 | 876 | $sth = $this->db->prepare($query); |
| 722 | 877 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -724,11 +879,16 @@ discard block |
||
| 724 | 879 | echo "error : ".$e->getMessage(); |
| 725 | 880 | } |
| 726 | 881 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 727 | - } else $all = array(); |
|
| 882 | + } else { |
|
| 883 | + $all = array(); |
|
| 884 | + } |
|
| 728 | 885 | } else { |
| 729 | 886 | if ($year == '' && $month == '') { |
| 730 | - if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 731 | - else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
|
| 887 | + if ($limit) { |
|
| 888 | + $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 889 | + } else { |
|
| 890 | + $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
|
| 891 | + } |
|
| 732 | 892 | try { |
| 733 | 893 | $sth = $this->db->prepare($query); |
| 734 | 894 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -736,7 +896,9 @@ discard block |
||
| 736 | 896 | echo "error : ".$e->getMessage(); |
| 737 | 897 | } |
| 738 | 898 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 739 | - } else $all = array(); |
|
| 899 | + } else { |
|
| 900 | + $all = array(); |
|
| 901 | + } |
|
| 740 | 902 | } |
| 741 | 903 | if (empty($all)) { |
| 742 | 904 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -761,7 +923,9 @@ discard block |
||
| 761 | 923 | $icao = $value['airport_arrival_icao']; |
| 762 | 924 | if (isset($all[$icao])) { |
| 763 | 925 | $all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
| 764 | - } else $all[$icao] = $value; |
|
| 926 | + } else { |
|
| 927 | + $all[$icao] = $value; |
|
| 928 | + } |
|
| 765 | 929 | } |
| 766 | 930 | $count = array(); |
| 767 | 931 | foreach ($all as $key => $row) { |
@@ -773,7 +937,9 @@ discard block |
||
| 773 | 937 | } |
| 774 | 938 | public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') { |
| 775 | 939 | global $globalDBdriver, $globalStatsFilters; |
| 776 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 940 | + if ($filter_name == '') { |
|
| 941 | + $filter_name = $this->filter_name; |
|
| 942 | + } |
|
| 777 | 943 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 778 | 944 | $Spotter = new Spotter($this->db); |
| 779 | 945 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -782,20 +948,32 @@ discard block |
||
| 782 | 948 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
| 783 | 949 | } |
| 784 | 950 | if ($globalDBdriver == 'mysql') { |
| 785 | - if ($limit) $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
| 786 | - else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
| 951 | + if ($limit) { |
|
| 952 | + $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
| 953 | + } else { |
|
| 954 | + $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
| 955 | + } |
|
| 787 | 956 | } else { |
| 788 | - if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
| 789 | - else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
| 957 | + if ($limit) { |
|
| 958 | + $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
| 959 | + } else { |
|
| 960 | + $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
| 961 | + } |
|
| 790 | 962 | } |
| 791 | 963 | $query_data = array(':filter_name' => $filter_name); |
| 792 | 964 | } else { |
| 793 | 965 | if ($globalDBdriver == 'mysql') { |
| 794 | - if ($limit) $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
| 795 | - else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
| 966 | + if ($limit) { |
|
| 967 | + $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
| 968 | + } else { |
|
| 969 | + $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
| 970 | + } |
|
| 796 | 971 | } else { |
| 797 | - if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
| 798 | - else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
| 972 | + if ($limit) { |
|
| 973 | + $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
| 974 | + } else { |
|
| 975 | + $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
| 976 | + } |
|
| 799 | 977 | } |
| 800 | 978 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
| 801 | 979 | } |
@@ -823,7 +1001,9 @@ discard block |
||
| 823 | 1001 | |
| 824 | 1002 | public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') { |
| 825 | 1003 | global $globalStatsFilters; |
| 826 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1004 | + if ($filter_name == '') { |
|
| 1005 | + $filter_name = $this->filter_name; |
|
| 1006 | + } |
|
| 827 | 1007 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 828 | 1008 | $Spotter = new Spotter($this->db); |
| 829 | 1009 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -860,7 +1040,9 @@ discard block |
||
| 860 | 1040 | } |
| 861 | 1041 | public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') { |
| 862 | 1042 | global $globalDBdriver, $globalStatsFilters; |
| 863 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1043 | + if ($filter_name == '') { |
|
| 1044 | + $filter_name = $this->filter_name; |
|
| 1045 | + } |
|
| 864 | 1046 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 865 | 1047 | $Spotter = new Spotter($this->db); |
| 866 | 1048 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -905,7 +1087,9 @@ discard block |
||
| 905 | 1087 | } |
| 906 | 1088 | public function countAllDates($stats_airline = '',$filter_name = '') { |
| 907 | 1089 | global $globalStatsFilters; |
| 908 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1090 | + if ($filter_name == '') { |
|
| 1091 | + $filter_name = $this->filter_name; |
|
| 1092 | + } |
|
| 909 | 1093 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 910 | 1094 | $Spotter = new Spotter($this->db); |
| 911 | 1095 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -942,7 +1126,9 @@ discard block |
||
| 942 | 1126 | } |
| 943 | 1127 | public function countAllDatesByAirlines($filter_name = '') { |
| 944 | 1128 | global $globalStatsFilters; |
| 945 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1129 | + if ($filter_name == '') { |
|
| 1130 | + $filter_name = $this->filter_name; |
|
| 1131 | + } |
|
| 946 | 1132 | $query = "SELECT stats_airline as airline_icao, flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND filter_name = :filter_name"; |
| 947 | 1133 | $query_data = array('filter_name' => $filter_name); |
| 948 | 1134 | try { |
@@ -964,7 +1150,9 @@ discard block |
||
| 964 | 1150 | } |
| 965 | 1151 | public function countAllMonths($stats_airline = '',$filter_name = '') { |
| 966 | 1152 | global $globalStatsFilters, $globalDBdriver; |
| 967 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1153 | + if ($filter_name == '') { |
|
| 1154 | + $filter_name = $this->filter_name; |
|
| 1155 | + } |
|
| 968 | 1156 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 969 | 1157 | $Spotter = new Spotter($this->db); |
| 970 | 1158 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -1049,7 +1237,9 @@ discard block |
||
| 1049 | 1237 | } |
| 1050 | 1238 | public function countAllMilitaryMonths($filter_name = '') { |
| 1051 | 1239 | global $globalStatsFilters; |
| 1052 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1240 | + if ($filter_name == '') { |
|
| 1241 | + $filter_name = $this->filter_name; |
|
| 1242 | + } |
|
| 1053 | 1243 | $query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'military_flights_bymonth' AND filter_name = :filter_name"; |
| 1054 | 1244 | try { |
| 1055 | 1245 | $sth = $this->db->prepare($query); |
@@ -1070,7 +1260,9 @@ discard block |
||
| 1070 | 1260 | } |
| 1071 | 1261 | public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') { |
| 1072 | 1262 | global $globalTimezone, $globalDBdriver, $globalStatsFilters; |
| 1073 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1263 | + if ($filter_name == '') { |
|
| 1264 | + $filter_name = $this->filter_name; |
|
| 1265 | + } |
|
| 1074 | 1266 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 1075 | 1267 | $Spotter = new Spotter($this->db); |
| 1076 | 1268 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -1078,12 +1270,18 @@ discard block |
||
| 1078 | 1270 | foreach ($airlines as $airline) { |
| 1079 | 1271 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
| 1080 | 1272 | } |
| 1081 | - if ($limit) $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
| 1082 | - else $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
| 1273 | + if ($limit) { |
|
| 1274 | + $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
| 1275 | + } else { |
|
| 1276 | + $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
| 1277 | + } |
|
| 1083 | 1278 | $query_data = array(':filter_name' => $filter_name); |
| 1084 | 1279 | } else { |
| 1085 | - if ($limit) $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
| 1086 | - else $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
| 1280 | + if ($limit) { |
|
| 1281 | + $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
| 1282 | + } else { |
|
| 1283 | + $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
| 1284 | + } |
|
| 1087 | 1285 | $query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
| 1088 | 1286 | } |
| 1089 | 1287 | if ($orderby == 'hour') { |
@@ -1093,7 +1291,9 @@ discard block |
||
| 1093 | 1291 | $query .= " ORDER BY CAST(flight_date AS integer) ASC"; |
| 1094 | 1292 | } |
| 1095 | 1293 | } |
| 1096 | - if ($orderby == 'count') $query .= " ORDER BY hour_count DESC"; |
|
| 1294 | + if ($orderby == 'count') { |
|
| 1295 | + $query .= " ORDER BY hour_count DESC"; |
|
| 1296 | + } |
|
| 1097 | 1297 | try { |
| 1098 | 1298 | $sth = $this->db->prepare($query); |
| 1099 | 1299 | $sth->execute($query_data); |
@@ -1117,8 +1317,12 @@ discard block |
||
| 1117 | 1317 | } |
| 1118 | 1318 | public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') { |
| 1119 | 1319 | global $globalStatsFilters; |
| 1120 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1121 | - if ($year == '') $year = date('Y'); |
|
| 1320 | + if ($filter_name == '') { |
|
| 1321 | + $filter_name = $this->filter_name; |
|
| 1322 | + } |
|
| 1323 | + if ($year == '') { |
|
| 1324 | + $year = date('Y'); |
|
| 1325 | + } |
|
| 1122 | 1326 | $all = $this->getSumStats('flights_bymonth',$year,$stats_airline,$filter_name,$month); |
| 1123 | 1327 | if (empty($all)) { |
| 1124 | 1328 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -1137,8 +1341,12 @@ discard block |
||
| 1137 | 1341 | } |
| 1138 | 1342 | public function countOverallMilitaryFlights($filter_name = '',$year = '', $month = '') { |
| 1139 | 1343 | global $globalStatsFilters; |
| 1140 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1141 | - if ($year == '') $year = date('Y'); |
|
| 1344 | + if ($filter_name == '') { |
|
| 1345 | + $filter_name = $this->filter_name; |
|
| 1346 | + } |
|
| 1347 | + if ($year == '') { |
|
| 1348 | + $year = date('Y'); |
|
| 1349 | + } |
|
| 1142 | 1350 | $all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month); |
| 1143 | 1351 | if (empty($all)) { |
| 1144 | 1352 | $filters = array(); |
@@ -1154,8 +1362,12 @@ discard block |
||
| 1154 | 1362 | } |
| 1155 | 1363 | public function countOverallArrival($stats_airline = '',$filter_name = '', $year = '', $month = '') { |
| 1156 | 1364 | global $globalStatsFilters; |
| 1157 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1158 | - if ($year == '') $year = date('Y'); |
|
| 1365 | + if ($filter_name == '') { |
|
| 1366 | + $filter_name = $this->filter_name; |
|
| 1367 | + } |
|
| 1368 | + if ($year == '') { |
|
| 1369 | + $year = date('Y'); |
|
| 1370 | + } |
|
| 1159 | 1371 | $all = $this->getSumStats('realarrivals_bymonth',$year,$stats_airline,$filter_name,$month); |
| 1160 | 1372 | if (empty($all)) { |
| 1161 | 1373 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -1174,7 +1386,9 @@ discard block |
||
| 1174 | 1386 | } |
| 1175 | 1387 | public function countOverallAircrafts($stats_airline = '',$filter_name = '',$year = '', $month = '') { |
| 1176 | 1388 | global $globalStatsFilters; |
| 1177 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1389 | + if ($filter_name == '') { |
|
| 1390 | + $filter_name = $this->filter_name; |
|
| 1391 | + } |
|
| 1178 | 1392 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 1179 | 1393 | $Spotter = new Spotter($this->db); |
| 1180 | 1394 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -1192,7 +1406,9 @@ discard block |
||
| 1192 | 1406 | } |
| 1193 | 1407 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1194 | 1408 | $all = $result[0]['nb']; |
| 1195 | - } else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month); |
|
| 1409 | + } else { |
|
| 1410 | + $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month); |
|
| 1411 | + } |
|
| 1196 | 1412 | } else { |
| 1197 | 1413 | if ($year == '' && $month == '') { |
| 1198 | 1414 | $query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
@@ -1204,7 +1420,9 @@ discard block |
||
| 1204 | 1420 | } |
| 1205 | 1421 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1206 | 1422 | $all = $result[0]['nb']; |
| 1207 | - } else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month); |
|
| 1423 | + } else { |
|
| 1424 | + $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month); |
|
| 1425 | + } |
|
| 1208 | 1426 | } |
| 1209 | 1427 | if (empty($all)) { |
| 1210 | 1428 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -1223,7 +1441,9 @@ discard block |
||
| 1223 | 1441 | } |
| 1224 | 1442 | public function countOverallAirlines($filter_name = '',$year = '',$month = '') { |
| 1225 | 1443 | global $globalStatsFilters; |
| 1226 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1444 | + if ($filter_name == '') { |
|
| 1445 | + $filter_name = $this->filter_name; |
|
| 1446 | + } |
|
| 1227 | 1447 | if ($year == '' && $month == '') { |
| 1228 | 1448 | $query = "SELECT COUNT(*) AS nb_airline FROM stats_airline WHERE filter_name = :filter_name"; |
| 1229 | 1449 | try { |
@@ -1234,7 +1454,9 @@ discard block |
||
| 1234 | 1454 | } |
| 1235 | 1455 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1236 | 1456 | $all = $result[0]['nb_airline']; |
| 1237 | - } else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month); |
|
| 1457 | + } else { |
|
| 1458 | + $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month); |
|
| 1459 | + } |
|
| 1238 | 1460 | if (empty($all)) { |
| 1239 | 1461 | $filters = array(); |
| 1240 | 1462 | $filters = array('year' => $year,'month' => $month); |
@@ -1249,7 +1471,9 @@ discard block |
||
| 1249 | 1471 | } |
| 1250 | 1472 | public function countOverallOwners($stats_airline = '',$filter_name = '',$year = '', $month = '') { |
| 1251 | 1473 | global $globalStatsFilters; |
| 1252 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1474 | + if ($filter_name == '') { |
|
| 1475 | + $filter_name = $this->filter_name; |
|
| 1476 | + } |
|
| 1253 | 1477 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 1254 | 1478 | $Spotter = new Spotter($this->db); |
| 1255 | 1479 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -1304,7 +1528,9 @@ discard block |
||
| 1304 | 1528 | } |
| 1305 | 1529 | public function countOverallPilots($stats_airline = '',$filter_name = '',$year = '',$month = '') { |
| 1306 | 1530 | global $globalStatsFilters; |
| 1307 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1531 | + if ($filter_name == '') { |
|
| 1532 | + $filter_name = $this->filter_name; |
|
| 1533 | + } |
|
| 1308 | 1534 | //if ($year == '') $year = date('Y'); |
| 1309 | 1535 | if ($year == '' && $month == '') { |
| 1310 | 1536 | $query = "SELECT count(*) as nb FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
@@ -1333,7 +1559,9 @@ discard block |
||
| 1333 | 1559 | } |
| 1334 | 1560 | |
| 1335 | 1561 | public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') { |
| 1336 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1562 | + if ($filter_name == '') { |
|
| 1563 | + $filter_name = $this->filter_name; |
|
| 1564 | + } |
|
| 1337 | 1565 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 1338 | 1566 | $Spotter = new Spotter($this->db); |
| 1339 | 1567 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -1357,7 +1585,9 @@ discard block |
||
| 1357 | 1585 | return $all; |
| 1358 | 1586 | } |
| 1359 | 1587 | public function getStats($type,$stats_airline = '', $filter_name = '') { |
| 1360 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1588 | + if ($filter_name == '') { |
|
| 1589 | + $filter_name = $this->filter_name; |
|
| 1590 | + } |
|
| 1361 | 1591 | $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date"; |
| 1362 | 1592 | $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
| 1363 | 1593 | try { |
@@ -1370,7 +1600,9 @@ discard block |
||
| 1370 | 1600 | return $all; |
| 1371 | 1601 | } |
| 1372 | 1602 | public function deleteStatsByType($type,$stats_airline = '', $filter_name = '') { |
| 1373 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1603 | + if ($filter_name == '') { |
|
| 1604 | + $filter_name = $this->filter_name; |
|
| 1605 | + } |
|
| 1374 | 1606 | $query = "DELETE FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
| 1375 | 1607 | $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
| 1376 | 1608 | try { |
@@ -1381,7 +1613,9 @@ discard block |
||
| 1381 | 1613 | } |
| 1382 | 1614 | } |
| 1383 | 1615 | public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') { |
| 1384 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1616 | + if ($filter_name == '') { |
|
| 1617 | + $filter_name = $this->filter_name; |
|
| 1618 | + } |
|
| 1385 | 1619 | global $globalArchiveMonths, $globalDBdriver; |
| 1386 | 1620 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 1387 | 1621 | $Spotter = new Spotter($this->db); |
@@ -1437,7 +1671,9 @@ discard block |
||
| 1437 | 1671 | } |
| 1438 | 1672 | public function getStatsTotal($type, $stats_airline = '', $filter_name = '') { |
| 1439 | 1673 | global $globalArchiveMonths, $globalDBdriver; |
| 1440 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1674 | + if ($filter_name == '') { |
|
| 1675 | + $filter_name = $this->filter_name; |
|
| 1676 | + } |
|
| 1441 | 1677 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 1442 | 1678 | $Spotter = new Spotter($this->db); |
| 1443 | 1679 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -1470,7 +1706,9 @@ discard block |
||
| 1470 | 1706 | } |
| 1471 | 1707 | public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') { |
| 1472 | 1708 | global $globalArchiveMonths, $globalDBdriver; |
| 1473 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1709 | + if ($filter_name == '') { |
|
| 1710 | + $filter_name = $this->filter_name; |
|
| 1711 | + } |
|
| 1474 | 1712 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 1475 | 1713 | $Spotter = new Spotter($this->db); |
| 1476 | 1714 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -1501,7 +1739,9 @@ discard block |
||
| 1501 | 1739 | } |
| 1502 | 1740 | public function getStatsAirlineTotal($filter_name = '') { |
| 1503 | 1741 | global $globalArchiveMonths, $globalDBdriver; |
| 1504 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1742 | + if ($filter_name == '') { |
|
| 1743 | + $filter_name = $this->filter_name; |
|
| 1744 | + } |
|
| 1505 | 1745 | if ($globalDBdriver == 'mysql') { |
| 1506 | 1746 | $query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name"; |
| 1507 | 1747 | } else { |
@@ -1518,7 +1758,9 @@ discard block |
||
| 1518 | 1758 | } |
| 1519 | 1759 | public function getStatsOwnerTotal($filter_name = '') { |
| 1520 | 1760 | global $globalArchiveMonths, $globalDBdriver; |
| 1521 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1761 | + if ($filter_name == '') { |
|
| 1762 | + $filter_name = $this->filter_name; |
|
| 1763 | + } |
|
| 1522 | 1764 | if ($globalDBdriver == 'mysql') { |
| 1523 | 1765 | $query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name"; |
| 1524 | 1766 | } else { |
@@ -1535,7 +1777,9 @@ discard block |
||
| 1535 | 1777 | } |
| 1536 | 1778 | public function getStatsOwner($owner_name,$filter_name = '') { |
| 1537 | 1779 | global $globalArchiveMonths, $globalDBdriver; |
| 1538 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1780 | + if ($filter_name == '') { |
|
| 1781 | + $filter_name = $this->filter_name; |
|
| 1782 | + } |
|
| 1539 | 1783 | $query = "SELECT cnt FROM stats_owner WHERE filter_name = :filter_name AND owner_name = :owner_name"; |
| 1540 | 1784 | try { |
| 1541 | 1785 | $sth = $this->db->prepare($query); |
@@ -1544,12 +1788,17 @@ discard block |
||
| 1544 | 1788 | echo "error : ".$e->getMessage(); |
| 1545 | 1789 | } |
| 1546 | 1790 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1547 | - if (isset($all[0]['cnt'])) return $all[0]['cnt']; |
|
| 1548 | - else return 0; |
|
| 1791 | + if (isset($all[0]['cnt'])) { |
|
| 1792 | + return $all[0]['cnt']; |
|
| 1793 | + } else { |
|
| 1794 | + return 0; |
|
| 1795 | + } |
|
| 1549 | 1796 | } |
| 1550 | 1797 | public function getStatsPilotTotal($filter_name = '') { |
| 1551 | 1798 | global $globalArchiveMonths, $globalDBdriver; |
| 1552 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1799 | + if ($filter_name == '') { |
|
| 1800 | + $filter_name = $this->filter_name; |
|
| 1801 | + } |
|
| 1553 | 1802 | if ($globalDBdriver == 'mysql') { |
| 1554 | 1803 | $query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name"; |
| 1555 | 1804 | } else { |
@@ -1566,7 +1815,9 @@ discard block |
||
| 1566 | 1815 | } |
| 1567 | 1816 | public function getStatsPilot($pilot,$filter_name = '') { |
| 1568 | 1817 | global $globalArchiveMonths, $globalDBdriver; |
| 1569 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1818 | + if ($filter_name == '') { |
|
| 1819 | + $filter_name = $this->filter_name; |
|
| 1820 | + } |
|
| 1570 | 1821 | $query = "SELECT cnt FROM stats_pilot WHERE filter_name = :filter_name AND (pilot_name = :pilot OR pilot_id = :pilot)"; |
| 1571 | 1822 | try { |
| 1572 | 1823 | $sth = $this->db->prepare($query); |
@@ -1575,13 +1826,18 @@ discard block |
||
| 1575 | 1826 | echo "error : ".$e->getMessage(); |
| 1576 | 1827 | } |
| 1577 | 1828 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1578 | - if (isset($all[0]['cnt'])) return $all[0]['cnt']; |
|
| 1579 | - else return 0; |
|
| 1829 | + if (isset($all[0]['cnt'])) { |
|
| 1830 | + return $all[0]['cnt']; |
|
| 1831 | + } else { |
|
| 1832 | + return 0; |
|
| 1833 | + } |
|
| 1580 | 1834 | } |
| 1581 | 1835 | |
| 1582 | 1836 | public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
| 1583 | 1837 | global $globalDBdriver; |
| 1584 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1838 | + if ($filter_name == '') { |
|
| 1839 | + $filter_name = $this->filter_name; |
|
| 1840 | + } |
|
| 1585 | 1841 | if ($globalDBdriver == 'mysql') { |
| 1586 | 1842 | $query = "INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) VALUES (:type,:cnt,:stats_date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = :cnt"; |
| 1587 | 1843 | } else { |
@@ -1597,7 +1853,9 @@ discard block |
||
| 1597 | 1853 | } |
| 1598 | 1854 | public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
| 1599 | 1855 | global $globalDBdriver; |
| 1600 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1856 | + if ($filter_name == '') { |
|
| 1857 | + $filter_name = $this->filter_name; |
|
| 1858 | + } |
|
| 1601 | 1859 | if ($globalDBdriver == 'mysql') { |
| 1602 | 1860 | $query = "INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) VALUES (:type,:cnt,:stats_date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date"; |
| 1603 | 1861 | } else { |
@@ -1983,10 +2241,14 @@ discard block |
||
| 1983 | 2241 | $Connection = new Connection($this->db); |
| 1984 | 2242 | date_default_timezone_set('UTC'); |
| 1985 | 2243 | $last_update = $this->getLastStatsUpdate('last_update_stats'); |
| 1986 | - if ($globalDebug) echo 'Update stats !'."\n"; |
|
| 2244 | + if ($globalDebug) { |
|
| 2245 | + echo 'Update stats !'."\n"; |
|
| 2246 | + } |
|
| 1987 | 2247 | if (isset($last_update[0]['value'])) { |
| 1988 | 2248 | $last_update_day = $last_update[0]['value']; |
| 1989 | - } else $last_update_day = '2012-12-12 12:12:12'; |
|
| 2249 | + } else { |
|
| 2250 | + $last_update_day = '2012-12-12 12:12:12'; |
|
| 2251 | + } |
|
| 1990 | 2252 | $reset = false; |
| 1991 | 2253 | //if ($globalStatsResetYear && date('Y',strtotime($last_update_day)) != date('Y')) { |
| 1992 | 2254 | if ($globalStatsResetYear) { |
@@ -1995,43 +2257,63 @@ discard block |
||
| 1995 | 2257 | } |
| 1996 | 2258 | $Spotter = new Spotter($this->db); |
| 1997 | 2259 | |
| 1998 | - if ($globalDebug) echo 'Count all aircraft types...'."\n"; |
|
| 2260 | + if ($globalDebug) { |
|
| 2261 | + echo 'Count all aircraft types...'."\n"; |
|
| 2262 | + } |
|
| 1999 | 2263 | $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day); |
| 2000 | 2264 | foreach ($alldata as $number) { |
| 2001 | 2265 | $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'','',$reset); |
| 2002 | 2266 | } |
| 2003 | - if ($globalDebug) echo 'Count all airlines...'."\n"; |
|
| 2267 | + if ($globalDebug) { |
|
| 2268 | + echo 'Count all airlines...'."\n"; |
|
| 2269 | + } |
|
| 2004 | 2270 | $alldata = $Spotter->countAllAirlines(false,0,$last_update_day); |
| 2005 | 2271 | foreach ($alldata as $number) { |
| 2006 | 2272 | $this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],'',$reset); |
| 2007 | 2273 | } |
| 2008 | - if ($globalDebug) echo 'Count all registrations...'."\n"; |
|
| 2274 | + if ($globalDebug) { |
|
| 2275 | + echo 'Count all registrations...'."\n"; |
|
| 2276 | + } |
|
| 2009 | 2277 | $alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day); |
| 2010 | 2278 | foreach ($alldata as $number) { |
| 2011 | 2279 | $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'','',$reset); |
| 2012 | 2280 | } |
| 2013 | - if ($globalDebug) echo 'Count all callsigns...'."\n"; |
|
| 2281 | + if ($globalDebug) { |
|
| 2282 | + echo 'Count all callsigns...'."\n"; |
|
| 2283 | + } |
|
| 2014 | 2284 | $alldata = $Spotter->countAllCallsigns(false,0,$last_update_day); |
| 2015 | 2285 | foreach ($alldata as $number) { |
| 2016 | 2286 | $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset); |
| 2017 | 2287 | } |
| 2018 | - if ($globalDebug) echo 'Count all owners...'."\n"; |
|
| 2288 | + if ($globalDebug) { |
|
| 2289 | + echo 'Count all owners...'."\n"; |
|
| 2290 | + } |
|
| 2019 | 2291 | $alldata = $Spotter->countAllOwners(false,0,$last_update_day); |
| 2020 | 2292 | foreach ($alldata as $number) { |
| 2021 | 2293 | $this->addStatOwner($number['owner_name'],$number['owner_count'],'','',$reset); |
| 2022 | 2294 | } |
| 2023 | - if ($globalDebug) echo 'Count all pilots...'."\n"; |
|
| 2295 | + if ($globalDebug) { |
|
| 2296 | + echo 'Count all pilots...'."\n"; |
|
| 2297 | + } |
|
| 2024 | 2298 | $alldata = $Spotter->countAllPilots(false,0,$last_update_day); |
| 2025 | 2299 | foreach ($alldata as $number) { |
| 2026 | - if ($number['pilot_id'] == 0 || $number['pilot_id'] == '') $number['pilot_id'] = $number['pilot_name']; |
|
| 2300 | + if ($number['pilot_id'] == 0 || $number['pilot_id'] == '') { |
|
| 2301 | + $number['pilot_id'] = $number['pilot_name']; |
|
| 2302 | + } |
|
| 2027 | 2303 | $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source'],$reset); |
| 2028 | 2304 | } |
| 2029 | 2305 | |
| 2030 | - if ($globalDebug) echo 'Count all departure airports...'."\n"; |
|
| 2306 | + if ($globalDebug) { |
|
| 2307 | + echo 'Count all departure airports...'."\n"; |
|
| 2308 | + } |
|
| 2031 | 2309 | $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day); |
| 2032 | - if ($globalDebug) echo 'Count all detected departure airports...'."\n"; |
|
| 2310 | + if ($globalDebug) { |
|
| 2311 | + echo 'Count all detected departure airports...'."\n"; |
|
| 2312 | + } |
|
| 2033 | 2313 | $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day); |
| 2034 | - if ($globalDebug) echo 'Order departure airports...'."\n"; |
|
| 2314 | + if ($globalDebug) { |
|
| 2315 | + echo 'Order departure airports...'."\n"; |
|
| 2316 | + } |
|
| 2035 | 2317 | $alldata = array(); |
| 2036 | 2318 | foreach ($pall as $value) { |
| 2037 | 2319 | $icao = $value['airport_departure_icao']; |
@@ -2041,7 +2323,9 @@ discard block |
||
| 2041 | 2323 | $icao = $value['airport_departure_icao']; |
| 2042 | 2324 | if (isset($alldata[$icao])) { |
| 2043 | 2325 | $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
| 2044 | - } else $alldata[$icao] = $value; |
|
| 2326 | + } else { |
|
| 2327 | + $alldata[$icao] = $value; |
|
| 2328 | + } |
|
| 2045 | 2329 | } |
| 2046 | 2330 | $count = array(); |
| 2047 | 2331 | foreach ($alldata as $key => $row) { |
@@ -2051,11 +2335,17 @@ discard block |
||
| 2051 | 2335 | foreach ($alldata as $number) { |
| 2052 | 2336 | echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'','',$reset); |
| 2053 | 2337 | } |
| 2054 | - if ($globalDebug) echo 'Count all arrival airports...'."\n"; |
|
| 2338 | + if ($globalDebug) { |
|
| 2339 | + echo 'Count all arrival airports...'."\n"; |
|
| 2340 | + } |
|
| 2055 | 2341 | $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day); |
| 2056 | - if ($globalDebug) echo 'Count all detected arrival airports...'."\n"; |
|
| 2342 | + if ($globalDebug) { |
|
| 2343 | + echo 'Count all detected arrival airports...'."\n"; |
|
| 2344 | + } |
|
| 2057 | 2345 | $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day); |
| 2058 | - if ($globalDebug) echo 'Order arrival airports...'."\n"; |
|
| 2346 | + if ($globalDebug) { |
|
| 2347 | + echo 'Order arrival airports...'."\n"; |
|
| 2348 | + } |
|
| 2059 | 2349 | $alldata = array(); |
| 2060 | 2350 | foreach ($pall as $value) { |
| 2061 | 2351 | $icao = $value['airport_arrival_icao']; |
@@ -2065,7 +2355,9 @@ discard block |
||
| 2065 | 2355 | $icao = $value['airport_arrival_icao']; |
| 2066 | 2356 | if (isset($alldata[$icao])) { |
| 2067 | 2357 | $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
| 2068 | - } else $alldata[$icao] = $value; |
|
| 2358 | + } else { |
|
| 2359 | + $alldata[$icao] = $value; |
|
| 2360 | + } |
|
| 2069 | 2361 | } |
| 2070 | 2362 | $count = array(); |
| 2071 | 2363 | foreach ($alldata as $key => $row) { |
@@ -2076,7 +2368,9 @@ discard block |
||
| 2076 | 2368 | echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'','',$reset); |
| 2077 | 2369 | } |
| 2078 | 2370 | if ($Connection->tableExists('countries')) { |
| 2079 | - if ($globalDebug) echo 'Count all flights by countries...'."\n"; |
|
| 2371 | + if ($globalDebug) { |
|
| 2372 | + echo 'Count all flights by countries...'."\n"; |
|
| 2373 | + } |
|
| 2080 | 2374 | //$SpotterArchive = new SpotterArchive(); |
| 2081 | 2375 | //$alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day); |
| 2082 | 2376 | $Spotter = new Spotter($this->db); |
@@ -2087,7 +2381,9 @@ discard block |
||
| 2087 | 2381 | } |
| 2088 | 2382 | |
| 2089 | 2383 | if (isset($globalAccidents) && $globalAccidents) { |
| 2090 | - if ($globalDebug) echo 'Count fatalities stats...'."\n"; |
|
| 2384 | + if ($globalDebug) { |
|
| 2385 | + echo 'Count fatalities stats...'."\n"; |
|
| 2386 | + } |
|
| 2091 | 2387 | $Accident = new Accident($this->db); |
| 2092 | 2388 | $this->deleteStatsByType('fatalities_byyear'); |
| 2093 | 2389 | $alldata = $Accident->countFatalitiesByYear(); |
@@ -2103,48 +2399,68 @@ discard block |
||
| 2103 | 2399 | |
| 2104 | 2400 | // Add by month using getstat if month finish... |
| 2105 | 2401 | //if (date('m',strtotime($last_update_day)) != date('m')) { |
| 2106 | - if ($globalDebug) echo 'Count all flights by months...'."\n"; |
|
| 2402 | + if ($globalDebug) { |
|
| 2403 | + echo 'Count all flights by months...'."\n"; |
|
| 2404 | + } |
|
| 2107 | 2405 | $last_month = date('Y-m-01 00:00:00', strtotime('-1 month', strtotime($last_update_day))); |
| 2108 | 2406 | $filter_last_month = array('since_date' => $last_month); |
| 2109 | 2407 | $Spotter = new Spotter($this->db); |
| 2110 | 2408 | $alldata = $Spotter->countAllMonths($filter_last_month); |
| 2111 | 2409 | $lastyear = false; |
| 2112 | 2410 | foreach ($alldata as $number) { |
| 2113 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
| 2411 | + if ($number['year_name'] != date('Y')) { |
|
| 2412 | + $lastyear = true; |
|
| 2413 | + } |
|
| 2114 | 2414 | $this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
| 2115 | 2415 | } |
| 2116 | - if ($globalDebug) echo 'Count all military flights by months...'."\n"; |
|
| 2416 | + if ($globalDebug) { |
|
| 2417 | + echo 'Count all military flights by months...'."\n"; |
|
| 2418 | + } |
|
| 2117 | 2419 | $alldata = $Spotter->countAllMilitaryMonths($filter_last_month); |
| 2118 | 2420 | foreach ($alldata as $number) { |
| 2119 | 2421 | $this->addStat('military_flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
| 2120 | 2422 | } |
| 2121 | - if ($globalDebug) echo 'Count all owners by months...'."\n"; |
|
| 2423 | + if ($globalDebug) { |
|
| 2424 | + echo 'Count all owners by months...'."\n"; |
|
| 2425 | + } |
|
| 2122 | 2426 | $alldata = $Spotter->countAllMonthsOwners($filter_last_month); |
| 2123 | 2427 | foreach ($alldata as $number) { |
| 2124 | 2428 | $this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
| 2125 | 2429 | } |
| 2126 | - if ($globalDebug) echo 'Count all pilots by months...'."\n"; |
|
| 2430 | + if ($globalDebug) { |
|
| 2431 | + echo 'Count all pilots by months...'."\n"; |
|
| 2432 | + } |
|
| 2127 | 2433 | $alldata = $Spotter->countAllMonthsPilots($filter_last_month); |
| 2128 | 2434 | foreach ($alldata as $number) { |
| 2129 | 2435 | $this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
| 2130 | 2436 | } |
| 2131 | - if ($globalDebug) echo 'Count all airlines by months...'."\n"; |
|
| 2437 | + if ($globalDebug) { |
|
| 2438 | + echo 'Count all airlines by months...'."\n"; |
|
| 2439 | + } |
|
| 2132 | 2440 | $alldata = $Spotter->countAllMonthsAirlines($filter_last_month); |
| 2133 | 2441 | foreach ($alldata as $number) { |
| 2134 | 2442 | $this->addStat('airlines_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
| 2135 | 2443 | } |
| 2136 | - if ($globalDebug) echo 'Count all aircrafts by months...'."\n"; |
|
| 2444 | + if ($globalDebug) { |
|
| 2445 | + echo 'Count all aircrafts by months...'."\n"; |
|
| 2446 | + } |
|
| 2137 | 2447 | $alldata = $Spotter->countAllMonthsAircrafts($filter_last_month); |
| 2138 | 2448 | foreach ($alldata as $number) { |
| 2139 | 2449 | $this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
| 2140 | 2450 | } |
| 2141 | - if ($globalDebug) echo 'Count all real arrivals by months...'."\n"; |
|
| 2451 | + if ($globalDebug) { |
|
| 2452 | + echo 'Count all real arrivals by months...'."\n"; |
|
| 2453 | + } |
|
| 2142 | 2454 | $alldata = $Spotter->countAllMonthsRealArrivals($filter_last_month); |
| 2143 | 2455 | foreach ($alldata as $number) { |
| 2144 | 2456 | $this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
| 2145 | 2457 | } |
| 2146 | - if ($globalDebug) echo 'Airports data...'."\n"; |
|
| 2147 | - if ($globalDebug) echo '...Departure'."\n"; |
|
| 2458 | + if ($globalDebug) { |
|
| 2459 | + echo 'Airports data...'."\n"; |
|
| 2460 | + } |
|
| 2461 | + if ($globalDebug) { |
|
| 2462 | + echo '...Departure'."\n"; |
|
| 2463 | + } |
|
| 2148 | 2464 | $this->deleteStatAirport('daily'); |
| 2149 | 2465 | // $pall = $Spotter->getLast7DaysAirportsDeparture(); |
| 2150 | 2466 | // $dall = $Spotter->getLast7DaysDetectedAirportsDeparture(); |
@@ -2262,7 +2578,9 @@ discard block |
||
| 2262 | 2578 | // Count by airlines |
| 2263 | 2579 | echo '--- Stats by airlines ---'."\n"; |
| 2264 | 2580 | if ($Connection->tableExists('countries')) { |
| 2265 | - if ($globalDebug) echo 'Count all flights by countries by airlines...'."\n"; |
|
| 2581 | + if ($globalDebug) { |
|
| 2582 | + echo 'Count all flights by countries by airlines...'."\n"; |
|
| 2583 | + } |
|
| 2266 | 2584 | $SpotterArchive = new SpotterArchive($this->db); |
| 2267 | 2585 | //$Spotter = new Spotter($this->db); |
| 2268 | 2586 | $alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false,0,$last_update_day); |
@@ -2271,37 +2589,53 @@ discard block |
||
| 2271 | 2589 | $this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],$number['airline_icao'],'',$reset); |
| 2272 | 2590 | } |
| 2273 | 2591 | } |
| 2274 | - if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n"; |
|
| 2592 | + if ($globalDebug) { |
|
| 2593 | + echo 'Count all aircraft types by airlines...'."\n"; |
|
| 2594 | + } |
|
| 2275 | 2595 | $Spotter = new Spotter($this->db); |
| 2276 | 2596 | $alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day); |
| 2277 | 2597 | foreach ($alldata as $number) { |
| 2278 | 2598 | $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao'],'',$reset); |
| 2279 | 2599 | } |
| 2280 | - if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n"; |
|
| 2600 | + if ($globalDebug) { |
|
| 2601 | + echo 'Count all aircraft registrations by airlines...'."\n"; |
|
| 2602 | + } |
|
| 2281 | 2603 | $alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day); |
| 2282 | 2604 | foreach ($alldata as $number) { |
| 2283 | 2605 | $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao'],'',$reset); |
| 2284 | 2606 | } |
| 2285 | - if ($globalDebug) echo 'Count all callsigns by airlines...'."\n"; |
|
| 2607 | + if ($globalDebug) { |
|
| 2608 | + echo 'Count all callsigns by airlines...'."\n"; |
|
| 2609 | + } |
|
| 2286 | 2610 | $alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day); |
| 2287 | 2611 | foreach ($alldata as $number) { |
| 2288 | 2612 | $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset); |
| 2289 | 2613 | } |
| 2290 | - if ($globalDebug) echo 'Count all owners by airlines...'."\n"; |
|
| 2614 | + if ($globalDebug) { |
|
| 2615 | + echo 'Count all owners by airlines...'."\n"; |
|
| 2616 | + } |
|
| 2291 | 2617 | $alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day); |
| 2292 | 2618 | foreach ($alldata as $number) { |
| 2293 | 2619 | $this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao'],'',$reset); |
| 2294 | 2620 | } |
| 2295 | - if ($globalDebug) echo 'Count all pilots by airlines...'."\n"; |
|
| 2621 | + if ($globalDebug) { |
|
| 2622 | + echo 'Count all pilots by airlines...'."\n"; |
|
| 2623 | + } |
|
| 2296 | 2624 | $alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day); |
| 2297 | 2625 | foreach ($alldata as $number) { |
| 2298 | 2626 | $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source'],$reset); |
| 2299 | 2627 | } |
| 2300 | - if ($globalDebug) echo 'Count all departure airports by airlines...'."\n"; |
|
| 2628 | + if ($globalDebug) { |
|
| 2629 | + echo 'Count all departure airports by airlines...'."\n"; |
|
| 2630 | + } |
|
| 2301 | 2631 | $pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day); |
| 2302 | - if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n"; |
|
| 2632 | + if ($globalDebug) { |
|
| 2633 | + echo 'Count all detected departure airports by airlines...'."\n"; |
|
| 2634 | + } |
|
| 2303 | 2635 | $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day); |
| 2304 | - if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n"; |
|
| 2636 | + if ($globalDebug) { |
|
| 2637 | + echo 'Order detected departure airports by airlines...'."\n"; |
|
| 2638 | + } |
|
| 2305 | 2639 | //$alldata = array(); |
| 2306 | 2640 | foreach ($dall as $value) { |
| 2307 | 2641 | $icao = $value['airport_departure_icao']; |
@@ -2322,11 +2656,17 @@ discard block |
||
| 2322 | 2656 | foreach ($alldata as $number) { |
| 2323 | 2657 | echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],$number['airline_icao'],'',$reset); |
| 2324 | 2658 | } |
| 2325 | - if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n"; |
|
| 2659 | + if ($globalDebug) { |
|
| 2660 | + echo 'Count all arrival airports by airlines...'."\n"; |
|
| 2661 | + } |
|
| 2326 | 2662 | $pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day); |
| 2327 | - if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n"; |
|
| 2663 | + if ($globalDebug) { |
|
| 2664 | + echo 'Count all detected arrival airports by airlines...'."\n"; |
|
| 2665 | + } |
|
| 2328 | 2666 | $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day); |
| 2329 | - if ($globalDebug) echo 'Order arrival airports by airlines...'."\n"; |
|
| 2667 | + if ($globalDebug) { |
|
| 2668 | + echo 'Order arrival airports by airlines...'."\n"; |
|
| 2669 | + } |
|
| 2330 | 2670 | //$alldata = array(); |
| 2331 | 2671 | foreach ($dall as $value) { |
| 2332 | 2672 | $icao = $value['airport_arrival_icao']; |
@@ -2345,37 +2685,53 @@ discard block |
||
| 2345 | 2685 | } |
| 2346 | 2686 | $alldata = $pall; |
| 2347 | 2687 | foreach ($alldata as $number) { |
| 2348 | - if ($number['airline_icao'] != '') echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],$number['airline_icao'],'',$reset); |
|
| 2688 | + if ($number['airline_icao'] != '') { |
|
| 2689 | + echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],$number['airline_icao'],'',$reset); |
|
| 2690 | + } |
|
| 2691 | + } |
|
| 2692 | + if ($globalDebug) { |
|
| 2693 | + echo 'Count all flights by months by airlines...'."\n"; |
|
| 2349 | 2694 | } |
| 2350 | - if ($globalDebug) echo 'Count all flights by months by airlines...'."\n"; |
|
| 2351 | 2695 | $Spotter = new Spotter($this->db); |
| 2352 | 2696 | $alldata = $Spotter->countAllMonthsByAirlines($filter_last_month); |
| 2353 | 2697 | $lastyear = false; |
| 2354 | 2698 | foreach ($alldata as $number) { |
| 2355 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
| 2699 | + if ($number['year_name'] != date('Y')) { |
|
| 2700 | + $lastyear = true; |
|
| 2701 | + } |
|
| 2356 | 2702 | $this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
| 2357 | 2703 | } |
| 2358 | - if ($globalDebug) echo 'Count all owners by months by airlines...'."\n"; |
|
| 2704 | + if ($globalDebug) { |
|
| 2705 | + echo 'Count all owners by months by airlines...'."\n"; |
|
| 2706 | + } |
|
| 2359 | 2707 | $alldata = $Spotter->countAllMonthsOwnersByAirlines($filter_last_month); |
| 2360 | 2708 | foreach ($alldata as $number) { |
| 2361 | 2709 | $this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
| 2362 | 2710 | } |
| 2363 | - if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n"; |
|
| 2711 | + if ($globalDebug) { |
|
| 2712 | + echo 'Count all pilots by months by airlines...'."\n"; |
|
| 2713 | + } |
|
| 2364 | 2714 | $alldata = $Spotter->countAllMonthsPilotsByAirlines($filter_last_month); |
| 2365 | 2715 | foreach ($alldata as $number) { |
| 2366 | 2716 | $this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
| 2367 | 2717 | } |
| 2368 | - if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n"; |
|
| 2718 | + if ($globalDebug) { |
|
| 2719 | + echo 'Count all aircrafts by months by airlines...'."\n"; |
|
| 2720 | + } |
|
| 2369 | 2721 | $alldata = $Spotter->countAllMonthsAircraftsByAirlines($filter_last_month); |
| 2370 | 2722 | foreach ($alldata as $number) { |
| 2371 | 2723 | $this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
| 2372 | 2724 | } |
| 2373 | - if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n"; |
|
| 2725 | + if ($globalDebug) { |
|
| 2726 | + echo 'Count all real arrivals by months by airlines...'."\n"; |
|
| 2727 | + } |
|
| 2374 | 2728 | $alldata = $Spotter->countAllMonthsRealArrivalsByAirlines($filter_last_month); |
| 2375 | 2729 | foreach ($alldata as $number) { |
| 2376 | 2730 | $this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
| 2377 | 2731 | } |
| 2378 | - if ($globalDebug) echo '...Departure'."\n"; |
|
| 2732 | + if ($globalDebug) { |
|
| 2733 | + echo '...Departure'."\n"; |
|
| 2734 | + } |
|
| 2379 | 2735 | $pall = $Spotter->getLast7DaysAirportsDepartureByAirlines(); |
| 2380 | 2736 | $dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines(); |
| 2381 | 2737 | foreach ($dall as $value) { |
@@ -2398,7 +2754,9 @@ discard block |
||
| 2398 | 2754 | foreach ($alldata as $number) { |
| 2399 | 2755 | $this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count'],$number['airline_icao']); |
| 2400 | 2756 | } |
| 2401 | - if ($globalDebug) echo '...Arrival'."\n"; |
|
| 2757 | + if ($globalDebug) { |
|
| 2758 | + echo '...Arrival'."\n"; |
|
| 2759 | + } |
|
| 2402 | 2760 | $pall = $Spotter->getLast7DaysAirportsArrivalByAirlines(); |
| 2403 | 2761 | $dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines(); |
| 2404 | 2762 | foreach ($dall as $value) { |
@@ -2422,13 +2780,19 @@ discard block |
||
| 2422 | 2780 | $this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count'],$number['airline_icao']); |
| 2423 | 2781 | } |
| 2424 | 2782 | |
| 2425 | - if ($globalDebug) echo 'Flights data...'."\n"; |
|
| 2426 | - if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n"; |
|
| 2783 | + if ($globalDebug) { |
|
| 2784 | + echo 'Flights data...'."\n"; |
|
| 2785 | + } |
|
| 2786 | + if ($globalDebug) { |
|
| 2787 | + echo '-> countAllDatesLastMonth...'."\n"; |
|
| 2788 | + } |
|
| 2427 | 2789 | $alldata = $Spotter->countAllDatesLastMonthByAirlines($filter_last_month); |
| 2428 | 2790 | foreach ($alldata as $number) { |
| 2429 | 2791 | $this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']); |
| 2430 | 2792 | } |
| 2431 | - if ($globalDebug) echo '-> countAllDates...'."\n"; |
|
| 2793 | + if ($globalDebug) { |
|
| 2794 | + echo '-> countAllDates...'."\n"; |
|
| 2795 | + } |
|
| 2432 | 2796 | //$previousdata = $this->countAllDatesByAirlines(); |
| 2433 | 2797 | $alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines($filter_last_month)); |
| 2434 | 2798 | $values = array(); |
@@ -2441,14 +2805,18 @@ discard block |
||
| 2441 | 2805 | $this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']); |
| 2442 | 2806 | } |
| 2443 | 2807 | |
| 2444 | - if ($globalDebug) echo '-> countAllHours...'."\n"; |
|
| 2808 | + if ($globalDebug) { |
|
| 2809 | + echo '-> countAllHours...'."\n"; |
|
| 2810 | + } |
|
| 2445 | 2811 | $alldata = $Spotter->countAllHoursByAirlines('hour',$filter_last_month); |
| 2446 | 2812 | foreach ($alldata as $number) { |
| 2447 | 2813 | $this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']); |
| 2448 | 2814 | } |
| 2449 | 2815 | |
| 2450 | 2816 | // Stats by filters |
| 2451 | - if (!isset($globalStatsFilters) || $globalStatsFilters == '') $globalStatsFilters = array(); |
|
| 2817 | + if (!isset($globalStatsFilters) || $globalStatsFilters == '') { |
|
| 2818 | + $globalStatsFilters = array(); |
|
| 2819 | + } |
|
| 2452 | 2820 | foreach ($globalStatsFilters as $name => $filter) { |
| 2453 | 2821 | if (!empty($filter)) { |
| 2454 | 2822 | //$filter_name = $filter['name']; |
@@ -2456,7 +2824,9 @@ discard block |
||
| 2456 | 2824 | $reset = false; |
| 2457 | 2825 | $last_update = $this->getLastStatsUpdate('last_update_stats_'.$filter_name); |
| 2458 | 2826 | if (isset($filter['resetall']) && isset($last_update[0]['value']) && strtotime($filter['resetall']) > strtotime($last_update[0]['value'])) { |
| 2459 | - if ($globalDebug) echo '!!! Delete stats for filter '.$filter_name.' !!!'."\n"; |
|
| 2827 | + if ($globalDebug) { |
|
| 2828 | + echo '!!! Delete stats for filter '.$filter_name.' !!!'."\n"; |
|
| 2829 | + } |
|
| 2460 | 2830 | $this->deleteOldStats($filter_name); |
| 2461 | 2831 | unset($last_update); |
| 2462 | 2832 | } |
@@ -2473,39 +2843,55 @@ discard block |
||
| 2473 | 2843 | $reset = true; |
| 2474 | 2844 | } |
| 2475 | 2845 | // Count by filter |
| 2476 | - if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n"; |
|
| 2846 | + if ($globalDebug) { |
|
| 2847 | + echo '--- Stats for filter '.$filter_name.' ---'."\n"; |
|
| 2848 | + } |
|
| 2477 | 2849 | $Spotter = new Spotter($this->db); |
| 2478 | - if ($globalDebug) echo 'Count all aircraft types...'."\n"; |
|
| 2850 | + if ($globalDebug) { |
|
| 2851 | + echo 'Count all aircraft types...'."\n"; |
|
| 2852 | + } |
|
| 2479 | 2853 | $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter); |
| 2480 | 2854 | foreach ($alldata as $number) { |
| 2481 | 2855 | $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'',$filter_name,$reset); |
| 2482 | 2856 | } |
| 2483 | - if ($globalDebug) echo 'Count all airlines...'."\n"; |
|
| 2857 | + if ($globalDebug) { |
|
| 2858 | + echo 'Count all airlines...'."\n"; |
|
| 2859 | + } |
|
| 2484 | 2860 | $alldata = $Spotter->countAllAirlines(false,0,$last_update_day,$filter); |
| 2485 | 2861 | foreach ($alldata as $number) { |
| 2486 | 2862 | $this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],$filter_name,$reset); |
| 2487 | 2863 | } |
| 2488 | - if ($globalDebug) echo 'Count all aircraft registrations...'."\n"; |
|
| 2864 | + if ($globalDebug) { |
|
| 2865 | + echo 'Count all aircraft registrations...'."\n"; |
|
| 2866 | + } |
|
| 2489 | 2867 | $alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day,$filter); |
| 2490 | 2868 | foreach ($alldata as $number) { |
| 2491 | 2869 | $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'',$filter_name,$reset); |
| 2492 | 2870 | } |
| 2493 | - if ($globalDebug) echo 'Count all callsigns...'."\n"; |
|
| 2871 | + if ($globalDebug) { |
|
| 2872 | + echo 'Count all callsigns...'."\n"; |
|
| 2873 | + } |
|
| 2494 | 2874 | $alldata = $Spotter->countAllCallsigns(false,0,$last_update_day,$filter); |
| 2495 | 2875 | foreach ($alldata as $number) { |
| 2496 | 2876 | $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],'',$filter_name,$reset); |
| 2497 | 2877 | } |
| 2498 | - if ($globalDebug) echo 'Count all owners...'."\n"; |
|
| 2878 | + if ($globalDebug) { |
|
| 2879 | + echo 'Count all owners...'."\n"; |
|
| 2880 | + } |
|
| 2499 | 2881 | $alldata = $Spotter->countAllOwners(false,0,$last_update_day,$filter); |
| 2500 | 2882 | foreach ($alldata as $number) { |
| 2501 | 2883 | $this->addStatOwner($number['owner_name'],$number['owner_count'],'',$filter_name,$reset); |
| 2502 | 2884 | } |
| 2503 | - if ($globalDebug) echo 'Count all pilots...'."\n"; |
|
| 2885 | + if ($globalDebug) { |
|
| 2886 | + echo 'Count all pilots...'."\n"; |
|
| 2887 | + } |
|
| 2504 | 2888 | $alldata = $Spotter->countAllPilots(false,0,$last_update_day,$filter); |
| 2505 | 2889 | foreach ($alldata as $number) { |
| 2506 | 2890 | $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'',$filter_name,$number['format_source'],$reset); |
| 2507 | 2891 | } |
| 2508 | - if ($globalDebug) echo 'Count departure airports...'."\n"; |
|
| 2892 | + if ($globalDebug) { |
|
| 2893 | + echo 'Count departure airports...'."\n"; |
|
| 2894 | + } |
|
| 2509 | 2895 | $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter); |
| 2510 | 2896 | $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter); |
| 2511 | 2897 | $alldata = array(); |
@@ -2517,7 +2903,9 @@ discard block |
||
| 2517 | 2903 | $icao = $value['airport_departure_icao']; |
| 2518 | 2904 | if (isset($alldata[$icao])) { |
| 2519 | 2905 | $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
| 2520 | - } else $alldata[$icao] = $value; |
|
| 2906 | + } else { |
|
| 2907 | + $alldata[$icao] = $value; |
|
| 2908 | + } |
|
| 2521 | 2909 | } |
| 2522 | 2910 | $count = array(); |
| 2523 | 2911 | foreach ($alldata as $key => $row) { |
@@ -2527,7 +2915,9 @@ discard block |
||
| 2527 | 2915 | foreach ($alldata as $number) { |
| 2528 | 2916 | echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'',$filter_name,$reset); |
| 2529 | 2917 | } |
| 2530 | - if ($globalDebug) echo 'Count all arrival airports...'."\n"; |
|
| 2918 | + if ($globalDebug) { |
|
| 2919 | + echo 'Count all arrival airports...'."\n"; |
|
| 2920 | + } |
|
| 2531 | 2921 | $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,false,$filter); |
| 2532 | 2922 | $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter); |
| 2533 | 2923 | $alldata = array(); |
@@ -2539,7 +2929,9 @@ discard block |
||
| 2539 | 2929 | $icao = $value['airport_arrival_icao']; |
| 2540 | 2930 | if (isset($alldata[$icao])) { |
| 2541 | 2931 | $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
| 2542 | - } else $alldata[$icao] = $value; |
|
| 2932 | + } else { |
|
| 2933 | + $alldata[$icao] = $value; |
|
| 2934 | + } |
|
| 2543 | 2935 | } |
| 2544 | 2936 | $count = array(); |
| 2545 | 2937 | foreach ($alldata as $key => $row) { |
@@ -2549,35 +2941,49 @@ discard block |
||
| 2549 | 2941 | foreach ($alldata as $number) { |
| 2550 | 2942 | echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'',$filter_name,$reset); |
| 2551 | 2943 | } |
| 2552 | - if ($globalDebug) echo 'Count all months...'."\n"; |
|
| 2944 | + if ($globalDebug) { |
|
| 2945 | + echo 'Count all months...'."\n"; |
|
| 2946 | + } |
|
| 2553 | 2947 | $Spotter = new Spotter($this->db); |
| 2554 | 2948 | $alldata = $Spotter->countAllMonths($filter); |
| 2555 | 2949 | $lastyear = false; |
| 2556 | 2950 | foreach ($alldata as $number) { |
| 2557 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
| 2951 | + if ($number['year_name'] != date('Y')) { |
|
| 2952 | + $lastyear = true; |
|
| 2953 | + } |
|
| 2558 | 2954 | $this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name); |
| 2559 | 2955 | } |
| 2560 | - if ($globalDebug) echo 'Count all owners by months...'."\n"; |
|
| 2956 | + if ($globalDebug) { |
|
| 2957 | + echo 'Count all owners by months...'."\n"; |
|
| 2958 | + } |
|
| 2561 | 2959 | $alldata = $Spotter->countAllMonthsOwners($filter); |
| 2562 | 2960 | foreach ($alldata as $number) { |
| 2563 | 2961 | $this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name); |
| 2564 | 2962 | } |
| 2565 | - if ($globalDebug) echo 'Count all pilots by months...'."\n"; |
|
| 2963 | + if ($globalDebug) { |
|
| 2964 | + echo 'Count all pilots by months...'."\n"; |
|
| 2965 | + } |
|
| 2566 | 2966 | $alldata = $Spotter->countAllMonthsPilots($filter); |
| 2567 | 2967 | foreach ($alldata as $number) { |
| 2568 | 2968 | $this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name); |
| 2569 | 2969 | } |
| 2570 | - if ($globalDebug) echo 'Count all military by months...'."\n"; |
|
| 2970 | + if ($globalDebug) { |
|
| 2971 | + echo 'Count all military by months...'."\n"; |
|
| 2972 | + } |
|
| 2571 | 2973 | $alldata = $Spotter->countAllMilitaryMonths($filter); |
| 2572 | 2974 | foreach ($alldata as $number) { |
| 2573 | 2975 | $this->addStat('military_flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name); |
| 2574 | 2976 | } |
| 2575 | - if ($globalDebug) echo 'Count all aircrafts by months...'."\n"; |
|
| 2977 | + if ($globalDebug) { |
|
| 2978 | + echo 'Count all aircrafts by months...'."\n"; |
|
| 2979 | + } |
|
| 2576 | 2980 | $alldata = $Spotter->countAllMonthsAircrafts($filter); |
| 2577 | 2981 | foreach ($alldata as $number) { |
| 2578 | 2982 | $this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name); |
| 2579 | 2983 | } |
| 2580 | - if ($globalDebug) echo 'Count all real arrivals by months...'."\n"; |
|
| 2984 | + if ($globalDebug) { |
|
| 2985 | + echo 'Count all real arrivals by months...'."\n"; |
|
| 2986 | + } |
|
| 2581 | 2987 | $alldata = $Spotter->countAllMonthsRealArrivals($filter); |
| 2582 | 2988 | foreach ($alldata as $number) { |
| 2583 | 2989 | $this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name); |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | try { |
| 17 | 17 | $sth = $this->db->prepare($query); |
| 18 | 18 | $sth->execute($query_values); |
| 19 | - } catch(PDOException $e) { |
|
| 19 | + } catch (PDOException $e) { |
|
| 20 | 20 | return "error : ".$e->getMessage(); |
| 21 | 21 | } |
| 22 | 22 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -29,20 +29,20 @@ discard block |
||
| 29 | 29 | try { |
| 30 | 30 | $sth = $this->db->prepare($query); |
| 31 | 31 | $sth->execute($query_values); |
| 32 | - } catch(PDOException $e) { |
|
| 32 | + } catch (PDOException $e) { |
|
| 33 | 33 | return "error : ".$e->getMessage(); |
| 34 | 34 | } |
| 35 | 35 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 36 | 36 | return $all; |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - public function getLocationInfobyNameType($name,$type) { |
|
| 39 | + public function getLocationInfobyNameType($name, $type) { |
|
| 40 | 40 | $query = "SELECT * FROM source_location WHERE name = :name AND type = :type"; |
| 41 | - $query_values = array(':name' => $name,':type' => $type); |
|
| 41 | + $query_values = array(':name' => $name, ':type' => $type); |
|
| 42 | 42 | try { |
| 43 | 43 | $sth = $this->db->prepare($query); |
| 44 | 44 | $sth->execute($query_values); |
| 45 | - } catch(PDOException $e) { |
|
| 45 | + } catch (PDOException $e) { |
|
| 46 | 46 | return "error : ".$e->getMessage(); |
| 47 | 47 | } |
| 48 | 48 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | try { |
| 56 | 56 | $sth = $this->db->prepare($query); |
| 57 | 57 | $sth->execute($query_values); |
| 58 | - } catch(PDOException $e) { |
|
| 58 | + } catch (PDOException $e) { |
|
| 59 | 59 | return "error : ".$e->getMessage(); |
| 60 | 60 | } |
| 61 | 61 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -65,10 +65,10 @@ discard block |
||
| 65 | 65 | public function getLocationInfoByType($type, $coord = array(), $limit = false) { |
| 66 | 66 | $query = "SELECT * FROM source_location WHERE type = :type"; |
| 67 | 67 | if (is_array($coord) && !empty($coord)) { |
| 68 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 69 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 70 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 71 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 68 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 69 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 70 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 71 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 72 | 72 | $query .= " AND source_location.latitude BETWEEN ".$minlat." AND ".$maxlat." AND source_location.longitude BETWEEN ".$minlong." AND ".$maxlong." AND source_location.latitude <> 0 AND source_location.longitude <> 0"; |
| 73 | 73 | } |
| 74 | 74 | $query .= " ORDER BY last_seen DESC"; |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | try { |
| 78 | 78 | $sth = $this->db->prepare($query); |
| 79 | 79 | $sth->execute($query_values); |
| 80 | - } catch(PDOException $e) { |
|
| 80 | + } catch (PDOException $e) { |
|
| 81 | 81 | return "error : ".$e->getMessage(); |
| 82 | 82 | } |
| 83 | 83 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | try { |
| 91 | 91 | $sth = $this->db->prepare($query); |
| 92 | 92 | $sth->execute($query_values); |
| 93 | - } catch(PDOException $e) { |
|
| 93 | + } catch (PDOException $e) { |
|
| 94 | 94 | return "error : ".$e->getMessage(); |
| 95 | 95 | } |
| 96 | 96 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -103,56 +103,56 @@ discard block |
||
| 103 | 103 | try { |
| 104 | 104 | $sth = $this->db->prepare($query); |
| 105 | 105 | $sth->execute($query_values); |
| 106 | - } catch(PDOException $e) { |
|
| 106 | + } catch (PDOException $e) { |
|
| 107 | 107 | return "error : ".$e->getMessage(); |
| 108 | 108 | } |
| 109 | 109 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 110 | 110 | return $all; |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - public function addLocation($name,$latitude,$longitude,$altitude,$city,$country,$source,$logo = 'antenna.png',$type = '',$source_id = 0,$location_id = 0,$last_seen = '', $description = '') { |
|
| 113 | + public function addLocation($name, $latitude, $longitude, $altitude, $city, $country, $source, $logo = 'antenna.png', $type = '', $source_id = 0, $location_id = 0, $last_seen = '', $description = '') { |
|
| 114 | 114 | if ($last_seen == '') $last_seen = date('Y-m-d H:i:s'); |
| 115 | 115 | $query = "INSERT INTO source_location (name,latitude,longitude,altitude,country,city,logo,source,type,source_id,last_seen,location_id,description) VALUES (:name,:latitude,:longitude,:altitude,:country,:city,:logo,:source,:type,:source_id,:last_seen,:location_id,:description)"; |
| 116 | - $query_values = array(':name' => $name,':latitude' => $latitude, ':longitude' => $longitude,':altitude' => $altitude,':city' => $city,':country' => $country,':logo' => $logo,':source' => $source,':type' => $type,':source_id' => $source_id,':last_seen' => $last_seen,':location_id' => $location_id,':description' => $description); |
|
| 116 | + $query_values = array(':name' => $name, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':city' => $city, ':country' => $country, ':logo' => $logo, ':source' => $source, ':type' => $type, ':source_id' => $source_id, ':last_seen' => $last_seen, ':location_id' => $location_id, ':description' => $description); |
|
| 117 | 117 | try { |
| 118 | 118 | $sth = $this->db->prepare($query); |
| 119 | 119 | $sth->execute($query_values); |
| 120 | - } catch(PDOException $e) { |
|
| 120 | + } catch (PDOException $e) { |
|
| 121 | 121 | echo "error : ".$e->getMessage(); |
| 122 | 122 | } |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | - public function updateLocation($name,$latitude,$longitude,$altitude,$city,$country,$source,$logo = 'antenna.png',$type = '',$source_id = 0,$location_id = 0,$last_seen = '',$description = '') { |
|
| 125 | + public function updateLocation($name, $latitude, $longitude, $altitude, $city, $country, $source, $logo = 'antenna.png', $type = '', $source_id = 0, $location_id = 0, $last_seen = '', $description = '') { |
|
| 126 | 126 | if ($last_seen == '') $last_seen = date('Y-m-d H:i:s'); |
| 127 | 127 | $query = "UPDATE source_location SET latitude = :latitude,longitude = :longitude,altitude = :altitude,country = :country,city = :city,logo = :logo,type = :type, source_id = :source_id, last_seen = :last_seen,location_id = :location_id, description = :description WHERE name = :name AND source = :source"; |
| 128 | - $query_values = array(':name' => $name,':latitude' => $latitude, ':longitude' => $longitude,':altitude' => $altitude,':city' => $city,':country' => $country,':logo' => $logo,':source' => $source,':type' => $type,':source_id' => $source_id,':last_seen' => $last_seen,':location_id' => $location_id,':description' => $description); |
|
| 128 | + $query_values = array(':name' => $name, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':city' => $city, ':country' => $country, ':logo' => $logo, ':source' => $source, ':type' => $type, ':source_id' => $source_id, ':last_seen' => $last_seen, ':location_id' => $location_id, ':description' => $description); |
|
| 129 | 129 | try { |
| 130 | 130 | $sth = $this->db->prepare($query); |
| 131 | 131 | $sth->execute($query_values); |
| 132 | - } catch(PDOException $e) { |
|
| 132 | + } catch (PDOException $e) { |
|
| 133 | 133 | return "error : ".$e->getMessage(); |
| 134 | 134 | } |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | - public function updateLocationDescByName($name,$source,$source_id = 0,$description = '') { |
|
| 137 | + public function updateLocationDescByName($name, $source, $source_id = 0, $description = '') { |
|
| 138 | 138 | $query = "UPDATE source_location SET description = :description WHERE source_id = :source_id AND name = :name AND source = :source"; |
| 139 | - $query_values = array(':name' => $name,':source' => $source,':source_id' => $source_id,':description' => $description); |
|
| 139 | + $query_values = array(':name' => $name, ':source' => $source, ':source_id' => $source_id, ':description' => $description); |
|
| 140 | 140 | try { |
| 141 | 141 | $sth = $this->db->prepare($query); |
| 142 | 142 | $sth->execute($query_values); |
| 143 | - } catch(PDOException $e) { |
|
| 143 | + } catch (PDOException $e) { |
|
| 144 | 144 | return "error : ".$e->getMessage(); |
| 145 | 145 | } |
| 146 | 146 | } |
| 147 | 147 | |
| 148 | - public function updateLocationByLocationID($name,$latitude,$longitude,$altitude,$city,$country,$source,$logo = 'antenna.png',$type = '',$source_id = 0, $location_id,$last_seen = '',$description = '') { |
|
| 148 | + public function updateLocationByLocationID($name, $latitude, $longitude, $altitude, $city, $country, $source, $logo = 'antenna.png', $type = '', $source_id = 0, $location_id, $last_seen = '', $description = '') { |
|
| 149 | 149 | if ($last_seen == '') $last_seen = date('Y-m-d H:i:s'); |
| 150 | 150 | $query = "UPDATE source_location SET latitude = :latitude,longitude = :longitude,altitude = :altitude,country = :country,city = :city,logo = :logo,type = :type, last_seen = :last_seen, description = :description WHERE location_id = :location_id AND source = :source AND source_id = :source_id"; |
| 151 | - $query_values = array(':source_id' => $source_id,':latitude' => $latitude, ':longitude' => $longitude,':altitude' => $altitude,':city' => $city,':country' => $country,':logo' => $logo,':source' => $source,':type' => $type,':last_seen' => $last_seen,':location_id' => $location_id,':description' => $description); |
|
| 151 | + $query_values = array(':source_id' => $source_id, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':city' => $city, ':country' => $country, ':logo' => $logo, ':source' => $source, ':type' => $type, ':last_seen' => $last_seen, ':location_id' => $location_id, ':description' => $description); |
|
| 152 | 152 | try { |
| 153 | 153 | $sth = $this->db->prepare($query); |
| 154 | 154 | $sth->execute($query_values); |
| 155 | - } catch(PDOException $e) { |
|
| 155 | + } catch (PDOException $e) { |
|
| 156 | 156 | echo "error : ".$e->getMessage(); |
| 157 | 157 | } |
| 158 | 158 | } |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | try { |
| 164 | 164 | $sth = $this->db->prepare($query); |
| 165 | 165 | $sth->execute($query_values); |
| 166 | - } catch(PDOException $e) { |
|
| 166 | + } catch (PDOException $e) { |
|
| 167 | 167 | return "error : ".$e->getMessage(); |
| 168 | 168 | } |
| 169 | 169 | } |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | try { |
| 175 | 175 | $sth = $this->db->prepare($query); |
| 176 | 176 | $sth->execute($query_values); |
| 177 | - } catch(PDOException $e) { |
|
| 177 | + } catch (PDOException $e) { |
|
| 178 | 178 | return "error : ".$e->getMessage(); |
| 179 | 179 | } |
| 180 | 180 | } |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | try { |
| 186 | 186 | $sth = $this->db->prepare($query); |
| 187 | 187 | $sth->execute($query_values); |
| 188 | - } catch(PDOException $e) { |
|
| 188 | + } catch (PDOException $e) { |
|
| 189 | 189 | return "error : ".$e->getMessage(); |
| 190 | 190 | } |
| 191 | 191 | } |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | try { |
| 196 | 196 | $sth = $this->db->prepare($query); |
| 197 | 197 | $sth->execute(); |
| 198 | - } catch(PDOException $e) { |
|
| 198 | + } catch (PDOException $e) { |
|
| 199 | 199 | return "error : ".$e->getMessage(); |
| 200 | 200 | } |
| 201 | 201 | } |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | try { |
| 225 | 225 | $sth = $this->db->prepare($query); |
| 226 | 226 | $sth->execute(array(':type' => $type)); |
| 227 | - } catch(PDOException $e) { |
|
| 227 | + } catch (PDOException $e) { |
|
| 228 | 228 | return "error"; |
| 229 | 229 | } |
| 230 | 230 | return "success"; |
@@ -7,7 +7,9 @@ discard block |
||
| 7 | 7 | public function __construct($dbc = null) { |
| 8 | 8 | $Connection = new Connection($dbc); |
| 9 | 9 | $this->db = $Connection->db; |
| 10 | - if ($this->db === null) die('Error: No DB connection.'); |
|
| 10 | + if ($this->db === null) { |
|
| 11 | + die('Error: No DB connection.'); |
|
| 12 | + } |
|
| 11 | 13 | } |
| 12 | 14 | |
| 13 | 15 | public function getAllLocationInfo() { |
@@ -72,7 +74,9 @@ discard block |
||
| 72 | 74 | $query .= " AND source_location.latitude BETWEEN ".$minlat." AND ".$maxlat." AND source_location.longitude BETWEEN ".$minlong." AND ".$maxlong." AND source_location.latitude <> 0 AND source_location.longitude <> 0"; |
| 73 | 75 | } |
| 74 | 76 | $query .= " ORDER BY last_seen DESC"; |
| 75 | - if ($limit) $query .= " LIMIT 200"; |
|
| 77 | + if ($limit) { |
|
| 78 | + $query .= " LIMIT 200"; |
|
| 79 | + } |
|
| 76 | 80 | $query_values = array(':type' => $type); |
| 77 | 81 | try { |
| 78 | 82 | $sth = $this->db->prepare($query); |
@@ -111,7 +115,9 @@ discard block |
||
| 111 | 115 | } |
| 112 | 116 | |
| 113 | 117 | public function addLocation($name,$latitude,$longitude,$altitude,$city,$country,$source,$logo = 'antenna.png',$type = '',$source_id = 0,$location_id = 0,$last_seen = '', $description = '') { |
| 114 | - if ($last_seen == '') $last_seen = date('Y-m-d H:i:s'); |
|
| 118 | + if ($last_seen == '') { |
|
| 119 | + $last_seen = date('Y-m-d H:i:s'); |
|
| 120 | + } |
|
| 115 | 121 | $query = "INSERT INTO source_location (name,latitude,longitude,altitude,country,city,logo,source,type,source_id,last_seen,location_id,description) VALUES (:name,:latitude,:longitude,:altitude,:country,:city,:logo,:source,:type,:source_id,:last_seen,:location_id,:description)"; |
| 116 | 122 | $query_values = array(':name' => $name,':latitude' => $latitude, ':longitude' => $longitude,':altitude' => $altitude,':city' => $city,':country' => $country,':logo' => $logo,':source' => $source,':type' => $type,':source_id' => $source_id,':last_seen' => $last_seen,':location_id' => $location_id,':description' => $description); |
| 117 | 123 | try { |
@@ -123,7 +129,9 @@ discard block |
||
| 123 | 129 | } |
| 124 | 130 | |
| 125 | 131 | public function updateLocation($name,$latitude,$longitude,$altitude,$city,$country,$source,$logo = 'antenna.png',$type = '',$source_id = 0,$location_id = 0,$last_seen = '',$description = '') { |
| 126 | - if ($last_seen == '') $last_seen = date('Y-m-d H:i:s'); |
|
| 132 | + if ($last_seen == '') { |
|
| 133 | + $last_seen = date('Y-m-d H:i:s'); |
|
| 134 | + } |
|
| 127 | 135 | $query = "UPDATE source_location SET latitude = :latitude,longitude = :longitude,altitude = :altitude,country = :country,city = :city,logo = :logo,type = :type, source_id = :source_id, last_seen = :last_seen,location_id = :location_id, description = :description WHERE name = :name AND source = :source"; |
| 128 | 136 | $query_values = array(':name' => $name,':latitude' => $latitude, ':longitude' => $longitude,':altitude' => $altitude,':city' => $city,':country' => $country,':logo' => $logo,':source' => $source,':type' => $type,':source_id' => $source_id,':last_seen' => $last_seen,':location_id' => $location_id,':description' => $description); |
| 129 | 137 | try { |
@@ -146,7 +154,9 @@ discard block |
||
| 146 | 154 | } |
| 147 | 155 | |
| 148 | 156 | public function updateLocationByLocationID($name,$latitude,$longitude,$altitude,$city,$country,$source,$logo = 'antenna.png',$type = '',$source_id = 0, $location_id,$last_seen = '',$description = '') { |
| 149 | - if ($last_seen == '') $last_seen = date('Y-m-d H:i:s'); |
|
| 157 | + if ($last_seen == '') { |
|
| 158 | + $last_seen = date('Y-m-d H:i:s'); |
|
| 159 | + } |
|
| 150 | 160 | $query = "UPDATE source_location SET latitude = :latitude,longitude = :longitude,altitude = :altitude,country = :country,city = :city,logo = :logo,type = :type, last_seen = :last_seen, description = :description WHERE location_id = :location_id AND source = :source AND source_id = :source_id"; |
| 151 | 161 | $query_values = array(':source_id' => $source_id,':latitude' => $latitude, ':longitude' => $longitude,':altitude' => $altitude,':city' => $city,':country' => $country,':logo' => $logo,':source' => $source,':type' => $type,':last_seen' => $last_seen,':location_id' => $location_id,':description' => $description); |
| 152 | 162 | try { |
@@ -14,36 +14,36 @@ |
||
| 14 | 14 | { |
| 15 | 15 | $coords = explode(',',$_GET['coord']); |
| 16 | 16 | if ((isset($_COOKIE['show_GroundStation']) && $_COOKIE['show_GroundStation'] == 'true') |
| 17 | - || (!isset($_COOKIE['show_GroundStation']) && (!isset($globalMapGroundStation) || $globalMapGroundStation === TRUE))) { |
|
| 17 | + || (!isset($_COOKIE['show_GroundStation']) && (!isset($globalMapGroundStation) || $globalMapGroundStation === TRUE))) { |
|
| 18 | 18 | //$spotter_array = $Source->getAllLocationInfo(); |
| 19 | 19 | $spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('gs',$coords)); |
| 20 | 20 | } |
| 21 | 21 | if ((isset($_COOKIE['show_WeatherStation']) && $_COOKIE['show_WeatherStation'] == 'true') |
| 22 | - || (!isset($_COOKIE['show_WeatherStation']) && (!isset($globalMapWeatherStation) || $globalMapWeatherStation === TRUE))) { |
|
| 22 | + || (!isset($_COOKIE['show_WeatherStation']) && (!isset($globalMapWeatherStation) || $globalMapWeatherStation === TRUE))) { |
|
| 23 | 23 | $spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('wx',$coords)); |
| 24 | 24 | } |
| 25 | 25 | if ((isset($_COOKIE['show_Lightning']) && $_COOKIE['show_Lightning'] == 'true') |
| 26 | - || (!isset($_COOKIE['show_Lightning']) && (!isset($globalMapLightning) || $globalMapLightning === TRUE))) { |
|
| 26 | + || (!isset($_COOKIE['show_Lightning']) && (!isset($globalMapLightning) || $globalMapLightning === TRUE))) { |
|
| 27 | 27 | $spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('lightning',$coords)); |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | if ((isset($_COOKIE['show_Fire']) && $_COOKIE['show_Fire'] == 'true') |
| 31 | - || (!isset($_COOKIE['show_Fire']) && (!isset($globalMapFire) || $globalMapFire === TRUE))) { |
|
| 31 | + || (!isset($_COOKIE['show_Fire']) && (!isset($globalMapFire) || $globalMapFire === TRUE))) { |
|
| 32 | 32 | $spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('fires',$coords,true)); |
| 33 | 33 | } |
| 34 | 34 | $spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('')); |
| 35 | 35 | } else { |
| 36 | 36 | if ((isset($_COOKIE['show_GroundStation']) && $_COOKIE['show_GroundStation'] == 'true') |
| 37 | - || (!isset($_COOKIE['show_GroundStation']) && (!isset($globalMapGroundStation) || $globalMapGroundStation === TRUE))) { |
|
| 37 | + || (!isset($_COOKIE['show_GroundStation']) && (!isset($globalMapGroundStation) || $globalMapGroundStation === TRUE))) { |
|
| 38 | 38 | //$spotter_array = $Source->getAllLocationInfo(); |
| 39 | 39 | $spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('gs')); |
| 40 | 40 | } |
| 41 | 41 | if ((isset($_COOKIE['show_WeatherStation']) && $_COOKIE['show_WeatherStation'] == 'true') |
| 42 | - || (!isset($_COOKIE['show_WeatherStation']) && (!isset($globalMapWeatherStation) || $globalMapWeatherStation === TRUE))) { |
|
| 42 | + || (!isset($_COOKIE['show_WeatherStation']) && (!isset($globalMapWeatherStation) || $globalMapWeatherStation === TRUE))) { |
|
| 43 | 43 | $spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('wx')); |
| 44 | 44 | } |
| 45 | 45 | if ((isset($_COOKIE['show_Lightning']) && $_COOKIE['show_Lightning'] == 'true') |
| 46 | - || (!isset($_COOKIE['show_Lightning']) && (!isset($globalMapLightning) || $globalMapLightning === TRUE))) { |
|
| 46 | + || (!isset($_COOKIE['show_Lightning']) && (!isset($globalMapLightning) || $globalMapLightning === TRUE))) { |
|
| 47 | 47 | $spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('lightning')); |
| 48 | 48 | } |
| 49 | 49 | /* |
@@ -12,39 +12,39 @@ discard block |
||
| 12 | 12 | if (!isset($globalDemo)) { |
| 13 | 13 | if (isset($_GET['coord'])) |
| 14 | 14 | { |
| 15 | - $coords = explode(',',$_GET['coord']); |
|
| 15 | + $coords = explode(',', $_GET['coord']); |
|
| 16 | 16 | if ((isset($_COOKIE['show_GroundStation']) && $_COOKIE['show_GroundStation'] == 'true') |
| 17 | 17 | || (!isset($_COOKIE['show_GroundStation']) && (!isset($globalMapGroundStation) || $globalMapGroundStation === TRUE))) { |
| 18 | 18 | //$spotter_array = $Source->getAllLocationInfo(); |
| 19 | - $spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('gs',$coords)); |
|
| 19 | + $spotter_array = array_merge($spotter_array, $Source->getLocationInfoByType('gs', $coords)); |
|
| 20 | 20 | } |
| 21 | 21 | if ((isset($_COOKIE['show_WeatherStation']) && $_COOKIE['show_WeatherStation'] == 'true') |
| 22 | 22 | || (!isset($_COOKIE['show_WeatherStation']) && (!isset($globalMapWeatherStation) || $globalMapWeatherStation === TRUE))) { |
| 23 | - $spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('wx',$coords)); |
|
| 23 | + $spotter_array = array_merge($spotter_array, $Source->getLocationInfoByType('wx', $coords)); |
|
| 24 | 24 | } |
| 25 | 25 | if ((isset($_COOKIE['show_Lightning']) && $_COOKIE['show_Lightning'] == 'true') |
| 26 | 26 | || (!isset($_COOKIE['show_Lightning']) && (!isset($globalMapLightning) || $globalMapLightning === TRUE))) { |
| 27 | - $spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('lightning',$coords)); |
|
| 27 | + $spotter_array = array_merge($spotter_array, $Source->getLocationInfoByType('lightning', $coords)); |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | if ((isset($_COOKIE['show_Fire']) && $_COOKIE['show_Fire'] == 'true') |
| 31 | 31 | || (!isset($_COOKIE['show_Fire']) && (!isset($globalMapFire) || $globalMapFire === TRUE))) { |
| 32 | - $spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('fires',$coords,true)); |
|
| 32 | + $spotter_array = array_merge($spotter_array, $Source->getLocationInfoByType('fires', $coords, true)); |
|
| 33 | 33 | } |
| 34 | - $spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('')); |
|
| 34 | + $spotter_array = array_merge($spotter_array, $Source->getLocationInfoByType('')); |
|
| 35 | 35 | } else { |
| 36 | 36 | if ((isset($_COOKIE['show_GroundStation']) && $_COOKIE['show_GroundStation'] == 'true') |
| 37 | 37 | || (!isset($_COOKIE['show_GroundStation']) && (!isset($globalMapGroundStation) || $globalMapGroundStation === TRUE))) { |
| 38 | 38 | //$spotter_array = $Source->getAllLocationInfo(); |
| 39 | - $spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('gs')); |
|
| 39 | + $spotter_array = array_merge($spotter_array, $Source->getLocationInfoByType('gs')); |
|
| 40 | 40 | } |
| 41 | 41 | if ((isset($_COOKIE['show_WeatherStation']) && $_COOKIE['show_WeatherStation'] == 'true') |
| 42 | 42 | || (!isset($_COOKIE['show_WeatherStation']) && (!isset($globalMapWeatherStation) || $globalMapWeatherStation === TRUE))) { |
| 43 | - $spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('wx')); |
|
| 43 | + $spotter_array = array_merge($spotter_array, $Source->getLocationInfoByType('wx')); |
|
| 44 | 44 | } |
| 45 | 45 | if ((isset($_COOKIE['show_Lightning']) && $_COOKIE['show_Lightning'] == 'true') |
| 46 | 46 | || (!isset($_COOKIE['show_Lightning']) && (!isset($globalMapLightning) || $globalMapLightning === TRUE))) { |
| 47 | - $spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('lightning')); |
|
| 47 | + $spotter_array = array_merge($spotter_array, $Source->getLocationInfoByType('lightning')); |
|
| 48 | 48 | } |
| 49 | 49 | /* |
| 50 | 50 | if ((isset($_COOKIE['show_Fire']) && $_COOKIE['show_Fire'] == 'true') |
@@ -52,14 +52,14 @@ discard block |
||
| 52 | 52 | $spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('fires',array(),true)); |
| 53 | 53 | } |
| 54 | 54 | */ |
| 55 | - $spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('')); |
|
| 55 | + $spotter_array = array_merge($spotter_array, $Source->getLocationInfoByType('')); |
|
| 56 | 56 | } |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | $output = '{"type": "FeatureCollection","features": ['; |
| 60 | 60 | if (!empty($spotter_array) && count($spotter_array) > 0) |
| 61 | 61 | { |
| 62 | - foreach($spotter_array as $spotter_item) |
|
| 62 | + foreach ($spotter_array as $spotter_item) |
|
| 63 | 63 | { |
| 64 | 64 | date_default_timezone_set('UTC'); |
| 65 | 65 | $output .= '{"type": "Feature",'; |
@@ -78,8 +78,8 @@ discard block |
||
| 78 | 78 | $output .= '"icon": "'.$globalURL.'/images/'.$spotter_item['logo'].'",'; |
| 79 | 79 | $output .= '"type": "'.$spotter_item['type'].'",'; |
| 80 | 80 | if ($spotter_item['type'] == 'wx') { |
| 81 | - $weather = json_decode($spotter_item['description'],true); |
|
| 82 | - if (isset($weather['temp'])) $output.= '"temp": "'.$weather['temp'].'",'; |
|
| 81 | + $weather = json_decode($spotter_item['description'], true); |
|
| 82 | + if (isset($weather['temp'])) $output .= '"temp": "'.$weather['temp'].'",'; |
|
| 83 | 83 | } |
| 84 | 84 | $output .= '"image_thumb": "'.$spotter_item['image_thumb'].'"'; |
| 85 | 85 | $output .= '},'; |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | $output .= '}'; |
| 90 | 90 | $output .= '},'; |
| 91 | 91 | } |
| 92 | - $output = substr($output, 0, -1); |
|
| 92 | + $output = substr($output, 0, -1); |
|
| 93 | 93 | } |
| 94 | 94 | $output .= ']}'; |
| 95 | 95 | print $output; |
@@ -79,7 +79,9 @@ |
||
| 79 | 79 | $output .= '"type": "'.$spotter_item['type'].'",'; |
| 80 | 80 | if ($spotter_item['type'] == 'wx') { |
| 81 | 81 | $weather = json_decode($spotter_item['description'],true); |
| 82 | - if (isset($weather['temp'])) $output.= '"temp": "'.$weather['temp'].'",'; |
|
| 82 | + if (isset($weather['temp'])) { |
|
| 83 | + $output.= '"temp": "'.$weather['temp'].'",'; |
|
| 84 | + } |
|
| 83 | 85 | } |
| 84 | 86 | $output .= '"image_thumb": "'.$spotter_item['image_thumb'].'"'; |
| 85 | 87 | $output .= '},'; |