@@ -12,10 +12,10 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | |
| 14 | 14 | /** |
| 15 | - * Get SQL query part for filter used |
|
| 16 | - * @param Array $filter the filter |
|
| 17 | - * @return Array the SQL part |
|
| 18 | - */ |
|
| 15 | + * Get SQL query part for filter used |
|
| 16 | + * @param Array $filter the filter |
|
| 17 | + * @return Array the SQL part |
|
| 18 | + */ |
|
| 19 | 19 | public function getFilter($filter = array(),$where = false,$and = false) { |
| 20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName; |
| 21 | 21 | $filters = array(); |
@@ -83,11 +83,11 @@ discard block |
||
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | /** |
| 86 | - * Gets all the spotter information based on the latest data entry |
|
| 87 | - * |
|
| 88 | - * @return Array the spotter information |
|
| 89 | - * |
|
| 90 | - */ |
|
| 86 | + * Gets all the spotter information based on the latest data entry |
|
| 87 | + * |
|
| 88 | + * @return Array the spotter information |
|
| 89 | + * |
|
| 90 | + */ |
|
| 91 | 91 | public function getLiveSpotterData($limit = '', $sort = '', $filter = array()) |
| 92 | 92 | { |
| 93 | 93 | global $globalDBdriver, $globalLiveInterval; |
@@ -126,11 +126,11 @@ discard block |
||
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | /** |
| 129 | - * Gets Minimal Live Spotter data |
|
| 130 | - * |
|
| 131 | - * @return Array the spotter information |
|
| 132 | - * |
|
| 133 | - */ |
|
| 129 | + * Gets Minimal Live Spotter data |
|
| 130 | + * |
|
| 131 | + * @return Array the spotter information |
|
| 132 | + * |
|
| 133 | + */ |
|
| 134 | 134 | public function getMinLiveSpotterData($filter = array()) |
| 135 | 135 | { |
| 136 | 136 | global $globalDBdriver, $globalLiveInterval; |
@@ -181,11 +181,11 @@ discard block |
||
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | /** |
| 184 | - * Gets Minimal Live Spotter data since xx seconds |
|
| 185 | - * |
|
| 186 | - * @return Array the spotter information |
|
| 187 | - * |
|
| 188 | - */ |
|
| 184 | + * Gets Minimal Live Spotter data since xx seconds |
|
| 185 | + * |
|
| 186 | + * @return Array the spotter information |
|
| 187 | + * |
|
| 188 | + */ |
|
| 189 | 189 | public function getMinLastLiveSpotterData($filter = array()) |
| 190 | 190 | { |
| 191 | 191 | global $globalDBdriver, $globalLiveInterval; |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | $query = 'SELECT a.aircraft_shadow, a.engine_type, a.engine_count, a.wake_category, spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
| 200 | 200 | FROM spotter_live LEFT JOIN (SELECT aircraft_shadow,engine_type, engine_count, wake_category,icao FROM aircraft) a ON spotter_live.aircraft_icao = a.icao'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
| 201 | 201 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
| 202 | - } else { |
|
| 202 | + } else { |
|
| 203 | 203 | /* |
| 204 | 204 | $query = "SELECT a.aircraft_shadow, spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
| 205 | 205 | FROM spotter_live WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | // echo $query; |
| 212 | 212 | } |
| 213 | 213 | |
| 214 | - try { |
|
| 214 | + try { |
|
| 215 | 215 | $sth = $this->db->prepare($query); |
| 216 | 216 | $sth->execute(); |
| 217 | 217 | } catch(PDOException $e) { |
@@ -223,11 +223,11 @@ discard block |
||
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | /** |
| 226 | - * Gets number of latest data entry |
|
| 227 | - * |
|
| 228 | - * @return String number of entry |
|
| 229 | - * |
|
| 230 | - */ |
|
| 226 | + * Gets number of latest data entry |
|
| 227 | + * |
|
| 228 | + * @return String number of entry |
|
| 229 | + * |
|
| 230 | + */ |
|
| 231 | 231 | public function getLiveSpotterCount($filter = array()) |
| 232 | 232 | { |
| 233 | 233 | global $globalDBdriver, $globalLiveInterval; |
@@ -254,11 +254,11 @@ discard block |
||
| 254 | 254 | } |
| 255 | 255 | |
| 256 | 256 | /** |
| 257 | - * Gets all the spotter information based on the latest data entry and coord |
|
| 258 | - * |
|
| 259 | - * @return Array the spotter information |
|
| 260 | - * |
|
| 261 | - */ |
|
| 257 | + * Gets all the spotter information based on the latest data entry and coord |
|
| 258 | + * |
|
| 259 | + * @return Array the spotter information |
|
| 260 | + * |
|
| 261 | + */ |
|
| 262 | 262 | public function getLiveSpotterDatabyCoord($coord, $filter = array()) |
| 263 | 263 | { |
| 264 | 264 | global $globalDBdriver, $globalLiveInterval; |
@@ -283,11 +283,11 @@ discard block |
||
| 283 | 283 | } |
| 284 | 284 | |
| 285 | 285 | /** |
| 286 | - * Gets all the spotter information based on a user's latitude and longitude |
|
| 287 | - * |
|
| 288 | - * @return Array the spotter information |
|
| 289 | - * |
|
| 290 | - */ |
|
| 286 | + * Gets all the spotter information based on a user's latitude and longitude |
|
| 287 | + * |
|
| 288 | + * @return Array the spotter information |
|
| 289 | + * |
|
| 290 | + */ |
|
| 291 | 291 | public function getLatestSpotterForLayar($lat, $lng, $radius, $interval) |
| 292 | 292 | { |
| 293 | 293 | $Spotter = new Spotter($this->db); |
@@ -297,145 +297,145 @@ discard block |
||
| 297 | 297 | return false; |
| 298 | 298 | } |
| 299 | 299 | } |
| 300 | - if ($lng != '') |
|
| 301 | - { |
|
| 302 | - if (!is_numeric($lng)) |
|
| 303 | - { |
|
| 304 | - return false; |
|
| 305 | - } |
|
| 306 | - } |
|
| 307 | - |
|
| 308 | - if ($radius != '') |
|
| 309 | - { |
|
| 310 | - if (!is_numeric($radius)) |
|
| 311 | - { |
|
| 312 | - return false; |
|
| 313 | - } |
|
| 314 | - } |
|
| 300 | + if ($lng != '') |
|
| 301 | + { |
|
| 302 | + if (!is_numeric($lng)) |
|
| 303 | + { |
|
| 304 | + return false; |
|
| 305 | + } |
|
| 306 | + } |
|
| 307 | + |
|
| 308 | + if ($radius != '') |
|
| 309 | + { |
|
| 310 | + if (!is_numeric($radius)) |
|
| 311 | + { |
|
| 312 | + return false; |
|
| 313 | + } |
|
| 314 | + } |
|
| 315 | 315 | $additional_query = ''; |
| 316 | - if ($interval != '') |
|
| 317 | - { |
|
| 318 | - if (!is_string($interval)) |
|
| 319 | - { |
|
| 320 | - //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
| 321 | - return false; |
|
| 322 | - } else { |
|
| 323 | - if ($interval == '1m') |
|
| 324 | - { |
|
| 325 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
| 326 | - } else if ($interval == '15m'){ |
|
| 327 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date '; |
|
| 328 | - } |
|
| 329 | - } |
|
| 330 | - } else { |
|
| 331 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
| 332 | - } |
|
| 333 | - |
|
| 334 | - $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live |
|
| 316 | + if ($interval != '') |
|
| 317 | + { |
|
| 318 | + if (!is_string($interval)) |
|
| 319 | + { |
|
| 320 | + //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
| 321 | + return false; |
|
| 322 | + } else { |
|
| 323 | + if ($interval == '1m') |
|
| 324 | + { |
|
| 325 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
| 326 | + } else if ($interval == '15m'){ |
|
| 327 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date '; |
|
| 328 | + } |
|
| 329 | + } |
|
| 330 | + } else { |
|
| 331 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
| 332 | + } |
|
| 333 | + |
|
| 334 | + $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live |
|
| 335 | 335 | WHERE spotter_live.latitude <> '' |
| 336 | 336 | AND spotter_live.longitude <> '' |
| 337 | 337 | ".$additional_query." |
| 338 | 338 | HAVING distance < :radius |
| 339 | 339 | ORDER BY distance"; |
| 340 | 340 | |
| 341 | - $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
| 341 | + $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
| 342 | 342 | |
| 343 | - return $spotter_array; |
|
| 344 | - } |
|
| 343 | + return $spotter_array; |
|
| 344 | + } |
|
| 345 | 345 | |
| 346 | 346 | |
| 347 | - /** |
|
| 348 | - * Gets all the spotter information based on a particular callsign |
|
| 349 | - * |
|
| 350 | - * @return Array the spotter information |
|
| 351 | - * |
|
| 352 | - */ |
|
| 347 | + /** |
|
| 348 | + * Gets all the spotter information based on a particular callsign |
|
| 349 | + * |
|
| 350 | + * @return Array the spotter information |
|
| 351 | + * |
|
| 352 | + */ |
|
| 353 | 353 | public function getLastLiveSpotterDataByIdent($ident) |
| 354 | 354 | { |
| 355 | 355 | $Spotter = new Spotter($this->db); |
| 356 | 356 | date_default_timezone_set('UTC'); |
| 357 | 357 | |
| 358 | 358 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 359 | - $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 GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 359 | + $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 GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 360 | 360 | |
| 361 | 361 | $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true); |
| 362 | 362 | |
| 363 | 363 | return $spotter_array; |
| 364 | 364 | } |
| 365 | 365 | |
| 366 | - /** |
|
| 367 | - * Gets all the spotter information based on a particular callsign |
|
| 368 | - * |
|
| 369 | - * @return Array the spotter information |
|
| 370 | - * |
|
| 371 | - */ |
|
| 366 | + /** |
|
| 367 | + * Gets all the spotter information based on a particular callsign |
|
| 368 | + * |
|
| 369 | + * @return Array the spotter information |
|
| 370 | + * |
|
| 371 | + */ |
|
| 372 | 372 | public function getDateLiveSpotterDataByIdent($ident,$date) |
| 373 | 373 | { |
| 374 | 374 | $Spotter = new Spotter($this->db); |
| 375 | 375 | date_default_timezone_set('UTC'); |
| 376 | 376 | |
| 377 | 377 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 378 | - $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.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 378 | + $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.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 379 | 379 | |
| 380 | - $date = date('c',$date); |
|
| 380 | + $date = date('c',$date); |
|
| 381 | 381 | $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
| 382 | 382 | |
| 383 | 383 | return $spotter_array; |
| 384 | 384 | } |
| 385 | 385 | |
| 386 | - /** |
|
| 387 | - * Gets last spotter information based on a particular callsign |
|
| 388 | - * |
|
| 389 | - * @return Array the spotter information |
|
| 390 | - * |
|
| 391 | - */ |
|
| 386 | + /** |
|
| 387 | + * Gets last spotter information based on a particular callsign |
|
| 388 | + * |
|
| 389 | + * @return Array the spotter information |
|
| 390 | + * |
|
| 391 | + */ |
|
| 392 | 392 | public function getLastLiveSpotterDataById($id) |
| 393 | 393 | { |
| 394 | 394 | $Spotter = new Spotter($this->db); |
| 395 | 395 | date_default_timezone_set('UTC'); |
| 396 | 396 | |
| 397 | 397 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 398 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 398 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 399 | 399 | |
| 400 | 400 | $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id),'',true); |
| 401 | 401 | |
| 402 | 402 | return $spotter_array; |
| 403 | 403 | } |
| 404 | 404 | |
| 405 | - /** |
|
| 406 | - * Gets last spotter information based on a particular callsign |
|
| 407 | - * |
|
| 408 | - * @return Array the spotter information |
|
| 409 | - * |
|
| 410 | - */ |
|
| 405 | + /** |
|
| 406 | + * Gets last spotter information based on a particular callsign |
|
| 407 | + * |
|
| 408 | + * @return Array the spotter information |
|
| 409 | + * |
|
| 410 | + */ |
|
| 411 | 411 | public function getDateLiveSpotterDataById($id,$date) |
| 412 | 412 | { |
| 413 | 413 | $Spotter = new Spotter($this->db); |
| 414 | 414 | date_default_timezone_set('UTC'); |
| 415 | 415 | |
| 416 | 416 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 417 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 418 | - $date = date('c',$date); |
|
| 417 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 418 | + $date = date('c',$date); |
|
| 419 | 419 | $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
| 420 | 420 | |
| 421 | 421 | return $spotter_array; |
| 422 | 422 | } |
| 423 | 423 | |
| 424 | - /** |
|
| 425 | - * Gets altitude information based on a particular callsign |
|
| 426 | - * |
|
| 427 | - * @return Array the spotter information |
|
| 428 | - * |
|
| 429 | - */ |
|
| 424 | + /** |
|
| 425 | + * Gets altitude information based on a particular callsign |
|
| 426 | + * |
|
| 427 | + * @return Array the spotter information |
|
| 428 | + * |
|
| 429 | + */ |
|
| 430 | 430 | public function getAltitudeLiveSpotterDataByIdent($ident) |
| 431 | 431 | { |
| 432 | 432 | |
| 433 | 433 | date_default_timezone_set('UTC'); |
| 434 | 434 | |
| 435 | 435 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 436 | - $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
| 436 | + $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
| 437 | 437 | |
| 438 | - try { |
|
| 438 | + try { |
|
| 439 | 439 | |
| 440 | 440 | $sth = $this->db->prepare($query); |
| 441 | 441 | $sth->execute(array(':ident' => $ident)); |
@@ -448,12 +448,12 @@ discard block |
||
| 448 | 448 | return $spotter_array; |
| 449 | 449 | } |
| 450 | 450 | |
| 451 | - /** |
|
| 452 | - * Gets all the spotter information based on a particular id |
|
| 453 | - * |
|
| 454 | - * @return Array the spotter information |
|
| 455 | - * |
|
| 456 | - */ |
|
| 451 | + /** |
|
| 452 | + * Gets all the spotter information based on a particular id |
|
| 453 | + * |
|
| 454 | + * @return Array the spotter information |
|
| 455 | + * |
|
| 456 | + */ |
|
| 457 | 457 | public function getAllLiveSpotterDataById($id,$liveinterval = false) |
| 458 | 458 | { |
| 459 | 459 | global $globalDBdriver, $globalLiveInterval; |
@@ -481,18 +481,18 @@ discard block |
||
| 481 | 481 | return $spotter_array; |
| 482 | 482 | } |
| 483 | 483 | |
| 484 | - /** |
|
| 485 | - * Gets all the spotter information based on a particular ident |
|
| 486 | - * |
|
| 487 | - * @return Array the spotter information |
|
| 488 | - * |
|
| 489 | - */ |
|
| 484 | + /** |
|
| 485 | + * Gets all the spotter information based on a particular ident |
|
| 486 | + * |
|
| 487 | + * @return Array the spotter information |
|
| 488 | + * |
|
| 489 | + */ |
|
| 490 | 490 | public function getAllLiveSpotterDataByIdent($ident) |
| 491 | 491 | { |
| 492 | 492 | date_default_timezone_set('UTC'); |
| 493 | 493 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 494 | 494 | $query = self::$global_query.' WHERE spotter_live.ident = :ident'; |
| 495 | - try { |
|
| 495 | + try { |
|
| 496 | 496 | |
| 497 | 497 | $sth = $this->db->prepare($query); |
| 498 | 498 | $sth->execute(array(':ident' => $ident)); |
@@ -506,23 +506,23 @@ discard block |
||
| 506 | 506 | |
| 507 | 507 | |
| 508 | 508 | /** |
| 509 | - * Deletes all info in the table |
|
| 510 | - * |
|
| 511 | - * @return String success or false |
|
| 512 | - * |
|
| 513 | - */ |
|
| 509 | + * Deletes all info in the table |
|
| 510 | + * |
|
| 511 | + * @return String success or false |
|
| 512 | + * |
|
| 513 | + */ |
|
| 514 | 514 | public function deleteLiveSpotterData() |
| 515 | 515 | { |
| 516 | 516 | global $globalDBdriver; |
| 517 | 517 | if ($globalDBdriver == 'mysql') { |
| 518 | 518 | //$query = "DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= spotter_live.date"; |
| 519 | 519 | $query = 'DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= spotter_live.date'; |
| 520 | - //$query = "DELETE FROM spotter_live WHERE spotter_live.id IN (SELECT spotter_live.id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= spotter_live.date)"; |
|
| 520 | + //$query = "DELETE FROM spotter_live WHERE spotter_live.id IN (SELECT spotter_live.id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= spotter_live.date)"; |
|
| 521 | 521 | } else { |
| 522 | 522 | $query = "DELETE FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= spotter_live.date"; |
| 523 | 523 | } |
| 524 | 524 | |
| 525 | - try { |
|
| 525 | + try { |
|
| 526 | 526 | |
| 527 | 527 | $sth = $this->db->prepare($query); |
| 528 | 528 | $sth->execute(); |
@@ -534,18 +534,18 @@ discard block |
||
| 534 | 534 | } |
| 535 | 535 | |
| 536 | 536 | /** |
| 537 | - * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
| 538 | - * |
|
| 539 | - * @return String success or false |
|
| 540 | - * |
|
| 541 | - */ |
|
| 537 | + * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
| 538 | + * |
|
| 539 | + * @return String success or false |
|
| 540 | + * |
|
| 541 | + */ |
|
| 542 | 542 | public function deleteLiveSpotterDataNotUpdated() |
| 543 | 543 | { |
| 544 | 544 | global $globalDBdriver, $globalDebug; |
| 545 | 545 | if ($globalDBdriver == 'mysql') { |
| 546 | 546 | //$query = 'SELECT flightaware_id FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) >= spotter_live.date AND spotter_live.flightaware_id NOT IN (SELECT flightaware_id FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) < spotter_live.date) LIMIT 800 OFFSET 0'; |
| 547 | - $query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0"; |
|
| 548 | - try { |
|
| 547 | + $query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0"; |
|
| 548 | + try { |
|
| 549 | 549 | |
| 550 | 550 | $sth = $this->db->prepare($query); |
| 551 | 551 | $sth->execute(); |
@@ -553,8 +553,8 @@ discard block |
||
| 553 | 553 | return "error"; |
| 554 | 554 | } |
| 555 | 555 | $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
| 556 | - $i = 0; |
|
| 557 | - $j =0; |
|
| 556 | + $i = 0; |
|
| 557 | + $j =0; |
|
| 558 | 558 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 559 | 559 | foreach($all as $row) |
| 560 | 560 | { |
@@ -562,20 +562,20 @@ discard block |
||
| 562 | 562 | $j++; |
| 563 | 563 | if ($j == 30) { |
| 564 | 564 | if ($globalDebug) echo "."; |
| 565 | - try { |
|
| 565 | + try { |
|
| 566 | 566 | |
| 567 | 567 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
| 568 | 568 | $sth->execute(); |
| 569 | 569 | } catch(PDOException $e) { |
| 570 | 570 | return "error"; |
| 571 | 571 | } |
| 572 | - $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
|
| 573 | - $j = 0; |
|
| 572 | + $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
|
| 573 | + $j = 0; |
|
| 574 | 574 | } |
| 575 | 575 | $query_delete .= "'".$row['flightaware_id']."',"; |
| 576 | 576 | } |
| 577 | 577 | if ($i > 0) { |
| 578 | - try { |
|
| 578 | + try { |
|
| 579 | 579 | |
| 580 | 580 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
| 581 | 581 | $sth->execute(); |
@@ -586,9 +586,9 @@ discard block |
||
| 586 | 586 | return "success"; |
| 587 | 587 | } elseif ($globalDBdriver == 'pgsql') { |
| 588 | 588 | //$query = "SELECT flightaware_id FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= spotter_live.date AND spotter_live.flightaware_id NOT IN (SELECT flightaware_id FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' < spotter_live.date) LIMIT 800 OFFSET 0"; |
| 589 | - //$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
| 590 | - $query = "DELETE FROM spotter_live WHERE flightaware_id IN (SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)"; |
|
| 591 | - try { |
|
| 589 | + //$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
| 590 | + $query = "DELETE FROM spotter_live WHERE flightaware_id IN (SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)"; |
|
| 591 | + try { |
|
| 592 | 592 | |
| 593 | 593 | $sth = $this->db->prepare($query); |
| 594 | 594 | $sth->execute(); |
@@ -632,17 +632,17 @@ discard block |
||
| 632 | 632 | } |
| 633 | 633 | |
| 634 | 634 | /** |
| 635 | - * Deletes all info in the table for an ident |
|
| 636 | - * |
|
| 637 | - * @return String success or false |
|
| 638 | - * |
|
| 639 | - */ |
|
| 635 | + * Deletes all info in the table for an ident |
|
| 636 | + * |
|
| 637 | + * @return String success or false |
|
| 638 | + * |
|
| 639 | + */ |
|
| 640 | 640 | public function deleteLiveSpotterDataByIdent($ident) |
| 641 | 641 | { |
| 642 | 642 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 643 | 643 | $query = 'DELETE FROM spotter_live WHERE ident = :ident'; |
| 644 | 644 | |
| 645 | - try { |
|
| 645 | + try { |
|
| 646 | 646 | |
| 647 | 647 | $sth = $this->db->prepare($query); |
| 648 | 648 | $sth->execute(array(':ident' => $ident)); |
@@ -654,17 +654,17 @@ discard block |
||
| 654 | 654 | } |
| 655 | 655 | |
| 656 | 656 | /** |
| 657 | - * Deletes all info in the table for an id |
|
| 658 | - * |
|
| 659 | - * @return String success or false |
|
| 660 | - * |
|
| 661 | - */ |
|
| 657 | + * Deletes all info in the table for an id |
|
| 658 | + * |
|
| 659 | + * @return String success or false |
|
| 660 | + * |
|
| 661 | + */ |
|
| 662 | 662 | public function deleteLiveSpotterDataById($id) |
| 663 | 663 | { |
| 664 | 664 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 665 | 665 | $query = 'DELETE FROM spotter_live WHERE flightaware_id = :id'; |
| 666 | 666 | |
| 667 | - try { |
|
| 667 | + try { |
|
| 668 | 668 | |
| 669 | 669 | $sth = $this->db->prepare($query); |
| 670 | 670 | $sth->execute(array(':id' => $id)); |
@@ -677,11 +677,11 @@ discard block |
||
| 677 | 677 | |
| 678 | 678 | |
| 679 | 679 | /** |
| 680 | - * Gets the aircraft ident within the last hour |
|
| 681 | - * |
|
| 682 | - * @return String the ident |
|
| 683 | - * |
|
| 684 | - */ |
|
| 680 | + * Gets the aircraft ident within the last hour |
|
| 681 | + * |
|
| 682 | + * @return String the ident |
|
| 683 | + * |
|
| 684 | + */ |
|
| 685 | 685 | public function getIdentFromLastHour($ident) |
| 686 | 686 | { |
| 687 | 687 | global $globalDBdriver, $globalTimezone; |
@@ -707,14 +707,14 @@ discard block |
||
| 707 | 707 | $ident_result = $row['ident']; |
| 708 | 708 | } |
| 709 | 709 | return $ident_result; |
| 710 | - } |
|
| 710 | + } |
|
| 711 | 711 | |
| 712 | 712 | /** |
| 713 | - * Check recent aircraft |
|
| 714 | - * |
|
| 715 | - * @return String the ident |
|
| 716 | - * |
|
| 717 | - */ |
|
| 713 | + * Check recent aircraft |
|
| 714 | + * |
|
| 715 | + * @return String the ident |
|
| 716 | + * |
|
| 717 | + */ |
|
| 718 | 718 | public function checkIdentRecent($ident) |
| 719 | 719 | { |
| 720 | 720 | global $globalDBdriver, $globalTimezone; |
@@ -740,14 +740,14 @@ discard block |
||
| 740 | 740 | $ident_result = $row['flightaware_id']; |
| 741 | 741 | } |
| 742 | 742 | return $ident_result; |
| 743 | - } |
|
| 743 | + } |
|
| 744 | 744 | |
| 745 | 745 | /** |
| 746 | - * Check recent aircraft by id |
|
| 747 | - * |
|
| 748 | - * @return String the ident |
|
| 749 | - * |
|
| 750 | - */ |
|
| 746 | + * Check recent aircraft by id |
|
| 747 | + * |
|
| 748 | + * @return String the ident |
|
| 749 | + * |
|
| 750 | + */ |
|
| 751 | 751 | public function checkIdRecent($id) |
| 752 | 752 | { |
| 753 | 753 | global $globalDBdriver, $globalTimezone; |
@@ -773,14 +773,14 @@ discard block |
||
| 773 | 773 | $ident_result = $row['flightaware_id']; |
| 774 | 774 | } |
| 775 | 775 | return $ident_result; |
| 776 | - } |
|
| 776 | + } |
|
| 777 | 777 | |
| 778 | 778 | /** |
| 779 | - * Check recent aircraft by ModeS |
|
| 780 | - * |
|
| 781 | - * @return String the ModeS |
|
| 782 | - * |
|
| 783 | - */ |
|
| 779 | + * Check recent aircraft by ModeS |
|
| 780 | + * |
|
| 781 | + * @return String the ModeS |
|
| 782 | + * |
|
| 783 | + */ |
|
| 784 | 784 | public function checkModeSRecent($modes) |
| 785 | 785 | { |
| 786 | 786 | global $globalDBdriver, $globalTimezone; |
@@ -807,19 +807,19 @@ discard block |
||
| 807 | 807 | $ident_result = $row['flightaware_id']; |
| 808 | 808 | } |
| 809 | 809 | return $ident_result; |
| 810 | - } |
|
| 810 | + } |
|
| 811 | 811 | |
| 812 | 812 | /** |
| 813 | - * Adds a new spotter data |
|
| 814 | - * |
|
| 815 | - * @param String $flightaware_id the ID from flightaware |
|
| 816 | - * @param String $ident the flight ident |
|
| 817 | - * @param String $aircraft_icao the aircraft type |
|
| 818 | - * @param String $departure_airport_icao the departure airport |
|
| 819 | - * @param String $arrival_airport_icao the arrival airport |
|
| 820 | - * @return String success or false |
|
| 821 | - * |
|
| 822 | - */ |
|
| 813 | + * Adds a new spotter data |
|
| 814 | + * |
|
| 815 | + * @param String $flightaware_id the ID from flightaware |
|
| 816 | + * @param String $ident the flight ident |
|
| 817 | + * @param String $aircraft_icao the aircraft type |
|
| 818 | + * @param String $departure_airport_icao the departure airport |
|
| 819 | + * @param String $arrival_airport_icao the arrival airport |
|
| 820 | + * @return String success or false |
|
| 821 | + * |
|
| 822 | + */ |
|
| 823 | 823 | public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $groundspeed = '', $date = '',$departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false,$registration = '',$pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false,$format_source = '', $source_name = '', $over_country = '') |
| 824 | 824 | { |
| 825 | 825 | global $globalURL, $globalArchive, $globalDebug; |
@@ -954,10 +954,10 @@ discard block |
||
| 954 | 954 | $arrival_airport_country = ''; |
| 955 | 955 | |
| 956 | 956 | |
| 957 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
| 958 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
| 959 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 960 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 957 | + if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
| 958 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
| 959 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 960 | + if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 961 | 961 | |
| 962 | 962 | $query = 'INSERT INTO spotter_live (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, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop, ModeS, pilot_id, pilot_name, verticalrate, ground, format_source, source_name, over_country) |
| 963 | 963 | VALUES (:flightaware_id,:ident,:registration,:airline_name,:airline_icao,:airline_country,:airline_type,:aircraft_icao,:aircraft_shadow,:aircraft_type,:aircraft_manufacturer,:departure_airport_icao,:departure_airport_name, :departure_airport_city, :departure_airport_country, :arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :latitude,:longitude,:waypoints,:altitude,:heading,:groundspeed,:date,:departure_airport_time,:arrival_airport_time,:squawk,:route_stop,:ModeS, :pilot_id, :pilot_name, :verticalrate, :ground, :format_source, :source_name, :over_country)'; |
@@ -967,14 +967,14 @@ discard block |
||
| 967 | 967 | |
| 968 | 968 | $sth = $this->db->prepare($query); |
| 969 | 969 | $sth->execute($query_values); |
| 970 | - } catch(PDOException $e) { |
|
| 971 | - return "error : ".$e->getMessage(); |
|
| 972 | - } |
|
| 970 | + } catch(PDOException $e) { |
|
| 971 | + return "error : ".$e->getMessage(); |
|
| 972 | + } |
|
| 973 | 973 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
| 974 | - if ($globalDebug) echo '(Add to SBS archive : '; |
|
| 975 | - $SpotterArchive = new SpotterArchive($this->db); |
|
| 976 | - $result = $SpotterArchive->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, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
|
| 977 | - if ($globalDebug) echo $result.')'; |
|
| 974 | + if ($globalDebug) echo '(Add to SBS archive : '; |
|
| 975 | + $SpotterArchive = new SpotterArchive($this->db); |
|
| 976 | + $result = $SpotterArchive->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, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
|
| 977 | + if ($globalDebug) echo $result.')'; |
|
| 978 | 978 | } |
| 979 | 979 | return "success"; |
| 980 | 980 | |
@@ -16,64 +16,64 @@ discard block |
||
| 16 | 16 | * @param Array $filter the filter |
| 17 | 17 | * @return Array the SQL part |
| 18 | 18 | */ |
| 19 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
| 19 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
| 20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName; |
| 21 | 21 | $filters = array(); |
| 22 | 22 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
| 23 | 23 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
| 24 | 24 | $filters = $globalStatsFilters[$globalFilterName]; |
| 25 | 25 | } else { |
| 26 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
| 26 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
| 27 | 27 | } |
| 28 | 28 | } |
| 29 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 29 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
| 30 | 30 | $filter_query_join = ''; |
| 31 | 31 | $filter_query_where = ''; |
| 32 | - foreach($filters as $flt) { |
|
| 32 | + foreach ($filters as $flt) { |
|
| 33 | 33 | if (isset($flt['airlines']) && !empty($flt['airlines'])) { |
| 34 | 34 | if ($flt['airlines'][0] != '') { |
| 35 | 35 | if (isset($flt['source'])) { |
| 36 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$flt['airlines'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) so ON so.flightaware_id = spotter_live.flightaware_id"; |
|
| 36 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $flt['airlines'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) so ON so.flightaware_id = spotter_live.flightaware_id"; |
|
| 37 | 37 | } else { |
| 38 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) so ON so.flightaware_id = spotter_live.flightaware_id"; |
|
| 38 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $flt['airlines'])."')) so ON so.flightaware_id = spotter_live.flightaware_id"; |
|
| 39 | 39 | } |
| 40 | 40 | } |
| 41 | 41 | } |
| 42 | 42 | if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) { |
| 43 | 43 | if (isset($flt['source'])) { |
| 44 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) so ON so.flightaware_id = spotter_live.flightaware_id"; |
|
| 44 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) so ON so.flightaware_id = spotter_live.flightaware_id"; |
|
| 45 | 45 | } else { |
| 46 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) so ON so.flightaware_id = spotter_live.flightaware_id"; |
|
| 46 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."')) so ON so.flightaware_id = spotter_live.flightaware_id"; |
|
| 47 | 47 | } |
| 48 | 48 | } |
| 49 | 49 | if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']))) { |
| 50 | 50 | if (isset($flt['source'])) { |
| 51 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) so ON so.flightaware_id = spotter_live.flightaware_id"; |
|
| 51 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','", $flt['source'])."')) so ON so.flightaware_id = spotter_live.flightaware_id"; |
|
| 52 | 52 | } |
| 53 | 53 | } |
| 54 | 54 | } |
| 55 | 55 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 56 | 56 | if ($filter['airlines'][0] != '') { |
| 57 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_live.flightaware_id"; |
|
| 57 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_live.flightaware_id"; |
|
| 58 | 58 | } |
| 59 | 59 | } |
| 60 | 60 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
| 61 | 61 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_live.flightaware_id "; |
| 62 | 62 | } |
| 63 | 63 | if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) { |
| 64 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) so ON so.flightaware_id = spotter_live.flightaware_id"; |
|
| 64 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $filter['pilots_id'])."')) so ON so.flightaware_id = spotter_live.flightaware_id"; |
|
| 65 | 65 | } |
| 66 | 66 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 67 | - $filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')"; |
|
| 67 | + $filter_query_where = " WHERE format_source IN ('".implode("','", $filter['source'])."')"; |
|
| 68 | 68 | } |
| 69 | 69 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
| 70 | 70 | $filter_query_where = " WHERE ident = '".$filter['ident']."'"; |
| 71 | 71 | } |
| 72 | 72 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 73 | 73 | if ($filter_query_where == '') { |
| 74 | - $filter_query_where = " WHERE format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 74 | + $filter_query_where = " WHERE format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 75 | 75 | } else { |
| 76 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 76 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 77 | 77 | } |
| 78 | 78 | } |
| 79 | 79 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
@@ -99,8 +99,8 @@ discard block |
||
| 99 | 99 | if ($limit != '') |
| 100 | 100 | { |
| 101 | 101 | $limit_array = explode(',', $limit); |
| 102 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 103 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 102 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 103 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 104 | 104 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 105 | 105 | { |
| 106 | 106 | $limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0]; |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | } else { |
| 121 | 121 | $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate".$filter_query.$orderby_query; |
| 122 | 122 | } |
| 123 | - $spotter_array = $Spotter->getDataFromDB($query.$limit_query,array(),'',true); |
|
| 123 | + $spotter_array = $Spotter->getDataFromDB($query.$limit_query, array(), '', true); |
|
| 124 | 124 | |
| 125 | 125 | return $spotter_array; |
| 126 | 126 | } |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | global $globalDBdriver, $globalLiveInterval; |
| 137 | 137 | date_default_timezone_set('UTC'); |
| 138 | 138 | |
| 139 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 139 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 140 | 140 | |
| 141 | 141 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
| 142 | 142 | if ($globalDBdriver == 'mysql') { |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | $query = 'SELECT a.aircraft_shadow, spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
| 148 | 148 | FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_live.aircraft_icao = a.icao'.$filter_query." spotter_live.latitude <> 0 AND spotter_live.longitude <> 0"; |
| 149 | 149 | */ |
| 150 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
| 150 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
| 151 | 151 | FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query." spotter_live.latitude <> 0 AND spotter_live.longitude <> 0"; |
| 152 | 152 | |
| 153 | 153 | // $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= spotter_live.date ORDER BY spotter_live.date GROUP BY spotter_live.flightaware_id'.$filter_query; |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | $query = "SELECT a.aircraft_shadow, spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
| 162 | 162 | FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_live.aircraft_icao = a.icao".$filter_query." spotter_live.latitude <> '0' AND spotter_live.longitude <> '0'"; |
| 163 | 163 | */ |
| 164 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
| 164 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
| 165 | 165 | FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate".$filter_query." spotter_live.latitude <> '0' AND spotter_live.longitude <> '0'"; |
| 166 | 166 | |
| 167 | 167 | } |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | try { |
| 172 | 172 | $sth = $this->db->prepare($query); |
| 173 | 173 | $sth->execute(); |
| 174 | - } catch(PDOException $e) { |
|
| 174 | + } catch (PDOException $e) { |
|
| 175 | 175 | echo $e->getMessage(); |
| 176 | 176 | die; |
| 177 | 177 | } |
@@ -191,12 +191,12 @@ discard block |
||
| 191 | 191 | global $globalDBdriver, $globalLiveInterval; |
| 192 | 192 | date_default_timezone_set('UTC'); |
| 193 | 193 | |
| 194 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 194 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 195 | 195 | |
| 196 | 196 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
| 197 | 197 | if ($globalDBdriver == 'mysql') { |
| 198 | 198 | |
| 199 | - $query = 'SELECT a.aircraft_shadow, a.engine_type, a.engine_count, a.wake_category, spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
| 199 | + $query = 'SELECT a.aircraft_shadow, a.engine_type, a.engine_count, a.wake_category, spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
| 200 | 200 | FROM spotter_live LEFT JOIN (SELECT aircraft_shadow,engine_type, engine_count, wake_category,icao FROM aircraft) a ON spotter_live.aircraft_icao = a.icao'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
| 201 | 201 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
| 202 | 202 | } else { |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | FROM spotter_live WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date |
| 206 | 206 | ".$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_live.aircraft_icao = a.icao ORDER BY spotter_live.flightaware_id, spotter_live.date'; |
| 207 | 207 | */ |
| 208 | - $query = "SELECT a.aircraft_shadow, a.engine_type, a.engine_count, a.wake_category, spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
| 208 | + $query = "SELECT a.aircraft_shadow, a.engine_type, a.engine_count, a.wake_category, spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
| 209 | 209 | FROM spotter_live LEFT JOIN (SELECT aircraft_shadow,engine_type, engine_count, wake_category, icao FROM aircraft) a ON spotter_live.aircraft_icao = a.icao".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
| 210 | 210 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
| 211 | 211 | // echo $query; |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | try { |
| 215 | 215 | $sth = $this->db->prepare($query); |
| 216 | 216 | $sth->execute(); |
| 217 | - } catch(PDOException $e) { |
|
| 217 | + } catch (PDOException $e) { |
|
| 218 | 218 | echo $e->getMessage(); |
| 219 | 219 | die; |
| 220 | 220 | } |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | public function getLiveSpotterCount($filter = array()) |
| 232 | 232 | { |
| 233 | 233 | global $globalDBdriver, $globalLiveInterval; |
| 234 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 234 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 235 | 235 | |
| 236 | 236 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
| 237 | 237 | if ($globalDBdriver == 'mysql') { |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | try { |
| 245 | 245 | $sth = $this->db->prepare($query); |
| 246 | 246 | $sth->execute(); |
| 247 | - } catch(PDOException $e) { |
|
| 247 | + } catch (PDOException $e) { |
|
| 248 | 248 | echo $e->getMessage(); |
| 249 | 249 | die; |
| 250 | 250 | } |
@@ -267,10 +267,10 @@ discard block |
||
| 267 | 267 | $filter_query = $this->getFilter($filter); |
| 268 | 268 | |
| 269 | 269 | if (is_array($coord)) { |
| 270 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 271 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 272 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 273 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 270 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 271 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 272 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 273 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 274 | 274 | } else return array(); |
| 275 | 275 | if ($globalDBdriver == 'mysql') { |
| 276 | 276 | //$query = "SELECT spotter_output.* FROM spotter_output WHERE spotter_output.flightaware_id IN (SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL ".$globalLiveInterval." SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")"; |
@@ -323,7 +323,7 @@ discard block |
||
| 323 | 323 | if ($interval == '1m') |
| 324 | 324 | { |
| 325 | 325 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
| 326 | - } else if ($interval == '15m'){ |
|
| 326 | + } else if ($interval == '15m') { |
|
| 327 | 327 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date '; |
| 328 | 328 | } |
| 329 | 329 | } |
@@ -331,14 +331,14 @@ discard block |
||
| 331 | 331 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
| 332 | 332 | } |
| 333 | 333 | |
| 334 | - $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live |
|
| 334 | + $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live |
|
| 335 | 335 | WHERE spotter_live.latitude <> '' |
| 336 | 336 | AND spotter_live.longitude <> '' |
| 337 | 337 | ".$additional_query." |
| 338 | 338 | HAVING distance < :radius |
| 339 | 339 | ORDER BY distance"; |
| 340 | 340 | |
| 341 | - $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
| 341 | + $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius)); |
|
| 342 | 342 | |
| 343 | 343 | return $spotter_array; |
| 344 | 344 | } |
@@ -356,9 +356,9 @@ discard block |
||
| 356 | 356 | date_default_timezone_set('UTC'); |
| 357 | 357 | |
| 358 | 358 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 359 | - $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 GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 359 | + $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 GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 360 | 360 | |
| 361 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true); |
|
| 361 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident), '', true); |
|
| 362 | 362 | |
| 363 | 363 | return $spotter_array; |
| 364 | 364 | } |
@@ -369,16 +369,16 @@ discard block |
||
| 369 | 369 | * @return Array the spotter information |
| 370 | 370 | * |
| 371 | 371 | */ |
| 372 | - public function getDateLiveSpotterDataByIdent($ident,$date) |
|
| 372 | + public function getDateLiveSpotterDataByIdent($ident, $date) |
|
| 373 | 373 | { |
| 374 | 374 | $Spotter = new Spotter($this->db); |
| 375 | 375 | date_default_timezone_set('UTC'); |
| 376 | 376 | |
| 377 | 377 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 378 | - $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.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 378 | + $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.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 379 | 379 | |
| 380 | - $date = date('c',$date); |
|
| 381 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
| 380 | + $date = date('c', $date); |
|
| 381 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
| 382 | 382 | |
| 383 | 383 | return $spotter_array; |
| 384 | 384 | } |
@@ -395,9 +395,9 @@ discard block |
||
| 395 | 395 | date_default_timezone_set('UTC'); |
| 396 | 396 | |
| 397 | 397 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 398 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 398 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 399 | 399 | |
| 400 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id),'',true); |
|
| 400 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id), '', true); |
|
| 401 | 401 | |
| 402 | 402 | return $spotter_array; |
| 403 | 403 | } |
@@ -408,15 +408,15 @@ discard block |
||
| 408 | 408 | * @return Array the spotter information |
| 409 | 409 | * |
| 410 | 410 | */ |
| 411 | - public function getDateLiveSpotterDataById($id,$date) |
|
| 411 | + public function getDateLiveSpotterDataById($id, $date) |
|
| 412 | 412 | { |
| 413 | 413 | $Spotter = new Spotter($this->db); |
| 414 | 414 | date_default_timezone_set('UTC'); |
| 415 | 415 | |
| 416 | 416 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 417 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 418 | - $date = date('c',$date); |
|
| 419 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
|
| 417 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 418 | + $date = date('c', $date); |
|
| 419 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true); |
|
| 420 | 420 | |
| 421 | 421 | return $spotter_array; |
| 422 | 422 | } |
@@ -433,13 +433,13 @@ discard block |
||
| 433 | 433 | date_default_timezone_set('UTC'); |
| 434 | 434 | |
| 435 | 435 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 436 | - $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
| 436 | + $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
| 437 | 437 | |
| 438 | 438 | try { |
| 439 | 439 | |
| 440 | 440 | $sth = $this->db->prepare($query); |
| 441 | 441 | $sth->execute(array(':ident' => $ident)); |
| 442 | - } catch(PDOException $e) { |
|
| 442 | + } catch (PDOException $e) { |
|
| 443 | 443 | echo $e->getMessage(); |
| 444 | 444 | die; |
| 445 | 445 | } |
@@ -454,7 +454,7 @@ discard block |
||
| 454 | 454 | * @return Array the spotter information |
| 455 | 455 | * |
| 456 | 456 | */ |
| 457 | - public function getAllLiveSpotterDataById($id,$liveinterval = false) |
|
| 457 | + public function getAllLiveSpotterDataById($id, $liveinterval = false) |
|
| 458 | 458 | { |
| 459 | 459 | global $globalDBdriver, $globalLiveInterval; |
| 460 | 460 | date_default_timezone_set('UTC'); |
@@ -473,7 +473,7 @@ discard block |
||
| 473 | 473 | try { |
| 474 | 474 | $sth = $this->db->prepare($query); |
| 475 | 475 | $sth->execute(array(':id' => $id)); |
| 476 | - } catch(PDOException $e) { |
|
| 476 | + } catch (PDOException $e) { |
|
| 477 | 477 | echo $e->getMessage(); |
| 478 | 478 | die; |
| 479 | 479 | } |
@@ -491,12 +491,12 @@ discard block |
||
| 491 | 491 | { |
| 492 | 492 | date_default_timezone_set('UTC'); |
| 493 | 493 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 494 | - $query = self::$global_query.' WHERE spotter_live.ident = :ident'; |
|
| 494 | + $query = self::$global_query.' WHERE spotter_live.ident = :ident'; |
|
| 495 | 495 | try { |
| 496 | 496 | |
| 497 | 497 | $sth = $this->db->prepare($query); |
| 498 | 498 | $sth->execute(array(':ident' => $ident)); |
| 499 | - } catch(PDOException $e) { |
|
| 499 | + } catch (PDOException $e) { |
|
| 500 | 500 | echo $e->getMessage(); |
| 501 | 501 | die; |
| 502 | 502 | } |
@@ -526,7 +526,7 @@ discard block |
||
| 526 | 526 | |
| 527 | 527 | $sth = $this->db->prepare($query); |
| 528 | 528 | $sth->execute(); |
| 529 | - } catch(PDOException $e) { |
|
| 529 | + } catch (PDOException $e) { |
|
| 530 | 530 | return "error"; |
| 531 | 531 | } |
| 532 | 532 | |
@@ -549,14 +549,14 @@ discard block |
||
| 549 | 549 | |
| 550 | 550 | $sth = $this->db->prepare($query); |
| 551 | 551 | $sth->execute(); |
| 552 | - } catch(PDOException $e) { |
|
| 552 | + } catch (PDOException $e) { |
|
| 553 | 553 | return "error"; |
| 554 | 554 | } |
| 555 | 555 | $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
| 556 | 556 | $i = 0; |
| 557 | - $j =0; |
|
| 557 | + $j = 0; |
|
| 558 | 558 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 559 | - foreach($all as $row) |
|
| 559 | + foreach ($all as $row) |
|
| 560 | 560 | { |
| 561 | 561 | $i++; |
| 562 | 562 | $j++; |
@@ -564,9 +564,9 @@ discard block |
||
| 564 | 564 | if ($globalDebug) echo "."; |
| 565 | 565 | try { |
| 566 | 566 | |
| 567 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
| 567 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
| 568 | 568 | $sth->execute(); |
| 569 | - } catch(PDOException $e) { |
|
| 569 | + } catch (PDOException $e) { |
|
| 570 | 570 | return "error"; |
| 571 | 571 | } |
| 572 | 572 | $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
@@ -577,9 +577,9 @@ discard block |
||
| 577 | 577 | if ($i > 0) { |
| 578 | 578 | try { |
| 579 | 579 | |
| 580 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
| 580 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
| 581 | 581 | $sth->execute(); |
| 582 | - } catch(PDOException $e) { |
|
| 582 | + } catch (PDOException $e) { |
|
| 583 | 583 | return "error"; |
| 584 | 584 | } |
| 585 | 585 | } |
@@ -592,7 +592,7 @@ discard block |
||
| 592 | 592 | |
| 593 | 593 | $sth = $this->db->prepare($query); |
| 594 | 594 | $sth->execute(); |
| 595 | - } catch(PDOException $e) { |
|
| 595 | + } catch (PDOException $e) { |
|
| 596 | 596 | return "error"; |
| 597 | 597 | } |
| 598 | 598 | /* $query_delete = "DELETE FROM spotter_live WHERE flightaware_id IN ("; |
@@ -640,13 +640,13 @@ discard block |
||
| 640 | 640 | public function deleteLiveSpotterDataByIdent($ident) |
| 641 | 641 | { |
| 642 | 642 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 643 | - $query = 'DELETE FROM spotter_live WHERE ident = :ident'; |
|
| 643 | + $query = 'DELETE FROM spotter_live WHERE ident = :ident'; |
|
| 644 | 644 | |
| 645 | 645 | try { |
| 646 | 646 | |
| 647 | 647 | $sth = $this->db->prepare($query); |
| 648 | 648 | $sth->execute(array(':ident' => $ident)); |
| 649 | - } catch(PDOException $e) { |
|
| 649 | + } catch (PDOException $e) { |
|
| 650 | 650 | return "error"; |
| 651 | 651 | } |
| 652 | 652 | |
@@ -662,13 +662,13 @@ discard block |
||
| 662 | 662 | public function deleteLiveSpotterDataById($id) |
| 663 | 663 | { |
| 664 | 664 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 665 | - $query = 'DELETE FROM spotter_live WHERE flightaware_id = :id'; |
|
| 665 | + $query = 'DELETE FROM spotter_live WHERE flightaware_id = :id'; |
|
| 666 | 666 | |
| 667 | 667 | try { |
| 668 | 668 | |
| 669 | 669 | $sth = $this->db->prepare($query); |
| 670 | 670 | $sth->execute(array(':id' => $id)); |
| 671 | - } catch(PDOException $e) { |
|
| 671 | + } catch (PDOException $e) { |
|
| 672 | 672 | return "error"; |
| 673 | 673 | } |
| 674 | 674 | |
@@ -686,13 +686,13 @@ discard block |
||
| 686 | 686 | { |
| 687 | 687 | global $globalDBdriver, $globalTimezone; |
| 688 | 688 | if ($globalDBdriver == 'mysql') { |
| 689 | - $query = 'SELECT spotter_live.ident FROM spotter_live |
|
| 689 | + $query = 'SELECT spotter_live.ident FROM spotter_live |
|
| 690 | 690 | WHERE spotter_live.ident = :ident |
| 691 | 691 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
| 692 | 692 | AND spotter_live.date < UTC_TIMESTAMP()'; |
| 693 | 693 | $query_data = array(':ident' => $ident); |
| 694 | 694 | } else { |
| 695 | - $query = "SELECT spotter_live.ident FROM spotter_live |
|
| 695 | + $query = "SELECT spotter_live.ident FROM spotter_live |
|
| 696 | 696 | WHERE spotter_live.ident = :ident |
| 697 | 697 | AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
| 698 | 698 | AND spotter_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -701,8 +701,8 @@ discard block |
||
| 701 | 701 | |
| 702 | 702 | $sth = $this->db->prepare($query); |
| 703 | 703 | $sth->execute($query_data); |
| 704 | - $ident_result=''; |
|
| 705 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 704 | + $ident_result = ''; |
|
| 705 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 706 | 706 | { |
| 707 | 707 | $ident_result = $row['ident']; |
| 708 | 708 | } |
@@ -719,13 +719,13 @@ discard block |
||
| 719 | 719 | { |
| 720 | 720 | global $globalDBdriver, $globalTimezone; |
| 721 | 721 | if ($globalDBdriver == 'mysql') { |
| 722 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 722 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 723 | 723 | WHERE spotter_live.ident = :ident |
| 724 | 724 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; |
| 725 | 725 | // AND spotter_live.date < UTC_TIMESTAMP()"; |
| 726 | 726 | $query_data = array(':ident' => $ident); |
| 727 | 727 | } else { |
| 728 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 728 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 729 | 729 | WHERE spotter_live.ident = :ident |
| 730 | 730 | AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'"; |
| 731 | 731 | // AND spotter_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -734,8 +734,8 @@ discard block |
||
| 734 | 734 | |
| 735 | 735 | $sth = $this->db->prepare($query); |
| 736 | 736 | $sth->execute($query_data); |
| 737 | - $ident_result=''; |
|
| 738 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 737 | + $ident_result = ''; |
|
| 738 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 739 | 739 | { |
| 740 | 740 | $ident_result = $row['flightaware_id']; |
| 741 | 741 | } |
@@ -752,13 +752,13 @@ discard block |
||
| 752 | 752 | { |
| 753 | 753 | global $globalDBdriver, $globalTimezone; |
| 754 | 754 | if ($globalDBdriver == 'mysql') { |
| 755 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 755 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 756 | 756 | WHERE spotter_live.flightaware_id = :id |
| 757 | 757 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; |
| 758 | 758 | // AND spotter_live.date < UTC_TIMESTAMP()"; |
| 759 | 759 | $query_data = array(':id' => $id); |
| 760 | 760 | } else { |
| 761 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 761 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 762 | 762 | WHERE spotter_live.flightaware_id = :id |
| 763 | 763 | AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'"; |
| 764 | 764 | // AND spotter_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -767,8 +767,8 @@ discard block |
||
| 767 | 767 | |
| 768 | 768 | $sth = $this->db->prepare($query); |
| 769 | 769 | $sth->execute($query_data); |
| 770 | - $ident_result=''; |
|
| 771 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 770 | + $ident_result = ''; |
|
| 771 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 772 | 772 | { |
| 773 | 773 | $ident_result = $row['flightaware_id']; |
| 774 | 774 | } |
@@ -785,13 +785,13 @@ discard block |
||
| 785 | 785 | { |
| 786 | 786 | global $globalDBdriver, $globalTimezone; |
| 787 | 787 | if ($globalDBdriver == 'mysql') { |
| 788 | - $query = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
| 788 | + $query = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
| 789 | 789 | WHERE spotter_live.ModeS = :modes |
| 790 | 790 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; |
| 791 | 791 | // AND spotter_live.date < UTC_TIMESTAMP()"; |
| 792 | 792 | $query_data = array(':modes' => $modes); |
| 793 | 793 | } else { |
| 794 | - $query = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
| 794 | + $query = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
| 795 | 795 | WHERE spotter_live.ModeS = :modes |
| 796 | 796 | AND spotter_live.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '30 MINUTE'"; |
| 797 | 797 | // // AND spotter_live.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'"; |
@@ -800,8 +800,8 @@ discard block |
||
| 800 | 800 | |
| 801 | 801 | $sth = $this->db->prepare($query); |
| 802 | 802 | $sth->execute($query_data); |
| 803 | - $ident_result=''; |
|
| 804 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 803 | + $ident_result = ''; |
|
| 804 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 805 | 805 | { |
| 806 | 806 | //$ident_result = $row['spotter_live_id']; |
| 807 | 807 | $ident_result = $row['flightaware_id']; |
@@ -820,7 +820,7 @@ discard block |
||
| 820 | 820 | * @return String success or false |
| 821 | 821 | * |
| 822 | 822 | */ |
| 823 | - public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $groundspeed = '', $date = '',$departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false,$registration = '',$pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false,$format_source = '', $source_name = '', $over_country = '') |
|
| 823 | + public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false, $registration = '', $pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false, $format_source = '', $source_name = '', $over_country = '') |
|
| 824 | 824 | { |
| 825 | 825 | global $globalURL, $globalArchive, $globalDebug; |
| 826 | 826 | $Common = new Common(); |
@@ -913,26 +913,26 @@ discard block |
||
| 913 | 913 | if ($date == '') $date = date("Y-m-d H:i:s", time()); |
| 914 | 914 | |
| 915 | 915 | |
| 916 | - $flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING); |
|
| 917 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
| 918 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 919 | - $departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING); |
|
| 920 | - $arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING); |
|
| 921 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 922 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 923 | - $waypoints = filter_var($waypoints,FILTER_SANITIZE_STRING); |
|
| 924 | - $altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 925 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
| 926 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 927 | - $squawk = filter_var($squawk,FILTER_SANITIZE_NUMBER_INT); |
|
| 928 | - $route_stop = filter_var($route_stop,FILTER_SANITIZE_STRING); |
|
| 929 | - $ModeS = filter_var($ModeS,FILTER_SANITIZE_STRING); |
|
| 930 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_STRING); |
|
| 931 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
| 932 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
| 933 | - $source_name = filter_var($source_name,FILTER_SANITIZE_STRING); |
|
| 934 | - $over_country = filter_var($over_country,FILTER_SANITIZE_STRING); |
|
| 935 | - $verticalrate = filter_var($verticalrate,FILTER_SANITIZE_NUMBER_INT); |
|
| 916 | + $flightaware_id = filter_var($flightaware_id, FILTER_SANITIZE_STRING); |
|
| 917 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 918 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
| 919 | + $departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING); |
|
| 920 | + $arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING); |
|
| 921 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 922 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 923 | + $waypoints = filter_var($waypoints, FILTER_SANITIZE_STRING); |
|
| 924 | + $altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 925 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
| 926 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 927 | + $squawk = filter_var($squawk, FILTER_SANITIZE_NUMBER_INT); |
|
| 928 | + $route_stop = filter_var($route_stop, FILTER_SANITIZE_STRING); |
|
| 929 | + $ModeS = filter_var($ModeS, FILTER_SANITIZE_STRING); |
|
| 930 | + $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_STRING); |
|
| 931 | + $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING); |
|
| 932 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
| 933 | + $source_name = filter_var($source_name, FILTER_SANITIZE_STRING); |
|
| 934 | + $over_country = filter_var($over_country, FILTER_SANITIZE_STRING); |
|
| 935 | + $verticalrate = filter_var($verticalrate, FILTER_SANITIZE_NUMBER_INT); |
|
| 936 | 936 | |
| 937 | 937 | $airline_name = ''; |
| 938 | 938 | $airline_icao = ''; |
@@ -954,26 +954,26 @@ discard block |
||
| 954 | 954 | $arrival_airport_country = ''; |
| 955 | 955 | |
| 956 | 956 | |
| 957 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
| 958 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
| 959 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 960 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 957 | + if ($squawk == '' || $Common->isInteger($squawk) === false) $squawk = NULL; |
|
| 958 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) $verticalrate = NULL; |
|
| 959 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
| 960 | + if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
| 961 | 961 | |
| 962 | - $query = 'INSERT INTO spotter_live (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, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop, ModeS, pilot_id, pilot_name, verticalrate, ground, format_source, source_name, over_country) |
|
| 962 | + $query = 'INSERT INTO spotter_live (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, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop, ModeS, pilot_id, pilot_name, verticalrate, ground, format_source, source_name, over_country) |
|
| 963 | 963 | VALUES (:flightaware_id,:ident,:registration,:airline_name,:airline_icao,:airline_country,:airline_type,:aircraft_icao,:aircraft_shadow,:aircraft_type,:aircraft_manufacturer,:departure_airport_icao,:departure_airport_name, :departure_airport_city, :departure_airport_country, :arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :latitude,:longitude,:waypoints,:altitude,:heading,:groundspeed,:date,:departure_airport_time,:arrival_airport_time,:squawk,:route_stop,:ModeS, :pilot_id, :pilot_name, :verticalrate, :ground, :format_source, :source_name, :over_country)'; |
| 964 | 964 | |
| 965 | - $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_type' => $aircraft_type,':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,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_name' => $arrival_airport_name,':arrival_airport_city' => $arrival_airport_city,':arrival_airport_country' => $arrival_airport_country,':latitude' => $latitude,':longitude' => $longitude, ':waypoints' => $waypoints,':altitude' => $altitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':departure_airport_time' => $departure_airport_time,':arrival_airport_time' => $arrival_airport_time, ':squawk' => $squawk,':route_stop' => $route_stop,':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source,':ground' => $ground, ':source_name' => $source_name, ':over_country' => $over_country); |
|
| 965 | + $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_type' => $aircraft_type, ':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, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_time' => $arrival_airport_time, ':squawk' => $squawk, ':route_stop' => $route_stop, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':ground' => $ground, ':source_name' => $source_name, ':over_country' => $over_country); |
|
| 966 | 966 | try { |
| 967 | 967 | |
| 968 | 968 | $sth = $this->db->prepare($query); |
| 969 | 969 | $sth->execute($query_values); |
| 970 | - } catch(PDOException $e) { |
|
| 970 | + } catch (PDOException $e) { |
|
| 971 | 971 | return "error : ".$e->getMessage(); |
| 972 | 972 | } |
| 973 | 973 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
| 974 | 974 | if ($globalDebug) echo '(Add to SBS archive : '; |
| 975 | 975 | $SpotterArchive = new SpotterArchive($this->db); |
| 976 | - $result = $SpotterArchive->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, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
|
| 976 | + $result = $SpotterArchive->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, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name, $verticalrate, $format_source, $source_name, $over_country); |
|
| 977 | 977 | if ($globalDebug) echo $result.')'; |
| 978 | 978 | } |
| 979 | 979 | return "success"; |
@@ -982,7 +982,7 @@ discard block |
||
| 982 | 982 | |
| 983 | 983 | public function getOrderBy() |
| 984 | 984 | { |
| 985 | - $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY spotter_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY spotter_live.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY spotter_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY spotter_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY spotter_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY spotter_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY spotter_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY spotter_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY spotter_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY spotter_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY spotter_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY spotter_live.date DESC")); |
|
| 985 | + $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY spotter_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY spotter_live.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY spotter_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY spotter_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY spotter_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY spotter_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY spotter_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY spotter_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY spotter_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY spotter_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY spotter_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY spotter_live.date DESC")); |
|
| 986 | 986 | return $orderby; |
| 987 | 987 | } |
| 988 | 988 | |