@@ -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 | |
@@ -18,22 +18,43 @@ discard block |
||
| 18 | 18 | } |
| 19 | 19 | header('Content-Type: text/javascript'); |
| 20 | 20 | |
| 21 | -if (!isset($globalJsonCompress)) $compress = true; |
|
| 22 | -else $compress = $globalJsonCompress; |
|
| 21 | +if (!isset($globalJsonCompress)) { |
|
| 22 | + $compress = true; |
|
| 23 | +} else { |
|
| 24 | + $compress = $globalJsonCompress; |
|
| 25 | +} |
|
| 23 | 26 | |
| 24 | 27 | $from_archive = false; |
| 25 | 28 | $min = false; |
| 26 | 29 | $allhistory = false; |
| 27 | 30 | $filter['source'] = array(); |
| 28 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt')); |
|
| 29 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup')); |
|
| 30 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars')); |
|
| 31 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs')); |
|
| 32 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs')); |
|
| 33 | -if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING); |
|
| 34 | -if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING); |
|
| 35 | -if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING); |
|
| 36 | -if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING); |
|
| 31 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') { |
|
| 32 | + $filter['source'] = array_merge($filter['source'],array('vatsimtxt')); |
|
| 33 | +} |
|
| 34 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') { |
|
| 35 | + $filter['source'] = array_merge($filter['source'],array('whazzup')); |
|
| 36 | +} |
|
| 37 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') { |
|
| 38 | + $filter['source'] = array_merge($filter['source'],array('phpvmacars')); |
|
| 39 | +} |
|
| 40 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') { |
|
| 41 | + $filter['source'] = array_merge($filter['source'],array('sbs')); |
|
| 42 | +} |
|
| 43 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') { |
|
| 44 | + $filter['source'] = array_merge($filter['source'],array('aprs')); |
|
| 45 | +} |
|
| 46 | +if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') { |
|
| 47 | + $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING); |
|
| 48 | +} |
|
| 49 | +if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') { |
|
| 50 | + $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING); |
|
| 51 | +} |
|
| 52 | +if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') { |
|
| 53 | + $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING); |
|
| 54 | +} |
|
| 55 | +if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') { |
|
| 56 | + $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING); |
|
| 57 | +} |
|
| 37 | 58 | |
| 38 | 59 | if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) { |
| 39 | 60 | $min = true; |
@@ -87,20 +108,30 @@ discard block |
||
| 87 | 108 | } |
| 88 | 109 | */ |
| 89 | 110 | $flightcnt = count($spotter_array); |
| 90 | - if ($flightcnt == '') $flightcnt = 0; |
|
| 91 | -} else $flightcnt = 0; |
|
| 111 | + if ($flightcnt == '') { |
|
| 112 | + $flightcnt = 0; |
|
| 113 | + } |
|
| 114 | + } else { |
|
| 115 | + $flightcnt = 0; |
|
| 116 | +} |
|
| 92 | 117 | |
| 93 | 118 | $sqltime = round(microtime(true)-$begintime,2); |
| 94 | 119 | |
| 95 | -if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) $usenextlatlon = false; |
|
| 96 | -else $usenextlatlon = true; |
|
| 120 | +if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) { |
|
| 121 | + $usenextlatlon = false; |
|
| 122 | +} else { |
|
| 123 | + $usenextlatlon = true; |
|
| 124 | +} |
|
| 97 | 125 | $j = 0; |
| 98 | 126 | $prev_flightaware_id = ''; |
| 99 | 127 | $aircrafts_shadow = array(); |
| 100 | 128 | $output = '{'; |
| 101 | 129 | $output .= '"type": "FeatureCollection",'; |
| 102 | - if ($min) $output .= '"minimal": "true",'; |
|
| 103 | - else $output .= '"minimal": "false",'; |
|
| 130 | + if ($min) { |
|
| 131 | + $output .= '"minimal": "true",'; |
|
| 132 | + } else { |
|
| 133 | + $output .= '"minimal": "false",'; |
|
| 134 | + } |
|
| 104 | 135 | $output .= '"fc": "'.$flightcnt.'",'; |
| 105 | 136 | $output .= '"sqt": "'.$sqltime.'",'; |
| 106 | 137 | |
@@ -137,11 +168,16 @@ discard block |
||
| 137 | 168 | //$output .= '"sqt": "'.$sqltime.'",'; |
| 138 | 169 | $output .= '"id": "'.$spotter_item['flightaware_id'].'",'; |
| 139 | 170 | $output .= '"properties": {'; |
| 140 | - if ($compress) $output .= '"fi": "'.$spotter_item['flightaware_id'].'",'; |
|
| 141 | - else $output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",'; |
|
| 171 | + if ($compress) { |
|
| 172 | + $output .= '"fi": "'.$spotter_item['flightaware_id'].'",'; |
|
| 173 | + } else { |
|
| 174 | + $output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",'; |
|
| 175 | + } |
|
| 142 | 176 | $output .= '"fc": "'.$flightcnt.'",'; |
| 143 | 177 | $output .= '"sqt": "'.$sqltime.'",'; |
| 144 | - if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",'; |
|
| 178 | + if (isset($begindate)) { |
|
| 179 | + $output .= '"archive_date": "'.$begindate.'",'; |
|
| 180 | + } |
|
| 145 | 181 | |
| 146 | 182 | /* |
| 147 | 183 | if ($min) $output .= '"minimal": "true",'; |
@@ -149,13 +185,21 @@ discard block |
||
| 149 | 185 | */ |
| 150 | 186 | //$output .= '"fc": "'.$spotter_item['nb'].'",'; |
| 151 | 187 | if (isset($spotter_item['ident']) && $spotter_item['ident'] != '') { |
| 152 | - if ($compress) $output .= '"c": "'.$spotter_item['ident'].'",'; |
|
| 153 | - else $output .= '"callsign": "'.$spotter_item['ident'].'",'; |
|
| 188 | + if ($compress) { |
|
| 189 | + $output .= '"c": "'.$spotter_item['ident'].'",'; |
|
| 190 | + } else { |
|
| 191 | + $output .= '"callsign": "'.$spotter_item['ident'].'",'; |
|
| 192 | + } |
|
| 154 | 193 | } else { |
| 155 | - if ($compress) $output .= '"c": "NA",'; |
|
| 156 | - else $output .= '"callsign": "NA",'; |
|
| 194 | + if ($compress) { |
|
| 195 | + $output .= '"c": "NA",'; |
|
| 196 | + } else { |
|
| 197 | + $output .= '"callsign": "NA",'; |
|
| 198 | + } |
|
| 199 | + } |
|
| 200 | + if (isset($spotter_item['registration'])) { |
|
| 201 | + $output .= '"registration": "'.$spotter_item['registration'].'",'; |
|
| 157 | 202 | } |
| 158 | - if (isset($spotter_item['registration'])) $output .= '"registration": "'.$spotter_item['registration'].'",'; |
|
| 159 | 203 | if (isset($spotter_item['aircraft_name']) && isset($spotter_item['aircraft_type'])) { |
| 160 | 204 | $output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')",'; |
| 161 | 205 | $output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ','_',$spotter_item['aircraft_name'])).'",'; |
@@ -168,25 +212,37 @@ discard block |
||
| 168 | 212 | $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",'; |
| 169 | 213 | } |
| 170 | 214 | if (!isset($spotter_item['aircraft_shadow'])) { |
| 171 | - if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') $spotter_item['aircraft_shadow'] = ''; |
|
| 172 | - else { |
|
| 215 | + if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') { |
|
| 216 | + $spotter_item['aircraft_shadow'] = ''; |
|
| 217 | + } else { |
|
| 173 | 218 | $aircraft_icao = $spotter_item['aircraft_icao']; |
| 174 | - if (isset($aircrafts_shadow[$aircraft_icao])) $spotter_item['aircraft_shadow'] = $aircrafts_shadow[$aircraft_icao]; |
|
| 175 | - else { |
|
| 219 | + if (isset($aircrafts_shadow[$aircraft_icao])) { |
|
| 220 | + $spotter_item['aircraft_shadow'] = $aircrafts_shadow[$aircraft_icao]; |
|
| 221 | + } else { |
|
| 176 | 222 | $aircraft_info = $Spotter->getAllAircraftInfo($spotter_item['aircraft_icao']); |
| 177 | - if (count($aircraft_info) > 0) $spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow']; |
|
| 178 | - elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') $spotter_item['aircraft_shadow'] = 'PA18.png'; |
|
| 179 | - else $spotter_item['aircraft_shadow'] = ''; |
|
| 223 | + if (count($aircraft_info) > 0) { |
|
| 224 | + $spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow']; |
|
| 225 | + } elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') { |
|
| 226 | + $spotter_item['aircraft_shadow'] = 'PA18.png'; |
|
| 227 | + } else { |
|
| 228 | + $spotter_item['aircraft_shadow'] = ''; |
|
| 229 | + } |
|
| 180 | 230 | $aircrafts_shadow[$aircraft_icao] = $spotter_item['aircraft_shadow']; |
| 181 | 231 | } |
| 182 | 232 | } |
| 183 | 233 | } |
| 184 | 234 | if ($spotter_item['aircraft_shadow'] == '') { |
| 185 | - if ($compress) $output .= '"as": "default.png",'; |
|
| 186 | - else $output .= '"aircraft_shadow": "default.png",'; |
|
| 235 | + if ($compress) { |
|
| 236 | + $output .= '"as": "default.png",'; |
|
| 237 | + } else { |
|
| 238 | + $output .= '"aircraft_shadow": "default.png",'; |
|
| 239 | + } |
|
| 187 | 240 | } else { |
| 188 | - if ($compress) $output .= '"as": "'.$spotter_item['aircraft_shadow'].'",'; |
|
| 189 | - else $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",'; |
|
| 241 | + if ($compress) { |
|
| 242 | + $output .= '"as": "'.$spotter_item['aircraft_shadow'].'",'; |
|
| 243 | + } else { |
|
| 244 | + $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",'; |
|
| 245 | + } |
|
| 190 | 246 | } |
| 191 | 247 | if (isset($spotter_item['airline_name'])) { |
| 192 | 248 | $output .= '"airline_name": "'.$spotter_item['airline_name'].'",'; |
@@ -194,8 +250,11 @@ discard block |
||
| 194 | 250 | $output .= '"airline_name": "NA",'; |
| 195 | 251 | } |
| 196 | 252 | if (isset($spotter_item['departure_airport'])) { |
| 197 | - if ($compress) $output .= '"dac": "'.$spotter_item['departure_airport'].'",'; |
|
| 198 | - else $output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",'; |
|
| 253 | + if ($compress) { |
|
| 254 | + $output .= '"dac": "'.$spotter_item['departure_airport'].'",'; |
|
| 255 | + } else { |
|
| 256 | + $output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",'; |
|
| 257 | + } |
|
| 199 | 258 | } |
| 200 | 259 | if (isset($spotter_item['departure_airport_city'])) { |
| 201 | 260 | $output .= '"departure_airport": "'.$spotter_item['departure_airport_city'].', '.$spotter_item['departure_airport_country'].'",'; |
@@ -207,8 +266,11 @@ discard block |
||
| 207 | 266 | $output .= '"arrival_airport_time": "'.$spotter_item['arrival_airport_time'].'",'; |
| 208 | 267 | } |
| 209 | 268 | if (isset($spotter_item['arrival_airport'])) { |
| 210 | - if ($compress) $output .= '"aac": "'.$spotter_item['arrival_airport'].'",'; |
|
| 211 | - else $output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",'; |
|
| 269 | + if ($compress) { |
|
| 270 | + $output .= '"aac": "'.$spotter_item['arrival_airport'].'",'; |
|
| 271 | + } else { |
|
| 272 | + $output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",'; |
|
| 273 | + } |
|
| 212 | 274 | } |
| 213 | 275 | if (isset($spotter_item['arrival_airport_city'])) { |
| 214 | 276 | $output .= '"arrival_airport": "'.$spotter_item['arrival_airport_city'].', '.$spotter_item['arrival_airport_country'].'",'; |
@@ -226,10 +288,16 @@ discard block |
||
| 226 | 288 | $output .= '"ground_speed": "'.$spotter_item['ground_speed'].'",'; |
| 227 | 289 | } |
| 228 | 290 | |
| 229 | - if ($compress) $output .= '"a": "'.$spotter_item['altitude'].'",'; |
|
| 230 | - else $output .= '"altitude": "'.$spotter_item['altitude'].'",'; |
|
| 231 | - if ($compress)$output .= '"h": "'.$spotter_item['heading'].'",'; |
|
| 232 | - else $output .= '"heading": "'.$spotter_item['heading'].'",'; |
|
| 291 | + if ($compress) { |
|
| 292 | + $output .= '"a": "'.$spotter_item['altitude'].'",'; |
|
| 293 | + } else { |
|
| 294 | + $output .= '"altitude": "'.$spotter_item['altitude'].'",'; |
|
| 295 | + } |
|
| 296 | + if ($compress) { |
|
| 297 | + $output .= '"h": "'.$spotter_item['heading'].'",'; |
|
| 298 | + } else { |
|
| 299 | + $output .= '"heading": "'.$spotter_item['heading'].'",'; |
|
| 300 | + } |
|
| 233 | 301 | |
| 234 | 302 | if (isset($archivespeed)) { |
| 235 | 303 | $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading'],$archivespeed); |
@@ -239,7 +307,9 @@ discard block |
||
| 239 | 307 | $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
| 240 | 308 | } |
| 241 | 309 | |
| 242 | - if (!$min) $output .= '"image": "'.$image.'",'; |
|
| 310 | + if (!$min) { |
|
| 311 | + $output .= '"image": "'.$image.'",'; |
|
| 312 | + } |
|
| 243 | 313 | if (isset($spotter_item['image_copyright']) && $spotter_item['image_copyright'] != '') { |
| 244 | 314 | $output .= '"image_copyright": "'.str_replace('"',"'",trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$spotter_item['image_copyright']))).'",'; |
| 245 | 315 | } |
@@ -247,8 +317,11 @@ discard block |
||
| 247 | 317 | $output .= '"image_source_website": "'.urlencode($spotter_item['image_source_website']).'",'; |
| 248 | 318 | } |
| 249 | 319 | if (isset($spotter_item['squawk'])) { |
| 250 | - if ($compress) $output .= '"sq": "'.$spotter_item['squawk'].'",'; |
|
| 251 | - else $output .= '"squawk": "'.$spotter_item['squawk'].'",'; |
|
| 320 | + if ($compress) { |
|
| 321 | + $output .= '"sq": "'.$spotter_item['squawk'].'",'; |
|
| 322 | + } else { |
|
| 323 | + $output .= '"squawk": "'.$spotter_item['squawk'].'",'; |
|
| 324 | + } |
|
| 252 | 325 | } |
| 253 | 326 | if (isset($spotter_item['squawk_usage'])) { |
| 254 | 327 | $output .= '"squawk_usage": "'.$spotter_item['squawk_usage'].'",'; |
@@ -266,8 +339,11 @@ discard block |
||
| 266 | 339 | $output .= '"acars": "'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"), '<br />',$spotter_item['acars']['message'])).'",'; |
| 267 | 340 | } |
| 268 | 341 | // type when not aircraft ? |
| 269 | - if ($compress) $output .= '"t": "aircraft"'; |
|
| 270 | - else $output .= '"type": "aircraft"'; |
|
| 342 | + if ($compress) { |
|
| 343 | + $output .= '"t": "aircraft"'; |
|
| 344 | + } else { |
|
| 345 | + $output .= '"type": "aircraft"'; |
|
| 346 | + } |
|
| 271 | 347 | $output .= '},'; |
| 272 | 348 | $output .= '"geometry": {'; |
| 273 | 349 | $output .= '"type": "Point",'; |
@@ -334,7 +410,9 @@ discard block |
||
| 334 | 410 | } |
| 335 | 411 | */ |
| 336 | 412 | $history = filter_input(INPUT_GET,'history',FILTER_SANITIZE_STRING); |
| 337 | - if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history']; |
|
| 413 | + if ($history == '' && isset($_COOKIE['history'])) { |
|
| 414 | + $history = $_COOKIE['history']; |
|
| 415 | + } |
|
| 338 | 416 | |
| 339 | 417 | if ((isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') |
| 340 | 418 | || (!isset($_COOKIE['flightpath']) |
@@ -356,8 +434,11 @@ discard block |
||
| 356 | 434 | $output_history .= ']}},'; |
| 357 | 435 | $output .= $output_history; |
| 358 | 436 | } |
| 359 | - if ($compress) $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": ['; |
|
| 360 | - else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": ['; |
|
| 437 | + if ($compress) { |
|
| 438 | + $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": ['; |
|
| 439 | + } else { |
|
| 440 | + $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": ['; |
|
| 441 | + } |
|
| 361 | 442 | } |
| 362 | 443 | $output_history .= '['; |
| 363 | 444 | $output_history .= $spotter_history['longitude'].', '; |
@@ -403,7 +484,9 @@ discard block |
||
| 403 | 484 | $output .= ']'; |
| 404 | 485 | $output .= ',"initial_sqltime": "'.$sqltime.'",'; |
| 405 | 486 | $output .= '"totaltime": "'.round(microtime(true)-$begintime,2).'",'; |
| 406 | - if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",'; |
|
| 487 | + if (isset($begindate)) { |
|
| 488 | + $output .= '"archive_date": "'.$begindate.'",'; |
|
| 489 | + } |
|
| 407 | 490 | $output .= '"fc": "'.$j.'"'; |
| 408 | 491 | } else { |
| 409 | 492 | $output .= '"features": '; |