@@ -133,6 +133,9 @@ discard block |
||
| 133 | 133 | fclose($fp); |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | + /** |
|
| 137 | + * @param string $in_file |
|
| 138 | + */ |
|
| 136 | 139 | public static function gunzip($in_file,$out_file_name = '') { |
| 137 | 140 | //echo $in_file.' -> '.$out_file_name."\n"; |
| 138 | 141 | $buffer_size = 4096; // read 4kb at a time |
@@ -318,6 +321,9 @@ discard block |
||
| 318 | 321 | } |
| 319 | 322 | |
| 320 | 323 | |
| 324 | + /** |
|
| 325 | + * @param string $latlong |
|
| 326 | + */ |
|
| 321 | 327 | public function convertDec($dms,$latlong) { |
| 322 | 328 | if ($latlong == 'latitude') { |
| 323 | 329 | $deg = substr($dms, 0, 2); |
@@ -352,6 +358,9 @@ discard block |
||
| 352 | 358 | return array('latitude' => round($latitude,5),'longitude' => round($longitude,5)); |
| 353 | 359 | } |
| 354 | 360 | |
| 361 | + /** |
|
| 362 | + * @param string $latlong |
|
| 363 | + */ |
|
| 355 | 364 | public function convertDM($coord,$latlong) { |
| 356 | 365 | if ($latlong == 'latitude') { |
| 357 | 366 | if ($coord < 0) $NSEW = 'S'; |
@@ -504,7 +513,7 @@ discard block |
||
| 504 | 513 | /** |
| 505 | 514 | * Returns list of available locales |
| 506 | 515 | * |
| 507 | - * @return array |
|
| 516 | + * @return string[] |
|
| 508 | 517 | */ |
| 509 | 518 | public function listLocaleDir() |
| 510 | 519 | { |
@@ -765,6 +774,10 @@ discard block |
||
| 765 | 774 | } |
| 766 | 775 | |
| 767 | 776 | // Come from comment : http://php.net/manual/fr/function.is-writable.php#73596 |
| 777 | + |
|
| 778 | + /** |
|
| 779 | + * @param string $path |
|
| 780 | + */ |
|
| 768 | 781 | public function is__writable($path) { |
| 769 | 782 | //will work in despite of Windows ACLs bug |
| 770 | 783 | //NOTE: use a trailing slash for folders!!! |
@@ -14,13 +14,13 @@ discard block |
||
| 14 | 14 | //protected $cookies = array(); |
| 15 | 15 | |
| 16 | 16 | /** |
| 17 | - * Get data from form result |
|
| 18 | - * @param String $url form URL |
|
| 19 | - * @param String $type type of submit form method (get or post) |
|
| 20 | - * @param String|array $data values form post method |
|
| 21 | - * @param array $headers header to submit with the form |
|
| 22 | - * @return String the result |
|
| 23 | - */ |
|
| 17 | + * Get data from form result |
|
| 18 | + * @param String $url form URL |
|
| 19 | + * @param String $type type of submit form method (get or post) |
|
| 20 | + * @param String|array $data values form post method |
|
| 21 | + * @param array $headers header to submit with the form |
|
| 22 | + * @return String the result |
|
| 23 | + */ |
|
| 24 | 24 | public function getData($url, $type = 'get', $data = '', $headers = '',$cookie = '',$referer = '',$timeout = '',$useragent = '', $sizelimit = false, $async = false, $getheaders = false) { |
| 25 | 25 | global $globalProxy, $globalForceIPv4; |
| 26 | 26 | $ch = curl_init(); |
@@ -175,10 +175,10 @@ discard block |
||
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | /** |
| 178 | - * Convert a HTML table to an array |
|
| 179 | - * @param String $data HTML page |
|
| 180 | - * @return array array of the tables in HTML page |
|
| 181 | - */ |
|
| 178 | + * Convert a HTML table to an array |
|
| 179 | + * @param String $data HTML page |
|
| 180 | + * @return array array of the tables in HTML page |
|
| 181 | + */ |
|
| 182 | 182 | public function table2array($data) { |
| 183 | 183 | if (!is_string($data)) return array(); |
| 184 | 184 | if ($data == '') return array(); |
@@ -212,10 +212,10 @@ discard block |
||
| 212 | 212 | } |
| 213 | 213 | |
| 214 | 214 | /** |
| 215 | - * Convert <p> part of a HTML page to an array |
|
| 216 | - * @param String $data HTML page |
|
| 217 | - * @return array array of the <p> in HTML page |
|
| 218 | - */ |
|
| 215 | + * Convert <p> part of a HTML page to an array |
|
| 216 | + * @param String $data HTML page |
|
| 217 | + * @return array array of the <p> in HTML page |
|
| 218 | + */ |
|
| 219 | 219 | public function text2array($data) { |
| 220 | 220 | $html = str_get_html($data); |
| 221 | 221 | if ($html === false) return array(); |
@@ -230,14 +230,14 @@ discard block |
||
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | /** |
| 233 | - * Give distance between 2 coordonnates |
|
| 234 | - * @param Float $lat latitude of first point |
|
| 235 | - * @param Float $lon longitude of first point |
|
| 236 | - * @param Float $latc latitude of second point |
|
| 237 | - * @param Float $lonc longitude of second point |
|
| 238 | - * @param String $unit km else no unit used |
|
| 239 | - * @return Float Distance in $unit |
|
| 240 | - */ |
|
| 233 | + * Give distance between 2 coordonnates |
|
| 234 | + * @param Float $lat latitude of first point |
|
| 235 | + * @param Float $lon longitude of first point |
|
| 236 | + * @param Float $latc latitude of second point |
|
| 237 | + * @param Float $lonc longitude of second point |
|
| 238 | + * @param String $unit km else no unit used |
|
| 239 | + * @return Float Distance in $unit |
|
| 240 | + */ |
|
| 241 | 241 | public function distance($lat, $lon, $latc, $lonc, $unit = 'km') { |
| 242 | 242 | if ($lat == $latc && $lon == $lonc) return 0; |
| 243 | 243 | $dist = rad2deg(acos(sin(deg2rad(floatval($lat)))*sin(deg2rad(floatval($latc)))+ cos(deg2rad(floatval($lat)))*cos(deg2rad(floatval($latc)))*cos(deg2rad(floatval($lon)-floatval($lonc)))))*60*1.1515; |
@@ -255,12 +255,12 @@ discard block |
||
| 255 | 255 | } |
| 256 | 256 | |
| 257 | 257 | /** |
| 258 | - * Give plunge between 2 altitudes and distance |
|
| 259 | - * @param Float $initial_altitude altitude of first point in m |
|
| 260 | - * @param Float $final_altitude altitude of second point in m |
|
| 261 | - * @param String $distance distance between two points in m |
|
| 262 | - * @return Float plunge |
|
| 263 | - */ |
|
| 258 | + * Give plunge between 2 altitudes and distance |
|
| 259 | + * @param Float $initial_altitude altitude of first point in m |
|
| 260 | + * @param Float $final_altitude altitude of second point in m |
|
| 261 | + * @param String $distance distance between two points in m |
|
| 262 | + * @return Float plunge |
|
| 263 | + */ |
|
| 264 | 264 | public function plunge($initial_altitude,$final_altitude,$distance) { |
| 265 | 265 | $plunge = rad2deg(asin(($final_altitude-$initial_altitude)/$distance)); |
| 266 | 266 | /* |
@@ -274,13 +274,13 @@ discard block |
||
| 274 | 274 | } |
| 275 | 275 | |
| 276 | 276 | /** |
| 277 | - * Give azimuth between 2 coordonnates |
|
| 278 | - * @param Float $lat latitude of first point |
|
| 279 | - * @param Float $lon longitude of first point |
|
| 280 | - * @param Float $latc latitude of second point |
|
| 281 | - * @param Float $lonc longitude of second point |
|
| 282 | - * @return Float Azimuth |
|
| 283 | - */ |
|
| 277 | + * Give azimuth between 2 coordonnates |
|
| 278 | + * @param Float $lat latitude of first point |
|
| 279 | + * @param Float $lon longitude of first point |
|
| 280 | + * @param Float $latc latitude of second point |
|
| 281 | + * @param Float $lonc longitude of second point |
|
| 282 | + * @return Float Azimuth |
|
| 283 | + */ |
|
| 284 | 284 | public function azimuth($lat, $lon, $latc, $lonc) { |
| 285 | 285 | $dX = $latc - $lat; |
| 286 | 286 | $dY = $lonc - $lon; |
@@ -291,11 +291,11 @@ discard block |
||
| 291 | 291 | |
| 292 | 292 | |
| 293 | 293 | /** |
| 294 | - * Check is distance realistic |
|
| 295 | - * @param int $timeDifference the time between the reception of both messages |
|
| 296 | - * @param float $distance distance covered |
|
| 297 | - * @return bool whether distance is realistic |
|
| 298 | - */ |
|
| 294 | + * Check is distance realistic |
|
| 295 | + * @param int $timeDifference the time between the reception of both messages |
|
| 296 | + * @param float $distance distance covered |
|
| 297 | + * @return bool whether distance is realistic |
|
| 298 | + */ |
|
| 299 | 299 | public function withinThreshold ($timeDifference, $distance) { |
| 300 | 300 | $x = abs($timeDifference); |
| 301 | 301 | $d = abs($distance); |
@@ -383,11 +383,11 @@ discard block |
||
| 383 | 383 | } |
| 384 | 384 | |
| 385 | 385 | /** |
| 386 | - * Copy folder contents |
|
| 387 | - * @param string $source Source path |
|
| 388 | - * @param string $dest Destination path |
|
| 389 | - * @return bool Returns true on success, false on failure |
|
| 390 | - */ |
|
| 386 | + * Copy folder contents |
|
| 387 | + * @param string $source Source path |
|
| 388 | + * @param string $dest Destination path |
|
| 389 | + * @return bool Returns true on success, false on failure |
|
| 390 | + */ |
|
| 391 | 391 | public function xcopy($source, $dest) |
| 392 | 392 | { |
| 393 | 393 | $files = glob($source.'*.*'); |
@@ -399,20 +399,20 @@ discard block |
||
| 399 | 399 | } |
| 400 | 400 | |
| 401 | 401 | /** |
| 402 | - * Check if an url exist |
|
| 403 | - * @param String $url url to check |
|
| 404 | - * @return bool Return true on succes false on failure |
|
| 405 | - */ |
|
| 402 | + * Check if an url exist |
|
| 403 | + * @param String $url url to check |
|
| 404 | + * @return bool Return true on succes false on failure |
|
| 405 | + */ |
|
| 406 | 406 | public function urlexist($url){ |
| 407 | 407 | $headers=get_headers($url); |
| 408 | 408 | return stripos($headers[0],"200 OK")?true:false; |
| 409 | 409 | } |
| 410 | 410 | |
| 411 | 411 | /** |
| 412 | - * Convert hexa to string |
|
| 413 | - * @param String $hex data in hexa |
|
| 414 | - * @return String Return result |
|
| 415 | - */ |
|
| 412 | + * Convert hexa to string |
|
| 413 | + * @param String $hex data in hexa |
|
| 414 | + * @return String Return result |
|
| 415 | + */ |
|
| 416 | 416 | public function hex2str($hex) { |
| 417 | 417 | $str = ''; |
| 418 | 418 | $hexln = strlen($hex); |
@@ -421,10 +421,10 @@ discard block |
||
| 421 | 421 | } |
| 422 | 422 | |
| 423 | 423 | /** |
| 424 | - * Convert hexa color to rgb |
|
| 425 | - * @param String $hex data in hexa |
|
| 426 | - * @return String Return result |
|
| 427 | - */ |
|
| 424 | + * Convert hexa color to rgb |
|
| 425 | + * @param String $hex data in hexa |
|
| 426 | + * @return String Return result |
|
| 427 | + */ |
|
| 428 | 428 | public function hex2rgb($hex) { |
| 429 | 429 | $hex = str_replace('#','',$hex); |
| 430 | 430 | return sscanf($hex, "%02x%02x%02x"); |
@@ -502,9 +502,9 @@ discard block |
||
| 502 | 502 | } |
| 503 | 503 | |
| 504 | 504 | /** |
| 505 | - * Returns list of available locales |
|
| 506 | - * |
|
| 507 | - * @return array |
|
| 505 | + * Returns list of available locales |
|
| 506 | + * |
|
| 507 | + * @return array |
|
| 508 | 508 | */ |
| 509 | 509 | public function listLocaleDir() |
| 510 | 510 | { |
@@ -603,100 +603,100 @@ discard block |
||
| 603 | 603 | public function remove_accents($string) { |
| 604 | 604 | if ( !preg_match('/[\x80-\xff]/', $string) ) return $string; |
| 605 | 605 | $chars = array( |
| 606 | - // Decompositions for Latin-1 Supplement |
|
| 607 | - chr(195).chr(128) => 'A', chr(195).chr(129) => 'A', |
|
| 608 | - chr(195).chr(130) => 'A', chr(195).chr(131) => 'A', |
|
| 609 | - chr(195).chr(132) => 'A', chr(195).chr(133) => 'A', |
|
| 610 | - chr(195).chr(135) => 'C', chr(195).chr(136) => 'E', |
|
| 611 | - chr(195).chr(137) => 'E', chr(195).chr(138) => 'E', |
|
| 612 | - chr(195).chr(139) => 'E', chr(195).chr(140) => 'I', |
|
| 613 | - chr(195).chr(141) => 'I', chr(195).chr(142) => 'I', |
|
| 614 | - chr(195).chr(143) => 'I', chr(195).chr(145) => 'N', |
|
| 615 | - chr(195).chr(146) => 'O', chr(195).chr(147) => 'O', |
|
| 616 | - chr(195).chr(148) => 'O', chr(195).chr(149) => 'O', |
|
| 617 | - chr(195).chr(150) => 'O', chr(195).chr(153) => 'U', |
|
| 618 | - chr(195).chr(154) => 'U', chr(195).chr(155) => 'U', |
|
| 619 | - chr(195).chr(156) => 'U', chr(195).chr(157) => 'Y', |
|
| 620 | - chr(195).chr(159) => 's', chr(195).chr(160) => 'a', |
|
| 621 | - chr(195).chr(161) => 'a', chr(195).chr(162) => 'a', |
|
| 622 | - chr(195).chr(163) => 'a', chr(195).chr(164) => 'a', |
|
| 623 | - chr(195).chr(165) => 'a', chr(195).chr(167) => 'c', |
|
| 624 | - chr(195).chr(168) => 'e', chr(195).chr(169) => 'e', |
|
| 625 | - chr(195).chr(170) => 'e', chr(195).chr(171) => 'e', |
|
| 626 | - chr(195).chr(172) => 'i', chr(195).chr(173) => 'i', |
|
| 627 | - chr(195).chr(174) => 'i', chr(195).chr(175) => 'i', |
|
| 628 | - chr(195).chr(177) => 'n', chr(195).chr(178) => 'o', |
|
| 629 | - chr(195).chr(179) => 'o', chr(195).chr(180) => 'o', |
|
| 630 | - chr(195).chr(181) => 'o', chr(195).chr(182) => 'o', |
|
| 631 | - chr(195).chr(182) => 'o', chr(195).chr(185) => 'u', |
|
| 632 | - chr(195).chr(186) => 'u', chr(195).chr(187) => 'u', |
|
| 633 | - chr(195).chr(188) => 'u', chr(195).chr(189) => 'y', |
|
| 634 | - chr(195).chr(191) => 'y', |
|
| 635 | - // Decompositions for Latin Extended-A |
|
| 636 | - chr(196).chr(128) => 'A', chr(196).chr(129) => 'a', |
|
| 637 | - chr(196).chr(130) => 'A', chr(196).chr(131) => 'a', |
|
| 638 | - chr(196).chr(132) => 'A', chr(196).chr(133) => 'a', |
|
| 639 | - chr(196).chr(134) => 'C', chr(196).chr(135) => 'c', |
|
| 640 | - chr(196).chr(136) => 'C', chr(196).chr(137) => 'c', |
|
| 641 | - chr(196).chr(138) => 'C', chr(196).chr(139) => 'c', |
|
| 642 | - chr(196).chr(140) => 'C', chr(196).chr(141) => 'c', |
|
| 643 | - chr(196).chr(142) => 'D', chr(196).chr(143) => 'd', |
|
| 644 | - chr(196).chr(144) => 'D', chr(196).chr(145) => 'd', |
|
| 645 | - chr(196).chr(146) => 'E', chr(196).chr(147) => 'e', |
|
| 646 | - chr(196).chr(148) => 'E', chr(196).chr(149) => 'e', |
|
| 647 | - chr(196).chr(150) => 'E', chr(196).chr(151) => 'e', |
|
| 648 | - chr(196).chr(152) => 'E', chr(196).chr(153) => 'e', |
|
| 649 | - chr(196).chr(154) => 'E', chr(196).chr(155) => 'e', |
|
| 650 | - chr(196).chr(156) => 'G', chr(196).chr(157) => 'g', |
|
| 651 | - chr(196).chr(158) => 'G', chr(196).chr(159) => 'g', |
|
| 652 | - chr(196).chr(160) => 'G', chr(196).chr(161) => 'g', |
|
| 653 | - chr(196).chr(162) => 'G', chr(196).chr(163) => 'g', |
|
| 654 | - chr(196).chr(164) => 'H', chr(196).chr(165) => 'h', |
|
| 655 | - chr(196).chr(166) => 'H', chr(196).chr(167) => 'h', |
|
| 656 | - chr(196).chr(168) => 'I', chr(196).chr(169) => 'i', |
|
| 657 | - chr(196).chr(170) => 'I', chr(196).chr(171) => 'i', |
|
| 658 | - chr(196).chr(172) => 'I', chr(196).chr(173) => 'i', |
|
| 659 | - chr(196).chr(174) => 'I', chr(196).chr(175) => 'i', |
|
| 660 | - chr(196).chr(176) => 'I', chr(196).chr(177) => 'i', |
|
| 661 | - chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij', |
|
| 662 | - chr(196).chr(180) => 'J', chr(196).chr(181) => 'j', |
|
| 663 | - chr(196).chr(182) => 'K', chr(196).chr(183) => 'k', |
|
| 664 | - chr(196).chr(184) => 'k', chr(196).chr(185) => 'L', |
|
| 665 | - chr(196).chr(186) => 'l', chr(196).chr(187) => 'L', |
|
| 666 | - chr(196).chr(188) => 'l', chr(196).chr(189) => 'L', |
|
| 667 | - chr(196).chr(190) => 'l', chr(196).chr(191) => 'L', |
|
| 668 | - chr(197).chr(128) => 'l', chr(197).chr(129) => 'L', |
|
| 669 | - chr(197).chr(130) => 'l', chr(197).chr(131) => 'N', |
|
| 670 | - chr(197).chr(132) => 'n', chr(197).chr(133) => 'N', |
|
| 671 | - chr(197).chr(134) => 'n', chr(197).chr(135) => 'N', |
|
| 672 | - chr(197).chr(136) => 'n', chr(197).chr(137) => 'N', |
|
| 673 | - chr(197).chr(138) => 'n', chr(197).chr(139) => 'N', |
|
| 674 | - chr(197).chr(140) => 'O', chr(197).chr(141) => 'o', |
|
| 675 | - chr(197).chr(142) => 'O', chr(197).chr(143) => 'o', |
|
| 676 | - chr(197).chr(144) => 'O', chr(197).chr(145) => 'o', |
|
| 677 | - chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe', |
|
| 678 | - chr(197).chr(148) => 'R',chr(197).chr(149) => 'r', |
|
| 679 | - chr(197).chr(150) => 'R',chr(197).chr(151) => 'r', |
|
| 680 | - chr(197).chr(152) => 'R',chr(197).chr(153) => 'r', |
|
| 681 | - chr(197).chr(154) => 'S',chr(197).chr(155) => 's', |
|
| 682 | - chr(197).chr(156) => 'S',chr(197).chr(157) => 's', |
|
| 683 | - chr(197).chr(158) => 'S',chr(197).chr(159) => 's', |
|
| 684 | - chr(197).chr(160) => 'S', chr(197).chr(161) => 's', |
|
| 685 | - chr(197).chr(162) => 'T', chr(197).chr(163) => 't', |
|
| 686 | - chr(197).chr(164) => 'T', chr(197).chr(165) => 't', |
|
| 687 | - chr(197).chr(166) => 'T', chr(197).chr(167) => 't', |
|
| 688 | - chr(197).chr(168) => 'U', chr(197).chr(169) => 'u', |
|
| 689 | - chr(197).chr(170) => 'U', chr(197).chr(171) => 'u', |
|
| 690 | - chr(197).chr(172) => 'U', chr(197).chr(173) => 'u', |
|
| 691 | - chr(197).chr(174) => 'U', chr(197).chr(175) => 'u', |
|
| 692 | - chr(197).chr(176) => 'U', chr(197).chr(177) => 'u', |
|
| 693 | - chr(197).chr(178) => 'U', chr(197).chr(179) => 'u', |
|
| 694 | - chr(197).chr(180) => 'W', chr(197).chr(181) => 'w', |
|
| 695 | - chr(197).chr(182) => 'Y', chr(197).chr(183) => 'y', |
|
| 696 | - chr(197).chr(184) => 'Y', chr(197).chr(185) => 'Z', |
|
| 697 | - chr(197).chr(186) => 'z', chr(197).chr(187) => 'Z', |
|
| 698 | - chr(197).chr(188) => 'z', chr(197).chr(189) => 'Z', |
|
| 699 | - chr(197).chr(190) => 'z', chr(197).chr(191) => 's' |
|
| 606 | + // Decompositions for Latin-1 Supplement |
|
| 607 | + chr(195).chr(128) => 'A', chr(195).chr(129) => 'A', |
|
| 608 | + chr(195).chr(130) => 'A', chr(195).chr(131) => 'A', |
|
| 609 | + chr(195).chr(132) => 'A', chr(195).chr(133) => 'A', |
|
| 610 | + chr(195).chr(135) => 'C', chr(195).chr(136) => 'E', |
|
| 611 | + chr(195).chr(137) => 'E', chr(195).chr(138) => 'E', |
|
| 612 | + chr(195).chr(139) => 'E', chr(195).chr(140) => 'I', |
|
| 613 | + chr(195).chr(141) => 'I', chr(195).chr(142) => 'I', |
|
| 614 | + chr(195).chr(143) => 'I', chr(195).chr(145) => 'N', |
|
| 615 | + chr(195).chr(146) => 'O', chr(195).chr(147) => 'O', |
|
| 616 | + chr(195).chr(148) => 'O', chr(195).chr(149) => 'O', |
|
| 617 | + chr(195).chr(150) => 'O', chr(195).chr(153) => 'U', |
|
| 618 | + chr(195).chr(154) => 'U', chr(195).chr(155) => 'U', |
|
| 619 | + chr(195).chr(156) => 'U', chr(195).chr(157) => 'Y', |
|
| 620 | + chr(195).chr(159) => 's', chr(195).chr(160) => 'a', |
|
| 621 | + chr(195).chr(161) => 'a', chr(195).chr(162) => 'a', |
|
| 622 | + chr(195).chr(163) => 'a', chr(195).chr(164) => 'a', |
|
| 623 | + chr(195).chr(165) => 'a', chr(195).chr(167) => 'c', |
|
| 624 | + chr(195).chr(168) => 'e', chr(195).chr(169) => 'e', |
|
| 625 | + chr(195).chr(170) => 'e', chr(195).chr(171) => 'e', |
|
| 626 | + chr(195).chr(172) => 'i', chr(195).chr(173) => 'i', |
|
| 627 | + chr(195).chr(174) => 'i', chr(195).chr(175) => 'i', |
|
| 628 | + chr(195).chr(177) => 'n', chr(195).chr(178) => 'o', |
|
| 629 | + chr(195).chr(179) => 'o', chr(195).chr(180) => 'o', |
|
| 630 | + chr(195).chr(181) => 'o', chr(195).chr(182) => 'o', |
|
| 631 | + chr(195).chr(182) => 'o', chr(195).chr(185) => 'u', |
|
| 632 | + chr(195).chr(186) => 'u', chr(195).chr(187) => 'u', |
|
| 633 | + chr(195).chr(188) => 'u', chr(195).chr(189) => 'y', |
|
| 634 | + chr(195).chr(191) => 'y', |
|
| 635 | + // Decompositions for Latin Extended-A |
|
| 636 | + chr(196).chr(128) => 'A', chr(196).chr(129) => 'a', |
|
| 637 | + chr(196).chr(130) => 'A', chr(196).chr(131) => 'a', |
|
| 638 | + chr(196).chr(132) => 'A', chr(196).chr(133) => 'a', |
|
| 639 | + chr(196).chr(134) => 'C', chr(196).chr(135) => 'c', |
|
| 640 | + chr(196).chr(136) => 'C', chr(196).chr(137) => 'c', |
|
| 641 | + chr(196).chr(138) => 'C', chr(196).chr(139) => 'c', |
|
| 642 | + chr(196).chr(140) => 'C', chr(196).chr(141) => 'c', |
|
| 643 | + chr(196).chr(142) => 'D', chr(196).chr(143) => 'd', |
|
| 644 | + chr(196).chr(144) => 'D', chr(196).chr(145) => 'd', |
|
| 645 | + chr(196).chr(146) => 'E', chr(196).chr(147) => 'e', |
|
| 646 | + chr(196).chr(148) => 'E', chr(196).chr(149) => 'e', |
|
| 647 | + chr(196).chr(150) => 'E', chr(196).chr(151) => 'e', |
|
| 648 | + chr(196).chr(152) => 'E', chr(196).chr(153) => 'e', |
|
| 649 | + chr(196).chr(154) => 'E', chr(196).chr(155) => 'e', |
|
| 650 | + chr(196).chr(156) => 'G', chr(196).chr(157) => 'g', |
|
| 651 | + chr(196).chr(158) => 'G', chr(196).chr(159) => 'g', |
|
| 652 | + chr(196).chr(160) => 'G', chr(196).chr(161) => 'g', |
|
| 653 | + chr(196).chr(162) => 'G', chr(196).chr(163) => 'g', |
|
| 654 | + chr(196).chr(164) => 'H', chr(196).chr(165) => 'h', |
|
| 655 | + chr(196).chr(166) => 'H', chr(196).chr(167) => 'h', |
|
| 656 | + chr(196).chr(168) => 'I', chr(196).chr(169) => 'i', |
|
| 657 | + chr(196).chr(170) => 'I', chr(196).chr(171) => 'i', |
|
| 658 | + chr(196).chr(172) => 'I', chr(196).chr(173) => 'i', |
|
| 659 | + chr(196).chr(174) => 'I', chr(196).chr(175) => 'i', |
|
| 660 | + chr(196).chr(176) => 'I', chr(196).chr(177) => 'i', |
|
| 661 | + chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij', |
|
| 662 | + chr(196).chr(180) => 'J', chr(196).chr(181) => 'j', |
|
| 663 | + chr(196).chr(182) => 'K', chr(196).chr(183) => 'k', |
|
| 664 | + chr(196).chr(184) => 'k', chr(196).chr(185) => 'L', |
|
| 665 | + chr(196).chr(186) => 'l', chr(196).chr(187) => 'L', |
|
| 666 | + chr(196).chr(188) => 'l', chr(196).chr(189) => 'L', |
|
| 667 | + chr(196).chr(190) => 'l', chr(196).chr(191) => 'L', |
|
| 668 | + chr(197).chr(128) => 'l', chr(197).chr(129) => 'L', |
|
| 669 | + chr(197).chr(130) => 'l', chr(197).chr(131) => 'N', |
|
| 670 | + chr(197).chr(132) => 'n', chr(197).chr(133) => 'N', |
|
| 671 | + chr(197).chr(134) => 'n', chr(197).chr(135) => 'N', |
|
| 672 | + chr(197).chr(136) => 'n', chr(197).chr(137) => 'N', |
|
| 673 | + chr(197).chr(138) => 'n', chr(197).chr(139) => 'N', |
|
| 674 | + chr(197).chr(140) => 'O', chr(197).chr(141) => 'o', |
|
| 675 | + chr(197).chr(142) => 'O', chr(197).chr(143) => 'o', |
|
| 676 | + chr(197).chr(144) => 'O', chr(197).chr(145) => 'o', |
|
| 677 | + chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe', |
|
| 678 | + chr(197).chr(148) => 'R',chr(197).chr(149) => 'r', |
|
| 679 | + chr(197).chr(150) => 'R',chr(197).chr(151) => 'r', |
|
| 680 | + chr(197).chr(152) => 'R',chr(197).chr(153) => 'r', |
|
| 681 | + chr(197).chr(154) => 'S',chr(197).chr(155) => 's', |
|
| 682 | + chr(197).chr(156) => 'S',chr(197).chr(157) => 's', |
|
| 683 | + chr(197).chr(158) => 'S',chr(197).chr(159) => 's', |
|
| 684 | + chr(197).chr(160) => 'S', chr(197).chr(161) => 's', |
|
| 685 | + chr(197).chr(162) => 'T', chr(197).chr(163) => 't', |
|
| 686 | + chr(197).chr(164) => 'T', chr(197).chr(165) => 't', |
|
| 687 | + chr(197).chr(166) => 'T', chr(197).chr(167) => 't', |
|
| 688 | + chr(197).chr(168) => 'U', chr(197).chr(169) => 'u', |
|
| 689 | + chr(197).chr(170) => 'U', chr(197).chr(171) => 'u', |
|
| 690 | + chr(197).chr(172) => 'U', chr(197).chr(173) => 'u', |
|
| 691 | + chr(197).chr(174) => 'U', chr(197).chr(175) => 'u', |
|
| 692 | + chr(197).chr(176) => 'U', chr(197).chr(177) => 'u', |
|
| 693 | + chr(197).chr(178) => 'U', chr(197).chr(179) => 'u', |
|
| 694 | + chr(197).chr(180) => 'W', chr(197).chr(181) => 'w', |
|
| 695 | + chr(197).chr(182) => 'Y', chr(197).chr(183) => 'y', |
|
| 696 | + chr(197).chr(184) => 'Y', chr(197).chr(185) => 'Z', |
|
| 697 | + chr(197).chr(186) => 'z', chr(197).chr(187) => 'Z', |
|
| 698 | + chr(197).chr(188) => 'z', chr(197).chr(189) => 'Z', |
|
| 699 | + chr(197).chr(190) => 'z', chr(197).chr(191) => 's' |
|
| 700 | 700 | ); |
| 701 | 701 | $string = strtr($string, $chars); |
| 702 | 702 | return $string; |
@@ -837,7 +837,7 @@ discard block |
||
| 837 | 837 | $dfX = $first_pass[$j][0]; |
| 838 | 838 | $dfDiffLong = abs($dfX - $dfPrevX); |
| 839 | 839 | if ($dfDiffLong > $dfDiffSpace && |
| 840 | - (($dfX > $dfLeftBorderX && $dfPrevX < $dfRightBorderX) || ($dfPrevX > $dfLeftBorderX && $dfX < $dfRightBorderX))) |
|
| 840 | + (($dfX > $dfLeftBorderX && $dfPrevX < $dfRightBorderX) || ($dfPrevX > $dfLeftBorderX && $dfX < $dfRightBorderX))) |
|
| 841 | 841 | { |
| 842 | 842 | $bHasBigDiff = true; |
| 843 | 843 | } else if ($dfDiffLong > $dfMaxSmallDiffLong) { |
@@ -857,8 +857,8 @@ discard block |
||
| 857 | 857 | $dfX2 = floatval($first_pass[$k][0]); |
| 858 | 858 | $dfY2 = floatval($first_pass[$k][1]); |
| 859 | 859 | if ($dfX1 > -180 && $dfX1 < $dfRightBorderX && $dfX2 == 180 && |
| 860 | - $k+1 < count($first_pass) && |
|
| 861 | - $first_pass[$k-1][0] > -180 && $first_pass[$k-1][0] < $dfRightBorderX) |
|
| 860 | + $k+1 < count($first_pass) && |
|
| 861 | + $first_pass[$k-1][0] > -180 && $first_pass[$k-1][0] < $dfRightBorderX) |
|
| 862 | 862 | { |
| 863 | 863 | $poNewLS[] = array(-180, $first_pass[$k][1]); |
| 864 | 864 | $k++; |
@@ -866,8 +866,8 @@ discard block |
||
| 866 | 866 | $poNewLS[] = array($first_pass[$k][0], $first_pass[$k][1]); |
| 867 | 867 | continue; |
| 868 | 868 | } else if ($dfX1 > $dfLeftBorderX && $dfX1 < 180 && $dfX2 == -180 && |
| 869 | - $k+1 < $first_pass_ln && |
|
| 870 | - $first_pass[$k-1][0] > $dfLeftBorderX && $first_pass[$k-1][0] < 180) |
|
| 869 | + $k+1 < $first_pass_ln && |
|
| 870 | + $first_pass[$k-1][0] > $dfLeftBorderX && $first_pass[$k-1][0] < 180) |
|
| 871 | 871 | { |
| 872 | 872 | $poNewLS[] = array(180, $first_pass[$k][1]); |
| 873 | 873 | $k++; |
@@ -21,12 +21,12 @@ discard block |
||
| 21 | 21 | * @param array $headers header to submit with the form |
| 22 | 22 | * @return String the result |
| 23 | 23 | */ |
| 24 | - public function getData($url, $type = 'get', $data = '', $headers = '',$cookie = '',$referer = '',$timeout = '',$useragent = '', $sizelimit = false, $async = false, $getheaders = false) { |
|
| 24 | + public function getData($url, $type = 'get', $data = '', $headers = '', $cookie = '', $referer = '', $timeout = '', $useragent = '', $sizelimit = false, $async = false, $getheaders = false) { |
|
| 25 | 25 | global $globalProxy, $globalForceIPv4; |
| 26 | 26 | $ch = curl_init(); |
| 27 | 27 | curl_setopt($ch, CURLOPT_URL, $url); |
| 28 | 28 | if (isset($globalForceIPv4) && $globalForceIPv4) { |
| 29 | - if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')){ |
|
| 29 | + if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')) { |
|
| 30 | 30 | curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); |
| 31 | 31 | } |
| 32 | 32 | } |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
| 38 | 38 | curl_setopt($ch, CURLINFO_HEADER_OUT, true); |
| 39 | 39 | if ($getheaders) curl_setopt($ch, CURLOPT_HEADER, 1); |
| 40 | - curl_setopt($ch,CURLOPT_ENCODING , "gzip"); |
|
| 40 | + curl_setopt($ch, CURLOPT_ENCODING, "gzip"); |
|
| 41 | 41 | //curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5'); |
| 42 | 42 | // curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; Linux x86_64; rv:42.0) Gecko/20100101 Firefox/42.0'); |
| 43 | 43 | if ($useragent == '') { |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | if (is_array($data)) { |
| 54 | 54 | curl_setopt($ch, CURLOPT_POST, count($data)); |
| 55 | 55 | $data_string = ''; |
| 56 | - foreach($data as $key=>$value) { $data_string .= $key.'='.$value.'&'; } |
|
| 56 | + foreach ($data as $key=>$value) { $data_string .= $key.'='.$value.'&'; } |
|
| 57 | 57 | rtrim($data_string, '&'); |
| 58 | 58 | curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string); |
| 59 | 59 | } else { |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | } |
| 66 | 66 | if ($cookie != '') { |
| 67 | 67 | if (is_array($cookie)) { |
| 68 | - curl_setopt($ch, CURLOPT_COOKIE, implode($cookie,';')); |
|
| 68 | + curl_setopt($ch, CURLOPT_COOKIE, implode($cookie, ';')); |
|
| 69 | 69 | } else { |
| 70 | 70 | curl_setopt($ch, CURLOPT_COOKIE, $cookie); |
| 71 | 71 | } |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | if ($sizelimit === true) { |
| 77 | 77 | curl_setopt($ch, CURLOPT_BUFFERSIZE, 128); |
| 78 | 78 | curl_setopt($ch, CURLOPT_NOPROGRESS, false); |
| 79 | - curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, function($curlr,$downloadsize, $downloaded, $uploadsize, $uploaded){ |
|
| 79 | + curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, function($curlr, $downloadsize, $downloaded, $uploadsize, $uploaded) { |
|
| 80 | 80 | return ($downloaded > (3*1024)) ? 1 : 0; |
| 81 | 81 | }); |
| 82 | 82 | } |
@@ -87,13 +87,13 @@ discard block |
||
| 87 | 87 | $result = curl_exec($ch); |
| 88 | 88 | $info = curl_getinfo($ch); |
| 89 | 89 | curl_close($ch); |
| 90 | - if ($info['http_code'] == '503' && strstr($result,'DDoS protection by CloudFlare')) { |
|
| 90 | + if ($info['http_code'] == '503' && strstr($result, 'DDoS protection by CloudFlare')) { |
|
| 91 | 91 | echo "Cloudflare Detected\n"; |
| 92 | 92 | require_once(dirname(__FILE__).'/libs/cloudflare-bypass/libraries/cloudflareClass.php'); |
| 93 | 93 | $useragent = UAgent::random(); |
| 94 | 94 | cloudflare::useUserAgent($useragent); |
| 95 | 95 | if ($clearanceCookie = cloudflare::bypass($url)) { |
| 96 | - return $this->getData($url,'get',$data,$headers,$clearanceCookie,$referer,$timeout,$useragent); |
|
| 96 | + return $this->getData($url, 'get', $data, $headers, $clearanceCookie, $referer, $timeout, $useragent); |
|
| 97 | 97 | } |
| 98 | 98 | } else { |
| 99 | 99 | return $result; |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
| 119 | 119 | if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer); |
| 120 | 120 | if (isset($globalForceIPv4) && $globalForceIPv4) { |
| 121 | - if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')){ |
|
| 121 | + if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')) { |
|
| 122 | 122 | curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); |
| 123 | 123 | } |
| 124 | 124 | } |
@@ -133,20 +133,20 @@ discard block |
||
| 133 | 133 | fclose($fp); |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | - public static function gunzip($in_file,$out_file_name = '') { |
|
| 136 | + public static function gunzip($in_file, $out_file_name = '') { |
|
| 137 | 137 | //echo $in_file.' -> '.$out_file_name."\n"; |
| 138 | 138 | $buffer_size = 4096; // read 4kb at a time |
| 139 | 139 | if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); |
| 140 | 140 | if ($in_file != '' && file_exists($in_file)) { |
| 141 | 141 | // PHP version of Ubuntu use gzopen64 instead of gzopen |
| 142 | - if (function_exists('gzopen')) $file = gzopen($in_file,'rb'); |
|
| 143 | - elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb'); |
|
| 142 | + if (function_exists('gzopen')) $file = gzopen($in_file, 'rb'); |
|
| 143 | + elseif (function_exists('gzopen64')) $file = gzopen64($in_file, 'rb'); |
|
| 144 | 144 | else { |
| 145 | 145 | echo 'gzopen not available'; |
| 146 | 146 | die; |
| 147 | 147 | } |
| 148 | 148 | $out_file = fopen($out_file_name, 'wb'); |
| 149 | - while(!gzeof($file)) { |
|
| 149 | + while (!gzeof($file)) { |
|
| 150 | 150 | fwrite($out_file, gzread($file, $buffer_size)); |
| 151 | 151 | } |
| 152 | 152 | fclose($out_file); |
@@ -154,19 +154,19 @@ discard block |
||
| 154 | 154 | } |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | - public static function bunzip2($in_file,$out_file_name = '') { |
|
| 157 | + public static function bunzip2($in_file, $out_file_name = '') { |
|
| 158 | 158 | //echo $in_file.' -> '.$out_file_name."\n"; |
| 159 | 159 | $buffer_size = 4096; // read 4kb at a time |
| 160 | 160 | if ($out_file_name == '') $out_file_name = str_replace('.bz2', '', $in_file); |
| 161 | 161 | if ($in_file != '' && file_exists($in_file)) { |
| 162 | 162 | // PHP version of Ubuntu use gzopen64 instead of gzopen |
| 163 | - if (function_exists('bzopen')) $file = bzopen($in_file,'rb'); |
|
| 163 | + if (function_exists('bzopen')) $file = bzopen($in_file, 'rb'); |
|
| 164 | 164 | else { |
| 165 | 165 | echo 'bzopen not available'; |
| 166 | 166 | die; |
| 167 | 167 | } |
| 168 | 168 | $out_file = fopen($out_file_name, 'wb'); |
| 169 | - while(!feof($file)) { |
|
| 169 | + while (!feof($file)) { |
|
| 170 | 170 | fwrite($out_file, bzread($file, $buffer_size)); |
| 171 | 171 | } |
| 172 | 172 | fclose($out_file); |
@@ -184,27 +184,27 @@ discard block |
||
| 184 | 184 | if ($data == '') return array(); |
| 185 | 185 | $html = str_get_html($data); |
| 186 | 186 | if ($html === false) return array(); |
| 187 | - $tabledata=array(); |
|
| 188 | - foreach($html->find('tr') as $element) |
|
| 187 | + $tabledata = array(); |
|
| 188 | + foreach ($html->find('tr') as $element) |
|
| 189 | 189 | { |
| 190 | 190 | $td = array(); |
| 191 | - foreach( $element->find('th') as $row) |
|
| 191 | + foreach ($element->find('th') as $row) |
|
| 192 | 192 | { |
| 193 | 193 | $td [] = trim($row->plaintext); |
| 194 | 194 | } |
| 195 | - $td=array_filter($td); |
|
| 195 | + $td = array_filter($td); |
|
| 196 | 196 | $tabledata[] = $td; |
| 197 | 197 | |
| 198 | 198 | $td = array(); |
| 199 | 199 | $tdi = array(); |
| 200 | - foreach( $element->find('td') as $row) |
|
| 200 | + foreach ($element->find('td') as $row) |
|
| 201 | 201 | { |
| 202 | 202 | $td [] = trim($row->plaintext); |
| 203 | 203 | $tdi [] = trim($row->innertext); |
| 204 | 204 | } |
| 205 | - $td=array_filter($td); |
|
| 206 | - $tdi=array_filter($tdi); |
|
| 207 | - $tabledata[]=array_merge($td,$tdi); |
|
| 205 | + $td = array_filter($td); |
|
| 206 | + $tdi = array_filter($tdi); |
|
| 207 | + $tabledata[] = array_merge($td, $tdi); |
|
| 208 | 208 | } |
| 209 | 209 | $html->clear(); |
| 210 | 210 | unset($html); |
@@ -219,8 +219,8 @@ discard block |
||
| 219 | 219 | public function text2array($data) { |
| 220 | 220 | $html = str_get_html($data); |
| 221 | 221 | if ($html === false) return array(); |
| 222 | - $tabledata=array(); |
|
| 223 | - foreach($html->find('p') as $element) |
|
| 222 | + $tabledata = array(); |
|
| 223 | + foreach ($html->find('p') as $element) |
|
| 224 | 224 | { |
| 225 | 225 | $tabledata [] = trim($element->plaintext); |
| 226 | 226 | } |
@@ -240,11 +240,11 @@ discard block |
||
| 240 | 240 | */ |
| 241 | 241 | public function distance($lat, $lon, $latc, $lonc, $unit = 'km') { |
| 242 | 242 | if ($lat == $latc && $lon == $lonc) return 0; |
| 243 | - $dist = rad2deg(acos(sin(deg2rad(floatval($lat)))*sin(deg2rad(floatval($latc)))+ cos(deg2rad(floatval($lat)))*cos(deg2rad(floatval($latc)))*cos(deg2rad(floatval($lon)-floatval($lonc)))))*60*1.1515; |
|
| 243 | + $dist = rad2deg(acos(sin(deg2rad(floatval($lat)))*sin(deg2rad(floatval($latc))) + cos(deg2rad(floatval($lat)))*cos(deg2rad(floatval($latc)))*cos(deg2rad(floatval($lon) - floatval($lonc)))))*60*1.1515; |
|
| 244 | 244 | if ($unit == "km") { |
| 245 | - return round($dist * 1.609344); |
|
| 245 | + return round($dist*1.609344); |
|
| 246 | 246 | } elseif ($unit == "m") { |
| 247 | - return round($dist * 1.609344 * 1000); |
|
| 247 | + return round($dist*1.609344*1000); |
|
| 248 | 248 | } elseif ($unit == "mile" || $unit == "mi") { |
| 249 | 249 | return round($dist); |
| 250 | 250 | } elseif ($unit == "nm") { |
@@ -261,8 +261,8 @@ discard block |
||
| 261 | 261 | * @param String $distance distance between two points in m |
| 262 | 262 | * @return Float plunge |
| 263 | 263 | */ |
| 264 | - public function plunge($initial_altitude,$final_altitude,$distance) { |
|
| 265 | - $plunge = rad2deg(asin(($final_altitude-$initial_altitude)/$distance)); |
|
| 264 | + public function plunge($initial_altitude, $final_altitude, $distance) { |
|
| 265 | + $plunge = rad2deg(asin(($final_altitude - $initial_altitude)/$distance)); |
|
| 266 | 266 | /* |
| 267 | 267 | $siter = 6378137.0 + $initial_altitude; |
| 268 | 268 | $planer = 6378137.0 + $final_altitude; |
@@ -284,8 +284,8 @@ discard block |
||
| 284 | 284 | public function azimuth($lat, $lon, $latc, $lonc) { |
| 285 | 285 | $dX = $latc - $lat; |
| 286 | 286 | $dY = $lonc - $lon; |
| 287 | - $azimuth = rad2deg(atan2($dY,$dX)); |
|
| 288 | - if ($azimuth < 0) return $azimuth+360; |
|
| 287 | + $azimuth = rad2deg(atan2($dY, $dX)); |
|
| 288 | + if ($azimuth < 0) return $azimuth + 360; |
|
| 289 | 289 | return $azimuth; |
| 290 | 290 | } |
| 291 | 291 | |
@@ -296,7 +296,7 @@ discard block |
||
| 296 | 296 | * @param float $distance distance covered |
| 297 | 297 | * @return bool whether distance is realistic |
| 298 | 298 | */ |
| 299 | - public function withinThreshold ($timeDifference, $distance) { |
|
| 299 | + public function withinThreshold($timeDifference, $distance) { |
|
| 300 | 300 | $x = abs($timeDifference); |
| 301 | 301 | $d = abs($distance); |
| 302 | 302 | if ($x == 0 || $d == 0) return true; |
@@ -312,13 +312,13 @@ discard block |
||
| 312 | 312 | return ($array !== array_values($array)); |
| 313 | 313 | } |
| 314 | 314 | |
| 315 | - public function isInteger($input){ |
|
| 315 | + public function isInteger($input) { |
|
| 316 | 316 | //return(ctype_digit(strval($input))); |
| 317 | - return preg_match('/^-?[0-9]+$/', (string)$input) ? true : false; |
|
| 317 | + return preg_match('/^-?[0-9]+$/', (string) $input) ? true : false; |
|
| 318 | 318 | } |
| 319 | 319 | |
| 320 | 320 | |
| 321 | - public function convertDec($dms,$latlong) { |
|
| 321 | + public function convertDec($dms, $latlong) { |
|
| 322 | 322 | if ($latlong == 'latitude') { |
| 323 | 323 | $deg = substr($dms, 0, 2); |
| 324 | 324 | $min = substr($dms, 2, 4); |
@@ -326,33 +326,33 @@ discard block |
||
| 326 | 326 | $deg = substr($dms, 0, 3); |
| 327 | 327 | $min = substr($dms, 3, 5); |
| 328 | 328 | } |
| 329 | - return $deg+(($min*60)/3600); |
|
| 329 | + return $deg + (($min*60)/3600); |
|
| 330 | 330 | } |
| 331 | 331 | |
| 332 | 332 | public function convertDecLatLong($coord) { |
| 333 | 333 | //N43°36.763' W5°46.845' |
| 334 | - $coords = explode(' ',$coord); |
|
| 334 | + $coords = explode(' ', $coord); |
|
| 335 | 335 | $latitude = ''; |
| 336 | 336 | $longitude = ''; |
| 337 | 337 | foreach ($coords as $latlong) { |
| 338 | - $type = substr($latlong,0,1); |
|
| 339 | - $degmin = explode('°',substr($latlong,1,-1)); |
|
| 338 | + $type = substr($latlong, 0, 1); |
|
| 339 | + $degmin = explode('°', substr($latlong, 1, -1)); |
|
| 340 | 340 | $deg = $degmin[0]; |
| 341 | 341 | $min = $degmin[1]; |
| 342 | 342 | if ($type == 'N') { |
| 343 | - $latitude = $deg+(($min*60)/3600); |
|
| 343 | + $latitude = $deg + (($min*60)/3600); |
|
| 344 | 344 | } elseif ($type == 'S') { |
| 345 | - $latitude = -($deg+(($min*60)/3600)); |
|
| 345 | + $latitude = -($deg + (($min*60)/3600)); |
|
| 346 | 346 | } elseif ($type == 'E') { |
| 347 | - $longitude = ($deg+(($min*60)/3600)); |
|
| 347 | + $longitude = ($deg + (($min*60)/3600)); |
|
| 348 | 348 | } elseif ($type == 'W') { |
| 349 | - $longitude = -($deg+(($min*60)/3600)); |
|
| 349 | + $longitude = -($deg + (($min*60)/3600)); |
|
| 350 | 350 | } |
| 351 | 351 | } |
| 352 | - return array('latitude' => round($latitude,5),'longitude' => round($longitude,5)); |
|
| 352 | + return array('latitude' => round($latitude, 5), 'longitude' => round($longitude, 5)); |
|
| 353 | 353 | } |
| 354 | 354 | |
| 355 | - public function convertDM($coord,$latlong) { |
|
| 355 | + public function convertDM($coord, $latlong) { |
|
| 356 | 356 | if ($latlong == 'latitude') { |
| 357 | 357 | if ($coord < 0) $NSEW = 'S'; |
| 358 | 358 | else $NSEW = 'N'; |
@@ -362,11 +362,11 @@ discard block |
||
| 362 | 362 | } |
| 363 | 363 | $coord = abs($coord); |
| 364 | 364 | $deg = floor($coord); |
| 365 | - $coord = ($coord-$deg)*60; |
|
| 365 | + $coord = ($coord - $deg)*60; |
|
| 366 | 366 | $min = $coord; |
| 367 | - return array('deg' => $deg,'min' => $min,'NSEW' => $NSEW); |
|
| 367 | + return array('deg' => $deg, 'min' => $min, 'NSEW' => $NSEW); |
|
| 368 | 368 | } |
| 369 | - public function convertDMS($coord,$latlong) { |
|
| 369 | + public function convertDMS($coord, $latlong) { |
|
| 370 | 370 | if ($latlong == 'latitude') { |
| 371 | 371 | if ($coord < 0) $NSEW = 'S'; |
| 372 | 372 | else $NSEW = 'N'; |
@@ -376,10 +376,10 @@ discard block |
||
| 376 | 376 | } |
| 377 | 377 | $coord = abs($coord); |
| 378 | 378 | $deg = floor($coord); |
| 379 | - $coord = ($coord-$deg)*60; |
|
| 379 | + $coord = ($coord - $deg)*60; |
|
| 380 | 380 | $min = floor($coord); |
| 381 | - $sec = round(($coord-$min)*60); |
|
| 382 | - return array('deg' => $deg,'min' => $min,'sec' => $sec,'NSEW' => $NSEW); |
|
| 381 | + $sec = round(($coord - $min)*60); |
|
| 382 | + return array('deg' => $deg, 'min' => $min, 'sec' => $sec, 'NSEW' => $NSEW); |
|
| 383 | 383 | } |
| 384 | 384 | |
| 385 | 385 | /** |
@@ -391,8 +391,8 @@ discard block |
||
| 391 | 391 | public function xcopy($source, $dest) |
| 392 | 392 | { |
| 393 | 393 | $files = glob($source.'*.*'); |
| 394 | - foreach($files as $file){ |
|
| 395 | - $file_to_go = str_replace($source,$dest,$file); |
|
| 394 | + foreach ($files as $file) { |
|
| 395 | + $file_to_go = str_replace($source, $dest, $file); |
|
| 396 | 396 | copy($file, $file_to_go); |
| 397 | 397 | } |
| 398 | 398 | return true; |
@@ -403,9 +403,9 @@ discard block |
||
| 403 | 403 | * @param String $url url to check |
| 404 | 404 | * @return bool Return true on succes false on failure |
| 405 | 405 | */ |
| 406 | - public function urlexist($url){ |
|
| 407 | - $headers=get_headers($url); |
|
| 408 | - return stripos($headers[0],"200 OK")?true:false; |
|
| 406 | + public function urlexist($url) { |
|
| 407 | + $headers = get_headers($url); |
|
| 408 | + return stripos($headers[0], "200 OK") ?true:false; |
|
| 409 | 409 | } |
| 410 | 410 | |
| 411 | 411 | /** |
@@ -416,7 +416,7 @@ discard block |
||
| 416 | 416 | public function hex2str($hex) { |
| 417 | 417 | $str = ''; |
| 418 | 418 | $hexln = strlen($hex); |
| 419 | - for($i=0;$i<$hexln;$i+=2) $str .= chr(hexdec(substr($hex,$i,2))); |
|
| 419 | + for ($i = 0; $i < $hexln; $i += 2) $str .= chr(hexdec(substr($hex, $i, 2))); |
|
| 420 | 420 | return $str; |
| 421 | 421 | } |
| 422 | 422 | |
@@ -426,7 +426,7 @@ discard block |
||
| 426 | 426 | * @return String Return result |
| 427 | 427 | */ |
| 428 | 428 | public function hex2rgb($hex) { |
| 429 | - $hex = str_replace('#','',$hex); |
|
| 429 | + $hex = str_replace('#', '', $hex); |
|
| 430 | 430 | return sscanf($hex, "%02x%02x%02x"); |
| 431 | 431 | } |
| 432 | 432 | |
@@ -434,33 +434,33 @@ discard block |
||
| 434 | 434 | //difference in longitudinal coordinates |
| 435 | 435 | $dLon = deg2rad($lon2) - deg2rad($lon1); |
| 436 | 436 | //difference in the phi of latitudinal coordinates |
| 437 | - $dPhi = log(tan(deg2rad($lat2) / 2 + M_PI / 4) / tan(deg2rad($lat1) / 2 + M_PI / 4)); |
|
| 437 | + $dPhi = log(tan(deg2rad($lat2)/2 + M_PI/4)/tan(deg2rad($lat1)/2 + M_PI/4)); |
|
| 438 | 438 | //we need to recalculate $dLon if it is greater than pi |
| 439 | - if(abs($dLon) > M_PI) { |
|
| 440 | - if($dLon > 0) { |
|
| 441 | - $dLon = (2 * M_PI - $dLon) * -1; |
|
| 439 | + if (abs($dLon) > M_PI) { |
|
| 440 | + if ($dLon > 0) { |
|
| 441 | + $dLon = (2*M_PI - $dLon)*-1; |
|
| 442 | 442 | } else { |
| 443 | - $dLon = 2 * M_PI + $dLon; |
|
| 443 | + $dLon = 2*M_PI + $dLon; |
|
| 444 | 444 | } |
| 445 | 445 | } |
| 446 | 446 | //return the angle, normalized |
| 447 | - return (rad2deg(atan2($dLon, $dPhi)) + 360) % 360; |
|
| 447 | + return (rad2deg(atan2($dLon, $dPhi)) + 360)%360; |
|
| 448 | 448 | } |
| 449 | 449 | |
| 450 | - public function checkLine($lat1,$lon1,$lat2,$lon2,$lat3,$lon3,$approx = 0.15) { |
|
| 450 | + public function checkLine($lat1, $lon1, $lat2, $lon2, $lat3, $lon3, $approx = 0.15) { |
|
| 451 | 451 | //$a = ($lon2-$lon1)*$lat3+($lat2-$lat1)*$lon3+($lat1*$lon2+$lat2*$lon1); |
| 452 | - $a = -($lon2-$lon1); |
|
| 452 | + $a = -($lon2 - $lon1); |
|
| 453 | 453 | $b = $lat2 - $lat1; |
| 454 | - $c = -($a*$lat1+$b*$lon1); |
|
| 455 | - $d = $a*$lat3+$b*$lon3+$c; |
|
| 454 | + $c = -($a*$lat1 + $b*$lon1); |
|
| 455 | + $d = $a*$lat3 + $b*$lon3 + $c; |
|
| 456 | 456 | if ($d > -$approx && $d < $approx) return true; |
| 457 | 457 | else return false; |
| 458 | 458 | } |
| 459 | 459 | |
| 460 | 460 | public function array_merge_noappend() { |
| 461 | 461 | $output = array(); |
| 462 | - foreach(func_get_args() as $array) { |
|
| 463 | - foreach($array as $key => $value) { |
|
| 462 | + foreach (func_get_args() as $array) { |
|
| 463 | + foreach ($array as $key => $value) { |
|
| 464 | 464 | $output[$key] = isset($output[$key]) ? |
| 465 | 465 | array_merge($output[$key], $value) : $value; |
| 466 | 466 | } |
@@ -524,7 +524,7 @@ discard block |
||
| 524 | 524 | return $result; |
| 525 | 525 | } |
| 526 | 526 | |
| 527 | - public function nextcoord($latitude, $longitude, $speed, $heading, $archivespeed = 1, $seconds = ''){ |
|
| 527 | + public function nextcoord($latitude, $longitude, $speed, $heading, $archivespeed = 1, $seconds = '') { |
|
| 528 | 528 | global $globalMapRefresh; |
| 529 | 529 | if ($seconds == '') { |
| 530 | 530 | $distance = ($speed*0.514444*$globalMapRefresh*$archivespeed)/1000; |
@@ -535,27 +535,27 @@ discard block |
||
| 535 | 535 | $latitude = deg2rad($latitude); |
| 536 | 536 | $longitude = deg2rad($longitude); |
| 537 | 537 | $bearing = deg2rad($heading); |
| 538 | - $latitude2 = asin( (sin($latitude) * cos($distance/$r)) + (cos($latitude) * sin($distance/$r) * cos($bearing)) ); |
|
| 539 | - $longitude2 = $longitude + atan2( sin($bearing)*sin($distance/$r)*cos($latitude), cos($distance/$r)-(sin($latitude)*sin($latitude2)) ); |
|
| 540 | - return array('latitude' => number_format(rad2deg($latitude2),5,'.',''),'longitude' => number_format(rad2deg($longitude2),5,'.','')); |
|
| 538 | + $latitude2 = asin((sin($latitude)*cos($distance/$r)) + (cos($latitude)*sin($distance/$r)*cos($bearing))); |
|
| 539 | + $longitude2 = $longitude + atan2(sin($bearing)*sin($distance/$r)*cos($latitude), cos($distance/$r) - (sin($latitude)*sin($latitude2))); |
|
| 540 | + return array('latitude' => number_format(rad2deg($latitude2), 5, '.', ''), 'longitude' => number_format(rad2deg($longitude2), 5, '.', '')); |
|
| 541 | 541 | } |
| 542 | 542 | |
| 543 | - public function getCoordfromDistanceBearing($latitude,$longitude,$bearing,$distance) { |
|
| 543 | + public function getCoordfromDistanceBearing($latitude, $longitude, $bearing, $distance) { |
|
| 544 | 544 | // distance in meter |
| 545 | 545 | $R = 6378.14; |
| 546 | - $latitude1 = $latitude * (M_PI/180); |
|
| 547 | - $longitude1 = $longitude * (M_PI/180); |
|
| 548 | - $brng = $bearing * (M_PI/180); |
|
| 546 | + $latitude1 = $latitude*(M_PI/180); |
|
| 547 | + $longitude1 = $longitude*(M_PI/180); |
|
| 548 | + $brng = $bearing*(M_PI/180); |
|
| 549 | 549 | $d = $distance; |
| 550 | 550 | |
| 551 | 551 | $latitude2 = asin(sin($latitude1)*cos($d/$R) + cos($latitude1)*sin($d/$R)*cos($brng)); |
| 552 | - $longitude2 = $longitude1 + atan2(sin($brng)*sin($d/$R)*cos($latitude1),cos($d/$R)-sin($latitude1)*sin($latitude2)); |
|
| 552 | + $longitude2 = $longitude1 + atan2(sin($brng)*sin($d/$R)*cos($latitude1), cos($d/$R) - sin($latitude1)*sin($latitude2)); |
|
| 553 | 553 | |
| 554 | - $latitude2 = $latitude2 * (180/M_PI); |
|
| 555 | - $longitude2 = $longitude2 * (180/M_PI); |
|
| 554 | + $latitude2 = $latitude2*(180/M_PI); |
|
| 555 | + $longitude2 = $longitude2*(180/M_PI); |
|
| 556 | 556 | |
| 557 | - $flat = round ($latitude2,6); |
|
| 558 | - $flong = round ($longitude2,6); |
|
| 557 | + $flat = round($latitude2, 6); |
|
| 558 | + $flong = round($longitude2, 6); |
|
| 559 | 559 | /* |
| 560 | 560 | $dx = $distance*cos($bearing); |
| 561 | 561 | $dy = $distance*sin($bearing); |
@@ -564,7 +564,7 @@ discard block |
||
| 564 | 564 | $flong = $longitude + $dlong; |
| 565 | 565 | $flat = $latitude + $dlat; |
| 566 | 566 | */ |
| 567 | - return array('latitude' => $flat,'longitude' => $flong); |
|
| 567 | + return array('latitude' => $flat, 'longitude' => $flong); |
|
| 568 | 568 | } |
| 569 | 569 | |
| 570 | 570 | /** |
@@ -578,14 +578,14 @@ discard block |
||
| 578 | 578 | * @param integer $level GZIP compression level (default: 9) |
| 579 | 579 | * @return string New filename (with .gz appended) if success, or false if operation fails |
| 580 | 580 | */ |
| 581 | - public function gzCompressFile($source, $level = 9){ |
|
| 582 | - $dest = $source . '.gz'; |
|
| 583 | - $mode = 'wb' . $level; |
|
| 581 | + public function gzCompressFile($source, $level = 9) { |
|
| 582 | + $dest = $source.'.gz'; |
|
| 583 | + $mode = 'wb'.$level; |
|
| 584 | 584 | $error = false; |
| 585 | 585 | if ($fp_out = gzopen($dest, $mode)) { |
| 586 | - if ($fp_in = fopen($source,'rb')) { |
|
| 586 | + if ($fp_in = fopen($source, 'rb')) { |
|
| 587 | 587 | while (!feof($fp_in)) |
| 588 | - gzwrite($fp_out, fread($fp_in, 1024 * 512)); |
|
| 588 | + gzwrite($fp_out, fread($fp_in, 1024*512)); |
|
| 589 | 589 | fclose($fp_in); |
| 590 | 590 | } else { |
| 591 | 591 | $error = true; |
@@ -601,7 +601,7 @@ discard block |
||
| 601 | 601 | } |
| 602 | 602 | |
| 603 | 603 | public function remove_accents($string) { |
| 604 | - if ( !preg_match('/[\x80-\xff]/', $string) ) return $string; |
|
| 604 | + if (!preg_match('/[\x80-\xff]/', $string)) return $string; |
|
| 605 | 605 | $chars = array( |
| 606 | 606 | // Decompositions for Latin-1 Supplement |
| 607 | 607 | chr(195).chr(128) => 'A', chr(195).chr(129) => 'A', |
@@ -658,7 +658,7 @@ discard block |
||
| 658 | 658 | chr(196).chr(172) => 'I', chr(196).chr(173) => 'i', |
| 659 | 659 | chr(196).chr(174) => 'I', chr(196).chr(175) => 'i', |
| 660 | 660 | chr(196).chr(176) => 'I', chr(196).chr(177) => 'i', |
| 661 | - chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij', |
|
| 661 | + chr(196).chr(178) => 'IJ', chr(196).chr(179) => 'ij', |
|
| 662 | 662 | chr(196).chr(180) => 'J', chr(196).chr(181) => 'j', |
| 663 | 663 | chr(196).chr(182) => 'K', chr(196).chr(183) => 'k', |
| 664 | 664 | chr(196).chr(184) => 'k', chr(196).chr(185) => 'L', |
@@ -674,13 +674,13 @@ discard block |
||
| 674 | 674 | chr(197).chr(140) => 'O', chr(197).chr(141) => 'o', |
| 675 | 675 | chr(197).chr(142) => 'O', chr(197).chr(143) => 'o', |
| 676 | 676 | chr(197).chr(144) => 'O', chr(197).chr(145) => 'o', |
| 677 | - chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe', |
|
| 678 | - chr(197).chr(148) => 'R',chr(197).chr(149) => 'r', |
|
| 679 | - chr(197).chr(150) => 'R',chr(197).chr(151) => 'r', |
|
| 680 | - chr(197).chr(152) => 'R',chr(197).chr(153) => 'r', |
|
| 681 | - chr(197).chr(154) => 'S',chr(197).chr(155) => 's', |
|
| 682 | - chr(197).chr(156) => 'S',chr(197).chr(157) => 's', |
|
| 683 | - chr(197).chr(158) => 'S',chr(197).chr(159) => 's', |
|
| 677 | + chr(197).chr(146) => 'OE', chr(197).chr(147) => 'oe', |
|
| 678 | + chr(197).chr(148) => 'R', chr(197).chr(149) => 'r', |
|
| 679 | + chr(197).chr(150) => 'R', chr(197).chr(151) => 'r', |
|
| 680 | + chr(197).chr(152) => 'R', chr(197).chr(153) => 'r', |
|
| 681 | + chr(197).chr(154) => 'S', chr(197).chr(155) => 's', |
|
| 682 | + chr(197).chr(156) => 'S', chr(197).chr(157) => 's', |
|
| 683 | + chr(197).chr(158) => 'S', chr(197).chr(159) => 's', |
|
| 684 | 684 | chr(197).chr(160) => 'S', chr(197).chr(161) => 's', |
| 685 | 685 | chr(197).chr(162) => 'T', chr(197).chr(163) => 't', |
| 686 | 686 | chr(197).chr(164) => 'T', chr(197).chr(165) => 't', |
@@ -714,7 +714,7 @@ discard block |
||
| 714 | 714 | for ($i = 0, $int = '', $concat_flag = true; $i < $length; $i++) { |
| 715 | 715 | if (is_numeric($string[$i]) && $concat_flag) { |
| 716 | 716 | $int .= $string[$i]; |
| 717 | - } elseif(!$concat && $concat_flag && strlen($int) > 0) { |
|
| 717 | + } elseif (!$concat && $concat_flag && strlen($int) > 0) { |
|
| 718 | 718 | $concat_flag = false; |
| 719 | 719 | } |
| 720 | 720 | } |
@@ -760,7 +760,7 @@ discard block |
||
| 760 | 760 | $slice = array_slice($arr, $offset + 1, $length); |
| 761 | 761 | return implode("", $slice); |
| 762 | 762 | } else { |
| 763 | - return mb_substr($string,$offset,$length,'UTF-8'); |
|
| 763 | + return mb_substr($string, $offset, $length, 'UTF-8'); |
|
| 764 | 764 | } |
| 765 | 765 | } |
| 766 | 766 | |
@@ -770,14 +770,14 @@ discard block |
||
| 770 | 770 | //NOTE: use a trailing slash for folders!!! |
| 771 | 771 | //see http://bugs.php.net/bug.php?id=27609 |
| 772 | 772 | //see http://bugs.php.net/bug.php?id=30931 |
| 773 | - if ($path{strlen($path)-1}=='/') // recursively return a temporary file path |
|
| 773 | + if ($path{strlen($path) - 1} == '/') // recursively return a temporary file path |
|
| 774 | 774 | return $this->is__writable($path.uniqid(mt_rand()).'.tmp'); |
| 775 | 775 | else if (is_dir($path)) |
| 776 | 776 | return $this->is__writable($path.'/'.uniqid(mt_rand()).'.tmp'); |
| 777 | 777 | // check tmp file for read/write capabilities |
| 778 | 778 | $rm = file_exists($path); |
| 779 | 779 | $f = @fopen($path, 'a'); |
| 780 | - if ($f===false) |
|
| 780 | + if ($f === false) |
|
| 781 | 781 | return false; |
| 782 | 782 | fclose($f); |
| 783 | 783 | if (!$rm) |
@@ -796,29 +796,29 @@ discard block |
||
| 796 | 796 | * @param Integer $offset Controls the likelyhood that lines will be split which cross the dateline |
| 797 | 797 | * @return Array Coordinate of the route |
| 798 | 798 | */ |
| 799 | - public function greatcircle($begin_lat,$begin_lon,$end_lat,$end_lon,$nbpts = 20, $offset = 10) { |
|
| 800 | - if ($nbpts <= 2) return array(array($begin_lon,$begin_lat),array($end_lon,$end_lat)); |
|
| 799 | + public function greatcircle($begin_lat, $begin_lon, $end_lat, $end_lon, $nbpts = 20, $offset = 10) { |
|
| 800 | + if ($nbpts <= 2) return array(array($begin_lon, $begin_lat), array($end_lon, $end_lat)); |
|
| 801 | 801 | $sx = deg2rad($begin_lon); |
| 802 | 802 | $sy = deg2rad($begin_lat); |
| 803 | 803 | $ex = deg2rad($end_lon); |
| 804 | 804 | $ey = deg2rad($end_lat); |
| 805 | 805 | $w = $sx - $ex; |
| 806 | 806 | $h = $sy - $ey; |
| 807 | - $z = pow(sin($h/2.0),2) + cos($sy)*cos($ey)*pow(sin($w/2.0),2); |
|
| 807 | + $z = pow(sin($h/2.0), 2) + cos($sy)*cos($ey)*pow(sin($w/2.0), 2); |
|
| 808 | 808 | $g = 2.0*asin(sqrt($z)); |
| 809 | - if ($g == M_PI || is_nan($g)) return array(array($begin_lon,$begin_lat),array($end_lon,$end_lat)); |
|
| 809 | + if ($g == M_PI || is_nan($g)) return array(array($begin_lon, $begin_lat), array($end_lon, $end_lat)); |
|
| 810 | 810 | $first_pass = array(); |
| 811 | - $delta = 1.0/($nbpts-1); |
|
| 812 | - for ($i =0; $i < $nbpts; ++$i) { |
|
| 811 | + $delta = 1.0/($nbpts - 1); |
|
| 812 | + for ($i = 0; $i < $nbpts; ++$i) { |
|
| 813 | 813 | $step = $delta*$i; |
| 814 | - $A = sin((1 - $step) * $g) / sin($g); |
|
| 815 | - $B = sin($step * $g) / sin($g); |
|
| 816 | - $x = $A * cos($sy) * cos($sx) + $B * cos($ey) * cos($ex); |
|
| 817 | - $y = $A * cos($sy) * sin($sx) + $B * cos($ey) * sin($ex); |
|
| 818 | - $z = $A * sin($sy) + $B * sin($ey); |
|
| 814 | + $A = sin((1 - $step)*$g)/sin($g); |
|
| 815 | + $B = sin($step*$g)/sin($g); |
|
| 816 | + $x = $A*cos($sy)*cos($sx) + $B*cos($ey)*cos($ex); |
|
| 817 | + $y = $A*cos($sy)*sin($sx) + $B*cos($ey)*sin($ex); |
|
| 818 | + $z = $A*sin($sy) + $B*sin($ey); |
|
| 819 | 819 | $lat = rad2deg(atan2($z, sqrt(pow($x, 2) + pow($y, 2)))); |
| 820 | 820 | $lon = rad2deg(atan2($y, $x)); |
| 821 | - $first_pass[] = array($lon,$lat); |
|
| 821 | + $first_pass[] = array($lon, $lat); |
|
| 822 | 822 | } |
| 823 | 823 | $bHasBigDiff = false; |
| 824 | 824 | $dfMaxSmallDiffLong = 0; |
@@ -833,7 +833,7 @@ discard block |
||
| 833 | 833 | // https://github.com/OSGeo/gdal/blob/7bfb9c452a59aac958bff0c8386b891edf8154ca/gdal/ogr/ogrgeometryfactory.cpp#L2342 |
| 834 | 834 | $first_pass_ln = count($first_pass); |
| 835 | 835 | for ($j = 1; $j < $first_pass_ln; ++$j) { |
| 836 | - $dfPrevX = $first_pass[$j-1][0]; |
|
| 836 | + $dfPrevX = $first_pass[$j - 1][0]; |
|
| 837 | 837 | $dfX = $first_pass[$j][0]; |
| 838 | 838 | $dfDiffLong = abs($dfX - $dfPrevX); |
| 839 | 839 | if ($dfDiffLong > $dfDiffSpace && |
@@ -851,14 +851,14 @@ discard block |
||
| 851 | 851 | //$poMulti[] = $poNewLS; |
| 852 | 852 | for ($k = 0; $k < $first_pass_ln; ++$k) { |
| 853 | 853 | $dfX0 = floatval($first_pass[$k][0]); |
| 854 | - if ($k > 0 && abs($dfX0 - $first_pass[$k-1][0]) > $dfDiffSpace) { |
|
| 855 | - $dfX1 = floatval($first_pass[$k-1][0]); |
|
| 856 | - $dfY1 = floatval($first_pass[$k-1][1]); |
|
| 854 | + if ($k > 0 && abs($dfX0 - $first_pass[$k - 1][0]) > $dfDiffSpace) { |
|
| 855 | + $dfX1 = floatval($first_pass[$k - 1][0]); |
|
| 856 | + $dfY1 = floatval($first_pass[$k - 1][1]); |
|
| 857 | 857 | $dfX2 = floatval($first_pass[$k][0]); |
| 858 | 858 | $dfY2 = floatval($first_pass[$k][1]); |
| 859 | 859 | if ($dfX1 > -180 && $dfX1 < $dfRightBorderX && $dfX2 == 180 && |
| 860 | - $k+1 < count($first_pass) && |
|
| 861 | - $first_pass[$k-1][0] > -180 && $first_pass[$k-1][0] < $dfRightBorderX) |
|
| 860 | + $k + 1 < count($first_pass) && |
|
| 861 | + $first_pass[$k - 1][0] > -180 && $first_pass[$k - 1][0] < $dfRightBorderX) |
|
| 862 | 862 | { |
| 863 | 863 | $poNewLS[] = array(-180, $first_pass[$k][1]); |
| 864 | 864 | $k++; |
@@ -866,8 +866,8 @@ discard block |
||
| 866 | 866 | $poNewLS[] = array($first_pass[$k][0], $first_pass[$k][1]); |
| 867 | 867 | continue; |
| 868 | 868 | } else if ($dfX1 > $dfLeftBorderX && $dfX1 < 180 && $dfX2 == -180 && |
| 869 | - $k+1 < $first_pass_ln && |
|
| 870 | - $first_pass[$k-1][0] > $dfLeftBorderX && $first_pass[$k-1][0] < 180) |
|
| 869 | + $k + 1 < $first_pass_ln && |
|
| 870 | + $first_pass[$k - 1][0] > $dfLeftBorderX && $first_pass[$k - 1][0] < 180) |
|
| 871 | 871 | { |
| 872 | 872 | $poNewLS[] = array(180, $first_pass[$k][1]); |
| 873 | 873 | $k++; |
@@ -890,12 +890,12 @@ discard block |
||
| 890 | 890 | } |
| 891 | 891 | if ($dfX1 <= 180 && $dfX2 >= 180 && $dfX1 < $dfX2) |
| 892 | 892 | { |
| 893 | - $dfRatio = (180 - $dfX1) / ($dfX2 - $dfX1); |
|
| 894 | - $dfY = $dfRatio * $dfY2 + (1 - $dfRatio) * $dfY1; |
|
| 895 | - $poNewLS[] = array($first_pass[$k-1][0] > $dfLeftBorderX ? 180 : -180, $dfY); |
|
| 893 | + $dfRatio = (180 - $dfX1)/($dfX2 - $dfX1); |
|
| 894 | + $dfY = $dfRatio*$dfY2 + (1 - $dfRatio)*$dfY1; |
|
| 895 | + $poNewLS[] = array($first_pass[$k - 1][0] > $dfLeftBorderX ? 180 : -180, $dfY); |
|
| 896 | 896 | $poMulti[] = $poNewLS; |
| 897 | 897 | $poNewLS = array(); |
| 898 | - $poNewLS[] = array($first_pass[$k-1][0] > $dfLeftBorderX ? -180 : 180, $dfY); |
|
| 898 | + $poNewLS[] = array($first_pass[$k - 1][0] > $dfLeftBorderX ? -180 : 180, $dfY); |
|
| 899 | 899 | //$poMulti[] = $poNewLS; |
| 900 | 900 | } else { |
| 901 | 901 | //$poNewLS[] = array(); |
@@ -913,7 +913,7 @@ discard block |
||
| 913 | 913 | $poNewLS0 = array(); |
| 914 | 914 | //$poMulti[] = $poNewLS0; |
| 915 | 915 | for ($l = 0; $l < $first_pass_ln; ++$l) { |
| 916 | - $poNewLS0[] = array($first_pass[$l][0],$first_pass[$l][1]); |
|
| 916 | + $poNewLS0[] = array($first_pass[$l][0], $first_pass[$l][1]); |
|
| 917 | 917 | } |
| 918 | 918 | $poMulti[] = $poNewLS0; |
| 919 | 919 | } |
@@ -36,7 +36,9 @@ discard block |
||
| 36 | 36 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
| 37 | 37 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
| 38 | 38 | curl_setopt($ch, CURLINFO_HEADER_OUT, true); |
| 39 | - if ($getheaders) curl_setopt($ch, CURLOPT_HEADER, 1); |
|
| 39 | + if ($getheaders) { |
|
| 40 | + curl_setopt($ch, CURLOPT_HEADER, 1); |
|
| 41 | + } |
|
| 40 | 42 | curl_setopt($ch,CURLOPT_ENCODING , "gzip"); |
| 41 | 43 | //curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5'); |
| 42 | 44 | // curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; Linux x86_64; rv:42.0) Gecko/20100101 Firefox/42.0'); |
@@ -45,8 +47,11 @@ discard block |
||
| 45 | 47 | } else { |
| 46 | 48 | curl_setopt($ch, CURLOPT_USERAGENT, $useragent); |
| 47 | 49 | } |
| 48 | - if ($timeout == '') curl_setopt($ch, CURLOPT_TIMEOUT, 10); |
|
| 49 | - else curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); |
|
| 50 | + if ($timeout == '') { |
|
| 51 | + curl_setopt($ch, CURLOPT_TIMEOUT, 10); |
|
| 52 | + } else { |
|
| 53 | + curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); |
|
| 54 | + } |
|
| 50 | 55 | //curl_setopt($ch, CURLOPT_HEADERFUNCTION, array('Common',"curlResponseHeaderCallback")); |
| 51 | 56 | if ($type == 'post') { |
| 52 | 57 | curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); |
@@ -59,7 +64,9 @@ discard block |
||
| 59 | 64 | } else { |
| 60 | 65 | curl_setopt($ch, CURLOPT_POSTFIELDS, $data); |
| 61 | 66 | } |
| 62 | - } elseif ($type != 'get' && $type != '') curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $type); |
|
| 67 | + } elseif ($type != 'get' && $type != '') { |
|
| 68 | + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $type); |
|
| 69 | + } |
|
| 63 | 70 | if ($headers != '') { |
| 64 | 71 | curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); |
| 65 | 72 | } |
@@ -103,8 +110,9 @@ discard block |
||
| 103 | 110 | private function curlResponseHeaderCallback($ch, $headerLine) { |
| 104 | 111 | global $curl_cookies; |
| 105 | 112 | $curl_cookies = array(); |
| 106 | - if (preg_match('/^Set-Cookie:\s*([^;]*)/mi', $headerLine, $cookie) == 1) |
|
| 107 | - $curl_cookies[] = $cookie; |
|
| 113 | + if (preg_match('/^Set-Cookie:\s*([^;]*)/mi', $headerLine, $cookie) == 1) { |
|
| 114 | + $curl_cookies[] = $cookie; |
|
| 115 | + } |
|
| 108 | 116 | return strlen($headerLine); // Needed by curl |
| 109 | 117 | } |
| 110 | 118 | |
@@ -116,7 +124,9 @@ discard block |
||
| 116 | 124 | curl_setopt($ch, CURLOPT_URL, $url); |
| 117 | 125 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
| 118 | 126 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
| 119 | - if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer); |
|
| 127 | + if ($referer != '') { |
|
| 128 | + curl_setopt($ch, CURLOPT_REFERER, $referer); |
|
| 129 | + } |
|
| 120 | 130 | if (isset($globalForceIPv4) && $globalForceIPv4) { |
| 121 | 131 | if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')){ |
| 122 | 132 | curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); |
@@ -128,7 +138,9 @@ discard block |
||
| 128 | 138 | curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5'); |
| 129 | 139 | curl_setopt($ch, CURLOPT_FILE, $fp); |
| 130 | 140 | curl_exec($ch); |
| 131 | - if (curl_errno($ch) && $globalDebug) echo 'Download error: '.curl_error($ch); |
|
| 141 | + if (curl_errno($ch) && $globalDebug) { |
|
| 142 | + echo 'Download error: '.curl_error($ch); |
|
| 143 | + } |
|
| 132 | 144 | curl_close($ch); |
| 133 | 145 | fclose($fp); |
| 134 | 146 | } |
@@ -136,12 +148,16 @@ discard block |
||
| 136 | 148 | public static function gunzip($in_file,$out_file_name = '') { |
| 137 | 149 | //echo $in_file.' -> '.$out_file_name."\n"; |
| 138 | 150 | $buffer_size = 4096; // read 4kb at a time |
| 139 | - if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); |
|
| 151 | + if ($out_file_name == '') { |
|
| 152 | + $out_file_name = str_replace('.gz', '', $in_file); |
|
| 153 | + } |
|
| 140 | 154 | if ($in_file != '' && file_exists($in_file)) { |
| 141 | 155 | // PHP version of Ubuntu use gzopen64 instead of gzopen |
| 142 | - if (function_exists('gzopen')) $file = gzopen($in_file,'rb'); |
|
| 143 | - elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb'); |
|
| 144 | - else { |
|
| 156 | + if (function_exists('gzopen')) { |
|
| 157 | + $file = gzopen($in_file,'rb'); |
|
| 158 | + } elseif (function_exists('gzopen64')) { |
|
| 159 | + $file = gzopen64($in_file,'rb'); |
|
| 160 | + } else { |
|
| 145 | 161 | echo 'gzopen not available'; |
| 146 | 162 | die; |
| 147 | 163 | } |
@@ -157,11 +173,14 @@ discard block |
||
| 157 | 173 | public static function bunzip2($in_file,$out_file_name = '') { |
| 158 | 174 | //echo $in_file.' -> '.$out_file_name."\n"; |
| 159 | 175 | $buffer_size = 4096; // read 4kb at a time |
| 160 | - if ($out_file_name == '') $out_file_name = str_replace('.bz2', '', $in_file); |
|
| 176 | + if ($out_file_name == '') { |
|
| 177 | + $out_file_name = str_replace('.bz2', '', $in_file); |
|
| 178 | + } |
|
| 161 | 179 | if ($in_file != '' && file_exists($in_file)) { |
| 162 | 180 | // PHP version of Ubuntu use gzopen64 instead of gzopen |
| 163 | - if (function_exists('bzopen')) $file = bzopen($in_file,'rb'); |
|
| 164 | - else { |
|
| 181 | + if (function_exists('bzopen')) { |
|
| 182 | + $file = bzopen($in_file,'rb'); |
|
| 183 | + } else { |
|
| 165 | 184 | echo 'bzopen not available'; |
| 166 | 185 | die; |
| 167 | 186 | } |
@@ -180,10 +199,16 @@ discard block |
||
| 180 | 199 | * @return array array of the tables in HTML page |
| 181 | 200 | */ |
| 182 | 201 | public function table2array($data) { |
| 183 | - if (!is_string($data)) return array(); |
|
| 184 | - if ($data == '') return array(); |
|
| 202 | + if (!is_string($data)) { |
|
| 203 | + return array(); |
|
| 204 | + } |
|
| 205 | + if ($data == '') { |
|
| 206 | + return array(); |
|
| 207 | + } |
|
| 185 | 208 | $html = str_get_html($data); |
| 186 | - if ($html === false) return array(); |
|
| 209 | + if ($html === false) { |
|
| 210 | + return array(); |
|
| 211 | + } |
|
| 187 | 212 | $tabledata=array(); |
| 188 | 213 | foreach($html->find('tr') as $element) |
| 189 | 214 | { |
@@ -218,7 +243,9 @@ discard block |
||
| 218 | 243 | */ |
| 219 | 244 | public function text2array($data) { |
| 220 | 245 | $html = str_get_html($data); |
| 221 | - if ($html === false) return array(); |
|
| 246 | + if ($html === false) { |
|
| 247 | + return array(); |
|
| 248 | + } |
|
| 222 | 249 | $tabledata=array(); |
| 223 | 250 | foreach($html->find('p') as $element) |
| 224 | 251 | { |
@@ -239,7 +266,9 @@ discard block |
||
| 239 | 266 | * @return Float Distance in $unit |
| 240 | 267 | */ |
| 241 | 268 | public function distance($lat, $lon, $latc, $lonc, $unit = 'km') { |
| 242 | - if ($lat == $latc && $lon == $lonc) return 0; |
|
| 269 | + if ($lat == $latc && $lon == $lonc) { |
|
| 270 | + return 0; |
|
| 271 | + } |
|
| 243 | 272 | $dist = rad2deg(acos(sin(deg2rad(floatval($lat)))*sin(deg2rad(floatval($latc)))+ cos(deg2rad(floatval($lat)))*cos(deg2rad(floatval($latc)))*cos(deg2rad(floatval($lon)-floatval($lonc)))))*60*1.1515; |
| 244 | 273 | if ($unit == "km") { |
| 245 | 274 | return round($dist * 1.609344); |
@@ -285,7 +314,9 @@ discard block |
||
| 285 | 314 | $dX = $latc - $lat; |
| 286 | 315 | $dY = $lonc - $lon; |
| 287 | 316 | $azimuth = rad2deg(atan2($dY,$dX)); |
| 288 | - if ($azimuth < 0) return $azimuth+360; |
|
| 317 | + if ($azimuth < 0) { |
|
| 318 | + return $azimuth+360; |
|
| 319 | + } |
|
| 289 | 320 | return $azimuth; |
| 290 | 321 | } |
| 291 | 322 | |
@@ -299,10 +330,16 @@ discard block |
||
| 299 | 330 | public function withinThreshold ($timeDifference, $distance) { |
| 300 | 331 | $x = abs($timeDifference); |
| 301 | 332 | $d = abs($distance); |
| 302 | - if ($x == 0 || $d == 0) return true; |
|
| 333 | + if ($x == 0 || $d == 0) { |
|
| 334 | + return true; |
|
| 335 | + } |
|
| 303 | 336 | // may be due to Internet jitter; distance is realistic |
| 304 | - if ($x < 0.7 && $d < 2000) return true; |
|
| 305 | - else return $d/$x < 1500*0.27778; // 1500 km/h max |
|
| 337 | + if ($x < 0.7 && $d < 2000) { |
|
| 338 | + return true; |
|
| 339 | + } else { |
|
| 340 | + return $d/$x < 1500*0.27778; |
|
| 341 | + } |
|
| 342 | + // 1500 km/h max |
|
| 306 | 343 | } |
| 307 | 344 | |
| 308 | 345 | |
@@ -354,11 +391,17 @@ discard block |
||
| 354 | 391 | |
| 355 | 392 | public function convertDM($coord,$latlong) { |
| 356 | 393 | if ($latlong == 'latitude') { |
| 357 | - if ($coord < 0) $NSEW = 'S'; |
|
| 358 | - else $NSEW = 'N'; |
|
| 394 | + if ($coord < 0) { |
|
| 395 | + $NSEW = 'S'; |
|
| 396 | + } else { |
|
| 397 | + $NSEW = 'N'; |
|
| 398 | + } |
|
| 359 | 399 | } else { |
| 360 | - if ($coord < 0) $NSEW = 'W'; |
|
| 361 | - else $NSEW = 'E'; |
|
| 400 | + if ($coord < 0) { |
|
| 401 | + $NSEW = 'W'; |
|
| 402 | + } else { |
|
| 403 | + $NSEW = 'E'; |
|
| 404 | + } |
|
| 362 | 405 | } |
| 363 | 406 | $coord = abs($coord); |
| 364 | 407 | $deg = floor($coord); |
@@ -368,11 +411,17 @@ discard block |
||
| 368 | 411 | } |
| 369 | 412 | public function convertDMS($coord,$latlong) { |
| 370 | 413 | if ($latlong == 'latitude') { |
| 371 | - if ($coord < 0) $NSEW = 'S'; |
|
| 372 | - else $NSEW = 'N'; |
|
| 414 | + if ($coord < 0) { |
|
| 415 | + $NSEW = 'S'; |
|
| 416 | + } else { |
|
| 417 | + $NSEW = 'N'; |
|
| 418 | + } |
|
| 373 | 419 | } else { |
| 374 | - if ($coord < 0) $NSEW = 'W'; |
|
| 375 | - else $NSEW = 'E'; |
|
| 420 | + if ($coord < 0) { |
|
| 421 | + $NSEW = 'W'; |
|
| 422 | + } else { |
|
| 423 | + $NSEW = 'E'; |
|
| 424 | + } |
|
| 376 | 425 | } |
| 377 | 426 | $coord = abs($coord); |
| 378 | 427 | $deg = floor($coord); |
@@ -416,7 +465,9 @@ discard block |
||
| 416 | 465 | public function hex2str($hex) { |
| 417 | 466 | $str = ''; |
| 418 | 467 | $hexln = strlen($hex); |
| 419 | - for($i=0;$i<$hexln;$i+=2) $str .= chr(hexdec(substr($hex,$i,2))); |
|
| 468 | + for($i=0;$i<$hexln;$i+=2) { |
|
| 469 | + $str .= chr(hexdec(substr($hex,$i,2))); |
|
| 470 | + } |
|
| 420 | 471 | return $str; |
| 421 | 472 | } |
| 422 | 473 | |
@@ -453,8 +504,11 @@ discard block |
||
| 453 | 504 | $b = $lat2 - $lat1; |
| 454 | 505 | $c = -($a*$lat1+$b*$lon1); |
| 455 | 506 | $d = $a*$lat3+$b*$lon3+$c; |
| 456 | - if ($d > -$approx && $d < $approx) return true; |
|
| 457 | - else return false; |
|
| 507 | + if ($d > -$approx && $d < $approx) { |
|
| 508 | + return true; |
|
| 509 | + } else { |
|
| 510 | + return false; |
|
| 511 | + } |
|
| 458 | 512 | } |
| 459 | 513 | |
| 460 | 514 | public function array_merge_noappend() { |
@@ -513,7 +567,9 @@ discard block |
||
| 513 | 567 | return $result; |
| 514 | 568 | } |
| 515 | 569 | $handle = @opendir('./locale'); |
| 516 | - if ($handle === false) return $result; |
|
| 570 | + if ($handle === false) { |
|
| 571 | + return $result; |
|
| 572 | + } |
|
| 517 | 573 | while (false !== ($file = readdir($handle))) { |
| 518 | 574 | $path = './locale'.'/'.$file.'/LC_MESSAGES/fam.mo'; |
| 519 | 575 | if ($file != "." && $file != ".." && @file_exists($path)) { |
@@ -584,8 +640,9 @@ discard block |
||
| 584 | 640 | $error = false; |
| 585 | 641 | if ($fp_out = gzopen($dest, $mode)) { |
| 586 | 642 | if ($fp_in = fopen($source,'rb')) { |
| 587 | - while (!feof($fp_in)) |
|
| 588 | - gzwrite($fp_out, fread($fp_in, 1024 * 512)); |
|
| 643 | + while (!feof($fp_in)) { |
|
| 644 | + gzwrite($fp_out, fread($fp_in, 1024 * 512)); |
|
| 645 | + } |
|
| 589 | 646 | fclose($fp_in); |
| 590 | 647 | } else { |
| 591 | 648 | $error = true; |
@@ -594,14 +651,17 @@ discard block |
||
| 594 | 651 | } else { |
| 595 | 652 | $error = true; |
| 596 | 653 | } |
| 597 | - if ($error) |
|
| 598 | - return false; |
|
| 599 | - else |
|
| 600 | - return $dest; |
|
| 654 | + if ($error) { |
|
| 655 | + return false; |
|
| 656 | + } else { |
|
| 657 | + return $dest; |
|
| 658 | + } |
|
| 601 | 659 | } |
| 602 | 660 | |
| 603 | 661 | public function remove_accents($string) { |
| 604 | - if ( !preg_match('/[\x80-\xff]/', $string) ) return $string; |
|
| 662 | + if ( !preg_match('/[\x80-\xff]/', $string) ) { |
|
| 663 | + return $string; |
|
| 664 | + } |
|
| 605 | 665 | $chars = array( |
| 606 | 666 | // Decompositions for Latin-1 Supplement |
| 607 | 667 | chr(195).chr(128) => 'A', chr(195).chr(129) => 'A', |
@@ -725,7 +785,9 @@ discard block |
||
| 725 | 785 | $ip = gethostbyname($host); |
| 726 | 786 | $s = socket_create(AF_INET, SOCK_STREAM, 0); |
| 727 | 787 | $r = @socket_connect($s, $ip, $port); |
| 728 | - if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n"; |
|
| 788 | + if (!socket_set_nonblock($s)) { |
|
| 789 | + echo "Unable to set nonblock on socket\n"; |
|
| 790 | + } |
|
| 729 | 791 | if ($r || socket_last_error() == 114 || socket_last_error() == 115) { |
| 730 | 792 | return $s; |
| 731 | 793 | } |
@@ -770,18 +832,22 @@ discard block |
||
| 770 | 832 | //NOTE: use a trailing slash for folders!!! |
| 771 | 833 | //see http://bugs.php.net/bug.php?id=27609 |
| 772 | 834 | //see http://bugs.php.net/bug.php?id=30931 |
| 773 | - if ($path{strlen($path)-1}=='/') // recursively return a temporary file path |
|
| 835 | + if ($path{strlen($path)-1}=='/') { |
|
| 836 | + // recursively return a temporary file path |
|
| 774 | 837 | return $this->is__writable($path.uniqid(mt_rand()).'.tmp'); |
| 775 | - else if (is_dir($path)) |
|
| 776 | - return $this->is__writable($path.'/'.uniqid(mt_rand()).'.tmp'); |
|
| 838 | + } else if (is_dir($path)) { |
|
| 839 | + return $this->is__writable($path.'/'.uniqid(mt_rand()).'.tmp'); |
|
| 840 | + } |
|
| 777 | 841 | // check tmp file for read/write capabilities |
| 778 | 842 | $rm = file_exists($path); |
| 779 | 843 | $f = @fopen($path, 'a'); |
| 780 | - if ($f===false) |
|
| 781 | - return false; |
|
| 844 | + if ($f===false) { |
|
| 845 | + return false; |
|
| 846 | + } |
|
| 782 | 847 | fclose($f); |
| 783 | - if (!$rm) |
|
| 784 | - unlink($path); |
|
| 848 | + if (!$rm) { |
|
| 849 | + unlink($path); |
|
| 850 | + } |
|
| 785 | 851 | return true; |
| 786 | 852 | } |
| 787 | 853 | |
@@ -797,7 +863,9 @@ discard block |
||
| 797 | 863 | * @return Array Coordinate of the route |
| 798 | 864 | */ |
| 799 | 865 | public function greatcircle($begin_lat,$begin_lon,$end_lat,$end_lon,$nbpts = 20, $offset = 10) { |
| 800 | - if ($nbpts <= 2) return array(array($begin_lon,$begin_lat),array($end_lon,$end_lat)); |
|
| 866 | + if ($nbpts <= 2) { |
|
| 867 | + return array(array($begin_lon,$begin_lat),array($end_lon,$end_lat)); |
|
| 868 | + } |
|
| 801 | 869 | $sx = deg2rad($begin_lon); |
| 802 | 870 | $sy = deg2rad($begin_lat); |
| 803 | 871 | $ex = deg2rad($end_lon); |
@@ -806,7 +874,9 @@ discard block |
||
| 806 | 874 | $h = $sy - $ey; |
| 807 | 875 | $z = pow(sin($h/2.0),2) + cos($sy)*cos($ey)*pow(sin($w/2.0),2); |
| 808 | 876 | $g = 2.0*asin(sqrt($z)); |
| 809 | - if ($g == M_PI || is_nan($g)) return array(array($begin_lon,$begin_lat),array($end_lon,$end_lat)); |
|
| 877 | + if ($g == M_PI || is_nan($g)) { |
|
| 878 | + return array(array($begin_lon,$begin_lat),array($end_lon,$end_lat)); |
|
| 879 | + } |
|
| 810 | 880 | $first_pass = array(); |
| 811 | 881 | $delta = 1.0/($nbpts-1); |
| 812 | 882 | for ($i =0; $i < $nbpts; ++$i) { |
@@ -286,6 +286,7 @@ discard block |
||
| 286 | 286 | * |
| 287 | 287 | * @param String $aircraft_registration the registration of the aircraft |
| 288 | 288 | * @param String $aircraft_name type of the aircraft |
| 289 | + * @param string $type |
|
| 289 | 290 | * @return array the aircraft thumbnail, orignal url and copyright |
| 290 | 291 | * |
| 291 | 292 | */ |
@@ -318,7 +319,7 @@ discard block |
||
| 318 | 319 | /** |
| 319 | 320 | * Gets the aircraft image from Deviantart |
| 320 | 321 | * |
| 321 | - * @param $type |
|
| 322 | + * @param string $type |
|
| 322 | 323 | * @param String $registration the registration of the aircraft |
| 323 | 324 | * @param String $name type of the aircraft |
| 324 | 325 | * @return array the aircraft thumbnail, orignal url and copyright |
@@ -360,6 +361,7 @@ discard block |
||
| 360 | 361 | * |
| 361 | 362 | * @param String $aircraft_registration the registration of the aircraft |
| 362 | 363 | * @param String $aircraft_name type of the aircraft |
| 364 | + * @param string $type |
|
| 363 | 365 | * @return array the aircraft thumbnail, orignal url and copyright |
| 364 | 366 | * |
| 365 | 367 | */ |
@@ -402,6 +404,7 @@ discard block |
||
| 402 | 404 | * |
| 403 | 405 | * @param String $aircraft_registration the registration of the aircraft |
| 404 | 406 | * @param String $aircraft_name type of the aircraft |
| 407 | + * @param string $type |
|
| 405 | 408 | * @return array the aircraft thumbnail, orignal url and copyright |
| 406 | 409 | * |
| 407 | 410 | */ |
@@ -436,6 +439,7 @@ discard block |
||
| 436 | 439 | * |
| 437 | 440 | * @param String $registration the registration of the aircraft |
| 438 | 441 | * @param String $name type of the aircraft |
| 442 | + * @param string $type |
|
| 439 | 443 | * @return array the aircraft thumbnail, orignal url and copyright |
| 440 | 444 | * |
| 441 | 445 | */ |
@@ -466,8 +470,8 @@ discard block |
||
| 466 | 470 | } |
| 467 | 471 | |
| 468 | 472 | /** |
| 469 | - * @param $type |
|
| 470 | - * @param $aircraft_icao |
|
| 473 | + * @param string $type |
|
| 474 | + * @param string $aircraft_icao |
|
| 471 | 475 | * @param $airline_icao |
| 472 | 476 | * @return array |
| 473 | 477 | */ |
@@ -490,7 +494,7 @@ discard block |
||
| 490 | 494 | /** |
| 491 | 495 | * Gets the aircraft image from Bing |
| 492 | 496 | * |
| 493 | - * @param $type |
|
| 497 | + * @param string $type |
|
| 494 | 498 | * @param String $aircraft_registration the registration of the aircraft |
| 495 | 499 | * @param String $aircraft_name type of the aircraft |
| 496 | 500 | * @return array the aircraft thumbnail, orignal url and copyright |
@@ -529,6 +533,7 @@ discard block |
||
| 529 | 533 | * |
| 530 | 534 | * @param String $aircraft_registration the registration of the aircraft |
| 531 | 535 | * @param String $aircraft_name type of the aircraft |
| 536 | + * @param string $type |
|
| 532 | 537 | * @return array the aircraft thumbnail, orignal url and copyright |
| 533 | 538 | * |
| 534 | 539 | */ |
@@ -554,6 +559,7 @@ discard block |
||
| 554 | 559 | * |
| 555 | 560 | * @param String $registration the registration of the aircraft/mmsi |
| 556 | 561 | * @param String $name name |
| 562 | + * @param string $type |
|
| 557 | 563 | * @return array the aircraft thumbnail, orignal url and copyright |
| 558 | 564 | * |
| 559 | 565 | */ |
@@ -615,6 +621,7 @@ discard block |
||
| 615 | 621 | * |
| 616 | 622 | * @param String $registration the registration of the aircraft |
| 617 | 623 | * @param String $name type of the aircraft |
| 624 | + * @param string $type |
|
| 618 | 625 | * @return array the aircraft thumbnail, orignal url and copyright |
| 619 | 626 | * |
| 620 | 627 | */ |
@@ -22,14 +22,14 @@ discard block |
||
| 22 | 22 | if ($this->db === null) die('Error: No DB connection. (Image)'); |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * Gets the images based on the aircraft registration |
|
| 27 | - * |
|
| 28 | - * @param $registration |
|
| 29 | - * @param string $aircraft_icao |
|
| 30 | - * @param string $airline_icao |
|
| 31 | - * @return array the images list |
|
| 32 | - */ |
|
| 25 | + /** |
|
| 26 | + * Gets the images based on the aircraft registration |
|
| 27 | + * |
|
| 28 | + * @param $registration |
|
| 29 | + * @param string $aircraft_icao |
|
| 30 | + * @param string $airline_icao |
|
| 31 | + * @return array the images list |
|
| 32 | + */ |
|
| 33 | 33 | public function getSpotterImage($registration,$aircraft_icao = '', $airline_icao = '') |
| 34 | 34 | { |
| 35 | 35 | $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
@@ -49,15 +49,15 @@ discard block |
||
| 49 | 49 | else return array(); |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - /** |
|
| 53 | - * Gets the images based on the ship name |
|
| 54 | - * |
|
| 55 | - * @param $mmsi |
|
| 56 | - * @param string $imo |
|
| 57 | - * @param string $name |
|
| 58 | - * @param string $type_name |
|
| 59 | - * @return array the images list |
|
| 60 | - */ |
|
| 52 | + /** |
|
| 53 | + * Gets the images based on the ship name |
|
| 54 | + * |
|
| 55 | + * @param $mmsi |
|
| 56 | + * @param string $imo |
|
| 57 | + * @param string $name |
|
| 58 | + * @param string $type_name |
|
| 59 | + * @return array the images list |
|
| 60 | + */ |
|
| 61 | 61 | public function getMarineImage($mmsi,$imo = '',$name = '',$type_name = '') |
| 62 | 62 | { |
| 63 | 63 | global $globalMarineImagePics; |
@@ -94,12 +94,12 @@ discard block |
||
| 94 | 94 | return $result; |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | - /** |
|
| 98 | - * Gets the image copyright based on the Exif data |
|
| 99 | - * |
|
| 100 | - * @param $url |
|
| 101 | - * @return String image copyright |
|
| 102 | - */ |
|
| 97 | + /** |
|
| 98 | + * Gets the image copyright based on the Exif data |
|
| 99 | + * |
|
| 100 | + * @param $url |
|
| 101 | + * @return String image copyright |
|
| 102 | + */ |
|
| 103 | 103 | public function getExifCopyright($url) { |
| 104 | 104 | $exif = exif_read_data($url); |
| 105 | 105 | $copyright = ''; |
@@ -113,14 +113,14 @@ discard block |
||
| 113 | 113 | return $copyright; |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | - /** |
|
| 117 | - * Adds the images based on the aircraft registration |
|
| 118 | - * |
|
| 119 | - * @param $registration |
|
| 120 | - * @param string $aircraft_icao |
|
| 121 | - * @param string $airline_icao |
|
| 122 | - * @return String either success or error |
|
| 123 | - */ |
|
| 116 | + /** |
|
| 117 | + * Adds the images based on the aircraft registration |
|
| 118 | + * |
|
| 119 | + * @param $registration |
|
| 120 | + * @param string $aircraft_icao |
|
| 121 | + * @param string $airline_icao |
|
| 122 | + * @return String either success or error |
|
| 123 | + */ |
|
| 124 | 124 | public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '') |
| 125 | 125 | { |
| 126 | 126 | global $globalDebug,$globalAircraftImageFetch, $globalOffline; |
@@ -147,14 +147,14 @@ discard block |
||
| 147 | 147 | return "success"; |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | - /** |
|
| 151 | - * Adds the images based on the marine name |
|
| 152 | - * |
|
| 153 | - * @param $mmsi |
|
| 154 | - * @param string $imo |
|
| 155 | - * @param string $name |
|
| 156 | - * @return String either success or error |
|
| 157 | - */ |
|
| 150 | + /** |
|
| 151 | + * Adds the images based on the marine name |
|
| 152 | + * |
|
| 153 | + * @param $mmsi |
|
| 154 | + * @param string $imo |
|
| 155 | + * @param string $name |
|
| 156 | + * @return String either success or error |
|
| 157 | + */ |
|
| 158 | 158 | public function addMarineImage($mmsi,$imo = '',$name = '') |
| 159 | 159 | { |
| 160 | 160 | global $globalDebug,$globalMarineImageFetch, $globalOffline; |
@@ -190,14 +190,14 @@ discard block |
||
| 190 | 190 | return "success"; |
| 191 | 191 | } |
| 192 | 192 | |
| 193 | - /** |
|
| 194 | - * Gets the aircraft image |
|
| 195 | - * |
|
| 196 | - * @param String $aircraft_registration the registration of the aircraft |
|
| 197 | - * @param string $aircraft_icao |
|
| 198 | - * @param string $airline_icao |
|
| 199 | - * @return array the aircraft thumbnail, orignal url and copyright |
|
| 200 | - */ |
|
| 193 | + /** |
|
| 194 | + * Gets the aircraft image |
|
| 195 | + * |
|
| 196 | + * @param String $aircraft_registration the registration of the aircraft |
|
| 197 | + * @param string $aircraft_icao |
|
| 198 | + * @param string $airline_icao |
|
| 199 | + * @return array the aircraft thumbnail, orignal url and copyright |
|
| 200 | + */ |
|
| 201 | 201 | public function findAircraftImage($aircraft_registration, $aircraft_icao = '', $airline_icao = '') |
| 202 | 202 | { |
| 203 | 203 | global $globalAircraftImageSources, $globalIVAO, $globalAircraftImageCheckICAO, $globalVA; |
@@ -241,14 +241,14 @@ discard block |
||
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | /** |
| 244 | - * Gets the vessel image |
|
| 245 | - * |
|
| 246 | - * @param String $mmsi the vessel mmsi |
|
| 247 | - * @param String $imo the vessel imo |
|
| 248 | - * @param String $name the vessel name |
|
| 249 | - * @return array the aircraft thumbnail, orignal url and copyright |
|
| 250 | - * |
|
| 251 | - */ |
|
| 244 | + * Gets the vessel image |
|
| 245 | + * |
|
| 246 | + * @param String $mmsi the vessel mmsi |
|
| 247 | + * @param String $imo the vessel imo |
|
| 248 | + * @param String $name the vessel name |
|
| 249 | + * @return array the aircraft thumbnail, orignal url and copyright |
|
| 250 | + * |
|
| 251 | + */ |
|
| 252 | 252 | public function findMarineImage($mmsi,$imo = '',$name = '') |
| 253 | 253 | { |
| 254 | 254 | global $globalMarineImageSources; |
@@ -282,13 +282,13 @@ discard block |
||
| 282 | 282 | } |
| 283 | 283 | |
| 284 | 284 | /** |
| 285 | - * Gets the aircraft image from Planespotters |
|
| 286 | - * |
|
| 287 | - * @param String $aircraft_registration the registration of the aircraft |
|
| 288 | - * @param String $aircraft_name type of the aircraft |
|
| 289 | - * @return array the aircraft thumbnail, orignal url and copyright |
|
| 290 | - * |
|
| 291 | - */ |
|
| 285 | + * Gets the aircraft image from Planespotters |
|
| 286 | + * |
|
| 287 | + * @param String $aircraft_registration the registration of the aircraft |
|
| 288 | + * @param String $aircraft_name type of the aircraft |
|
| 289 | + * @return array the aircraft thumbnail, orignal url and copyright |
|
| 290 | + * |
|
| 291 | + */ |
|
| 292 | 292 | public function fromPlanespotters($type,$aircraft_registration, $aircraft_name='') { |
| 293 | 293 | $Common = new Common(); |
| 294 | 294 | // If aircraft registration is only number, also check with aircraft model |
@@ -315,14 +315,14 @@ discard block |
||
| 315 | 315 | return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
| 316 | 316 | } |
| 317 | 317 | |
| 318 | - /** |
|
| 319 | - * Gets the aircraft image from Deviantart |
|
| 320 | - * |
|
| 321 | - * @param $type |
|
| 322 | - * @param String $registration the registration of the aircraft |
|
| 323 | - * @param String $name type of the aircraft |
|
| 324 | - * @return array the aircraft thumbnail, orignal url and copyright |
|
| 325 | - */ |
|
| 318 | + /** |
|
| 319 | + * Gets the aircraft image from Deviantart |
|
| 320 | + * |
|
| 321 | + * @param $type |
|
| 322 | + * @param String $registration the registration of the aircraft |
|
| 323 | + * @param String $name type of the aircraft |
|
| 324 | + * @return array the aircraft thumbnail, orignal url and copyright |
|
| 325 | + */ |
|
| 326 | 326 | public function fromDeviantart($type,$registration, $name='') { |
| 327 | 327 | $Common = new Common(); |
| 328 | 328 | if ($type == 'aircraft') { |
@@ -356,13 +356,13 @@ discard block |
||
| 356 | 356 | } |
| 357 | 357 | |
| 358 | 358 | /** |
| 359 | - * Gets the aircraft image from JetPhotos |
|
| 360 | - * |
|
| 361 | - * @param String $aircraft_registration the registration of the aircraft |
|
| 362 | - * @param String $aircraft_name type of the aircraft |
|
| 363 | - * @return array the aircraft thumbnail, orignal url and copyright |
|
| 364 | - * |
|
| 365 | - */ |
|
| 359 | + * Gets the aircraft image from JetPhotos |
|
| 360 | + * |
|
| 361 | + * @param String $aircraft_registration the registration of the aircraft |
|
| 362 | + * @param String $aircraft_name type of the aircraft |
|
| 363 | + * @return array the aircraft thumbnail, orignal url and copyright |
|
| 364 | + * |
|
| 365 | + */ |
|
| 366 | 366 | public function fromJetPhotos($type,$aircraft_registration, $aircraft_name='') { |
| 367 | 367 | $Common = new Common(); |
| 368 | 368 | $url= 'http://jetphotos.net/showphotos.php?displaymode=2®search='.$aircraft_registration; |
@@ -398,13 +398,13 @@ discard block |
||
| 398 | 398 | } |
| 399 | 399 | |
| 400 | 400 | /** |
| 401 | - * Gets the aircraft image from PlanePictures |
|
| 402 | - * |
|
| 403 | - * @param String $aircraft_registration the registration of the aircraft |
|
| 404 | - * @param String $aircraft_name type of the aircraft |
|
| 405 | - * @return array the aircraft thumbnail, orignal url and copyright |
|
| 406 | - * |
|
| 407 | - */ |
|
| 401 | + * Gets the aircraft image from PlanePictures |
|
| 402 | + * |
|
| 403 | + * @param String $aircraft_registration the registration of the aircraft |
|
| 404 | + * @param String $aircraft_name type of the aircraft |
|
| 405 | + * @return array the aircraft thumbnail, orignal url and copyright |
|
| 406 | + * |
|
| 407 | + */ |
|
| 408 | 408 | public function fromPlanePictures($type,$aircraft_registration, $aircraft_name='') { |
| 409 | 409 | $Common = new Common(); |
| 410 | 410 | $url= 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2'; |
@@ -432,13 +432,13 @@ discard block |
||
| 432 | 432 | } |
| 433 | 433 | |
| 434 | 434 | /** |
| 435 | - * Gets the aircraft image from Flickr |
|
| 436 | - * |
|
| 437 | - * @param String $registration the registration of the aircraft |
|
| 438 | - * @param String $name type of the aircraft |
|
| 439 | - * @return array the aircraft thumbnail, orignal url and copyright |
|
| 440 | - * |
|
| 441 | - */ |
|
| 435 | + * Gets the aircraft image from Flickr |
|
| 436 | + * |
|
| 437 | + * @param String $registration the registration of the aircraft |
|
| 438 | + * @param String $name type of the aircraft |
|
| 439 | + * @return array the aircraft thumbnail, orignal url and copyright |
|
| 440 | + * |
|
| 441 | + */ |
|
| 442 | 442 | public function fromFlickr($type,$registration,$name='') { |
| 443 | 443 | $Common = new Common(); |
| 444 | 444 | if ($type == 'aircraft') { |
@@ -465,13 +465,13 @@ discard block |
||
| 465 | 465 | return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
| 466 | 466 | } |
| 467 | 467 | |
| 468 | - /** |
|
| 469 | - * @param $type |
|
| 470 | - * @param $aircraft_icao |
|
| 471 | - * @param $airline_icao |
|
| 472 | - * @return array |
|
| 473 | - */ |
|
| 474 | - public function fromIvaoMtl($type, $aircraft_icao, $airline_icao) { |
|
| 468 | + /** |
|
| 469 | + * @param $type |
|
| 470 | + * @param $aircraft_icao |
|
| 471 | + * @param $airline_icao |
|
| 472 | + * @return array |
|
| 473 | + */ |
|
| 474 | + public function fromIvaoMtl($type, $aircraft_icao, $airline_icao) { |
|
| 475 | 475 | $Common = new Common(); |
| 476 | 476 | //echo "\n".'SEARCH IMAGE : http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg'; |
| 477 | 477 | if ($Common->urlexist('http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg')) { |
@@ -487,14 +487,14 @@ discard block |
||
| 487 | 487 | } |
| 488 | 488 | } |
| 489 | 489 | |
| 490 | - /** |
|
| 491 | - * Gets the aircraft image from Bing |
|
| 492 | - * |
|
| 493 | - * @param $type |
|
| 494 | - * @param String $aircraft_registration the registration of the aircraft |
|
| 495 | - * @param String $aircraft_name type of the aircraft |
|
| 496 | - * @return array the aircraft thumbnail, orignal url and copyright |
|
| 497 | - */ |
|
| 490 | + /** |
|
| 491 | + * Gets the aircraft image from Bing |
|
| 492 | + * |
|
| 493 | + * @param $type |
|
| 494 | + * @param String $aircraft_registration the registration of the aircraft |
|
| 495 | + * @param String $aircraft_name type of the aircraft |
|
| 496 | + * @return array the aircraft thumbnail, orignal url and copyright |
|
| 497 | + */ |
|
| 498 | 498 | public function fromBing($type,$aircraft_registration,$aircraft_name='') { |
| 499 | 499 | global $globalImageBingKey; |
| 500 | 500 | $Common = new Common(); |
@@ -525,13 +525,13 @@ discard block |
||
| 525 | 525 | } |
| 526 | 526 | |
| 527 | 527 | /** |
| 528 | - * Gets the aircraft image from airport-data |
|
| 529 | - * |
|
| 530 | - * @param String $aircraft_registration the registration of the aircraft |
|
| 531 | - * @param String $aircraft_name type of the aircraft |
|
| 532 | - * @return array the aircraft thumbnail, orignal url and copyright |
|
| 533 | - * |
|
| 534 | - */ |
|
| 528 | + * Gets the aircraft image from airport-data |
|
| 529 | + * |
|
| 530 | + * @param String $aircraft_registration the registration of the aircraft |
|
| 531 | + * @param String $aircraft_name type of the aircraft |
|
| 532 | + * @return array the aircraft thumbnail, orignal url and copyright |
|
| 533 | + * |
|
| 534 | + */ |
|
| 535 | 535 | public function fromAirportData($type,$aircraft_registration,$aircraft_name='') { |
| 536 | 536 | $Common = new Common(); |
| 537 | 537 | $url = 'http://www.airport-data.com/api/ac_thumb.json?&n=1&r='.$aircraft_registration; |
@@ -550,13 +550,13 @@ discard block |
||
| 550 | 550 | } |
| 551 | 551 | |
| 552 | 552 | /** |
| 553 | - * Gets image from WikiMedia |
|
| 554 | - * |
|
| 555 | - * @param String $registration the registration of the aircraft/mmsi |
|
| 556 | - * @param String $name name |
|
| 557 | - * @return array the aircraft thumbnail, orignal url and copyright |
|
| 558 | - * |
|
| 559 | - */ |
|
| 553 | + * Gets image from WikiMedia |
|
| 554 | + * |
|
| 555 | + * @param String $registration the registration of the aircraft/mmsi |
|
| 556 | + * @param String $name name |
|
| 557 | + * @return array the aircraft thumbnail, orignal url and copyright |
|
| 558 | + * |
|
| 559 | + */ |
|
| 560 | 560 | public function fromWikimedia($type,$registration,$name='') { |
| 561 | 561 | $Common = new Common(); |
| 562 | 562 | if ($type == 'aircraft') { |
@@ -611,13 +611,13 @@ discard block |
||
| 611 | 611 | } |
| 612 | 612 | |
| 613 | 613 | /** |
| 614 | - * Gets the aircraft image from custom url |
|
| 615 | - * |
|
| 616 | - * @param String $registration the registration of the aircraft |
|
| 617 | - * @param String $name type of the aircraft |
|
| 618 | - * @return array the aircraft thumbnail, orignal url and copyright |
|
| 619 | - * |
|
| 620 | - */ |
|
| 614 | + * Gets the aircraft image from custom url |
|
| 615 | + * |
|
| 616 | + * @param String $registration the registration of the aircraft |
|
| 617 | + * @param String $name type of the aircraft |
|
| 618 | + * @return array the aircraft thumbnail, orignal url and copyright |
|
| 619 | + * |
|
| 620 | + */ |
|
| 621 | 621 | public function fromCustomSource($type,$registration,$name='') { |
| 622 | 622 | global $globalAircraftImageCustomSources, $globalMarineImageCustomSources, $globalDebug; |
| 623 | 623 | //$globalAircraftImageCustomSource[] = array('thumbnail' => '','original' => '', 'copyright' => '', 'source_website' => '', 'source' => '','exif' => true); |
@@ -30,22 +30,22 @@ discard block |
||
| 30 | 30 | * @param string $airline_icao |
| 31 | 31 | * @return array the images list |
| 32 | 32 | */ |
| 33 | - public function getSpotterImage($registration,$aircraft_icao = '', $airline_icao = '') |
|
| 33 | + public function getSpotterImage($registration, $aircraft_icao = '', $airline_icao = '') |
|
| 34 | 34 | { |
| 35 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 36 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 37 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
| 35 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
| 36 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
| 37 | + $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING); |
|
| 38 | 38 | $reg = $registration; |
| 39 | 39 | if (($reg == '' || $reg == 'NA') && $aircraft_icao != '') $reg = $aircraft_icao.$airline_icao; |
| 40 | 40 | $reg = trim($reg); |
| 41 | - $query = "SELECT spotter_image.image, spotter_image.image_thumbnail, spotter_image.image_source, spotter_image.image_source_website,spotter_image.image_copyright, spotter_image.registration |
|
| 41 | + $query = "SELECT spotter_image.image, spotter_image.image_thumbnail, spotter_image.image_source, spotter_image.image_source_website,spotter_image.image_copyright, spotter_image.registration |
|
| 42 | 42 | FROM spotter_image |
| 43 | 43 | WHERE spotter_image.registration = :registration LIMIT 1"; |
| 44 | 44 | $sth = $this->db->prepare($query); |
| 45 | 45 | $sth->execute(array(':registration' => $reg)); |
| 46 | 46 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 47 | 47 | if (!empty($result)) return $result; |
| 48 | - elseif ($registration != '' && ($aircraft_icao != '' || $airline_icao != '')) return $this->getSpotterImage('',$aircraft_icao,$airline_icao); |
|
| 48 | + elseif ($registration != '' && ($aircraft_icao != '' || $airline_icao != '')) return $this->getSpotterImage('', $aircraft_icao, $airline_icao); |
|
| 49 | 49 | else return array(); |
| 50 | 50 | } |
| 51 | 51 | |
@@ -58,34 +58,34 @@ discard block |
||
| 58 | 58 | * @param string $type_name |
| 59 | 59 | * @return array the images list |
| 60 | 60 | */ |
| 61 | - public function getMarineImage($mmsi,$imo = '',$name = '',$type_name = '') |
|
| 61 | + public function getMarineImage($mmsi, $imo = '', $name = '', $type_name = '') |
|
| 62 | 62 | { |
| 63 | 63 | global $globalMarineImagePics; |
| 64 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
|
| 65 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
| 66 | - $name = filter_var($name,FILTER_SANITIZE_STRING); |
|
| 67 | - $type_name = str_replace(''',"'",filter_var($type_name,FILTER_SANITIZE_STRING)); |
|
| 64 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); |
|
| 65 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
| 66 | + $name = filter_var($name, FILTER_SANITIZE_STRING); |
|
| 67 | + $type_name = str_replace(''', "'", filter_var($type_name, FILTER_SANITIZE_STRING)); |
|
| 68 | 68 | if (isset($globalMarineImagePics) && !empty($globalMarineImagePics)) { |
| 69 | 69 | if ($type_name != '' && isset($globalMarineImagePics['type'][$type_name])) { |
| 70 | 70 | if (!isset($globalMarineImagePics['type'][$type_name]['image_thumbnail'])) { |
| 71 | 71 | $globalMarineImagePics['type'][$type_name]['image_thumbnail'] = $globalMarineImagePics['type'][$type_name]['image']; |
| 72 | 72 | } |
| 73 | - return array($globalMarineImagePics['type'][$type_name]+array('image_thumbnail' => '','image' => '', 'image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 73 | + return array($globalMarineImagePics['type'][$type_name] + array('image_thumbnail' => '', 'image' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); |
|
| 74 | 74 | } |
| 75 | 75 | } |
| 76 | 76 | $name = trim($name); |
| 77 | 77 | if ($mmsi == '' && $imo == '' && $name == '') return array(); |
| 78 | - $query = "SELECT marine_image.image, marine_image.image_thumbnail, marine_image.image_source, marine_image.image_source_website,marine_image.image_copyright, marine_image.mmsi, marine_image.imo, marine_image.name |
|
| 78 | + $query = "SELECT marine_image.image, marine_image.image_thumbnail, marine_image.image_source, marine_image.image_source_website,marine_image.image_copyright, marine_image.mmsi, marine_image.imo, marine_image.name |
|
| 79 | 79 | FROM marine_image |
| 80 | 80 | WHERE marine_image.mmsi = :mmsi"; |
| 81 | 81 | $query_data = array(':mmsi' => $mmsi); |
| 82 | 82 | if ($imo != '') { |
| 83 | 83 | $query .= " AND marine_image.imo = :imo"; |
| 84 | - $query_data = array_merge($query_data,array(':imo' => $imo)); |
|
| 84 | + $query_data = array_merge($query_data, array(':imo' => $imo)); |
|
| 85 | 85 | } |
| 86 | 86 | if ($name != '') { |
| 87 | 87 | $query .= " AND marine_image.name = :name"; |
| 88 | - $query_data = array_merge($query_data,array(':name' => $name)); |
|
| 88 | + $query_data = array_merge($query_data, array(':name' => $name)); |
|
| 89 | 89 | } |
| 90 | 90 | $query .= " LIMIT 1"; |
| 91 | 91 | $sth = $this->db->prepare($query); |
@@ -106,9 +106,9 @@ discard block |
||
| 106 | 106 | if (isset($exif['COMPUTED']['copyright'])) $copyright = $exif['COMPUTED']['copyright']; |
| 107 | 107 | elseif (isset($exif['copyright'])) $copyright = $exif['copyright']; |
| 108 | 108 | if ($copyright != '') { |
| 109 | - $copyright = str_replace('Copyright ','',$copyright); |
|
| 110 | - $copyright = str_replace('© ','',$copyright); |
|
| 111 | - $copyright = str_replace('(c) ','',$copyright); |
|
| 109 | + $copyright = str_replace('Copyright ', '', $copyright); |
|
| 110 | + $copyright = str_replace('© ', '', $copyright); |
|
| 111 | + $copyright = str_replace('(c) ', '', $copyright); |
|
| 112 | 112 | } |
| 113 | 113 | return $copyright; |
| 114 | 114 | } |
@@ -121,25 +121,25 @@ discard block |
||
| 121 | 121 | * @param string $airline_icao |
| 122 | 122 | * @return String either success or error |
| 123 | 123 | */ |
| 124 | - public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '') |
|
| 124 | + public function addSpotterImage($registration, $aircraft_icao = '', $airline_icao = '') |
|
| 125 | 125 | { |
| 126 | - global $globalDebug,$globalAircraftImageFetch, $globalOffline; |
|
| 126 | + global $globalDebug, $globalAircraftImageFetch, $globalOffline; |
|
| 127 | 127 | if ((isset($globalAircraftImageFetch) && $globalAircraftImageFetch === FALSE) || (isset($globalOffline) && $globalOffline === TRUE)) return ''; |
| 128 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 128 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
| 129 | 129 | $registration = trim($registration); |
| 130 | 130 | //getting the aircraft image |
| 131 | 131 | if ($globalDebug && $registration != '') echo 'Try to find an aircraft image for '.$registration.'...'; |
| 132 | 132 | elseif ($globalDebug && $aircraft_icao != '') echo 'Try to find an aircraft image for '.$aircraft_icao.'...'; |
| 133 | 133 | elseif ($globalDebug && $airline_icao != '') echo 'Try to find an aircraft image for '.$airline_icao.'...'; |
| 134 | - $image_url = $this->findAircraftImage($registration,$aircraft_icao,$airline_icao); |
|
| 134 | + $image_url = $this->findAircraftImage($registration, $aircraft_icao, $airline_icao); |
|
| 135 | 135 | if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao; |
| 136 | 136 | if ($image_url['original'] != '') { |
| 137 | 137 | if ($globalDebug) echo 'Found !'."\n"; |
| 138 | - $query = "INSERT INTO spotter_image (registration, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:registration,:image,:image_thumbnail,:copyright,:source,:source_website)"; |
|
| 138 | + $query = "INSERT INTO spotter_image (registration, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:registration,:image,:image_thumbnail,:copyright,:source,:source_website)"; |
|
| 139 | 139 | try { |
| 140 | 140 | $sth = $this->db->prepare($query); |
| 141 | - $sth->execute(array(':registration' => $registration,':image' => $image_url['original'],':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'],':source' => $image_url['source'],':source_website' => $image_url['source_website'])); |
|
| 142 | - } catch(PDOException $e) { |
|
| 141 | + $sth->execute(array(':registration' => $registration, ':image' => $image_url['original'], ':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'], ':source' => $image_url['source'], ':source_website' => $image_url['source_website'])); |
|
| 142 | + } catch (PDOException $e) { |
|
| 143 | 143 | echo $e->getMessage()."\n"; |
| 144 | 144 | return "error"; |
| 145 | 145 | } |
@@ -155,13 +155,13 @@ discard block |
||
| 155 | 155 | * @param string $name |
| 156 | 156 | * @return String either success or error |
| 157 | 157 | */ |
| 158 | - public function addMarineImage($mmsi,$imo = '',$name = '') |
|
| 158 | + public function addMarineImage($mmsi, $imo = '', $name = '') |
|
| 159 | 159 | { |
| 160 | - global $globalDebug,$globalMarineImageFetch, $globalOffline; |
|
| 160 | + global $globalDebug, $globalMarineImageFetch, $globalOffline; |
|
| 161 | 161 | if ((isset($globalMarineImageFetch) && !$globalMarineImageFetch) || (isset($globalOffline) && $globalOffline === TRUE)) return ''; |
| 162 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
|
| 163 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
| 164 | - $name = filter_var($name,FILTER_SANITIZE_STRING); |
|
| 162 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); |
|
| 163 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
| 164 | + $name = filter_var($name, FILTER_SANITIZE_STRING); |
|
| 165 | 165 | $name = trim($name); |
| 166 | 166 | $Marine = new Marine($this->db); |
| 167 | 167 | if ($imo == '' || $name == '') { |
@@ -175,14 +175,14 @@ discard block |
||
| 175 | 175 | |
| 176 | 176 | //getting the aircraft image |
| 177 | 177 | if ($globalDebug && $name != '') echo 'Try to find an vessel image for '.$name.'...'; |
| 178 | - $image_url = $this->findMarineImage($mmsi,$imo,$name); |
|
| 178 | + $image_url = $this->findMarineImage($mmsi, $imo, $name); |
|
| 179 | 179 | if ($image_url['original'] != '') { |
| 180 | 180 | if ($globalDebug) echo 'Found !'."\n"; |
| 181 | - $query = "INSERT INTO marine_image (mmsi,imo,name, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:mmsi,:imo,:name,:image,:image_thumbnail,:copyright,:source,:source_website)"; |
|
| 181 | + $query = "INSERT INTO marine_image (mmsi,imo,name, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:mmsi,:imo,:name,:image,:image_thumbnail,:copyright,:source,:source_website)"; |
|
| 182 | 182 | try { |
| 183 | 183 | $sth = $this->db->prepare($query); |
| 184 | - $sth->execute(array(':mmsi' => $mmsi,':imo' => $imo,':name' => $name,':image' => $image_url['original'],':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'],':source' => $image_url['source'],':source_website' => $image_url['source_website'])); |
|
| 185 | - } catch(PDOException $e) { |
|
| 184 | + $sth->execute(array(':mmsi' => $mmsi, ':imo' => $imo, ':name' => $name, ':image' => $image_url['original'], ':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'], ':source' => $image_url['source'], ':source_website' => $image_url['source_website'])); |
|
| 185 | + } catch (PDOException $e) { |
|
| 186 | 186 | echo $e->getMessage()."\n"; |
| 187 | 187 | return "error"; |
| 188 | 188 | } |
@@ -203,9 +203,9 @@ discard block |
||
| 203 | 203 | global $globalAircraftImageSources, $globalIVAO, $globalAircraftImageCheckICAO, $globalVA; |
| 204 | 204 | $Spotter = new Spotter($this->db); |
| 205 | 205 | if (!isset($globalIVAO)) $globalIVAO = FALSE; |
| 206 | - $aircraft_registration = filter_var($aircraft_registration,FILTER_SANITIZE_STRING); |
|
| 206 | + $aircraft_registration = filter_var($aircraft_registration, FILTER_SANITIZE_STRING); |
|
| 207 | 207 | if ($aircraft_registration != '' && $aircraft_registration != 'NA' && (!isset($globalVA) || $globalVA !== TRUE)) { |
| 208 | - if (strpos($aircraft_registration,'/') !== false) return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
| 208 | + if (strpos($aircraft_registration, '/') !== false) return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
| 209 | 209 | $aircraft_registration = urlencode(trim($aircraft_registration)); |
| 210 | 210 | $aircraft_info = $Spotter->getAircraftInfoByRegistration($aircraft_registration); |
| 211 | 211 | if (isset($aircraft_info[0]['aircraft_name'])) $aircraft_name = $aircraft_info[0]['aircraft_name']; |
@@ -219,25 +219,25 @@ discard block |
||
| 219 | 219 | if (isset($aircraft_info[0]['type'])) $aircraft_name = $aircraft_info[0]['type']; |
| 220 | 220 | else $aircraft_name = ''; |
| 221 | 221 | $aircraft_registration = $aircraft_icao; |
| 222 | - } else return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
| 222 | + } else return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
| 223 | 223 | unset($Spotter); |
| 224 | - if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters'); |
|
| 224 | + if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl', 'wikimedia', 'airportdata', 'deviantart', 'flickr', 'bing', 'jetphotos', 'planepictures', 'planespotters'); |
|
| 225 | 225 | foreach ($globalAircraftImageSources as $source) { |
| 226 | 226 | $source = strtolower($source); |
| 227 | - if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl('aircraft',$aircraft_icao,$airline_icao); |
|
| 228 | - if ($source == 'planespotters' && !$globalIVAO && extension_loaded('simplexml')) $images_array = $this->fromPlanespotters('aircraft',$aircraft_registration,$aircraft_name); |
|
| 229 | - if ($source == 'flickr' && extension_loaded('simplexml')) $images_array = $this->fromFlickr('aircraft',$aircraft_registration,$aircraft_name); |
|
| 230 | - if ($source == 'bing') $images_array = $this->fromBing('aircraft',$aircraft_registration,$aircraft_name); |
|
| 231 | - if ($source == 'deviantart' && extension_loaded('simplexml')) $images_array = $this->fromDeviantart('aircraft',$aircraft_registration,$aircraft_name); |
|
| 232 | - if ($source == 'wikimedia') $images_array = $this->fromWikimedia('aircraft',$aircraft_registration,$aircraft_name); |
|
| 233 | - if ($source == 'jetphotos' && !$globalIVAO && class_exists("DomDocument")) $images_array = $this->fromJetPhotos('aircraft',$aircraft_registration,$aircraft_name); |
|
| 234 | - if ($source == 'planepictures' && !$globalIVAO && class_exists("DomDocument")) $images_array = $this->fromPlanePictures('aircraft',$aircraft_registration,$aircraft_name); |
|
| 235 | - if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData('aircraft',$aircraft_registration,$aircraft_name); |
|
| 236 | - if ($source == 'customsources') $images_array = $this->fromCustomSource('aircraft',$aircraft_registration,$aircraft_name); |
|
| 227 | + if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl('aircraft', $aircraft_icao, $airline_icao); |
|
| 228 | + if ($source == 'planespotters' && !$globalIVAO && extension_loaded('simplexml')) $images_array = $this->fromPlanespotters('aircraft', $aircraft_registration, $aircraft_name); |
|
| 229 | + if ($source == 'flickr' && extension_loaded('simplexml')) $images_array = $this->fromFlickr('aircraft', $aircraft_registration, $aircraft_name); |
|
| 230 | + if ($source == 'bing') $images_array = $this->fromBing('aircraft', $aircraft_registration, $aircraft_name); |
|
| 231 | + if ($source == 'deviantart' && extension_loaded('simplexml')) $images_array = $this->fromDeviantart('aircraft', $aircraft_registration, $aircraft_name); |
|
| 232 | + if ($source == 'wikimedia') $images_array = $this->fromWikimedia('aircraft', $aircraft_registration, $aircraft_name); |
|
| 233 | + if ($source == 'jetphotos' && !$globalIVAO && class_exists("DomDocument")) $images_array = $this->fromJetPhotos('aircraft', $aircraft_registration, $aircraft_name); |
|
| 234 | + if ($source == 'planepictures' && !$globalIVAO && class_exists("DomDocument")) $images_array = $this->fromPlanePictures('aircraft', $aircraft_registration, $aircraft_name); |
|
| 235 | + if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData('aircraft', $aircraft_registration, $aircraft_name); |
|
| 236 | + if ($source == 'customsources') $images_array = $this->fromCustomSource('aircraft', $aircraft_registration, $aircraft_name); |
|
| 237 | 237 | if (isset($images_array) && $images_array['original'] != '') return $images_array; |
| 238 | 238 | } |
| 239 | 239 | if ((!isset($globalAircraftImageCheckICAO) || $globalAircraftImageCheckICAO === TRUE) && isset($aircraft_icao)) return $this->findAircraftImage($aircraft_icao); |
| 240 | - return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
| 240 | + return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | /** |
@@ -249,14 +249,14 @@ discard block |
||
| 249 | 249 | * @return array the aircraft thumbnail, orignal url and copyright |
| 250 | 250 | * |
| 251 | 251 | */ |
| 252 | - public function findMarineImage($mmsi,$imo = '',$name = '') |
|
| 252 | + public function findMarineImage($mmsi, $imo = '', $name = '') |
|
| 253 | 253 | { |
| 254 | 254 | global $globalMarineImageSources; |
| 255 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
|
| 255 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); |
|
| 256 | 256 | //$imo = filter_var($imo,FILTER_SANITIZE_STRING); |
| 257 | - $name = filter_var($name,FILTER_SANITIZE_STRING); |
|
| 257 | + $name = filter_var($name, FILTER_SANITIZE_STRING); |
|
| 258 | 258 | $name = trim($name); |
| 259 | - if (strlen($name) < 4) return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
| 259 | + if (strlen($name) < 4) return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
| 260 | 260 | /* |
| 261 | 261 | $Marine = new Marine($this->db); |
| 262 | 262 | if ($imo == '' || $name == '') { |
@@ -268,17 +268,17 @@ discard block |
||
| 268 | 268 | } |
| 269 | 269 | unset($Marine); |
| 270 | 270 | */ |
| 271 | - if (!isset($globalMarineImageSources)) $globalMarineImageSources = array('wikimedia','deviantart','flickr','bing'); |
|
| 271 | + if (!isset($globalMarineImageSources)) $globalMarineImageSources = array('wikimedia', 'deviantart', 'flickr', 'bing'); |
|
| 272 | 272 | foreach ($globalMarineImageSources as $source) { |
| 273 | 273 | $source = strtolower($source); |
| 274 | - if ($source == 'flickr') $images_array = $this->fromFlickr('marine',$mmsi,$name); |
|
| 275 | - if ($source == 'bing') $images_array = $this->fromBing('marine',$mmsi,$name); |
|
| 276 | - if ($source == 'deviantart') $images_array = $this->fromDeviantart('marine',$mmsi,$name); |
|
| 277 | - if ($source == 'wikimedia') $images_array = $this->fromWikimedia('marine',$mmsi,$name); |
|
| 278 | - if ($source == 'customsources') $images_array = $this->fromCustomSource('marine',$mmsi,$name); |
|
| 274 | + if ($source == 'flickr') $images_array = $this->fromFlickr('marine', $mmsi, $name); |
|
| 275 | + if ($source == 'bing') $images_array = $this->fromBing('marine', $mmsi, $name); |
|
| 276 | + if ($source == 'deviantart') $images_array = $this->fromDeviantart('marine', $mmsi, $name); |
|
| 277 | + if ($source == 'wikimedia') $images_array = $this->fromWikimedia('marine', $mmsi, $name); |
|
| 278 | + if ($source == 'customsources') $images_array = $this->fromCustomSource('marine', $mmsi, $name); |
|
| 279 | 279 | if (isset($images_array) && $images_array['original'] != '') return $images_array; |
| 280 | 280 | } |
| 281 | - return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
| 281 | + return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
| 282 | 282 | } |
| 283 | 283 | |
| 284 | 284 | /** |
@@ -289,30 +289,30 @@ discard block |
||
| 289 | 289 | * @return array the aircraft thumbnail, orignal url and copyright |
| 290 | 290 | * |
| 291 | 291 | */ |
| 292 | - public function fromPlanespotters($type,$aircraft_registration, $aircraft_name='') { |
|
| 292 | + public function fromPlanespotters($type, $aircraft_registration, $aircraft_name = '') { |
|
| 293 | 293 | $Common = new Common(); |
| 294 | 294 | // If aircraft registration is only number, also check with aircraft model |
| 295 | - if (preg_match('/^[[:digit]]+$/',$aircraft_registration) && $aircraft_name != '') { |
|
| 296 | - $url= 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$aircraft_registration.'&actype=s_'.urlencode($aircraft_name).'&output=rss'; |
|
| 295 | + if (preg_match('/^[[:digit]]+$/', $aircraft_registration) && $aircraft_name != '') { |
|
| 296 | + $url = 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$aircraft_registration.'&actype=s_'.urlencode($aircraft_name).'&output=rss'; |
|
| 297 | 297 | } else { |
| 298 | 298 | //$url= 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$airline_aircraft_type.'&output=rss'; |
| 299 | - $url= 'http://www.planespotters.net/Aviation_Photos/search.php?reg='.$aircraft_registration.'&output=rss'; |
|
| 299 | + $url = 'http://www.planespotters.net/Aviation_Photos/search.php?reg='.$aircraft_registration.'&output=rss'; |
|
| 300 | 300 | } |
| 301 | 301 | $data = $Common->getData($url); |
| 302 | - if (substr($data, 0, 5) != "<?xml") return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
| 302 | + if (substr($data, 0, 5) != "<?xml") return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
| 303 | 303 | if ($xml = simplexml_load_string($data)) { |
| 304 | 304 | if (isset($xml->channel->item)) { |
| 305 | 305 | $image_url = array(); |
| 306 | - $thumbnail_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url); |
|
| 306 | + $thumbnail_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url); |
|
| 307 | 307 | $image_url['thumbnail'] = $thumbnail_url; |
| 308 | - $image_url['original'] = str_replace('thumbnail','original',$thumbnail_url); |
|
| 309 | - $image_url['copyright'] = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright); |
|
| 310 | - $image_url['source_website'] = trim((string)$xml->channel->item->link); |
|
| 308 | + $image_url['original'] = str_replace('thumbnail', 'original', $thumbnail_url); |
|
| 309 | + $image_url['copyright'] = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright); |
|
| 310 | + $image_url['source_website'] = trim((string) $xml->channel->item->link); |
|
| 311 | 311 | $image_url['source'] = 'planespotters'; |
| 312 | 312 | return $image_url; |
| 313 | 313 | } |
| 314 | 314 | } |
| 315 | - return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
| 315 | + return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
| 316 | 316 | } |
| 317 | 317 | |
| 318 | 318 | /** |
@@ -323,36 +323,36 @@ discard block |
||
| 323 | 323 | * @param String $name type of the aircraft |
| 324 | 324 | * @return array the aircraft thumbnail, orignal url and copyright |
| 325 | 325 | */ |
| 326 | - public function fromDeviantart($type,$registration, $name='') { |
|
| 326 | + public function fromDeviantart($type, $registration, $name = '') { |
|
| 327 | 327 | $Common = new Common(); |
| 328 | 328 | if ($type == 'aircraft') { |
| 329 | 329 | // If aircraft registration is only number, also check with aircraft model |
| 330 | - if (preg_match('/^[[:digit]]+$/',$registration) && $name != '') { |
|
| 331 | - $url= 'http://backend.deviantart.com/rss.xml?type=deviation&q='.$registration.'%20'.urlencode($name); |
|
| 330 | + if (preg_match('/^[[:digit]]+$/', $registration) && $name != '') { |
|
| 331 | + $url = 'http://backend.deviantart.com/rss.xml?type=deviation&q='.$registration.'%20'.urlencode($name); |
|
| 332 | 332 | } else { |
| 333 | - $url= 'http://backend.deviantart.com/rss.xml?type=deviation&q=aircraft%20'.$registration; |
|
| 333 | + $url = 'http://backend.deviantart.com/rss.xml?type=deviation&q=aircraft%20'.$registration; |
|
| 334 | 334 | } |
| 335 | 335 | } elseif ($type == 'marine') { |
| 336 | - $url= 'http://backend.deviantart.com/rss.xml?type=deviation&q=ship%20"'.urlencode($name).'"'; |
|
| 336 | + $url = 'http://backend.deviantart.com/rss.xml?type=deviation&q=ship%20"'.urlencode($name).'"'; |
|
| 337 | 337 | } else { |
| 338 | - $url= 'http://backend.deviantart.com/rss.xml?type=deviation&q="'.urlencode($name).'"'; |
|
| 338 | + $url = 'http://backend.deviantart.com/rss.xml?type=deviation&q="'.urlencode($name).'"'; |
|
| 339 | 339 | } |
| 340 | 340 | $data = $Common->getData($url); |
| 341 | - if (substr($data, 0, 5) != "<?xml") return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
| 341 | + if (substr($data, 0, 5) != "<?xml") return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
| 342 | 342 | if ($xml = simplexml_load_string($data)) { |
| 343 | 343 | if (isset($xml->channel->item->link)) { |
| 344 | 344 | $image_url = array(); |
| 345 | - $thumbnail_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url); |
|
| 345 | + $thumbnail_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url); |
|
| 346 | 346 | $image_url['thumbnail'] = $thumbnail_url; |
| 347 | - $original_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->content->attributes()->url); |
|
| 347 | + $original_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->content->attributes()->url); |
|
| 348 | 348 | $image_url['original'] = $original_url; |
| 349 | - $image_url['copyright'] = str_replace('Copyright ','',trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright)); |
|
| 350 | - $image_url['source_website'] = trim((string)$xml->channel->item->link); |
|
| 349 | + $image_url['copyright'] = str_replace('Copyright ', '', trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright)); |
|
| 350 | + $image_url['source_website'] = trim((string) $xml->channel->item->link); |
|
| 351 | 351 | $image_url['source'] = 'deviantart'; |
| 352 | 352 | return $image_url; |
| 353 | 353 | } |
| 354 | 354 | } |
| 355 | - return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
| 355 | + return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
| 356 | 356 | } |
| 357 | 357 | |
| 358 | 358 | /** |
@@ -363,38 +363,38 @@ discard block |
||
| 363 | 363 | * @return array the aircraft thumbnail, orignal url and copyright |
| 364 | 364 | * |
| 365 | 365 | */ |
| 366 | - public function fromJetPhotos($type,$aircraft_registration, $aircraft_name='') { |
|
| 366 | + public function fromJetPhotos($type, $aircraft_registration, $aircraft_name = '') { |
|
| 367 | 367 | $Common = new Common(); |
| 368 | - $url= 'http://jetphotos.net/showphotos.php?displaymode=2®search='.$aircraft_registration; |
|
| 368 | + $url = 'http://jetphotos.net/showphotos.php?displaymode=2®search='.$aircraft_registration; |
|
| 369 | 369 | $data = $Common->getData($url); |
| 370 | 370 | $dom = new DOMDocument(); |
| 371 | 371 | @$dom->loadHTML($data); |
| 372 | 372 | $all_pics = array(); |
| 373 | - foreach($dom->getElementsByTagName('img') as $image) { |
|
| 373 | + foreach ($dom->getElementsByTagName('img') as $image) { |
|
| 374 | 374 | if ($image->getAttribute('itemprop') == "http://schema.org/image") { |
| 375 | 375 | $all_pics[] = $image->getAttribute('src'); |
| 376 | 376 | } |
| 377 | 377 | } |
| 378 | 378 | $all_authors = array(); |
| 379 | - foreach($dom->getElementsByTagName('meta') as $author) { |
|
| 379 | + foreach ($dom->getElementsByTagName('meta') as $author) { |
|
| 380 | 380 | if ($author->getAttribute('itemprop') == "http://schema.org/author") { |
| 381 | 381 | $all_authors[] = $author->getAttribute('content'); |
| 382 | 382 | } |
| 383 | 383 | } |
| 384 | 384 | $all_ref = array(); |
| 385 | - foreach($dom->getElementsByTagName('a') as $link) { |
|
| 385 | + foreach ($dom->getElementsByTagName('a') as $link) { |
|
| 386 | 386 | $all_ref[] = $link->getAttribute('href'); |
| 387 | 387 | } |
| 388 | 388 | if (isset($all_pics[0])) { |
| 389 | 389 | $image_url = array(); |
| 390 | 390 | $image_url['thumbnail'] = $all_pics[0]; |
| 391 | - $image_url['original'] = str_replace('_tb','',$all_pics[0]); |
|
| 391 | + $image_url['original'] = str_replace('_tb', '', $all_pics[0]); |
|
| 392 | 392 | $image_url['copyright'] = $all_authors[0]; |
| 393 | 393 | $image_url['source_website'] = 'http://jetphotos.net'.$all_ref[8]; |
| 394 | 394 | $image_url['source'] = 'JetPhotos'; |
| 395 | 395 | return $image_url; |
| 396 | 396 | } |
| 397 | - return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
| 397 | + return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
| 398 | 398 | } |
| 399 | 399 | |
| 400 | 400 | /** |
@@ -405,30 +405,30 @@ discard block |
||
| 405 | 405 | * @return array the aircraft thumbnail, orignal url and copyright |
| 406 | 406 | * |
| 407 | 407 | */ |
| 408 | - public function fromPlanePictures($type,$aircraft_registration, $aircraft_name='') { |
|
| 408 | + public function fromPlanePictures($type, $aircraft_registration, $aircraft_name = '') { |
|
| 409 | 409 | $Common = new Common(); |
| 410 | - $url= 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2'; |
|
| 410 | + $url = 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2'; |
|
| 411 | 411 | $data = $Common->getData($url); |
| 412 | 412 | $dom = new DOMDocument(); |
| 413 | 413 | @$dom->loadHTML($data); |
| 414 | 414 | $all_pics = array(); |
| 415 | - foreach($dom->getElementsByTagName('img') as $image) { |
|
| 415 | + foreach ($dom->getElementsByTagName('img') as $image) { |
|
| 416 | 416 | $all_pics[] = $image->getAttribute('src'); |
| 417 | 417 | } |
| 418 | 418 | $all_links = array(); |
| 419 | - foreach($dom->getElementsByTagName('a') as $link) { |
|
| 420 | - $all_links[] = array('text' => $link->textContent,'href' => $link->getAttribute('href')); |
|
| 419 | + foreach ($dom->getElementsByTagName('a') as $link) { |
|
| 420 | + $all_links[] = array('text' => $link->textContent, 'href' => $link->getAttribute('href')); |
|
| 421 | 421 | } |
| 422 | - if (isset($all_pics[1]) && !preg_match('/bit.ly/',$all_pics[1]) && !preg_match('/flagge/',$all_pics[1])) { |
|
| 422 | + if (isset($all_pics[1]) && !preg_match('/bit.ly/', $all_pics[1]) && !preg_match('/flagge/', $all_pics[1])) { |
|
| 423 | 423 | $image_url = array(); |
| 424 | 424 | $image_url['thumbnail'] = 'http://www.planepictures.net/'.$all_pics[1]; |
| 425 | - $image_url['original'] = 'http://www.planepictures.net/'.str_replace('_TN','',$all_pics[1]); |
|
| 425 | + $image_url['original'] = 'http://www.planepictures.net/'.str_replace('_TN', '', $all_pics[1]); |
|
| 426 | 426 | $image_url['copyright'] = $all_links[6]['text']; |
| 427 | 427 | $image_url['source_website'] = 'http://www.planepictures.net/'.$all_links[2]['href']; |
| 428 | 428 | $image_url['source'] = 'PlanePictures'; |
| 429 | 429 | return $image_url; |
| 430 | 430 | } |
| 431 | - return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
| 431 | + return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
| 432 | 432 | } |
| 433 | 433 | |
| 434 | 434 | /** |
@@ -439,7 +439,7 @@ discard block |
||
| 439 | 439 | * @return array the aircraft thumbnail, orignal url and copyright |
| 440 | 440 | * |
| 441 | 441 | */ |
| 442 | - public function fromFlickr($type,$registration,$name='') { |
|
| 442 | + public function fromFlickr($type, $registration, $name = '') { |
|
| 443 | 443 | $Common = new Common(); |
| 444 | 444 | if ($type == 'aircraft') { |
| 445 | 445 | if ($name != '') $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.','.urlencode($name); |
@@ -449,20 +449,20 @@ discard block |
||
| 449 | 449 | else $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.',ship'; |
| 450 | 450 | } |
| 451 | 451 | $data = $Common->getData($url); |
| 452 | - if (substr($data, 0, 5) != "<?xml") return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
| 452 | + if (substr($data, 0, 5) != "<?xml") return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
| 453 | 453 | if ($xml = simplexml_load_string($data)) { |
| 454 | 454 | if (isset($xml->channel->item)) { |
| 455 | - $original_url = trim((string)$xml->channel->item->enclosure->attributes()->url); |
|
| 455 | + $original_url = trim((string) $xml->channel->item->enclosure->attributes()->url); |
|
| 456 | 456 | $image_url = array(); |
| 457 | 457 | $image_url['thumbnail'] = $original_url; |
| 458 | 458 | $image_url['original'] = $original_url; |
| 459 | - $image_url['copyright'] = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->credit); |
|
| 460 | - $image_url['source_website'] = trim((string)$xml->channel->item->link); |
|
| 459 | + $image_url['copyright'] = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->credit); |
|
| 460 | + $image_url['source_website'] = trim((string) $xml->channel->item->link); |
|
| 461 | 461 | $image_url['source'] = 'flickr'; |
| 462 | 462 | return $image_url; |
| 463 | 463 | } |
| 464 | 464 | } |
| 465 | - return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
| 465 | + return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
| 466 | 466 | } |
| 467 | 467 | |
| 468 | 468 | /** |
@@ -483,7 +483,7 @@ discard block |
||
| 483 | 483 | $image_url['source'] = 'ivao.aero'; |
| 484 | 484 | return $image_url; |
| 485 | 485 | } else { |
| 486 | - return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
| 486 | + return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
| 487 | 487 | } |
| 488 | 488 | } |
| 489 | 489 | |
@@ -495,10 +495,10 @@ discard block |
||
| 495 | 495 | * @param String $aircraft_name type of the aircraft |
| 496 | 496 | * @return array the aircraft thumbnail, orignal url and copyright |
| 497 | 497 | */ |
| 498 | - public function fromBing($type,$aircraft_registration,$aircraft_name='') { |
|
| 498 | + public function fromBing($type, $aircraft_registration, $aircraft_name = '') { |
|
| 499 | 499 | global $globalImageBingKey; |
| 500 | 500 | $Common = new Common(); |
| 501 | - if (!isset($globalImageBingKey) || $globalImageBingKey == '') return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
| 501 | + if (!isset($globalImageBingKey) || $globalImageBingKey == '') return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
| 502 | 502 | if ($type == 'aircraft') { |
| 503 | 503 | if ($aircraft_name != '') $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.$aircraft_registration.'%20'.urlencode($aircraft_name).'%20-site:planespotters.com%20-site:flickr.com%27'; |
| 504 | 504 | else $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Baircraft%20-site:planespotters.com%20-site:flickr.com%27'; |
@@ -506,8 +506,8 @@ discard block |
||
| 506 | 506 | if ($aircraft_name != '') $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.urlencode($aircraft_name).'%20%2Bship%20-site:flickr.com%27'; |
| 507 | 507 | else $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Bship%20-site:flickr.com%27'; |
| 508 | 508 | } |
| 509 | - $headers = array("Authorization: Basic " . base64_encode("ignored:".$globalImageBingKey)); |
|
| 510 | - $data = $Common->getData($url,'get','',$headers); |
|
| 509 | + $headers = array("Authorization: Basic ".base64_encode("ignored:".$globalImageBingKey)); |
|
| 510 | + $data = $Common->getData($url, 'get', '', $headers); |
|
| 511 | 511 | $result = json_decode($data); |
| 512 | 512 | if (isset($result->d->results[0]->MediaUrl)) { |
| 513 | 513 | $image_url = array(); |
@@ -521,7 +521,7 @@ discard block |
||
| 521 | 521 | $image_url['source'] = 'bing'; |
| 522 | 522 | return $image_url; |
| 523 | 523 | } |
| 524 | - return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
| 524 | + return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
| 525 | 525 | } |
| 526 | 526 | |
| 527 | 527 | /** |
@@ -532,21 +532,21 @@ discard block |
||
| 532 | 532 | * @return array the aircraft thumbnail, orignal url and copyright |
| 533 | 533 | * |
| 534 | 534 | */ |
| 535 | - public function fromAirportData($type,$aircraft_registration,$aircraft_name='') { |
|
| 535 | + public function fromAirportData($type, $aircraft_registration, $aircraft_name = '') { |
|
| 536 | 536 | $Common = new Common(); |
| 537 | 537 | $url = 'http://www.airport-data.com/api/ac_thumb.json?&n=1&r='.$aircraft_registration; |
| 538 | 538 | $data = $Common->getData($url); |
| 539 | 539 | $result = json_decode($data); |
| 540 | 540 | if (isset($result->count) && $result->count > 0) { |
| 541 | 541 | $image_url = array(); |
| 542 | - $image_url['original'] = str_replace('thumbnails','large',$result->data[0]->image); |
|
| 542 | + $image_url['original'] = str_replace('thumbnails', 'large', $result->data[0]->image); |
|
| 543 | 543 | $image_url['source_website'] = $result->data[0]->link; |
| 544 | 544 | $image_url['thumbnail'] = $result->data[0]->image; |
| 545 | 545 | $image_url['copyright'] = $result->data[0]->photographer; |
| 546 | 546 | $image_url['source'] = 'AirportData'; |
| 547 | 547 | return $image_url; |
| 548 | 548 | } |
| 549 | - return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
| 549 | + return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
| 550 | 550 | } |
| 551 | 551 | |
| 552 | 552 | /** |
@@ -557,20 +557,20 @@ discard block |
||
| 557 | 557 | * @return array the aircraft thumbnail, orignal url and copyright |
| 558 | 558 | * |
| 559 | 559 | */ |
| 560 | - public function fromWikimedia($type,$registration,$name='') { |
|
| 560 | + public function fromWikimedia($type, $registration, $name = '') { |
|
| 561 | 561 | $Common = new Common(); |
| 562 | 562 | if ($type == 'aircraft') { |
| 563 | 563 | if ($name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20'.urlencode($name); |
| 564 | 564 | else $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20aircraft'; |
| 565 | 565 | } elseif ($type == 'marine') { |
| 566 | 566 | if ($name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.urlencode($name).'%20ship"'; |
| 567 | - else return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
| 567 | + else return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
| 568 | 568 | } |
| 569 | 569 | $data = $Common->getData($url); |
| 570 | 570 | $result = json_decode($data); |
| 571 | 571 | if (isset($result->query->search[0]->title)) { |
| 572 | 572 | $fileo = $result->query->search[0]->title; |
| 573 | - if (substr($fileo,-3) == 'pdf') return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
| 573 | + if (substr($fileo, -3) == 'pdf') return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
| 574 | 574 | $file = urlencode($fileo); |
| 575 | 575 | $url2 = 'https://commons.wikimedia.org/w/api.php?action=query&format=json&continue&iilimit=500&prop=imageinfo&iiprop=user|url|size|mime|sha1|timestamp&iiurlwidth=200%27&titles='.$file; |
| 576 | 576 | $data2 = $Common->getData($url2); |
@@ -595,11 +595,11 @@ discard block |
||
| 595 | 595 | if (isset($result2->query->pages)) { |
| 596 | 596 | foreach ($result2->query->pages as $page) { |
| 597 | 597 | if (isset($page->imageinfo[0]->extmetadata->Artist)) { |
| 598 | - $image_url['copyright'] = preg_replace('/ from(.*)/','',strip_tags($page->imageinfo[0]->extmetadata->Artist->value)); |
|
| 598 | + $image_url['copyright'] = preg_replace('/ from(.*)/', '', strip_tags($page->imageinfo[0]->extmetadata->Artist->value)); |
|
| 599 | 599 | if (isset($page->imageinfo[0]->extmetadata->License->value)) { |
| 600 | 600 | $image_url['copyright'] = $image_url['copyright'].' (under '.$page->imageinfo[0]->extmetadata->License->value.')'; |
| 601 | 601 | } |
| 602 | - $image_url['copyright'] = trim(str_replace('\n','',$image_url['copyright'])); |
|
| 602 | + $image_url['copyright'] = trim(str_replace('\n', '', $image_url['copyright'])); |
|
| 603 | 603 | return $image_url; |
| 604 | 604 | } |
| 605 | 605 | } |
@@ -607,7 +607,7 @@ discard block |
||
| 607 | 607 | return $image_url; |
| 608 | 608 | } |
| 609 | 609 | } |
| 610 | - return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
| 610 | + return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
| 611 | 611 | } |
| 612 | 612 | |
| 613 | 613 | /** |
@@ -618,7 +618,7 @@ discard block |
||
| 618 | 618 | * @return array the aircraft thumbnail, orignal url and copyright |
| 619 | 619 | * |
| 620 | 620 | */ |
| 621 | - public function fromCustomSource($type,$registration,$name='') { |
|
| 621 | + public function fromCustomSource($type, $registration, $name = '') { |
|
| 622 | 622 | global $globalAircraftImageCustomSources, $globalMarineImageCustomSources, $globalDebug; |
| 623 | 623 | //$globalAircraftImageCustomSource[] = array('thumbnail' => '','original' => '', 'copyright' => '', 'source_website' => '', 'source' => '','exif' => true); |
| 624 | 624 | if (!empty($globalAircraftImageCustomSources) && $type == 'aircraft') { |
@@ -635,15 +635,15 @@ discard block |
||
| 635 | 635 | print_r($source); |
| 636 | 636 | print_r($customsources); |
| 637 | 637 | } |
| 638 | - $url = str_replace('{registration}',$registration,$source['original']); |
|
| 639 | - $url_thumbnail = str_replace('{registration}',$registration,$source['thumbnail']); |
|
| 638 | + $url = str_replace('{registration}', $registration, $source['original']); |
|
| 639 | + $url_thumbnail = str_replace('{registration}', $registration, $source['thumbnail']); |
|
| 640 | 640 | if ($Common->urlexist($url)) { |
| 641 | 641 | $image_url = array(); |
| 642 | 642 | $image_url['thumbnail'] = $url_thumbnail; |
| 643 | 643 | $image_url['original'] = $url; |
| 644 | 644 | if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url); |
| 645 | 645 | else $exifCopyright = ''; |
| 646 | - if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
| 646 | + if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
| 647 | 647 | elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright']; |
| 648 | 648 | else $image_url['copyright'] = $source['source_website']; |
| 649 | 649 | $image_url['source_website'] = $source['source_website']; |
@@ -651,8 +651,8 @@ discard block |
||
| 651 | 651 | return $image_url; |
| 652 | 652 | } |
| 653 | 653 | } |
| 654 | - return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
| 655 | - } else return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
| 654 | + return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
| 655 | + } else return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
| 656 | 656 | |
| 657 | 657 | if (!empty($globalMarineImageCustomSources) && $type == 'marine') { |
| 658 | 658 | $customsources = array(); |
@@ -668,19 +668,19 @@ discard block |
||
| 668 | 668 | print_r($source); |
| 669 | 669 | print_r($customsources); |
| 670 | 670 | } |
| 671 | - $url = str_replace('{registration}',$registration,$source['original']); |
|
| 672 | - $url = str_replace('{mmsi}',$registration,$url); |
|
| 673 | - $url = str_replace('{name}',$name,$url); |
|
| 674 | - $url_thumbnail = str_replace('{registration}',$registration,$source['thumbnail']); |
|
| 675 | - $url_thumbnail = str_replace('{mmsi}',$registration,$url_thumbnail); |
|
| 676 | - $url_thumbnail = str_replace('{name}',$name,$url_thumbnail); |
|
| 671 | + $url = str_replace('{registration}', $registration, $source['original']); |
|
| 672 | + $url = str_replace('{mmsi}', $registration, $url); |
|
| 673 | + $url = str_replace('{name}', $name, $url); |
|
| 674 | + $url_thumbnail = str_replace('{registration}', $registration, $source['thumbnail']); |
|
| 675 | + $url_thumbnail = str_replace('{mmsi}', $registration, $url_thumbnail); |
|
| 676 | + $url_thumbnail = str_replace('{name}', $name, $url_thumbnail); |
|
| 677 | 677 | if ($Common->urlexist($url)) { |
| 678 | 678 | $image_url = array(); |
| 679 | 679 | $image_url['thumbnail'] = $url_thumbnail; |
| 680 | 680 | $image_url['original'] = $url; |
| 681 | 681 | if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url); |
| 682 | 682 | else $exifCopyright = ''; |
| 683 | - if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
| 683 | + if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
| 684 | 684 | elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright']; |
| 685 | 685 | else $image_url['copyright'] = $source['source_website']; |
| 686 | 686 | $image_url['source_website'] = $source['source_website']; |
@@ -19,7 +19,9 @@ discard block |
||
| 19 | 19 | public function __construct($dbc = null) { |
| 20 | 20 | $Connection = new Connection($dbc); |
| 21 | 21 | $this->db = $Connection->db(); |
| 22 | - if ($this->db === null) die('Error: No DB connection. (Image)'); |
|
| 22 | + if ($this->db === null) { |
|
| 23 | + die('Error: No DB connection. (Image)'); |
|
| 24 | + } |
|
| 23 | 25 | } |
| 24 | 26 | |
| 25 | 27 | /** |
@@ -36,7 +38,9 @@ discard block |
||
| 36 | 38 | $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
| 37 | 39 | $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
| 38 | 40 | $reg = $registration; |
| 39 | - if (($reg == '' || $reg == 'NA') && $aircraft_icao != '') $reg = $aircraft_icao.$airline_icao; |
|
| 41 | + if (($reg == '' || $reg == 'NA') && $aircraft_icao != '') { |
|
| 42 | + $reg = $aircraft_icao.$airline_icao; |
|
| 43 | + } |
|
| 40 | 44 | $reg = trim($reg); |
| 41 | 45 | $query = "SELECT spotter_image.image, spotter_image.image_thumbnail, spotter_image.image_source, spotter_image.image_source_website,spotter_image.image_copyright, spotter_image.registration |
| 42 | 46 | FROM spotter_image |
@@ -44,9 +48,13 @@ discard block |
||
| 44 | 48 | $sth = $this->db->prepare($query); |
| 45 | 49 | $sth->execute(array(':registration' => $reg)); |
| 46 | 50 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 47 | - if (!empty($result)) return $result; |
|
| 48 | - elseif ($registration != '' && ($aircraft_icao != '' || $airline_icao != '')) return $this->getSpotterImage('',$aircraft_icao,$airline_icao); |
|
| 49 | - else return array(); |
|
| 51 | + if (!empty($result)) { |
|
| 52 | + return $result; |
|
| 53 | + } elseif ($registration != '' && ($aircraft_icao != '' || $airline_icao != '')) { |
|
| 54 | + return $this->getSpotterImage('',$aircraft_icao,$airline_icao); |
|
| 55 | + } else { |
|
| 56 | + return array(); |
|
| 57 | + } |
|
| 50 | 58 | } |
| 51 | 59 | |
| 52 | 60 | /** |
@@ -74,7 +82,9 @@ discard block |
||
| 74 | 82 | } |
| 75 | 83 | } |
| 76 | 84 | $name = trim($name); |
| 77 | - if ($mmsi == '' && $imo == '' && $name == '') return array(); |
|
| 85 | + if ($mmsi == '' && $imo == '' && $name == '') { |
|
| 86 | + return array(); |
|
| 87 | + } |
|
| 78 | 88 | $query = "SELECT marine_image.image, marine_image.image_thumbnail, marine_image.image_source, marine_image.image_source_website,marine_image.image_copyright, marine_image.mmsi, marine_image.imo, marine_image.name |
| 79 | 89 | FROM marine_image |
| 80 | 90 | WHERE marine_image.mmsi = :mmsi"; |
@@ -103,8 +113,11 @@ discard block |
||
| 103 | 113 | public function getExifCopyright($url) { |
| 104 | 114 | $exif = exif_read_data($url); |
| 105 | 115 | $copyright = ''; |
| 106 | - if (isset($exif['COMPUTED']['copyright'])) $copyright = $exif['COMPUTED']['copyright']; |
|
| 107 | - elseif (isset($exif['copyright'])) $copyright = $exif['copyright']; |
|
| 116 | + if (isset($exif['COMPUTED']['copyright'])) { |
|
| 117 | + $copyright = $exif['COMPUTED']['copyright']; |
|
| 118 | + } elseif (isset($exif['copyright'])) { |
|
| 119 | + $copyright = $exif['copyright']; |
|
| 120 | + } |
|
| 108 | 121 | if ($copyright != '') { |
| 109 | 122 | $copyright = str_replace('Copyright ','',$copyright); |
| 110 | 123 | $copyright = str_replace('© ','',$copyright); |
@@ -124,17 +137,27 @@ discard block |
||
| 124 | 137 | public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '') |
| 125 | 138 | { |
| 126 | 139 | global $globalDebug,$globalAircraftImageFetch, $globalOffline; |
| 127 | - if ((isset($globalAircraftImageFetch) && $globalAircraftImageFetch === FALSE) || (isset($globalOffline) && $globalOffline === TRUE)) return ''; |
|
| 140 | + if ((isset($globalAircraftImageFetch) && $globalAircraftImageFetch === FALSE) || (isset($globalOffline) && $globalOffline === TRUE)) { |
|
| 141 | + return ''; |
|
| 142 | + } |
|
| 128 | 143 | $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
| 129 | 144 | $registration = trim($registration); |
| 130 | 145 | //getting the aircraft image |
| 131 | - if ($globalDebug && $registration != '') echo 'Try to find an aircraft image for '.$registration.'...'; |
|
| 132 | - elseif ($globalDebug && $aircraft_icao != '') echo 'Try to find an aircraft image for '.$aircraft_icao.'...'; |
|
| 133 | - elseif ($globalDebug && $airline_icao != '') echo 'Try to find an aircraft image for '.$airline_icao.'...'; |
|
| 146 | + if ($globalDebug && $registration != '') { |
|
| 147 | + echo 'Try to find an aircraft image for '.$registration.'...'; |
|
| 148 | + } elseif ($globalDebug && $aircraft_icao != '') { |
|
| 149 | + echo 'Try to find an aircraft image for '.$aircraft_icao.'...'; |
|
| 150 | + } elseif ($globalDebug && $airline_icao != '') { |
|
| 151 | + echo 'Try to find an aircraft image for '.$airline_icao.'...'; |
|
| 152 | + } |
|
| 134 | 153 | $image_url = $this->findAircraftImage($registration,$aircraft_icao,$airline_icao); |
| 135 | - if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao; |
|
| 154 | + if ($registration == '' && $aircraft_icao != '') { |
|
| 155 | + $registration = $aircraft_icao.$airline_icao; |
|
| 156 | + } |
|
| 136 | 157 | if ($image_url['original'] != '') { |
| 137 | - if ($globalDebug) echo 'Found !'."\n"; |
|
| 158 | + if ($globalDebug) { |
|
| 159 | + echo 'Found !'."\n"; |
|
| 160 | + } |
|
| 138 | 161 | $query = "INSERT INTO spotter_image (registration, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:registration,:image,:image_thumbnail,:copyright,:source,:source_website)"; |
| 139 | 162 | try { |
| 140 | 163 | $sth = $this->db->prepare($query); |
@@ -143,7 +166,9 @@ discard block |
||
| 143 | 166 | echo $e->getMessage()."\n"; |
| 144 | 167 | return "error"; |
| 145 | 168 | } |
| 146 | - } elseif ($globalDebug) echo "Not found :'(\n"; |
|
| 169 | + } elseif ($globalDebug) { |
|
| 170 | + echo "Not found :'(\n"; |
|
| 171 | + } |
|
| 147 | 172 | return "success"; |
| 148 | 173 | } |
| 149 | 174 | |
@@ -158,7 +183,9 @@ discard block |
||
| 158 | 183 | public function addMarineImage($mmsi,$imo = '',$name = '') |
| 159 | 184 | { |
| 160 | 185 | global $globalDebug,$globalMarineImageFetch, $globalOffline; |
| 161 | - if ((isset($globalMarineImageFetch) && !$globalMarineImageFetch) || (isset($globalOffline) && $globalOffline === TRUE)) return ''; |
|
| 186 | + if ((isset($globalMarineImageFetch) && !$globalMarineImageFetch) || (isset($globalOffline) && $globalOffline === TRUE)) { |
|
| 187 | + return ''; |
|
| 188 | + } |
|
| 162 | 189 | $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
| 163 | 190 | $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
| 164 | 191 | $name = filter_var($name,FILTER_SANITIZE_STRING); |
@@ -168,16 +195,22 @@ discard block |
||
| 168 | 195 | $identity = $Marine->getIdentity($mmsi); |
| 169 | 196 | if (isset($identity[0]['mmsi'])) { |
| 170 | 197 | $imo = $identity[0]['imo']; |
| 171 | - if ($identity[0]['ship_name'] != '') $name = $identity[0]['ship_name']; |
|
| 198 | + if ($identity[0]['ship_name'] != '') { |
|
| 199 | + $name = $identity[0]['ship_name']; |
|
| 200 | + } |
|
| 172 | 201 | } |
| 173 | 202 | } |
| 174 | 203 | unset($Marine); |
| 175 | 204 | |
| 176 | 205 | //getting the aircraft image |
| 177 | - if ($globalDebug && $name != '') echo 'Try to find an vessel image for '.$name.'...'; |
|
| 206 | + if ($globalDebug && $name != '') { |
|
| 207 | + echo 'Try to find an vessel image for '.$name.'...'; |
|
| 208 | + } |
|
| 178 | 209 | $image_url = $this->findMarineImage($mmsi,$imo,$name); |
| 179 | 210 | if ($image_url['original'] != '') { |
| 180 | - if ($globalDebug) echo 'Found !'."\n"; |
|
| 211 | + if ($globalDebug) { |
|
| 212 | + echo 'Found !'."\n"; |
|
| 213 | + } |
|
| 181 | 214 | $query = "INSERT INTO marine_image (mmsi,imo,name, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:mmsi,:imo,:name,:image,:image_thumbnail,:copyright,:source,:source_website)"; |
| 182 | 215 | try { |
| 183 | 216 | $sth = $this->db->prepare($query); |
@@ -186,7 +219,9 @@ discard block |
||
| 186 | 219 | echo $e->getMessage()."\n"; |
| 187 | 220 | return "error"; |
| 188 | 221 | } |
| 189 | - } elseif ($globalDebug) echo "Not found :'(\n"; |
|
| 222 | + } elseif ($globalDebug) { |
|
| 223 | + echo "Not found :'(\n"; |
|
| 224 | + } |
|
| 190 | 225 | return "success"; |
| 191 | 226 | } |
| 192 | 227 | |
@@ -202,41 +237,85 @@ discard block |
||
| 202 | 237 | { |
| 203 | 238 | global $globalAircraftImageSources, $globalIVAO, $globalAircraftImageCheckICAO, $globalVA; |
| 204 | 239 | $Spotter = new Spotter($this->db); |
| 205 | - if (!isset($globalIVAO)) $globalIVAO = FALSE; |
|
| 240 | + if (!isset($globalIVAO)) { |
|
| 241 | + $globalIVAO = FALSE; |
|
| 242 | + } |
|
| 206 | 243 | $aircraft_registration = filter_var($aircraft_registration,FILTER_SANITIZE_STRING); |
| 207 | 244 | if ($aircraft_registration != '' && $aircraft_registration != 'NA' && (!isset($globalVA) || $globalVA !== TRUE)) { |
| 208 | - if (strpos($aircraft_registration,'/') !== false) return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
| 245 | + if (strpos($aircraft_registration,'/') !== false) { |
|
| 246 | + return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
| 247 | + } |
|
| 209 | 248 | $aircraft_registration = urlencode(trim($aircraft_registration)); |
| 210 | 249 | $aircraft_info = $Spotter->getAircraftInfoByRegistration($aircraft_registration); |
| 211 | - if (isset($aircraft_info[0]['aircraft_name'])) $aircraft_name = $aircraft_info[0]['aircraft_name']; |
|
| 212 | - else $aircraft_name = ''; |
|
| 213 | - if (isset($aircraft_info[0]['aircraft_icao'])) $aircraft_name = $aircraft_info[0]['aircraft_icao']; |
|
| 214 | - else $aircraft_icao = ''; |
|
| 215 | - if (isset($aircraft_info[0]['airline_icao'])) $airline_icao = $aircraft_info[0]['airline_icao']; |
|
| 216 | - else $airline_icao = ''; |
|
| 250 | + if (isset($aircraft_info[0]['aircraft_name'])) { |
|
| 251 | + $aircraft_name = $aircraft_info[0]['aircraft_name']; |
|
| 252 | + } else { |
|
| 253 | + $aircraft_name = ''; |
|
| 254 | + } |
|
| 255 | + if (isset($aircraft_info[0]['aircraft_icao'])) { |
|
| 256 | + $aircraft_name = $aircraft_info[0]['aircraft_icao']; |
|
| 257 | + } else { |
|
| 258 | + $aircraft_icao = ''; |
|
| 259 | + } |
|
| 260 | + if (isset($aircraft_info[0]['airline_icao'])) { |
|
| 261 | + $airline_icao = $aircraft_info[0]['airline_icao']; |
|
| 262 | + } else { |
|
| 263 | + $airline_icao = ''; |
|
| 264 | + } |
|
| 217 | 265 | } elseif ($aircraft_icao != '') { |
| 218 | 266 | $aircraft_info = $Spotter->getAllAircraftInfo($aircraft_icao); |
| 219 | - if (isset($aircraft_info[0]['type'])) $aircraft_name = $aircraft_info[0]['type']; |
|
| 220 | - else $aircraft_name = ''; |
|
| 267 | + if (isset($aircraft_info[0]['type'])) { |
|
| 268 | + $aircraft_name = $aircraft_info[0]['type']; |
|
| 269 | + } else { |
|
| 270 | + $aircraft_name = ''; |
|
| 271 | + } |
|
| 221 | 272 | $aircraft_registration = $aircraft_icao; |
| 222 | - } else return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
| 273 | + } else { |
|
| 274 | + return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
| 275 | + } |
|
| 223 | 276 | unset($Spotter); |
| 224 | - if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters'); |
|
| 277 | + if (!isset($globalAircraftImageSources)) { |
|
| 278 | + $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters'); |
|
| 279 | + } |
|
| 225 | 280 | foreach ($globalAircraftImageSources as $source) { |
| 226 | 281 | $source = strtolower($source); |
| 227 | - if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl('aircraft',$aircraft_icao,$airline_icao); |
|
| 228 | - if ($source == 'planespotters' && !$globalIVAO && extension_loaded('simplexml')) $images_array = $this->fromPlanespotters('aircraft',$aircraft_registration,$aircraft_name); |
|
| 229 | - if ($source == 'flickr' && extension_loaded('simplexml')) $images_array = $this->fromFlickr('aircraft',$aircraft_registration,$aircraft_name); |
|
| 230 | - if ($source == 'bing') $images_array = $this->fromBing('aircraft',$aircraft_registration,$aircraft_name); |
|
| 231 | - if ($source == 'deviantart' && extension_loaded('simplexml')) $images_array = $this->fromDeviantart('aircraft',$aircraft_registration,$aircraft_name); |
|
| 232 | - if ($source == 'wikimedia') $images_array = $this->fromWikimedia('aircraft',$aircraft_registration,$aircraft_name); |
|
| 233 | - if ($source == 'jetphotos' && !$globalIVAO && class_exists("DomDocument")) $images_array = $this->fromJetPhotos('aircraft',$aircraft_registration,$aircraft_name); |
|
| 234 | - if ($source == 'planepictures' && !$globalIVAO && class_exists("DomDocument")) $images_array = $this->fromPlanePictures('aircraft',$aircraft_registration,$aircraft_name); |
|
| 235 | - if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData('aircraft',$aircraft_registration,$aircraft_name); |
|
| 236 | - if ($source == 'customsources') $images_array = $this->fromCustomSource('aircraft',$aircraft_registration,$aircraft_name); |
|
| 237 | - if (isset($images_array) && $images_array['original'] != '') return $images_array; |
|
| 238 | - } |
|
| 239 | - if ((!isset($globalAircraftImageCheckICAO) || $globalAircraftImageCheckICAO === TRUE) && isset($aircraft_icao)) return $this->findAircraftImage($aircraft_icao); |
|
| 282 | + if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') { |
|
| 283 | + $images_array = $this->fromIvaoMtl('aircraft',$aircraft_icao,$airline_icao); |
|
| 284 | + } |
|
| 285 | + if ($source == 'planespotters' && !$globalIVAO && extension_loaded('simplexml')) { |
|
| 286 | + $images_array = $this->fromPlanespotters('aircraft',$aircraft_registration,$aircraft_name); |
|
| 287 | + } |
|
| 288 | + if ($source == 'flickr' && extension_loaded('simplexml')) { |
|
| 289 | + $images_array = $this->fromFlickr('aircraft',$aircraft_registration,$aircraft_name); |
|
| 290 | + } |
|
| 291 | + if ($source == 'bing') { |
|
| 292 | + $images_array = $this->fromBing('aircraft',$aircraft_registration,$aircraft_name); |
|
| 293 | + } |
|
| 294 | + if ($source == 'deviantart' && extension_loaded('simplexml')) { |
|
| 295 | + $images_array = $this->fromDeviantart('aircraft',$aircraft_registration,$aircraft_name); |
|
| 296 | + } |
|
| 297 | + if ($source == 'wikimedia') { |
|
| 298 | + $images_array = $this->fromWikimedia('aircraft',$aircraft_registration,$aircraft_name); |
|
| 299 | + } |
|
| 300 | + if ($source == 'jetphotos' && !$globalIVAO && class_exists("DomDocument")) { |
|
| 301 | + $images_array = $this->fromJetPhotos('aircraft',$aircraft_registration,$aircraft_name); |
|
| 302 | + } |
|
| 303 | + if ($source == 'planepictures' && !$globalIVAO && class_exists("DomDocument")) { |
|
| 304 | + $images_array = $this->fromPlanePictures('aircraft',$aircraft_registration,$aircraft_name); |
|
| 305 | + } |
|
| 306 | + if ($source == 'airportdata' && !$globalIVAO) { |
|
| 307 | + $images_array = $this->fromAirportData('aircraft',$aircraft_registration,$aircraft_name); |
|
| 308 | + } |
|
| 309 | + if ($source == 'customsources') { |
|
| 310 | + $images_array = $this->fromCustomSource('aircraft',$aircraft_registration,$aircraft_name); |
|
| 311 | + } |
|
| 312 | + if (isset($images_array) && $images_array['original'] != '') { |
|
| 313 | + return $images_array; |
|
| 314 | + } |
|
| 315 | + } |
|
| 316 | + if ((!isset($globalAircraftImageCheckICAO) || $globalAircraftImageCheckICAO === TRUE) && isset($aircraft_icao)) { |
|
| 317 | + return $this->findAircraftImage($aircraft_icao); |
|
| 318 | + } |
|
| 240 | 319 | return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
| 241 | 320 | } |
| 242 | 321 | |
@@ -256,7 +335,9 @@ discard block |
||
| 256 | 335 | //$imo = filter_var($imo,FILTER_SANITIZE_STRING); |
| 257 | 336 | $name = filter_var($name,FILTER_SANITIZE_STRING); |
| 258 | 337 | $name = trim($name); |
| 259 | - if (strlen($name) < 4) return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
| 338 | + if (strlen($name) < 4) { |
|
| 339 | + return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
| 340 | + } |
|
| 260 | 341 | /* |
| 261 | 342 | $Marine = new Marine($this->db); |
| 262 | 343 | if ($imo == '' || $name == '') { |
@@ -268,15 +349,29 @@ discard block |
||
| 268 | 349 | } |
| 269 | 350 | unset($Marine); |
| 270 | 351 | */ |
| 271 | - if (!isset($globalMarineImageSources)) $globalMarineImageSources = array('wikimedia','deviantart','flickr','bing'); |
|
| 352 | + if (!isset($globalMarineImageSources)) { |
|
| 353 | + $globalMarineImageSources = array('wikimedia','deviantart','flickr','bing'); |
|
| 354 | + } |
|
| 272 | 355 | foreach ($globalMarineImageSources as $source) { |
| 273 | 356 | $source = strtolower($source); |
| 274 | - if ($source == 'flickr') $images_array = $this->fromFlickr('marine',$mmsi,$name); |
|
| 275 | - if ($source == 'bing') $images_array = $this->fromBing('marine',$mmsi,$name); |
|
| 276 | - if ($source == 'deviantart') $images_array = $this->fromDeviantart('marine',$mmsi,$name); |
|
| 277 | - if ($source == 'wikimedia') $images_array = $this->fromWikimedia('marine',$mmsi,$name); |
|
| 278 | - if ($source == 'customsources') $images_array = $this->fromCustomSource('marine',$mmsi,$name); |
|
| 279 | - if (isset($images_array) && $images_array['original'] != '') return $images_array; |
|
| 357 | + if ($source == 'flickr') { |
|
| 358 | + $images_array = $this->fromFlickr('marine',$mmsi,$name); |
|
| 359 | + } |
|
| 360 | + if ($source == 'bing') { |
|
| 361 | + $images_array = $this->fromBing('marine',$mmsi,$name); |
|
| 362 | + } |
|
| 363 | + if ($source == 'deviantart') { |
|
| 364 | + $images_array = $this->fromDeviantart('marine',$mmsi,$name); |
|
| 365 | + } |
|
| 366 | + if ($source == 'wikimedia') { |
|
| 367 | + $images_array = $this->fromWikimedia('marine',$mmsi,$name); |
|
| 368 | + } |
|
| 369 | + if ($source == 'customsources') { |
|
| 370 | + $images_array = $this->fromCustomSource('marine',$mmsi,$name); |
|
| 371 | + } |
|
| 372 | + if (isset($images_array) && $images_array['original'] != '') { |
|
| 373 | + return $images_array; |
|
| 374 | + } |
|
| 280 | 375 | } |
| 281 | 376 | return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
| 282 | 377 | } |
@@ -299,7 +394,9 @@ discard block |
||
| 299 | 394 | $url= 'http://www.planespotters.net/Aviation_Photos/search.php?reg='.$aircraft_registration.'&output=rss'; |
| 300 | 395 | } |
| 301 | 396 | $data = $Common->getData($url); |
| 302 | - if (substr($data, 0, 5) != "<?xml") return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
| 397 | + if (substr($data, 0, 5) != "<?xml") { |
|
| 398 | + return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
| 399 | + } |
|
| 303 | 400 | if ($xml = simplexml_load_string($data)) { |
| 304 | 401 | if (isset($xml->channel->item)) { |
| 305 | 402 | $image_url = array(); |
@@ -338,7 +435,9 @@ discard block |
||
| 338 | 435 | $url= 'http://backend.deviantart.com/rss.xml?type=deviation&q="'.urlencode($name).'"'; |
| 339 | 436 | } |
| 340 | 437 | $data = $Common->getData($url); |
| 341 | - if (substr($data, 0, 5) != "<?xml") return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
| 438 | + if (substr($data, 0, 5) != "<?xml") { |
|
| 439 | + return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
| 440 | + } |
|
| 342 | 441 | if ($xml = simplexml_load_string($data)) { |
| 343 | 442 | if (isset($xml->channel->item->link)) { |
| 344 | 443 | $image_url = array(); |
@@ -442,14 +541,22 @@ discard block |
||
| 442 | 541 | public function fromFlickr($type,$registration,$name='') { |
| 443 | 542 | $Common = new Common(); |
| 444 | 543 | if ($type == 'aircraft') { |
| 445 | - if ($name != '') $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.','.urlencode($name); |
|
| 446 | - else $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.',aircraft'; |
|
| 544 | + if ($name != '') { |
|
| 545 | + $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.','.urlencode($name); |
|
| 546 | + } else { |
|
| 547 | + $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.',aircraft'; |
|
| 548 | + } |
|
| 447 | 549 | } elseif ($type == 'marine') { |
| 448 | - if ($name != '') $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags=ship,'.urlencode($name); |
|
| 449 | - else $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.',ship'; |
|
| 550 | + if ($name != '') { |
|
| 551 | + $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags=ship,'.urlencode($name); |
|
| 552 | + } else { |
|
| 553 | + $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.',ship'; |
|
| 554 | + } |
|
| 450 | 555 | } |
| 451 | 556 | $data = $Common->getData($url); |
| 452 | - if (substr($data, 0, 5) != "<?xml") return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
| 557 | + if (substr($data, 0, 5) != "<?xml") { |
|
| 558 | + return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
| 559 | + } |
|
| 453 | 560 | if ($xml = simplexml_load_string($data)) { |
| 454 | 561 | if (isset($xml->channel->item)) { |
| 455 | 562 | $original_url = trim((string)$xml->channel->item->enclosure->attributes()->url); |
@@ -498,13 +605,21 @@ discard block |
||
| 498 | 605 | public function fromBing($type,$aircraft_registration,$aircraft_name='') { |
| 499 | 606 | global $globalImageBingKey; |
| 500 | 607 | $Common = new Common(); |
| 501 | - if (!isset($globalImageBingKey) || $globalImageBingKey == '') return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
| 608 | + if (!isset($globalImageBingKey) || $globalImageBingKey == '') { |
|
| 609 | + return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
| 610 | + } |
|
| 502 | 611 | if ($type == 'aircraft') { |
| 503 | - if ($aircraft_name != '') $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.$aircraft_registration.'%20'.urlencode($aircraft_name).'%20-site:planespotters.com%20-site:flickr.com%27'; |
|
| 504 | - else $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Baircraft%20-site:planespotters.com%20-site:flickr.com%27'; |
|
| 612 | + if ($aircraft_name != '') { |
|
| 613 | + $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.$aircraft_registration.'%20'.urlencode($aircraft_name).'%20-site:planespotters.com%20-site:flickr.com%27'; |
|
| 614 | + } else { |
|
| 615 | + $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Baircraft%20-site:planespotters.com%20-site:flickr.com%27'; |
|
| 616 | + } |
|
| 505 | 617 | } elseif ($type == 'marine') { |
| 506 | - if ($aircraft_name != '') $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.urlencode($aircraft_name).'%20%2Bship%20-site:flickr.com%27'; |
|
| 507 | - else $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Bship%20-site:flickr.com%27'; |
|
| 618 | + if ($aircraft_name != '') { |
|
| 619 | + $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.urlencode($aircraft_name).'%20%2Bship%20-site:flickr.com%27'; |
|
| 620 | + } else { |
|
| 621 | + $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Bship%20-site:flickr.com%27'; |
|
| 622 | + } |
|
| 508 | 623 | } |
| 509 | 624 | $headers = array("Authorization: Basic " . base64_encode("ignored:".$globalImageBingKey)); |
| 510 | 625 | $data = $Common->getData($url,'get','',$headers); |
@@ -560,17 +675,25 @@ discard block |
||
| 560 | 675 | public function fromWikimedia($type,$registration,$name='') { |
| 561 | 676 | $Common = new Common(); |
| 562 | 677 | if ($type == 'aircraft') { |
| 563 | - if ($name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20'.urlencode($name); |
|
| 564 | - else $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20aircraft'; |
|
| 678 | + if ($name != '') { |
|
| 679 | + $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20'.urlencode($name); |
|
| 680 | + } else { |
|
| 681 | + $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20aircraft'; |
|
| 682 | + } |
|
| 565 | 683 | } elseif ($type == 'marine') { |
| 566 | - if ($name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.urlencode($name).'%20ship"'; |
|
| 567 | - else return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
| 684 | + if ($name != '') { |
|
| 685 | + $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.urlencode($name).'%20ship"'; |
|
| 686 | + } else { |
|
| 687 | + return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
| 688 | + } |
|
| 568 | 689 | } |
| 569 | 690 | $data = $Common->getData($url); |
| 570 | 691 | $result = json_decode($data); |
| 571 | 692 | if (isset($result->query->search[0]->title)) { |
| 572 | 693 | $fileo = $result->query->search[0]->title; |
| 573 | - if (substr($fileo,-3) == 'pdf') return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
| 694 | + if (substr($fileo,-3) == 'pdf') { |
|
| 695 | + return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
| 696 | + } |
|
| 574 | 697 | $file = urlencode($fileo); |
| 575 | 698 | $url2 = 'https://commons.wikimedia.org/w/api.php?action=query&format=json&continue&iilimit=500&prop=imageinfo&iiprop=user|url|size|mime|sha1|timestamp&iiurlwidth=200%27&titles='.$file; |
| 576 | 699 | $data2 = $Common->getData($url2); |
@@ -641,18 +764,27 @@ discard block |
||
| 641 | 764 | $image_url = array(); |
| 642 | 765 | $image_url['thumbnail'] = $url_thumbnail; |
| 643 | 766 | $image_url['original'] = $url; |
| 644 | - if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url); |
|
| 645 | - else $exifCopyright = ''; |
|
| 646 | - if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
| 647 | - elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright']; |
|
| 648 | - else $image_url['copyright'] = $source['source_website']; |
|
| 767 | + if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) { |
|
| 768 | + $exifCopyright = $this->getExifCopyright($url); |
|
| 769 | + } else { |
|
| 770 | + $exifCopyright = ''; |
|
| 771 | + } |
|
| 772 | + if ($exifCopyright != '') { |
|
| 773 | + $image_url['copyright'] = $exifCopyright; |
|
| 774 | + } elseif (isset($source['copyright'])) { |
|
| 775 | + $image_url['copyright'] = $source['copyright']; |
|
| 776 | + } else { |
|
| 777 | + $image_url['copyright'] = $source['source_website']; |
|
| 778 | + } |
|
| 649 | 779 | $image_url['source_website'] = $source['source_website']; |
| 650 | 780 | $image_url['source'] = $source['source']; |
| 651 | 781 | return $image_url; |
| 652 | 782 | } |
| 653 | 783 | } |
| 654 | 784 | return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
| 655 | - } else return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
| 785 | + } else { |
|
| 786 | + return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
| 787 | + } |
|
| 656 | 788 | |
| 657 | 789 | if (!empty($globalMarineImageCustomSources) && $type == 'marine') { |
| 658 | 790 | $customsources = array(); |
@@ -678,18 +810,27 @@ discard block |
||
| 678 | 810 | $image_url = array(); |
| 679 | 811 | $image_url['thumbnail'] = $url_thumbnail; |
| 680 | 812 | $image_url['original'] = $url; |
| 681 | - if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url); |
|
| 682 | - else $exifCopyright = ''; |
|
| 683 | - if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
| 684 | - elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright']; |
|
| 685 | - else $image_url['copyright'] = $source['source_website']; |
|
| 813 | + if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) { |
|
| 814 | + $exifCopyright = $this->getExifCopyright($url); |
|
| 815 | + } else { |
|
| 816 | + $exifCopyright = ''; |
|
| 817 | + } |
|
| 818 | + if ($exifCopyright != '') { |
|
| 819 | + $image_url['copyright'] = $exifCopyright; |
|
| 820 | + } elseif (isset($source['copyright'])) { |
|
| 821 | + $image_url['copyright'] = $source['copyright']; |
|
| 822 | + } else { |
|
| 823 | + $image_url['copyright'] = $source['source_website']; |
|
| 824 | + } |
|
| 686 | 825 | $image_url['source_website'] = $source['source_website']; |
| 687 | 826 | $image_url['source'] = $source['source']; |
| 688 | 827 | return $image_url; |
| 689 | 828 | } |
| 690 | 829 | } |
| 691 | 830 | return false; |
| 692 | - } else return false; |
|
| 831 | + } else { |
|
| 832 | + return false; |
|
| 833 | + } |
|
| 693 | 834 | } |
| 694 | 835 | } |
| 695 | 836 | |
@@ -1784,7 +1784,7 @@ discard block |
||
| 1784 | 1784 | /** |
| 1785 | 1785 | * Counts all hours |
| 1786 | 1786 | * |
| 1787 | - * @param $orderby |
|
| 1787 | + * @param string $orderby |
|
| 1788 | 1788 | * @param array $filters |
| 1789 | 1789 | * @return array the hour list |
| 1790 | 1790 | */ |
@@ -2263,7 +2263,7 @@ discard block |
||
| 2263 | 2263 | /** |
| 2264 | 2264 | * Parses the direction degrees to working |
| 2265 | 2265 | * |
| 2266 | - * @param Float $direction the direction in degrees |
|
| 2266 | + * @param integer $direction the direction in degrees |
|
| 2267 | 2267 | * @return array the direction information |
| 2268 | 2268 | * |
| 2269 | 2269 | */ |
@@ -18,13 +18,13 @@ discard block |
||
| 18 | 18 | if ($this->db === null) die('Error: No DB connection. (Marine)'); |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * Get SQL query part for filter used |
|
| 23 | - * @param array $filter the filter |
|
| 24 | - * @param bool $where |
|
| 25 | - * @param bool $and |
|
| 26 | - * @return string the SQL part |
|
| 27 | - */ |
|
| 21 | + /** |
|
| 22 | + * Get SQL query part for filter used |
|
| 23 | + * @param array $filter the filter |
|
| 24 | + * @param bool $where |
|
| 25 | + * @param bool $and |
|
| 26 | + * @return string the SQL part |
|
| 27 | + */ |
|
| 28 | 28 | public function getFilter($filter = array(),$where = false,$and = false) { |
| 29 | 29 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
| 30 | 30 | $filters = array(); |
@@ -96,14 +96,14 @@ discard block |
||
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | /** |
| 99 | - * Executes the SQL statements to get the spotter information |
|
| 100 | - * |
|
| 101 | - * @param String $query the SQL query |
|
| 102 | - * @param array $params parameter of the query |
|
| 103 | - * @param String $limitQuery the limit query |
|
| 104 | - * @return array the spotter information |
|
| 105 | - * |
|
| 106 | - */ |
|
| 99 | + * Executes the SQL statements to get the spotter information |
|
| 100 | + * |
|
| 101 | + * @param String $query the SQL query |
|
| 102 | + * @param array $params parameter of the query |
|
| 103 | + * @param String $limitQuery the limit query |
|
| 104 | + * @return array the spotter information |
|
| 105 | + * |
|
| 106 | + */ |
|
| 107 | 107 | public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false) |
| 108 | 108 | { |
| 109 | 109 | global $globalVM; |
@@ -253,14 +253,14 @@ discard block |
||
| 253 | 253 | } |
| 254 | 254 | |
| 255 | 255 | |
| 256 | - /** |
|
| 257 | - * Gets all the spotter information based on the latest data entry |
|
| 258 | - * |
|
| 259 | - * @param string $limit |
|
| 260 | - * @param string $sort |
|
| 261 | - * @param array $filter |
|
| 262 | - * @return array the spotter information |
|
| 263 | - */ |
|
| 256 | + /** |
|
| 257 | + * Gets all the spotter information based on the latest data entry |
|
| 258 | + * |
|
| 259 | + * @param string $limit |
|
| 260 | + * @param string $sort |
|
| 261 | + * @param array $filter |
|
| 262 | + * @return array the spotter information |
|
| 263 | + */ |
|
| 264 | 264 | public function getLatestMarineData($limit = '', $sort = '', $filter = array()) |
| 265 | 265 | { |
| 266 | 266 | global $global_marine_query; |
@@ -295,7 +295,7 @@ discard block |
||
| 295 | 295 | * @param string $id |
| 296 | 296 | * @return array the spotter information |
| 297 | 297 | */ |
| 298 | - public function getMarineDataByID($id = '') |
|
| 298 | + public function getMarineDataByID($id = '') |
|
| 299 | 299 | { |
| 300 | 300 | global $global_marine_query; |
| 301 | 301 | |
@@ -308,15 +308,15 @@ discard block |
||
| 308 | 308 | return $spotter_array; |
| 309 | 309 | } |
| 310 | 310 | |
| 311 | - /** |
|
| 312 | - * Gets all the spotter information based on the callsign |
|
| 313 | - * |
|
| 314 | - * @param string $ident |
|
| 315 | - * @param string $limit |
|
| 316 | - * @param string $sort |
|
| 317 | - * @param array $filter |
|
| 318 | - * @return array the spotter information |
|
| 319 | - */ |
|
| 311 | + /** |
|
| 312 | + * Gets all the spotter information based on the callsign |
|
| 313 | + * |
|
| 314 | + * @param string $ident |
|
| 315 | + * @param string $limit |
|
| 316 | + * @param string $sort |
|
| 317 | + * @param array $filter |
|
| 318 | + * @return array the spotter information |
|
| 319 | + */ |
|
| 320 | 320 | public function getMarineDataByIdent($ident = '', $limit = '', $sort = '', $filter = array()) |
| 321 | 321 | { |
| 322 | 322 | global $global_marine_query; |
@@ -367,15 +367,15 @@ discard block |
||
| 367 | 367 | return $spotter_array; |
| 368 | 368 | } |
| 369 | 369 | |
| 370 | - /** |
|
| 371 | - * Gets all the marine information based on the type |
|
| 372 | - * |
|
| 373 | - * @param string $type |
|
| 374 | - * @param string $limit |
|
| 375 | - * @param string $sort |
|
| 376 | - * @param array $filter |
|
| 377 | - * @return array the marine information |
|
| 378 | - */ |
|
| 370 | + /** |
|
| 371 | + * Gets all the marine information based on the type |
|
| 372 | + * |
|
| 373 | + * @param string $type |
|
| 374 | + * @param string $limit |
|
| 375 | + * @param string $sort |
|
| 376 | + * @param array $filter |
|
| 377 | + * @return array the marine information |
|
| 378 | + */ |
|
| 379 | 379 | public function getMarineDataByType($type = '', $limit = '', $sort = '', $filter = array()) |
| 380 | 380 | { |
| 381 | 381 | global $global_marine_query; |
@@ -423,14 +423,14 @@ discard block |
||
| 423 | 423 | return $spotter_array; |
| 424 | 424 | } |
| 425 | 425 | |
| 426 | - /** |
|
| 427 | - * @param string $date |
|
| 428 | - * @param string $limit |
|
| 429 | - * @param string $sort |
|
| 430 | - * @param array $filter |
|
| 431 | - * @return array |
|
| 432 | - */ |
|
| 433 | - public function getMarineDataByDate($date = '', $limit = '', $sort = '', $filter = array()) |
|
| 426 | + /** |
|
| 427 | + * @param string $date |
|
| 428 | + * @param string $limit |
|
| 429 | + * @param string $sort |
|
| 430 | + * @param array $filter |
|
| 431 | + * @return array |
|
| 432 | + */ |
|
| 433 | + public function getMarineDataByDate($date = '', $limit = '', $sort = '', $filter = array()) |
|
| 434 | 434 | { |
| 435 | 435 | global $global_marine_query, $globalTimezone, $globalDBdriver; |
| 436 | 436 | |
@@ -487,15 +487,15 @@ discard block |
||
| 487 | 487 | return $spotter_array; |
| 488 | 488 | } |
| 489 | 489 | |
| 490 | - /** |
|
| 491 | - * Gets all the marine information based on the captain |
|
| 492 | - * |
|
| 493 | - * @param string $captain |
|
| 494 | - * @param string $limit |
|
| 495 | - * @param string $sort |
|
| 496 | - * @param array $filter |
|
| 497 | - * @return array the marine information |
|
| 498 | - */ |
|
| 490 | + /** |
|
| 491 | + * Gets all the marine information based on the captain |
|
| 492 | + * |
|
| 493 | + * @param string $captain |
|
| 494 | + * @param string $limit |
|
| 495 | + * @param string $sort |
|
| 496 | + * @param array $filter |
|
| 497 | + * @return array the marine information |
|
| 498 | + */ |
|
| 499 | 499 | public function getMarineDataByCaptain($captain = '', $limit = '', $sort = '', $filter = array()) |
| 500 | 500 | { |
| 501 | 501 | global $global_marine_query; |
@@ -533,15 +533,15 @@ discard block |
||
| 533 | 533 | return $spotter_array; |
| 534 | 534 | } |
| 535 | 535 | |
| 536 | - /** |
|
| 537 | - * Gets all the marine information based on the race |
|
| 538 | - * |
|
| 539 | - * @param string $race |
|
| 540 | - * @param string $limit |
|
| 541 | - * @param string $sort |
|
| 542 | - * @param array $filter |
|
| 543 | - * @return array the marine information |
|
| 544 | - */ |
|
| 536 | + /** |
|
| 537 | + * Gets all the marine information based on the race |
|
| 538 | + * |
|
| 539 | + * @param string $race |
|
| 540 | + * @param string $limit |
|
| 541 | + * @param string $sort |
|
| 542 | + * @param array $filter |
|
| 543 | + * @return array the marine information |
|
| 544 | + */ |
|
| 545 | 545 | public function getMarineDataByRace($race = '', $limit = '', $sort = '', $filter = array()) |
| 546 | 546 | { |
| 547 | 547 | global $global_marine_query,$globalDBdriver; |
@@ -583,13 +583,13 @@ discard block |
||
| 583 | 583 | return $spotter_array; |
| 584 | 584 | } |
| 585 | 585 | |
| 586 | - /** |
|
| 587 | - * Count races by captain |
|
| 588 | - * |
|
| 589 | - * @param $captain |
|
| 590 | - * @param array $filters |
|
| 591 | - * @return Integer number of race for a captain |
|
| 592 | - */ |
|
| 586 | + /** |
|
| 587 | + * Count races by captain |
|
| 588 | + * |
|
| 589 | + * @param $captain |
|
| 590 | + * @param array $filters |
|
| 591 | + * @return Integer number of race for a captain |
|
| 592 | + */ |
|
| 593 | 593 | public function countRacesByCaptain($captain,$filters = array()) |
| 594 | 594 | { |
| 595 | 595 | $captain = filter_var($captain,FILTER_SANITIZE_STRING); |
@@ -604,13 +604,13 @@ discard block |
||
| 604 | 604 | return $result[0]['nb']; |
| 605 | 605 | } |
| 606 | 606 | |
| 607 | - /** |
|
| 608 | - * Count captains by race |
|
| 609 | - * |
|
| 610 | - * @param $race |
|
| 611 | - * @param array $filters |
|
| 612 | - * @return String Duration of all races |
|
| 613 | - */ |
|
| 607 | + /** |
|
| 608 | + * Count captains by race |
|
| 609 | + * |
|
| 610 | + * @param $race |
|
| 611 | + * @param array $filters |
|
| 612 | + * @return String Duration of all races |
|
| 613 | + */ |
|
| 614 | 614 | public function countCaptainsByRace($race,$filters = array()) |
| 615 | 615 | { |
| 616 | 616 | $race = filter_var($race,FILTER_SANITIZE_STRING); |
@@ -625,16 +625,16 @@ discard block |
||
| 625 | 625 | return $result[0]['nb']; |
| 626 | 626 | } |
| 627 | 627 | |
| 628 | - /** |
|
| 629 | - * Gets all boat types that have been used by a captain |
|
| 630 | - * |
|
| 631 | - * @param $captain |
|
| 632 | - * @param array $filters |
|
| 633 | - * @param string $year |
|
| 634 | - * @param string $month |
|
| 635 | - * @param string $day |
|
| 636 | - * @return array the boat list |
|
| 637 | - */ |
|
| 628 | + /** |
|
| 629 | + * Gets all boat types that have been used by a captain |
|
| 630 | + * |
|
| 631 | + * @param $captain |
|
| 632 | + * @param array $filters |
|
| 633 | + * @param string $year |
|
| 634 | + * @param string $month |
|
| 635 | + * @param string $day |
|
| 636 | + * @return array the boat list |
|
| 637 | + */ |
|
| 638 | 638 | public function countAllBoatTypesByCaptain($captain,$filters = array(),$year = '',$month = '',$day = '') |
| 639 | 639 | { |
| 640 | 640 | global $globalDBdriver; |
@@ -678,16 +678,16 @@ discard block |
||
| 678 | 678 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
| 679 | 679 | } |
| 680 | 680 | |
| 681 | - /** |
|
| 682 | - * Gets all boat types that have been used on a race |
|
| 683 | - * |
|
| 684 | - * @param $race |
|
| 685 | - * @param array $filters |
|
| 686 | - * @param string $year |
|
| 687 | - * @param string $month |
|
| 688 | - * @param string $day |
|
| 689 | - * @return array the boat list |
|
| 690 | - */ |
|
| 681 | + /** |
|
| 682 | + * Gets all boat types that have been used on a race |
|
| 683 | + * |
|
| 684 | + * @param $race |
|
| 685 | + * @param array $filters |
|
| 686 | + * @param string $year |
|
| 687 | + * @param string $month |
|
| 688 | + * @param string $day |
|
| 689 | + * @return array the boat list |
|
| 690 | + */ |
|
| 691 | 691 | public function countAllBoatTypesByRace($race,$filters = array(),$year = '',$month = '',$day = '') |
| 692 | 692 | { |
| 693 | 693 | global $globalDBdriver; |
@@ -731,16 +731,16 @@ discard block |
||
| 731 | 731 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
| 732 | 732 | } |
| 733 | 733 | |
| 734 | - /** |
|
| 735 | - * Gets race duration by captain |
|
| 736 | - * |
|
| 737 | - * @param $captain |
|
| 738 | - * @param array $filters |
|
| 739 | - * @param string $year |
|
| 740 | - * @param string $month |
|
| 741 | - * @param string $day |
|
| 742 | - * @return String Duration of all race |
|
| 743 | - */ |
|
| 734 | + /** |
|
| 735 | + * Gets race duration by captain |
|
| 736 | + * |
|
| 737 | + * @param $captain |
|
| 738 | + * @param array $filters |
|
| 739 | + * @param string $year |
|
| 740 | + * @param string $month |
|
| 741 | + * @param string $day |
|
| 742 | + * @return String Duration of all race |
|
| 743 | + */ |
|
| 744 | 744 | public function getRaceDurationByCaptain($captain,$filters = array(),$year = '',$month = '',$day = '') |
| 745 | 745 | { |
| 746 | 746 | global $globalDBdriver; |
@@ -785,16 +785,16 @@ discard block |
||
| 785 | 785 | else return $result[0]['duration']; |
| 786 | 786 | } |
| 787 | 787 | |
| 788 | - /** |
|
| 789 | - * Gets race duration by captains |
|
| 790 | - * |
|
| 791 | - * @param bool $limit |
|
| 792 | - * @param array $filters |
|
| 793 | - * @param string $year |
|
| 794 | - * @param string $month |
|
| 795 | - * @param string $day |
|
| 796 | - * @return array Duration of all race |
|
| 797 | - */ |
|
| 788 | + /** |
|
| 789 | + * Gets race duration by captains |
|
| 790 | + * |
|
| 791 | + * @param bool $limit |
|
| 792 | + * @param array $filters |
|
| 793 | + * @param string $year |
|
| 794 | + * @param string $month |
|
| 795 | + * @param string $day |
|
| 796 | + * @return array Duration of all race |
|
| 797 | + */ |
|
| 798 | 798 | public function getRaceDurationByCaptains($limit = true,$filters = array(),$year = '',$month = '',$day = '') |
| 799 | 799 | { |
| 800 | 800 | global $globalDBdriver; |
@@ -852,12 +852,12 @@ discard block |
||
| 852 | 852 | |
| 853 | 853 | } |
| 854 | 854 | |
| 855 | - /** |
|
| 856 | - * Gets a list of all captain names and captain ids |
|
| 857 | - * |
|
| 858 | - * @param array $filters |
|
| 859 | - * @return array list of captain names and captain ids |
|
| 860 | - */ |
|
| 855 | + /** |
|
| 856 | + * Gets a list of all captain names and captain ids |
|
| 857 | + * |
|
| 858 | + * @param array $filters |
|
| 859 | + * @return array list of captain names and captain ids |
|
| 860 | + */ |
|
| 861 | 861 | public function getAllCaptainNames($filters = array()) |
| 862 | 862 | { |
| 863 | 863 | $filter_query = $this->getFilter($filters,true,true); |
@@ -870,12 +870,12 @@ discard block |
||
| 870 | 870 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
| 871 | 871 | } |
| 872 | 872 | |
| 873 | - /** |
|
| 874 | - * Gets a list of all race names and race ids |
|
| 875 | - * |
|
| 876 | - * @param array $filters |
|
| 877 | - * @return array list of race names and race ids |
|
| 878 | - */ |
|
| 873 | + /** |
|
| 874 | + * Gets a list of all race names and race ids |
|
| 875 | + * |
|
| 876 | + * @param array $filters |
|
| 877 | + * @return array list of race names and race ids |
|
| 878 | + */ |
|
| 879 | 879 | public function getAllRaceNames($filters = array()) |
| 880 | 880 | { |
| 881 | 881 | $filter_query = $this->getFilter($filters,true,true); |
@@ -889,13 +889,13 @@ discard block |
||
| 889 | 889 | } |
| 890 | 890 | |
| 891 | 891 | |
| 892 | - /** |
|
| 893 | - * Gets all source name |
|
| 894 | - * |
|
| 895 | - * @param String type format of source |
|
| 896 | - * @param array $filters |
|
| 897 | - * @return array list of source name |
|
| 898 | - */ |
|
| 892 | + /** |
|
| 893 | + * Gets all source name |
|
| 894 | + * |
|
| 895 | + * @param String type format of source |
|
| 896 | + * @param array $filters |
|
| 897 | + * @return array list of source name |
|
| 898 | + */ |
|
| 899 | 899 | public function getAllSourceName($type = '',$filters = array()) |
| 900 | 900 | { |
| 901 | 901 | $filter_query = $this->getFilter($filters,true,true); |
@@ -924,12 +924,12 @@ discard block |
||
| 924 | 924 | } |
| 925 | 925 | |
| 926 | 926 | |
| 927 | - /** |
|
| 928 | - * Gets a list of all idents/callsigns |
|
| 929 | - * |
|
| 930 | - * @param array $filters |
|
| 931 | - * @return array list of ident/callsign names |
|
| 932 | - */ |
|
| 927 | + /** |
|
| 928 | + * Gets a list of all idents/callsigns |
|
| 929 | + * |
|
| 930 | + * @param array $filters |
|
| 931 | + * @return array list of ident/callsign names |
|
| 932 | + */ |
|
| 933 | 933 | public function getAllIdents($filters = array()) |
| 934 | 934 | { |
| 935 | 935 | $filter_query = $this->getFilter($filters,true,true); |
@@ -952,12 +952,12 @@ discard block |
||
| 952 | 952 | return $ident_array; |
| 953 | 953 | } |
| 954 | 954 | |
| 955 | - /** |
|
| 956 | - * Gets all info from a mmsi |
|
| 957 | - * |
|
| 958 | - * @param $mmsi |
|
| 959 | - * @return array ident |
|
| 960 | - */ |
|
| 955 | + /** |
|
| 956 | + * Gets all info from a mmsi |
|
| 957 | + * |
|
| 958 | + * @param $mmsi |
|
| 959 | + * @return array ident |
|
| 960 | + */ |
|
| 961 | 961 | public function getIdentity($mmsi) |
| 962 | 962 | { |
| 963 | 963 | $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
@@ -969,14 +969,14 @@ discard block |
||
| 969 | 969 | else return array(); |
| 970 | 970 | } |
| 971 | 971 | |
| 972 | - /** |
|
| 973 | - * Add identity |
|
| 974 | - * @param $mmsi |
|
| 975 | - * @param $imo |
|
| 976 | - * @param $ident |
|
| 977 | - * @param $callsign |
|
| 978 | - * @param $type |
|
| 979 | - */ |
|
| 972 | + /** |
|
| 973 | + * Add identity |
|
| 974 | + * @param $mmsi |
|
| 975 | + * @param $imo |
|
| 976 | + * @param $ident |
|
| 977 | + * @param $callsign |
|
| 978 | + * @param $type |
|
| 979 | + */ |
|
| 980 | 980 | public function addIdentity($mmsi,$imo,$ident,$callsign,$type) |
| 981 | 981 | { |
| 982 | 982 | $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
@@ -1042,13 +1042,13 @@ discard block |
||
| 1042 | 1042 | } |
| 1043 | 1043 | |
| 1044 | 1044 | /** |
| 1045 | - * Update ident tracker data |
|
| 1046 | - * |
|
| 1047 | - * @param String $fammarine_id the ID |
|
| 1048 | - * @param String $ident the marine ident |
|
| 1049 | - * @return String success or false |
|
| 1050 | - * |
|
| 1051 | - */ |
|
| 1045 | + * Update ident tracker data |
|
| 1046 | + * |
|
| 1047 | + * @param String $fammarine_id the ID |
|
| 1048 | + * @param String $ident the marine ident |
|
| 1049 | + * @return String success or false |
|
| 1050 | + * |
|
| 1051 | + */ |
|
| 1052 | 1052 | public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL) |
| 1053 | 1053 | { |
| 1054 | 1054 | $query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id'; |
@@ -1063,13 +1063,13 @@ discard block |
||
| 1063 | 1063 | } |
| 1064 | 1064 | |
| 1065 | 1065 | /** |
| 1066 | - * Update arrival marine data |
|
| 1067 | - * |
|
| 1068 | - * @param String $fammarine_id the ID |
|
| 1069 | - * @param String $arrival_code the marine ident |
|
| 1070 | - * @return String success or false |
|
| 1071 | - * |
|
| 1072 | - */ |
|
| 1066 | + * Update arrival marine data |
|
| 1067 | + * |
|
| 1068 | + * @param String $fammarine_id the ID |
|
| 1069 | + * @param String $arrival_code the marine ident |
|
| 1070 | + * @return String success or false |
|
| 1071 | + * |
|
| 1072 | + */ |
|
| 1073 | 1073 | public function updateArrivalPortNameMarineData($fammarine_id = '', $arrival_code = '',$fromsource = NULL) |
| 1074 | 1074 | { |
| 1075 | 1075 | $query = 'UPDATE marine_output SET arrival_port_name = :arrival_code WHERE fammarine_id = :fammarine_id'; |
@@ -1084,19 +1084,19 @@ discard block |
||
| 1084 | 1084 | } |
| 1085 | 1085 | |
| 1086 | 1086 | /** |
| 1087 | - * Update Status data |
|
| 1088 | - * |
|
| 1089 | - * @param String $fammarine_id the ID |
|
| 1090 | - * @param String $status_id the marine status id |
|
| 1091 | - * @param String $status the marine status |
|
| 1092 | - * @return String success or false |
|
| 1093 | - * |
|
| 1094 | - */ |
|
| 1087 | + * Update Status data |
|
| 1088 | + * |
|
| 1089 | + * @param String $fammarine_id the ID |
|
| 1090 | + * @param String $status_id the marine status id |
|
| 1091 | + * @param String $status the marine status |
|
| 1092 | + * @return String success or false |
|
| 1093 | + * |
|
| 1094 | + */ |
|
| 1095 | 1095 | public function updateStatusMarineData($fammarine_id = '', $status_id = '',$status = '') |
| 1096 | 1096 | { |
| 1097 | 1097 | |
| 1098 | 1098 | $query = 'UPDATE marine_output SET status = :status, status_id = :status_id WHERE fammarine_id = :fammarine_id'; |
| 1099 | - $query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id); |
|
| 1099 | + $query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id); |
|
| 1100 | 1100 | |
| 1101 | 1101 | try { |
| 1102 | 1102 | $sth = $this->db->prepare($query); |
@@ -1109,22 +1109,22 @@ discard block |
||
| 1109 | 1109 | |
| 1110 | 1110 | } |
| 1111 | 1111 | |
| 1112 | - /** |
|
| 1113 | - * Update latest marine data |
|
| 1114 | - * |
|
| 1115 | - * @param String $fammarine_id the ID |
|
| 1116 | - * @param String $ident the marine ident |
|
| 1117 | - * @param string $latitude |
|
| 1118 | - * @param string $longitude |
|
| 1119 | - * @param float $groundspeed |
|
| 1120 | - * @param string $date |
|
| 1121 | - * @param float $distance |
|
| 1122 | - * @param integer $race_rank |
|
| 1123 | - * @param integer $race_time |
|
| 1124 | - * @param string $status |
|
| 1125 | - * @param string $race_begin |
|
| 1126 | - * @return String success or false |
|
| 1127 | - */ |
|
| 1112 | + /** |
|
| 1113 | + * Update latest marine data |
|
| 1114 | + * |
|
| 1115 | + * @param String $fammarine_id the ID |
|
| 1116 | + * @param String $ident the marine ident |
|
| 1117 | + * @param string $latitude |
|
| 1118 | + * @param string $longitude |
|
| 1119 | + * @param float $groundspeed |
|
| 1120 | + * @param string $date |
|
| 1121 | + * @param float $distance |
|
| 1122 | + * @param integer $race_rank |
|
| 1123 | + * @param integer $race_time |
|
| 1124 | + * @param string $status |
|
| 1125 | + * @param string $race_begin |
|
| 1126 | + * @return String success or false |
|
| 1127 | + */ |
|
| 1128 | 1128 | public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '',$distance = NULL,$race_rank = NULL, $race_time = NULL, $status = '', $race_begin = '') |
| 1129 | 1129 | { |
| 1130 | 1130 | if ($latitude == '') $latitude = NULL; |
@@ -1149,36 +1149,36 @@ discard block |
||
| 1149 | 1149 | |
| 1150 | 1150 | } |
| 1151 | 1151 | |
| 1152 | - /** |
|
| 1153 | - * Adds a new marine data |
|
| 1154 | - * |
|
| 1155 | - * @param String $fammarine_id the ID |
|
| 1156 | - * @param String $ident the marine ident |
|
| 1157 | - * @param String $latitude latitude of flight |
|
| 1158 | - * @param String $longitude latitude of flight |
|
| 1159 | - * @param String $heading heading of flight |
|
| 1160 | - * @param String $groundspeed speed of flight |
|
| 1161 | - * @param String $date date of flight |
|
| 1162 | - * @param string $mmsi |
|
| 1163 | - * @param string $type |
|
| 1164 | - * @param string $typeid |
|
| 1165 | - * @param string $imo |
|
| 1166 | - * @param string $callsign |
|
| 1167 | - * @param string $arrival_code |
|
| 1168 | - * @param string $arrival_date |
|
| 1169 | - * @param string $status |
|
| 1170 | - * @param string $statusid |
|
| 1171 | - * @param string $format_source |
|
| 1172 | - * @param string $source_name |
|
| 1173 | - * @param string $captain_id |
|
| 1174 | - * @param string $captain_name |
|
| 1175 | - * @param string $race_id |
|
| 1176 | - * @param string $race_name |
|
| 1177 | - * @param string $distance |
|
| 1178 | - * @param string $race_rank |
|
| 1179 | - * @param string $race_time |
|
| 1180 | - * @return String success or false |
|
| 1181 | - */ |
|
| 1152 | + /** |
|
| 1153 | + * Adds a new marine data |
|
| 1154 | + * |
|
| 1155 | + * @param String $fammarine_id the ID |
|
| 1156 | + * @param String $ident the marine ident |
|
| 1157 | + * @param String $latitude latitude of flight |
|
| 1158 | + * @param String $longitude latitude of flight |
|
| 1159 | + * @param String $heading heading of flight |
|
| 1160 | + * @param String $groundspeed speed of flight |
|
| 1161 | + * @param String $date date of flight |
|
| 1162 | + * @param string $mmsi |
|
| 1163 | + * @param string $type |
|
| 1164 | + * @param string $typeid |
|
| 1165 | + * @param string $imo |
|
| 1166 | + * @param string $callsign |
|
| 1167 | + * @param string $arrival_code |
|
| 1168 | + * @param string $arrival_date |
|
| 1169 | + * @param string $status |
|
| 1170 | + * @param string $statusid |
|
| 1171 | + * @param string $format_source |
|
| 1172 | + * @param string $source_name |
|
| 1173 | + * @param string $captain_id |
|
| 1174 | + * @param string $captain_name |
|
| 1175 | + * @param string $race_id |
|
| 1176 | + * @param string $race_name |
|
| 1177 | + * @param string $distance |
|
| 1178 | + * @param string $race_rank |
|
| 1179 | + * @param string $race_time |
|
| 1180 | + * @return String success or false |
|
| 1181 | + */ |
|
| 1182 | 1182 | public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '',$type = '',$typeid = '',$imo = '',$callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$format_source = '', $source_name = '', $captain_id = '',$captain_name = '',$race_id = '', $race_name = '', $distance = '',$race_rank = '', $race_time = '') |
| 1183 | 1183 | { |
| 1184 | 1184 | global $globalURL, $globalMarineImageFetch; |
@@ -1311,12 +1311,12 @@ discard block |
||
| 1311 | 1311 | } |
| 1312 | 1312 | |
| 1313 | 1313 | |
| 1314 | - /** |
|
| 1315 | - * Gets the aircraft ident within the last hour |
|
| 1316 | - * |
|
| 1317 | - * @param $ident |
|
| 1318 | - * @return String the ident |
|
| 1319 | - */ |
|
| 1314 | + /** |
|
| 1315 | + * Gets the aircraft ident within the last hour |
|
| 1316 | + * |
|
| 1317 | + * @param $ident |
|
| 1318 | + * @return String the ident |
|
| 1319 | + */ |
|
| 1320 | 1320 | public function getIdentFromLastHour($ident) |
| 1321 | 1321 | { |
| 1322 | 1322 | global $globalDBdriver, $globalTimezone; |
@@ -1332,11 +1332,11 @@ discard block |
||
| 1332 | 1332 | AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
| 1333 | 1333 | AND marine_output.date < now() AT TIME ZONE 'UTC'"; |
| 1334 | 1334 | $query_data = array(':ident' => $ident); |
| 1335 | - } |
|
| 1335 | + } |
|
| 1336 | 1336 | |
| 1337 | 1337 | $sth = $this->db->prepare($query); |
| 1338 | 1338 | $sth->execute($query_data); |
| 1339 | - $ident_result=''; |
|
| 1339 | + $ident_result=''; |
|
| 1340 | 1340 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
| 1341 | 1341 | { |
| 1342 | 1342 | $ident_result = $row['ident']; |
@@ -1346,12 +1346,12 @@ discard block |
||
| 1346 | 1346 | } |
| 1347 | 1347 | |
| 1348 | 1348 | |
| 1349 | - /** |
|
| 1350 | - * Gets the aircraft data from the last 20 seconds |
|
| 1351 | - * |
|
| 1352 | - * @param string $q |
|
| 1353 | - * @return array the marine data |
|
| 1354 | - */ |
|
| 1349 | + /** |
|
| 1350 | + * Gets the aircraft data from the last 20 seconds |
|
| 1351 | + * |
|
| 1352 | + * @param string $q |
|
| 1353 | + * @return array the marine data |
|
| 1354 | + */ |
|
| 1355 | 1355 | public function getRealTimeData($q = '') |
| 1356 | 1356 | { |
| 1357 | 1357 | global $globalDBdriver; |
@@ -1386,15 +1386,15 @@ discard block |
||
| 1386 | 1386 | } |
| 1387 | 1387 | |
| 1388 | 1388 | |
| 1389 | - /** |
|
| 1390 | - * Gets all number of flight over countries |
|
| 1391 | - * |
|
| 1392 | - * @param bool $limit |
|
| 1393 | - * @param int $olderthanmonths |
|
| 1394 | - * @param string $sincedate |
|
| 1395 | - * @param array $filters |
|
| 1396 | - * @return array the airline country list |
|
| 1397 | - */ |
|
| 1389 | + /** |
|
| 1390 | + * Gets all number of flight over countries |
|
| 1391 | + * |
|
| 1392 | + * @param bool $limit |
|
| 1393 | + * @param int $olderthanmonths |
|
| 1394 | + * @param string $sincedate |
|
| 1395 | + * @param array $filters |
|
| 1396 | + * @return array the airline country list |
|
| 1397 | + */ |
|
| 1398 | 1398 | |
| 1399 | 1399 | public function countAllMarineOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) |
| 1400 | 1400 | { |
@@ -1465,18 +1465,18 @@ discard block |
||
| 1465 | 1465 | } |
| 1466 | 1466 | |
| 1467 | 1467 | |
| 1468 | - /** |
|
| 1469 | - * Gets all callsigns that have flown over |
|
| 1470 | - * |
|
| 1471 | - * @param bool $limit |
|
| 1472 | - * @param int $olderthanmonths |
|
| 1473 | - * @param string $sincedate |
|
| 1474 | - * @param array $filters |
|
| 1475 | - * @param string $year |
|
| 1476 | - * @param string $month |
|
| 1477 | - * @param string $day |
|
| 1478 | - * @return array the callsign list |
|
| 1479 | - */ |
|
| 1468 | + /** |
|
| 1469 | + * Gets all callsigns that have flown over |
|
| 1470 | + * |
|
| 1471 | + * @param bool $limit |
|
| 1472 | + * @param int $olderthanmonths |
|
| 1473 | + * @param string $sincedate |
|
| 1474 | + * @param array $filters |
|
| 1475 | + * @param string $year |
|
| 1476 | + * @param string $month |
|
| 1477 | + * @param string $day |
|
| 1478 | + * @return array the callsign list |
|
| 1479 | + */ |
|
| 1480 | 1480 | public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '') |
| 1481 | 1481 | { |
| 1482 | 1482 | global $globalDBdriver; |
@@ -1542,12 +1542,12 @@ discard block |
||
| 1542 | 1542 | } |
| 1543 | 1543 | |
| 1544 | 1544 | |
| 1545 | - /** |
|
| 1546 | - * Counts all dates |
|
| 1547 | - * |
|
| 1548 | - * @param array $filters |
|
| 1549 | - * @return array the date list |
|
| 1550 | - */ |
|
| 1545 | + /** |
|
| 1546 | + * Counts all dates |
|
| 1547 | + * |
|
| 1548 | + * @param array $filters |
|
| 1549 | + * @return array the date list |
|
| 1550 | + */ |
|
| 1551 | 1551 | public function countAllDates($filters = array()) |
| 1552 | 1552 | { |
| 1553 | 1553 | global $globalTimezone, $globalDBdriver; |
@@ -1592,12 +1592,12 @@ discard block |
||
| 1592 | 1592 | } |
| 1593 | 1593 | |
| 1594 | 1594 | |
| 1595 | - /** |
|
| 1596 | - * Counts all dates during the last 7 days |
|
| 1597 | - * |
|
| 1598 | - * @param array $filters |
|
| 1599 | - * @return array the date list |
|
| 1600 | - */ |
|
| 1595 | + /** |
|
| 1596 | + * Counts all dates during the last 7 days |
|
| 1597 | + * |
|
| 1598 | + * @param array $filters |
|
| 1599 | + * @return array the date list |
|
| 1600 | + */ |
|
| 1601 | 1601 | public function countAllDatesLast7Days($filters = array()) |
| 1602 | 1602 | { |
| 1603 | 1603 | global $globalTimezone, $globalDBdriver; |
@@ -1619,7 +1619,7 @@ discard block |
||
| 1619 | 1619 | $query .= " GROUP BY date_name |
| 1620 | 1620 | ORDER BY date_name ASC"; |
| 1621 | 1621 | $query_data = array(':offset' => $offset); |
| 1622 | - } |
|
| 1622 | + } |
|
| 1623 | 1623 | |
| 1624 | 1624 | $sth = $this->db->prepare($query); |
| 1625 | 1625 | $sth->execute($query_data); |
@@ -1638,12 +1638,12 @@ discard block |
||
| 1638 | 1638 | return $date_array; |
| 1639 | 1639 | } |
| 1640 | 1640 | |
| 1641 | - /** |
|
| 1642 | - * Counts all dates during the last month |
|
| 1643 | - * |
|
| 1644 | - * @param array $filters |
|
| 1645 | - * @return array the date list |
|
| 1646 | - */ |
|
| 1641 | + /** |
|
| 1642 | + * Counts all dates during the last month |
|
| 1643 | + * |
|
| 1644 | + * @param array $filters |
|
| 1645 | + * @return array the date list |
|
| 1646 | + */ |
|
| 1647 | 1647 | public function countAllDatesLastMonth($filters = array()) |
| 1648 | 1648 | { |
| 1649 | 1649 | global $globalTimezone, $globalDBdriver; |
@@ -1665,7 +1665,7 @@ discard block |
||
| 1665 | 1665 | $query .= " GROUP BY date_name |
| 1666 | 1666 | ORDER BY date_name ASC"; |
| 1667 | 1667 | $query_data = array(':offset' => $offset); |
| 1668 | - } |
|
| 1668 | + } |
|
| 1669 | 1669 | |
| 1670 | 1670 | $sth = $this->db->prepare($query); |
| 1671 | 1671 | $sth->execute($query_data); |
@@ -1687,11 +1687,11 @@ discard block |
||
| 1687 | 1687 | |
| 1688 | 1688 | |
| 1689 | 1689 | /** |
| 1690 | - * Counts all month |
|
| 1691 | - * |
|
| 1692 | - * @return array the month list |
|
| 1693 | - * |
|
| 1694 | - */ |
|
| 1690 | + * Counts all month |
|
| 1691 | + * |
|
| 1692 | + * @return array the month list |
|
| 1693 | + * |
|
| 1694 | + */ |
|
| 1695 | 1695 | public function countAllMonths($filters = array()) |
| 1696 | 1696 | { |
| 1697 | 1697 | global $globalTimezone, $globalDBdriver; |
@@ -1733,12 +1733,12 @@ discard block |
||
| 1733 | 1733 | } |
| 1734 | 1734 | |
| 1735 | 1735 | |
| 1736 | - /** |
|
| 1737 | - * Counts all dates during the last year |
|
| 1738 | - * |
|
| 1739 | - * @param $filters |
|
| 1740 | - * @return array the date list |
|
| 1741 | - */ |
|
| 1736 | + /** |
|
| 1737 | + * Counts all dates during the last year |
|
| 1738 | + * |
|
| 1739 | + * @param $filters |
|
| 1740 | + * @return array the date list |
|
| 1741 | + */ |
|
| 1742 | 1742 | public function countAllMonthsLastYear($filters) |
| 1743 | 1743 | { |
| 1744 | 1744 | global $globalTimezone, $globalDBdriver; |
@@ -1760,7 +1760,7 @@ discard block |
||
| 1760 | 1760 | $query .= " GROUP BY year_name, month_name |
| 1761 | 1761 | ORDER BY year_name, month_name ASC"; |
| 1762 | 1762 | $query_data = array(':offset' => $offset); |
| 1763 | - } |
|
| 1763 | + } |
|
| 1764 | 1764 | |
| 1765 | 1765 | $sth = $this->db->prepare($query); |
| 1766 | 1766 | $sth->execute($query_data); |
@@ -1781,13 +1781,13 @@ discard block |
||
| 1781 | 1781 | } |
| 1782 | 1782 | |
| 1783 | 1783 | |
| 1784 | - /** |
|
| 1785 | - * Counts all hours |
|
| 1786 | - * |
|
| 1787 | - * @param $orderby |
|
| 1788 | - * @param array $filters |
|
| 1789 | - * @return array the hour list |
|
| 1790 | - */ |
|
| 1784 | + /** |
|
| 1785 | + * Counts all hours |
|
| 1786 | + * |
|
| 1787 | + * @param $orderby |
|
| 1788 | + * @param array $filters |
|
| 1789 | + * @return array the hour list |
|
| 1790 | + */ |
|
| 1791 | 1791 | public function countAllHours($orderby,$filters = array()) |
| 1792 | 1792 | { |
| 1793 | 1793 | global $globalTimezone, $globalDBdriver; |
@@ -1848,13 +1848,13 @@ discard block |
||
| 1848 | 1848 | } |
| 1849 | 1849 | |
| 1850 | 1850 | |
| 1851 | - /** |
|
| 1852 | - * Counts all hours by date |
|
| 1853 | - * |
|
| 1854 | - * @param $date |
|
| 1855 | - * @param array $filters |
|
| 1856 | - * @return array the hour list |
|
| 1857 | - */ |
|
| 1851 | + /** |
|
| 1852 | + * Counts all hours by date |
|
| 1853 | + * |
|
| 1854 | + * @param $date |
|
| 1855 | + * @param array $filters |
|
| 1856 | + * @return array the hour list |
|
| 1857 | + */ |
|
| 1858 | 1858 | public function countAllHoursByDate($date, $filters = array()) |
| 1859 | 1859 | { |
| 1860 | 1860 | global $globalTimezone, $globalDBdriver; |
@@ -1896,13 +1896,13 @@ discard block |
||
| 1896 | 1896 | } |
| 1897 | 1897 | |
| 1898 | 1898 | |
| 1899 | - /** |
|
| 1900 | - * Counts all hours by a ident/callsign |
|
| 1901 | - * |
|
| 1902 | - * @param $ident |
|
| 1903 | - * @param array $filters |
|
| 1904 | - * @return array the hour list |
|
| 1905 | - */ |
|
| 1899 | + /** |
|
| 1900 | + * Counts all hours by a ident/callsign |
|
| 1901 | + * |
|
| 1902 | + * @param $ident |
|
| 1903 | + * @param array $filters |
|
| 1904 | + * @return array the hour list |
|
| 1905 | + */ |
|
| 1906 | 1906 | public function countAllHoursByIdent($ident, $filters = array()) |
| 1907 | 1907 | { |
| 1908 | 1908 | global $globalTimezone, $globalDBdriver; |
@@ -1944,15 +1944,15 @@ discard block |
||
| 1944 | 1944 | return $hour_array; |
| 1945 | 1945 | } |
| 1946 | 1946 | |
| 1947 | - /** |
|
| 1948 | - * Gets all aircraft registrations that have flown over |
|
| 1949 | - * |
|
| 1950 | - * @param bool $limit |
|
| 1951 | - * @param int $olderthanmonths |
|
| 1952 | - * @param string $sincedate |
|
| 1953 | - * @param array $filters |
|
| 1954 | - * @return array the aircraft list |
|
| 1955 | - */ |
|
| 1947 | + /** |
|
| 1948 | + * Gets all aircraft registrations that have flown over |
|
| 1949 | + * |
|
| 1950 | + * @param bool $limit |
|
| 1951 | + * @param int $olderthanmonths |
|
| 1952 | + * @param string $sincedate |
|
| 1953 | + * @param array $filters |
|
| 1954 | + * @return array the aircraft list |
|
| 1955 | + */ |
|
| 1956 | 1956 | public function countAllCaptainsByRaces($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) |
| 1957 | 1957 | { |
| 1958 | 1958 | global $globalDBdriver; |
@@ -1990,14 +1990,14 @@ discard block |
||
| 1990 | 1990 | return $marine_array; |
| 1991 | 1991 | } |
| 1992 | 1992 | |
| 1993 | - /** |
|
| 1994 | - * Counts all vessels |
|
| 1995 | - * |
|
| 1996 | - * @param array $filters |
|
| 1997 | - * @param string $year |
|
| 1998 | - * @param string $month |
|
| 1999 | - * @return Integer the number of vessels |
|
| 2000 | - */ |
|
| 1993 | + /** |
|
| 1994 | + * Counts all vessels |
|
| 1995 | + * |
|
| 1996 | + * @param array $filters |
|
| 1997 | + * @param string $year |
|
| 1998 | + * @param string $month |
|
| 1999 | + * @return Integer the number of vessels |
|
| 2000 | + */ |
|
| 2001 | 2001 | public function countOverallMarine($filters = array(),$year = '',$month = '') |
| 2002 | 2002 | { |
| 2003 | 2003 | global $globalDBdriver; |
@@ -2031,14 +2031,14 @@ discard block |
||
| 2031 | 2031 | return $sth->fetchColumn(); |
| 2032 | 2032 | } |
| 2033 | 2033 | |
| 2034 | - /** |
|
| 2035 | - * Counts all vessel type |
|
| 2036 | - * |
|
| 2037 | - * @param array $filters |
|
| 2038 | - * @param string $year |
|
| 2039 | - * @param string $month |
|
| 2040 | - * @return Integer the number of vessels |
|
| 2041 | - */ |
|
| 2034 | + /** |
|
| 2035 | + * Counts all vessel type |
|
| 2036 | + * |
|
| 2037 | + * @param array $filters |
|
| 2038 | + * @param string $year |
|
| 2039 | + * @param string $month |
|
| 2040 | + * @return Integer the number of vessels |
|
| 2041 | + */ |
|
| 2042 | 2042 | public function countOverallMarineTypes($filters = array(),$year = '',$month = '') |
| 2043 | 2043 | { |
| 2044 | 2044 | global $globalDBdriver; |
@@ -2071,14 +2071,14 @@ discard block |
||
| 2071 | 2071 | return $sth->fetchColumn(); |
| 2072 | 2072 | } |
| 2073 | 2073 | |
| 2074 | - /** |
|
| 2075 | - * Gets a number of all race |
|
| 2076 | - * |
|
| 2077 | - * @param array $filters |
|
| 2078 | - * @param string $year |
|
| 2079 | - * @param string $month |
|
| 2080 | - * @return Integer number of races |
|
| 2081 | - */ |
|
| 2074 | + /** |
|
| 2075 | + * Gets a number of all race |
|
| 2076 | + * |
|
| 2077 | + * @param array $filters |
|
| 2078 | + * @param string $year |
|
| 2079 | + * @param string $month |
|
| 2080 | + * @return Integer number of races |
|
| 2081 | + */ |
|
| 2082 | 2082 | public function countOverallMarineRaces($filters = array(),$year = '',$month = '') |
| 2083 | 2083 | { |
| 2084 | 2084 | global $globalDBdriver; |
@@ -2111,14 +2111,14 @@ discard block |
||
| 2111 | 2111 | return $sth->fetchColumn(); |
| 2112 | 2112 | } |
| 2113 | 2113 | |
| 2114 | - /** |
|
| 2115 | - * Gets a number of all captain |
|
| 2116 | - * |
|
| 2117 | - * @param array $filters |
|
| 2118 | - * @param string $year |
|
| 2119 | - * @param string $month |
|
| 2120 | - * @return Integer number of captain |
|
| 2121 | - */ |
|
| 2114 | + /** |
|
| 2115 | + * Gets a number of all captain |
|
| 2116 | + * |
|
| 2117 | + * @param array $filters |
|
| 2118 | + * @param string $year |
|
| 2119 | + * @param string $month |
|
| 2120 | + * @return Integer number of captain |
|
| 2121 | + */ |
|
| 2122 | 2122 | public function countOverallMarineCaptains($filters = array(),$year = '',$month = '') |
| 2123 | 2123 | { |
| 2124 | 2124 | global $globalDBdriver; |
@@ -2151,12 +2151,12 @@ discard block |
||
| 2151 | 2151 | return $sth->fetchColumn(); |
| 2152 | 2152 | } |
| 2153 | 2153 | |
| 2154 | - /** |
|
| 2155 | - * Counts all hours of today |
|
| 2156 | - * |
|
| 2157 | - * @param array $filters |
|
| 2158 | - * @return array the hour list |
|
| 2159 | - */ |
|
| 2154 | + /** |
|
| 2155 | + * Counts all hours of today |
|
| 2156 | + * |
|
| 2157 | + * @param array $filters |
|
| 2158 | + * @return array the hour list |
|
| 2159 | + */ |
|
| 2160 | 2160 | public function countAllHoursFromToday($filters = array()) |
| 2161 | 2161 | { |
| 2162 | 2162 | global $globalTimezone, $globalDBdriver; |
@@ -2196,12 +2196,12 @@ discard block |
||
| 2196 | 2196 | } |
| 2197 | 2197 | |
| 2198 | 2198 | |
| 2199 | - /** |
|
| 2200 | - * Gets the Barrie Spotter ID based on the FlightAware ID |
|
| 2201 | - * |
|
| 2202 | - * @return Integer the Barrie Spotter ID |
|
| 2199 | + /** |
|
| 2200 | + * Gets the Barrie Spotter ID based on the FlightAware ID |
|
| 2201 | + * |
|
| 2202 | + * @return Integer the Barrie Spotter ID |
|
| 2203 | 2203 | q * |
| 2204 | - */ |
|
| 2204 | + */ |
|
| 2205 | 2205 | public function getMarineIDBasedOnFamMarineID($fammarine_id) |
| 2206 | 2206 | { |
| 2207 | 2207 | $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
@@ -2222,13 +2222,13 @@ discard block |
||
| 2222 | 2222 | |
| 2223 | 2223 | |
| 2224 | 2224 | /** |
| 2225 | - * Parses a date string |
|
| 2226 | - * |
|
| 2227 | - * @param String $dateString the date string |
|
| 2228 | - * @param String $timezone the timezone of a user |
|
| 2229 | - * @return array the time information |
|
| 2230 | - * |
|
| 2231 | - */ |
|
| 2225 | + * Parses a date string |
|
| 2226 | + * |
|
| 2227 | + * @param String $dateString the date string |
|
| 2228 | + * @param String $timezone the timezone of a user |
|
| 2229 | + * @return array the time information |
|
| 2230 | + * |
|
| 2231 | + */ |
|
| 2232 | 2232 | public function parseDateString($dateString, $timezone = '') |
| 2233 | 2233 | { |
| 2234 | 2234 | $time_array = array(); |
@@ -2261,12 +2261,12 @@ discard block |
||
| 2261 | 2261 | } |
| 2262 | 2262 | |
| 2263 | 2263 | /** |
| 2264 | - * Parses the direction degrees to working |
|
| 2265 | - * |
|
| 2266 | - * @param Float $direction the direction in degrees |
|
| 2267 | - * @return array the direction information |
|
| 2268 | - * |
|
| 2269 | - */ |
|
| 2264 | + * Parses the direction degrees to working |
|
| 2265 | + * |
|
| 2266 | + * @param Float $direction the direction in degrees |
|
| 2267 | + * @return array the direction information |
|
| 2268 | + * |
|
| 2269 | + */ |
|
| 2270 | 2270 | public function parseDirection($direction = 0) |
| 2271 | 2271 | { |
| 2272 | 2272 | if ($direction == '') $direction = 0; |
@@ -2345,12 +2345,12 @@ discard block |
||
| 2345 | 2345 | |
| 2346 | 2346 | |
| 2347 | 2347 | /** |
| 2348 | - * Gets Country from latitude/longitude |
|
| 2349 | - * |
|
| 2350 | - * @param Float $latitude latitute of the flight |
|
| 2351 | - * @param Float $longitude longitute of the flight |
|
| 2352 | - * @return String the countries |
|
| 2353 | - */ |
|
| 2348 | + * Gets Country from latitude/longitude |
|
| 2349 | + * |
|
| 2350 | + * @param Float $latitude latitute of the flight |
|
| 2351 | + * @param Float $longitude longitute of the flight |
|
| 2352 | + * @return String the countries |
|
| 2353 | + */ |
|
| 2354 | 2354 | public function getCountryFromLatitudeLongitude($latitude,$longitude) |
| 2355 | 2355 | { |
| 2356 | 2356 | global $globalDBdriver, $globalDebug; |
@@ -2387,11 +2387,11 @@ discard block |
||
| 2387 | 2387 | } |
| 2388 | 2388 | |
| 2389 | 2389 | /** |
| 2390 | - * Gets Country from iso2 |
|
| 2391 | - * |
|
| 2392 | - * @param String $iso2 ISO2 country code |
|
| 2393 | - * @return String the countries |
|
| 2394 | - */ |
|
| 2390 | + * Gets Country from iso2 |
|
| 2391 | + * |
|
| 2392 | + * @param String $iso2 ISO2 country code |
|
| 2393 | + * @return String the countries |
|
| 2394 | + */ |
|
| 2395 | 2395 | public function getCountryFromISO2($iso2) |
| 2396 | 2396 | { |
| 2397 | 2397 | global $globalDBdriver, $globalDebug; |
@@ -2420,12 +2420,12 @@ discard block |
||
| 2420 | 2420 | |
| 2421 | 2421 | |
| 2422 | 2422 | /** |
| 2423 | - * Gets the short url from bit.ly |
|
| 2424 | - * |
|
| 2425 | - * @param String $url the full url |
|
| 2426 | - * @return String the bit.ly url |
|
| 2427 | - * |
|
| 2428 | - */ |
|
| 2423 | + * Gets the short url from bit.ly |
|
| 2424 | + * |
|
| 2425 | + * @param String $url the full url |
|
| 2426 | + * @return String the bit.ly url |
|
| 2427 | + * |
|
| 2428 | + */ |
|
| 2429 | 2429 | public function getBitlyURL($url) |
| 2430 | 2430 | { |
| 2431 | 2431 | global $globalBitlyAccessToken; |
@@ -2451,18 +2451,18 @@ discard block |
||
| 2451 | 2451 | } |
| 2452 | 2452 | |
| 2453 | 2453 | |
| 2454 | - /** |
|
| 2455 | - * Gets all vessels types that have flown over |
|
| 2456 | - * |
|
| 2457 | - * @param bool $limit |
|
| 2458 | - * @param int $olderthanmonths |
|
| 2459 | - * @param string $sincedate |
|
| 2460 | - * @param array $filters |
|
| 2461 | - * @param string $year |
|
| 2462 | - * @param string $month |
|
| 2463 | - * @param string $day |
|
| 2464 | - * @return array the vessel type list |
|
| 2465 | - */ |
|
| 2454 | + /** |
|
| 2455 | + * Gets all vessels types that have flown over |
|
| 2456 | + * |
|
| 2457 | + * @param bool $limit |
|
| 2458 | + * @param int $olderthanmonths |
|
| 2459 | + * @param string $sincedate |
|
| 2460 | + * @param array $filters |
|
| 2461 | + * @param string $year |
|
| 2462 | + * @param string $month |
|
| 2463 | + * @param string $day |
|
| 2464 | + * @return array the vessel type list |
|
| 2465 | + */ |
|
| 2466 | 2466 | public function countAllMarineTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '') |
| 2467 | 2467 | { |
| 2468 | 2468 | global $globalDBdriver; |
@@ -2527,27 +2527,27 @@ discard block |
||
| 2527 | 2527 | return $marine_array; |
| 2528 | 2528 | } |
| 2529 | 2529 | |
| 2530 | - /** |
|
| 2531 | - * Gets all the tracker information |
|
| 2532 | - * |
|
| 2533 | - * @param string $q |
|
| 2534 | - * @param string $callsign |
|
| 2535 | - * @param string $mmsi |
|
| 2536 | - * @param string $imo |
|
| 2537 | - * @param string $date_posted |
|
| 2538 | - * @param string $limit |
|
| 2539 | - * @param string $sort |
|
| 2540 | - * @param string $includegeodata |
|
| 2541 | - * @param string $origLat |
|
| 2542 | - * @param string $origLon |
|
| 2543 | - * @param string $dist |
|
| 2544 | - * @param string $captain_id |
|
| 2545 | - * @param string $captain_name |
|
| 2546 | - * @param string $race_id |
|
| 2547 | - * @param string $race_name |
|
| 2548 | - * @param array $filters |
|
| 2549 | - * @return array the tracker information |
|
| 2550 | - */ |
|
| 2530 | + /** |
|
| 2531 | + * Gets all the tracker information |
|
| 2532 | + * |
|
| 2533 | + * @param string $q |
|
| 2534 | + * @param string $callsign |
|
| 2535 | + * @param string $mmsi |
|
| 2536 | + * @param string $imo |
|
| 2537 | + * @param string $date_posted |
|
| 2538 | + * @param string $limit |
|
| 2539 | + * @param string $sort |
|
| 2540 | + * @param string $includegeodata |
|
| 2541 | + * @param string $origLat |
|
| 2542 | + * @param string $origLon |
|
| 2543 | + * @param string $dist |
|
| 2544 | + * @param string $captain_id |
|
| 2545 | + * @param string $captain_name |
|
| 2546 | + * @param string $race_id |
|
| 2547 | + * @param string $race_name |
|
| 2548 | + * @param array $filters |
|
| 2549 | + * @return array the tracker information |
|
| 2550 | + */ |
|
| 2551 | 2551 | public function searchMarineData($q = '', $callsign = '',$mmsi = '', $imo = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '',$captain_id = '',$captain_name = '',$race_id = '',$race_name = '',$filters = array()) |
| 2552 | 2552 | { |
| 2553 | 2553 | global $globalTimezone, $globalDBdriver; |
@@ -2723,12 +2723,12 @@ discard block |
||
| 2723 | 2723 | return $marine_array; |
| 2724 | 2724 | } |
| 2725 | 2725 | |
| 2726 | - /** |
|
| 2727 | - * Check marine by id |
|
| 2728 | - * |
|
| 2729 | - * @param $id |
|
| 2730 | - * @return String the ident |
|
| 2731 | - */ |
|
| 2726 | + /** |
|
| 2727 | + * Check marine by id |
|
| 2728 | + * |
|
| 2729 | + * @param $id |
|
| 2730 | + * @return String the ident |
|
| 2731 | + */ |
|
| 2732 | 2732 | public function checkId($id) |
| 2733 | 2733 | { |
| 2734 | 2734 | global $globalDBdriver, $globalTimezone; |
@@ -2744,12 +2744,12 @@ discard block |
||
| 2744 | 2744 | return $ident_result; |
| 2745 | 2745 | } |
| 2746 | 2746 | |
| 2747 | - /** |
|
| 2748 | - * Gets all info from a race |
|
| 2749 | - * |
|
| 2750 | - * @param $race_name |
|
| 2751 | - * @return array race |
|
| 2752 | - */ |
|
| 2747 | + /** |
|
| 2748 | + * Gets all info from a race |
|
| 2749 | + * |
|
| 2750 | + * @param $race_name |
|
| 2751 | + * @return array race |
|
| 2752 | + */ |
|
| 2753 | 2753 | public function getRaceByName($race_name) |
| 2754 | 2754 | { |
| 2755 | 2755 | $race_name = filter_var($race_name,FILTER_SANITIZE_STRING); |
@@ -2761,12 +2761,12 @@ discard block |
||
| 2761 | 2761 | else return array(); |
| 2762 | 2762 | } |
| 2763 | 2763 | |
| 2764 | - /** |
|
| 2765 | - * Gets all info from a race |
|
| 2766 | - * |
|
| 2767 | - * @param $race_id |
|
| 2768 | - * @return array race |
|
| 2769 | - */ |
|
| 2764 | + /** |
|
| 2765 | + * Gets all info from a race |
|
| 2766 | + * |
|
| 2767 | + * @param $race_id |
|
| 2768 | + * @return array race |
|
| 2769 | + */ |
|
| 2770 | 2770 | public function getRace($race_id) |
| 2771 | 2771 | { |
| 2772 | 2772 | $race_id = filter_var($race_id,FILTER_SANITIZE_NUMBER_INT); |
@@ -2778,15 +2778,15 @@ discard block |
||
| 2778 | 2778 | else return array(); |
| 2779 | 2779 | } |
| 2780 | 2780 | |
| 2781 | - /** |
|
| 2782 | - * Add race |
|
| 2783 | - * @param $race_id |
|
| 2784 | - * @param $race_name |
|
| 2785 | - * @param $race_creator |
|
| 2786 | - * @param $race_desc |
|
| 2787 | - * @param $race_startdate |
|
| 2788 | - * @param $race_markers |
|
| 2789 | - */ |
|
| 2781 | + /** |
|
| 2782 | + * Add race |
|
| 2783 | + * @param $race_id |
|
| 2784 | + * @param $race_name |
|
| 2785 | + * @param $race_creator |
|
| 2786 | + * @param $race_desc |
|
| 2787 | + * @param $race_startdate |
|
| 2788 | + * @param $race_markers |
|
| 2789 | + */ |
|
| 2790 | 2790 | public function addRace($race_id,$race_name,$race_creator,$race_desc,$race_startdate,$race_markers) |
| 2791 | 2791 | { |
| 2792 | 2792 | $race_id = filter_var($race_id,FILTER_SANITIZE_NUMBER_INT); |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | require_once(dirname(__FILE__).'/class.Image.php'); |
| 10 | 10 | $global_marine_query = "SELECT marine_output.* FROM marine_output"; |
| 11 | 11 | |
| 12 | -class Marine{ |
|
| 12 | +class Marine { |
|
| 13 | 13 | public $db; |
| 14 | 14 | |
| 15 | 15 | public function __construct($dbc = null) { |
@@ -25,33 +25,33 @@ discard block |
||
| 25 | 25 | * @param bool $and |
| 26 | 26 | * @return string the SQL part |
| 27 | 27 | */ |
| 28 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
| 28 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
| 29 | 29 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
| 30 | 30 | $filters = array(); |
| 31 | 31 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
| 32 | 32 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
| 33 | 33 | $filters = $globalStatsFilters[$globalFilterName]; |
| 34 | 34 | } else { |
| 35 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
| 35 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
| 36 | 36 | } |
| 37 | 37 | } |
| 38 | 38 | if (isset($filter[0]['source'])) { |
| 39 | - $filters = array_merge($filters,$filter); |
|
| 39 | + $filters = array_merge($filters, $filter); |
|
| 40 | 40 | } |
| 41 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 41 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
| 42 | 42 | $filter_query_join = ''; |
| 43 | 43 | $filter_query_where = ''; |
| 44 | - foreach($filters as $flt) { |
|
| 44 | + foreach ($filters as $flt) { |
|
| 45 | 45 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
| 46 | 46 | if (isset($flt['source'])) { |
| 47 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."') AND marine_output.format_source IN ('".implode("','",$flt['source'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; |
|
| 47 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."') AND marine_output.format_source IN ('".implode("','", $flt['source'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; |
|
| 48 | 48 | } else { |
| 49 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; |
|
| 49 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; |
|
| 50 | 50 | } |
| 51 | 51 | } |
| 52 | 52 | } |
| 53 | 53 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 54 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
| 54 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
| 55 | 55 | } |
| 56 | 56 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
| 57 | 57 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
| 90 | 90 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
| 91 | 91 | if ($filter_query_where != '') { |
| 92 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
| 92 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
| 93 | 93 | } |
| 94 | 94 | $filter_query = $filter_query_join.$filter_query_where; |
| 95 | 95 | return $filter_query; |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | * @return array the spotter information |
| 105 | 105 | * |
| 106 | 106 | */ |
| 107 | - public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false) |
|
| 107 | + public function getDataFromDB($query, $params = array(), $limitQuery = '', $schedules = false) |
|
| 108 | 108 | { |
| 109 | 109 | global $globalVM; |
| 110 | 110 | date_default_timezone_set('UTC'); |
@@ -125,13 +125,13 @@ discard block |
||
| 125 | 125 | $sth = $this->db->prepare($query.$limitQuery); |
| 126 | 126 | $sth->execute($params); |
| 127 | 127 | } catch (PDOException $e) { |
| 128 | - printf("Invalid query : %s\nWhole query: %s\n",$e->getMessage(), $query.$limitQuery); |
|
| 128 | + printf("Invalid query : %s\nWhole query: %s\n", $e->getMessage(), $query.$limitQuery); |
|
| 129 | 129 | exit(); |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | $num_rows = 0; |
| 133 | 133 | $spotter_array = array(); |
| 134 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 134 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 135 | 135 | { |
| 136 | 136 | $num_rows++; |
| 137 | 137 | $temp_array = array(); |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | } |
| 151 | 151 | if (isset($row['fammarine_id'])) $temp_array['fammarine_id'] = $row['fammarine_id']; |
| 152 | 152 | if (isset($row['mmsi'])) $temp_array['mmsi'] = $row['mmsi']; |
| 153 | - if (isset($row['type'])) $temp_array['type'] = html_entity_decode($row['type'],ENT_QUOTES); |
|
| 153 | + if (isset($row['type'])) $temp_array['type'] = html_entity_decode($row['type'], ENT_QUOTES); |
|
| 154 | 154 | if (isset($row['type_id'])) $temp_array['type_id'] = $row['type_id']; |
| 155 | 155 | if (isset($row['status'])) $temp_array['status'] = $row['status']; |
| 156 | 156 | if (isset($row['status_id'])) $temp_array['status_id'] = $row['status_id']; |
@@ -173,10 +173,10 @@ discard block |
||
| 173 | 173 | } |
| 174 | 174 | if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed']; |
| 175 | 175 | |
| 176 | - if(isset($temp_array['mmsi']) && $temp_array['mmsi'] != "") |
|
| 176 | + if (isset($temp_array['mmsi']) && $temp_array['mmsi'] != "") |
|
| 177 | 177 | { |
| 178 | 178 | $Image = new Image($this->db); |
| 179 | - if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']); |
|
| 179 | + if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'], '', $temp_array['ident']); |
|
| 180 | 180 | else $image_array = $Image->getMarineImage($temp_array['mmsi']); |
| 181 | 181 | unset($Image); |
| 182 | 182 | if (count($image_array) > 0) { |
@@ -186,10 +186,10 @@ discard block |
||
| 186 | 186 | $temp_array['image_source_website'] = $image_array[0]['image_source_website']; |
| 187 | 187 | $temp_array['image_copyright'] = $image_array[0]['image_copyright']; |
| 188 | 188 | } |
| 189 | - } elseif(isset($temp_array['type']) && $temp_array['type'] != "") |
|
| 189 | + } elseif (isset($temp_array['type']) && $temp_array['type'] != "") |
|
| 190 | 190 | { |
| 191 | 191 | $Image = new Image($this->db); |
| 192 | - $image_array = $Image->getMarineImage('','','',$temp_array['type']); |
|
| 192 | + $image_array = $Image->getMarineImage('', '', '', $temp_array['type']); |
|
| 193 | 193 | unset($Image); |
| 194 | 194 | if (count($image_array) > 0) { |
| 195 | 195 | $temp_array['image'] = $image_array[0]['image']; |
@@ -224,17 +224,17 @@ discard block |
||
| 224 | 224 | { |
| 225 | 225 | $temp_array['date'] = "about ".$dateArray['hours']." hours ago"; |
| 226 | 226 | } else { |
| 227 | - $temp_array['date'] = date("M j Y, g:i a",strtotime($row['date']." UTC")); |
|
| 227 | + $temp_array['date'] = date("M j Y, g:i a", strtotime($row['date']." UTC")); |
|
| 228 | 228 | } |
| 229 | 229 | $temp_array['date_minutes_past'] = $dateArray['minutes']; |
| 230 | - $temp_array['date_iso_8601'] = date("c",strtotime($row['date']." UTC")); |
|
| 231 | - $temp_array['date_rfc_2822'] = date("r",strtotime($row['date']." UTC")); |
|
| 230 | + $temp_array['date_iso_8601'] = date("c", strtotime($row['date']." UTC")); |
|
| 231 | + $temp_array['date_rfc_2822'] = date("r", strtotime($row['date']." UTC")); |
|
| 232 | 232 | $temp_array['date_unix'] = strtotime($row['date']." UTC"); |
| 233 | 233 | if (isset($row['last_seen']) && $row['last_seen'] != '') { |
| 234 | 234 | if (strtotime($row['last_seen']) > strtotime($row['date'])) { |
| 235 | 235 | $temp_array['duration'] = strtotime($row['last_seen']) - strtotime($row['date']); |
| 236 | - $temp_array['last_seen_date_iso_8601'] = date("c",strtotime($row['last_seen']." UTC")); |
|
| 237 | - $temp_array['last_seen_date_rfc_2822'] = date("r",strtotime($row['last_seen']." UTC")); |
|
| 236 | + $temp_array['last_seen_date_iso_8601'] = date("c", strtotime($row['last_seen']." UTC")); |
|
| 237 | + $temp_array['last_seen_date_rfc_2822'] = date("r", strtotime($row['last_seen']." UTC")); |
|
| 238 | 238 | $temp_array['last_seen_date_unix'] = strtotime($row['last_seen']." UTC"); |
| 239 | 239 | } |
| 240 | 240 | } |
@@ -269,8 +269,8 @@ discard block |
||
| 269 | 269 | if ($limit != "") |
| 270 | 270 | { |
| 271 | 271 | $limit_array = explode(",", $limit); |
| 272 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 273 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 272 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 273 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 274 | 274 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 275 | 275 | { |
| 276 | 276 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
@@ -284,8 +284,8 @@ discard block |
||
| 284 | 284 | } else { |
| 285 | 285 | $orderby_query = " ORDER BY marine_output.date DESC"; |
| 286 | 286 | } |
| 287 | - $query = $global_marine_query.$filter_query." ".$orderby_query; |
|
| 288 | - $spotter_array = $this->getDataFromDB($query, array(),$limit_query,true); |
|
| 287 | + $query = $global_marine_query.$filter_query." ".$orderby_query; |
|
| 288 | + $spotter_array = $this->getDataFromDB($query, array(), $limit_query, true); |
|
| 289 | 289 | return $spotter_array; |
| 290 | 290 | } |
| 291 | 291 | |
@@ -303,8 +303,8 @@ discard block |
||
| 303 | 303 | if ($id == '') return array(); |
| 304 | 304 | $additional_query = "marine_output.fammarine_id = :id"; |
| 305 | 305 | $query_values = array(':id' => $id); |
| 306 | - $query = $global_marine_query." WHERE ".$additional_query." "; |
|
| 307 | - $spotter_array = $this->getDataFromDB($query,$query_values); |
|
| 306 | + $query = $global_marine_query." WHERE ".$additional_query." "; |
|
| 307 | + $spotter_array = $this->getDataFromDB($query, $query_values); |
|
| 308 | 308 | return $spotter_array; |
| 309 | 309 | } |
| 310 | 310 | |
@@ -326,7 +326,7 @@ discard block |
||
| 326 | 326 | $query_values = array(); |
| 327 | 327 | $limit_query = ''; |
| 328 | 328 | $additional_query = ''; |
| 329 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 329 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 330 | 330 | if ($ident != "") |
| 331 | 331 | { |
| 332 | 332 | if (!is_string($ident)) |
@@ -342,8 +342,8 @@ discard block |
||
| 342 | 342 | { |
| 343 | 343 | $limit_array = explode(",", $limit); |
| 344 | 344 | |
| 345 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 346 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 345 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 346 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 347 | 347 | |
| 348 | 348 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 349 | 349 | { |
@@ -385,7 +385,7 @@ discard block |
||
| 385 | 385 | $query_values = array(); |
| 386 | 386 | $limit_query = ''; |
| 387 | 387 | $additional_query = ''; |
| 388 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 388 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 389 | 389 | if (!is_string($type)) |
| 390 | 390 | { |
| 391 | 391 | return array(); |
@@ -398,8 +398,8 @@ discard block |
||
| 398 | 398 | { |
| 399 | 399 | $limit_array = explode(",", $limit); |
| 400 | 400 | |
| 401 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 402 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 401 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 402 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 403 | 403 | |
| 404 | 404 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 405 | 405 | { |
@@ -438,7 +438,7 @@ discard block |
||
| 438 | 438 | $limit_query = ''; |
| 439 | 439 | $additional_query = ''; |
| 440 | 440 | |
| 441 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 441 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 442 | 442 | |
| 443 | 443 | if ($date != "") |
| 444 | 444 | { |
@@ -464,8 +464,8 @@ discard block |
||
| 464 | 464 | { |
| 465 | 465 | $limit_array = explode(",", $limit); |
| 466 | 466 | |
| 467 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 468 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 467 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 468 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 469 | 469 | |
| 470 | 470 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 471 | 471 | { |
@@ -503,8 +503,8 @@ discard block |
||
| 503 | 503 | $query_values = array(); |
| 504 | 504 | $limit_query = ''; |
| 505 | 505 | $additional_query = ''; |
| 506 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 507 | - $captain = filter_var($captain,FILTER_SANITIZE_STRING); |
|
| 506 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 507 | + $captain = filter_var($captain, FILTER_SANITIZE_STRING); |
|
| 508 | 508 | if ($captain != "") |
| 509 | 509 | { |
| 510 | 510 | $additional_query = " AND (marine_output.captain_name = :captain OR marine_output.captain_id = :captain)"; |
@@ -513,8 +513,8 @@ discard block |
||
| 513 | 513 | if ($limit != "") |
| 514 | 514 | { |
| 515 | 515 | $limit_array = explode(",", $limit); |
| 516 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 517 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 516 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 517 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 518 | 518 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 519 | 519 | { |
| 520 | 520 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
@@ -544,13 +544,13 @@ discard block |
||
| 544 | 544 | */ |
| 545 | 545 | public function getMarineDataByRace($race = '', $limit = '', $sort = '', $filter = array()) |
| 546 | 546 | { |
| 547 | - global $global_marine_query,$globalDBdriver; |
|
| 547 | + global $global_marine_query, $globalDBdriver; |
|
| 548 | 548 | date_default_timezone_set('UTC'); |
| 549 | 549 | $query_values = array(); |
| 550 | 550 | $limit_query = ''; |
| 551 | 551 | $additional_query = ''; |
| 552 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 553 | - $race = filter_var($race,FILTER_SANITIZE_STRING); |
|
| 552 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 553 | + $race = filter_var($race, FILTER_SANITIZE_STRING); |
|
| 554 | 554 | if ($race != "") |
| 555 | 555 | { |
| 556 | 556 | $additional_query = " AND (marine_output.race_name = :race OR marine_output.race_id = :race)"; |
@@ -559,8 +559,8 @@ discard block |
||
| 559 | 559 | if ($limit != "") |
| 560 | 560 | { |
| 561 | 561 | $limit_array = explode(",", $limit); |
| 562 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 563 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 562 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 563 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 564 | 564 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 565 | 565 | { |
| 566 | 566 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
@@ -590,14 +590,14 @@ discard block |
||
| 590 | 590 | * @param array $filters |
| 591 | 591 | * @return Integer number of race for a captain |
| 592 | 592 | */ |
| 593 | - public function countRacesByCaptain($captain,$filters = array()) |
|
| 593 | + public function countRacesByCaptain($captain, $filters = array()) |
|
| 594 | 594 | { |
| 595 | - $captain = filter_var($captain,FILTER_SANITIZE_STRING); |
|
| 596 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 597 | - $query = "SELECT COUNT(*) AS nb |
|
| 595 | + $captain = filter_var($captain, FILTER_SANITIZE_STRING); |
|
| 596 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 597 | + $query = "SELECT COUNT(*) AS nb |
|
| 598 | 598 | FROM marine_output".$filter_query." (marine_output.captain_name = :captain OR marine_output.captain_id = :captain)"; |
| 599 | 599 | $query_values = array(); |
| 600 | - $query_values = array_merge($query_values,array(':captain' => $captain)); |
|
| 600 | + $query_values = array_merge($query_values, array(':captain' => $captain)); |
|
| 601 | 601 | $sth = $this->db->prepare($query); |
| 602 | 602 | $sth->execute($query_values); |
| 603 | 603 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -611,14 +611,14 @@ discard block |
||
| 611 | 611 | * @param array $filters |
| 612 | 612 | * @return String Duration of all races |
| 613 | 613 | */ |
| 614 | - public function countCaptainsByRace($race,$filters = array()) |
|
| 614 | + public function countCaptainsByRace($race, $filters = array()) |
|
| 615 | 615 | { |
| 616 | - $race = filter_var($race,FILTER_SANITIZE_STRING); |
|
| 617 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 618 | - $query = "SELECT COUNT(*) AS nb |
|
| 616 | + $race = filter_var($race, FILTER_SANITIZE_STRING); |
|
| 617 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 618 | + $query = "SELECT COUNT(*) AS nb |
|
| 619 | 619 | FROM marine_output".$filter_query." (marine_output.race_name = :race OR marine_output.race_id = :race)"; |
| 620 | 620 | $query_values = array(); |
| 621 | - $query_values = array_merge($query_values,array(':race' => $race)); |
|
| 621 | + $query_values = array_merge($query_values, array(':race' => $race)); |
|
| 622 | 622 | $sth = $this->db->prepare($query); |
| 623 | 623 | $sth->execute($query_values); |
| 624 | 624 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -635,44 +635,44 @@ discard block |
||
| 635 | 635 | * @param string $day |
| 636 | 636 | * @return array the boat list |
| 637 | 637 | */ |
| 638 | - public function countAllBoatTypesByCaptain($captain,$filters = array(),$year = '',$month = '',$day = '') |
|
| 638 | + public function countAllBoatTypesByCaptain($captain, $filters = array(), $year = '', $month = '', $day = '') |
|
| 639 | 639 | { |
| 640 | 640 | global $globalDBdriver; |
| 641 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 642 | - $captain = filter_var($captain,FILTER_SANITIZE_STRING); |
|
| 643 | - $query = "SELECT DISTINCT marine_output.type, COUNT(marine_output.type) AS type_count |
|
| 641 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 642 | + $captain = filter_var($captain, FILTER_SANITIZE_STRING); |
|
| 643 | + $query = "SELECT DISTINCT marine_output.type, COUNT(marine_output.type) AS type_count |
|
| 644 | 644 | FROM marine_output".$filter_query." (marine_output.captain_id = :captain OR marine_output.captain_name = :captain)"; |
| 645 | 645 | $query_values = array(); |
| 646 | 646 | if ($year != '') { |
| 647 | 647 | if ($globalDBdriver == 'mysql') { |
| 648 | 648 | $query .= " AND YEAR(marine_output.date) = :year"; |
| 649 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 649 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 650 | 650 | } else { |
| 651 | 651 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
| 652 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 652 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 653 | 653 | } |
| 654 | 654 | } |
| 655 | 655 | if ($month != '') { |
| 656 | 656 | if ($globalDBdriver == 'mysql') { |
| 657 | 657 | $query .= " AND MONTH(marine_output.date) = :month"; |
| 658 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 658 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 659 | 659 | } else { |
| 660 | 660 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
| 661 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 661 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 662 | 662 | } |
| 663 | 663 | } |
| 664 | 664 | if ($day != '') { |
| 665 | 665 | if ($globalDBdriver == 'mysql') { |
| 666 | 666 | $query .= " AND DAY(marine_output.date) = :day"; |
| 667 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 667 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 668 | 668 | } else { |
| 669 | 669 | $query .= " AND EXTRACT(DAY FROM marine_output.date) = :day"; |
| 670 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 670 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 671 | 671 | } |
| 672 | 672 | } |
| 673 | 673 | $query .= " GROUP BY marine_output.type |
| 674 | 674 | ORDER BY type_count DESC"; |
| 675 | - $query_values = array_merge($query_values,array(':captain' => $captain)); |
|
| 675 | + $query_values = array_merge($query_values, array(':captain' => $captain)); |
|
| 676 | 676 | $sth = $this->db->prepare($query); |
| 677 | 677 | $sth->execute($query_values); |
| 678 | 678 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -688,44 +688,44 @@ discard block |
||
| 688 | 688 | * @param string $day |
| 689 | 689 | * @return array the boat list |
| 690 | 690 | */ |
| 691 | - public function countAllBoatTypesByRace($race,$filters = array(),$year = '',$month = '',$day = '') |
|
| 691 | + public function countAllBoatTypesByRace($race, $filters = array(), $year = '', $month = '', $day = '') |
|
| 692 | 692 | { |
| 693 | 693 | global $globalDBdriver; |
| 694 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 695 | - $race = filter_var($race,FILTER_SANITIZE_STRING); |
|
| 696 | - $query = "SELECT DISTINCT marine_output.type, COUNT(marine_output.type) AS type_count |
|
| 694 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 695 | + $race = filter_var($race, FILTER_SANITIZE_STRING); |
|
| 696 | + $query = "SELECT DISTINCT marine_output.type, COUNT(marine_output.type) AS type_count |
|
| 697 | 697 | FROM marine_output".$filter_query." (marine_output.race_id = :race OR marine_output.race_name = :race)"; |
| 698 | 698 | $query_values = array(); |
| 699 | 699 | if ($year != '') { |
| 700 | 700 | if ($globalDBdriver == 'mysql') { |
| 701 | 701 | $query .= " AND YEAR(marine_output.date) = :year"; |
| 702 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 702 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 703 | 703 | } else { |
| 704 | 704 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
| 705 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 705 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 706 | 706 | } |
| 707 | 707 | } |
| 708 | 708 | if ($month != '') { |
| 709 | 709 | if ($globalDBdriver == 'mysql') { |
| 710 | 710 | $query .= " AND MONTH(marine_output.date) = :month"; |
| 711 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 711 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 712 | 712 | } else { |
| 713 | 713 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
| 714 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 714 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 715 | 715 | } |
| 716 | 716 | } |
| 717 | 717 | if ($day != '') { |
| 718 | 718 | if ($globalDBdriver == 'mysql') { |
| 719 | 719 | $query .= " AND DAY(marine_output.date) = :day"; |
| 720 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 720 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 721 | 721 | } else { |
| 722 | 722 | $query .= " AND EXTRACT(DAY FROM marine_output.date) = :day"; |
| 723 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 723 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 724 | 724 | } |
| 725 | 725 | } |
| 726 | 726 | $query .= " GROUP BY marine_output.type |
| 727 | 727 | ORDER BY type_count DESC"; |
| 728 | - $query_values = array_merge($query_values,array(':race' => $race)); |
|
| 728 | + $query_values = array_merge($query_values, array(':race' => $race)); |
|
| 729 | 729 | $sth = $this->db->prepare($query); |
| 730 | 730 | $sth->execute($query_values); |
| 731 | 731 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -741,47 +741,47 @@ discard block |
||
| 741 | 741 | * @param string $day |
| 742 | 742 | * @return String Duration of all race |
| 743 | 743 | */ |
| 744 | - public function getRaceDurationByCaptain($captain,$filters = array(),$year = '',$month = '',$day = '') |
|
| 744 | + public function getRaceDurationByCaptain($captain, $filters = array(), $year = '', $month = '', $day = '') |
|
| 745 | 745 | { |
| 746 | 746 | global $globalDBdriver; |
| 747 | - $captain = filter_var($captain,FILTER_SANITIZE_STRING); |
|
| 748 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 749 | - $query = "SELECT SUM(last_seen - date) AS duration |
|
| 747 | + $captain = filter_var($captain, FILTER_SANITIZE_STRING); |
|
| 748 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 749 | + $query = "SELECT SUM(last_seen - date) AS duration |
|
| 750 | 750 | FROM marine_output".$filter_query." (marine_output.captain_name = :captain OR marine_output.captain_id = :captain) |
| 751 | 751 | AND last_seen > date"; |
| 752 | 752 | $query_values = array(); |
| 753 | 753 | if ($year != '') { |
| 754 | 754 | if ($globalDBdriver == 'mysql') { |
| 755 | 755 | $query .= " AND YEAR(marine_output.date) = :year"; |
| 756 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 756 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 757 | 757 | } else { |
| 758 | 758 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
| 759 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 759 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 760 | 760 | } |
| 761 | 761 | } |
| 762 | 762 | if ($month != '') { |
| 763 | 763 | if ($globalDBdriver == 'mysql') { |
| 764 | 764 | $query .= " AND MONTH(marine_output.date) = :month"; |
| 765 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 765 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 766 | 766 | } else { |
| 767 | 767 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
| 768 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 768 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 769 | 769 | } |
| 770 | 770 | } |
| 771 | 771 | if ($day != '') { |
| 772 | 772 | if ($globalDBdriver == 'mysql') { |
| 773 | 773 | $query .= " AND DAY(marine_output.date) = :day"; |
| 774 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 774 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 775 | 775 | } else { |
| 776 | 776 | $query .= " AND EXTRACT(DAY FROM marine_output.date) = :day"; |
| 777 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 777 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 778 | 778 | } |
| 779 | 779 | } |
| 780 | - $query_values = array_merge($query_values,array(':captain' => $captain)); |
|
| 780 | + $query_values = array_merge($query_values, array(':captain' => $captain)); |
|
| 781 | 781 | $sth = $this->db->prepare($query); |
| 782 | 782 | $sth->execute($query_values); |
| 783 | 783 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 784 | - if (is_int($result[0]['duration'])) return gmdate('H:i:s',$result[0]['duration']); |
|
| 784 | + if (is_int($result[0]['duration'])) return gmdate('H:i:s', $result[0]['duration']); |
|
| 785 | 785 | else return $result[0]['duration']; |
| 786 | 786 | } |
| 787 | 787 | |
@@ -795,38 +795,38 @@ discard block |
||
| 795 | 795 | * @param string $day |
| 796 | 796 | * @return array Duration of all race |
| 797 | 797 | */ |
| 798 | - public function getRaceDurationByCaptains($limit = true,$filters = array(),$year = '',$month = '',$day = '') |
|
| 798 | + public function getRaceDurationByCaptains($limit = true, $filters = array(), $year = '', $month = '', $day = '') |
|
| 799 | 799 | { |
| 800 | 800 | global $globalDBdriver; |
| 801 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 802 | - $query = "SELECT SUM(last_seen - date) AS duration, captain_id, captain_name |
|
| 801 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 802 | + $query = "SELECT SUM(last_seen - date) AS duration, captain_id, captain_name |
|
| 803 | 803 | FROM marine_output".$filter_query." last_seen > date"; |
| 804 | 804 | $query_values = array(); |
| 805 | 805 | if ($year != '') { |
| 806 | 806 | if ($globalDBdriver == 'mysql') { |
| 807 | 807 | $query .= " AND YEAR(marine_output.date) = :year"; |
| 808 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 808 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 809 | 809 | } else { |
| 810 | 810 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
| 811 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 811 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 812 | 812 | } |
| 813 | 813 | } |
| 814 | 814 | if ($month != '') { |
| 815 | 815 | if ($globalDBdriver == 'mysql') { |
| 816 | 816 | $query .= " AND MONTH(marine_output.date) = :month"; |
| 817 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 817 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 818 | 818 | } else { |
| 819 | 819 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
| 820 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 820 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 821 | 821 | } |
| 822 | 822 | } |
| 823 | 823 | if ($day != '') { |
| 824 | 824 | if ($globalDBdriver == 'mysql') { |
| 825 | 825 | $query .= " AND DAY(marine_output.date) = :day"; |
| 826 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 826 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 827 | 827 | } else { |
| 828 | 828 | $query .= " AND EXTRACT(DAY FROM marine_output.date) = :day"; |
| 829 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 829 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 830 | 830 | } |
| 831 | 831 | } |
| 832 | 832 | $query .= " GROUP BY marine_output.captain_id,marine_output.captain_name ORDER BY duration DESC"; |
@@ -838,7 +838,7 @@ discard block |
||
| 838 | 838 | $duration_array = array(); |
| 839 | 839 | $temp_array = array(); |
| 840 | 840 | |
| 841 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 841 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 842 | 842 | { |
| 843 | 843 | if ($row['duration'] != '') { |
| 844 | 844 | $temp_array['marine_duration_days'] = $row['duration']; |
@@ -860,8 +860,8 @@ discard block |
||
| 860 | 860 | */ |
| 861 | 861 | public function getAllCaptainNames($filters = array()) |
| 862 | 862 | { |
| 863 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 864 | - $query = "SELECT DISTINCT marine_output.captain_name, marine_output.captain_id |
|
| 863 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 864 | + $query = "SELECT DISTINCT marine_output.captain_name, marine_output.captain_id |
|
| 865 | 865 | FROM marine_output".$filter_query." marine_output.captain_name <> '' |
| 866 | 866 | ORDER BY marine_output.captain_name ASC"; |
| 867 | 867 | |
@@ -878,8 +878,8 @@ discard block |
||
| 878 | 878 | */ |
| 879 | 879 | public function getAllRaceNames($filters = array()) |
| 880 | 880 | { |
| 881 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 882 | - $query = "SELECT DISTINCT marine_output.race_name, marine_output.race_id |
|
| 881 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 882 | + $query = "SELECT DISTINCT marine_output.race_name, marine_output.race_id |
|
| 883 | 883 | FROM marine_output".$filter_query." marine_output.race_name <> '' |
| 884 | 884 | ORDER BY marine_output.race_name ASC"; |
| 885 | 885 | |
@@ -896,11 +896,11 @@ discard block |
||
| 896 | 896 | * @param array $filters |
| 897 | 897 | * @return array list of source name |
| 898 | 898 | */ |
| 899 | - public function getAllSourceName($type = '',$filters = array()) |
|
| 899 | + public function getAllSourceName($type = '', $filters = array()) |
|
| 900 | 900 | { |
| 901 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 901 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 902 | 902 | $query_values = array(); |
| 903 | - $query = "SELECT DISTINCT marine_output.source_name |
|
| 903 | + $query = "SELECT DISTINCT marine_output.source_name |
|
| 904 | 904 | FROM marine_output".$filter_query." marine_output.source_name <> ''"; |
| 905 | 905 | if ($type != '') { |
| 906 | 906 | $query_values = array(':type' => $type); |
@@ -915,7 +915,7 @@ discard block |
||
| 915 | 915 | $source_array = array(); |
| 916 | 916 | $temp_array = array(); |
| 917 | 917 | |
| 918 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 918 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 919 | 919 | { |
| 920 | 920 | $temp_array['source_name'] = $row['source_name']; |
| 921 | 921 | $source_array[] = $temp_array; |
@@ -932,8 +932,8 @@ discard block |
||
| 932 | 932 | */ |
| 933 | 933 | public function getAllIdents($filters = array()) |
| 934 | 934 | { |
| 935 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 936 | - $query = "SELECT DISTINCT marine_output.ident |
|
| 935 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 936 | + $query = "SELECT DISTINCT marine_output.ident |
|
| 937 | 937 | FROM marine_output".$filter_query." marine_output.ident <> '' |
| 938 | 938 | ORDER BY marine_output.date ASC LIMIT 700 OFFSET 0"; |
| 939 | 939 | |
@@ -943,7 +943,7 @@ discard block |
||
| 943 | 943 | $ident_array = array(); |
| 944 | 944 | $temp_array = array(); |
| 945 | 945 | |
| 946 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 946 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 947 | 947 | { |
| 948 | 948 | $temp_array['ident'] = $row['ident']; |
| 949 | 949 | $ident_array[] = $temp_array; |
@@ -960,7 +960,7 @@ discard block |
||
| 960 | 960 | */ |
| 961 | 961 | public function getIdentity($mmsi) |
| 962 | 962 | { |
| 963 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
|
| 963 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT); |
|
| 964 | 964 | $query = "SELECT * FROM marine_identity WHERE mmsi = :mmsi LIMIT 1"; |
| 965 | 965 | $sth = $this->db->prepare($query); |
| 966 | 966 | $sth->execute(array(':mmsi' => $mmsi)); |
@@ -977,23 +977,23 @@ discard block |
||
| 977 | 977 | * @param $callsign |
| 978 | 978 | * @param $type |
| 979 | 979 | */ |
| 980 | - public function addIdentity($mmsi,$imo,$ident,$callsign,$type) |
|
| 980 | + public function addIdentity($mmsi, $imo, $ident, $callsign, $type) |
|
| 981 | 981 | { |
| 982 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
|
| 982 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT); |
|
| 983 | 983 | if ($mmsi != '') { |
| 984 | - $imo = filter_var($imo,FILTER_SANITIZE_NUMBER_INT); |
|
| 985 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
| 986 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 987 | - $type = filter_var($type,FILTER_SANITIZE_STRING); |
|
| 984 | + $imo = filter_var($imo, FILTER_SANITIZE_NUMBER_INT); |
|
| 985 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 986 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
| 987 | + $type = filter_var($type, FILTER_SANITIZE_STRING); |
|
| 988 | 988 | $identinfo = $this->getIdentity($mmsi); |
| 989 | 989 | if (empty($identinfo)) { |
| 990 | - $query = "INSERT INTO marine_identity (mmsi,imo,call_sign,ship_name,type) VALUES (:mmsi,:imo,:call_sign,:ship_name,:type)"; |
|
| 990 | + $query = "INSERT INTO marine_identity (mmsi,imo,call_sign,ship_name,type) VALUES (:mmsi,:imo,:call_sign,:ship_name,:type)"; |
|
| 991 | 991 | $sth = $this->db->prepare($query); |
| 992 | - $sth->execute(array(':mmsi' => $mmsi,':imo' => $imo,':call_sign' => $callsign,':ship_name' => $ident,':type' => $type)); |
|
| 992 | + $sth->execute(array(':mmsi' => $mmsi, ':imo' => $imo, ':call_sign' => $callsign, ':ship_name' => $ident, ':type' => $type)); |
|
| 993 | 993 | } elseif ($ident != '' && $identinfo['ship_name'] != $ident) { |
| 994 | - $query = "UPDATE marine_identity SET ship_name = :ship_name,type = :type WHERE mmsi = :mmsi"; |
|
| 994 | + $query = "UPDATE marine_identity SET ship_name = :ship_name,type = :type WHERE mmsi = :mmsi"; |
|
| 995 | 995 | $sth = $this->db->prepare($query); |
| 996 | - $sth->execute(array(':mmsi' => $mmsi,':ship_name' => $ident,':type' => $type)); |
|
| 996 | + $sth->execute(array(':mmsi' => $mmsi, ':ship_name' => $ident, ':type' => $type)); |
|
| 997 | 997 | } |
| 998 | 998 | } |
| 999 | 999 | } |
@@ -1014,12 +1014,12 @@ discard block |
||
| 1014 | 1014 | } else $offset = '+00:00'; |
| 1015 | 1015 | |
| 1016 | 1016 | if ($globalDBdriver == 'mysql') { |
| 1017 | - $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
|
| 1017 | + $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
|
| 1018 | 1018 | FROM marine_output |
| 1019 | 1019 | WHERE marine_output.date <> '' |
| 1020 | 1020 | ORDER BY marine_output.date ASC LIMIT 0,100"; |
| 1021 | 1021 | } else { |
| 1022 | - $query = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
| 1022 | + $query = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
| 1023 | 1023 | FROM marine_output |
| 1024 | 1024 | WHERE marine_output.date <> '' |
| 1025 | 1025 | ORDER BY marine_output.date ASC LIMIT 0,100"; |
@@ -1031,7 +1031,7 @@ discard block |
||
| 1031 | 1031 | $date_array = array(); |
| 1032 | 1032 | $temp_array = array(); |
| 1033 | 1033 | |
| 1034 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1034 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1035 | 1035 | { |
| 1036 | 1036 | $temp_array['date'] = $row['date']; |
| 1037 | 1037 | |
@@ -1049,10 +1049,10 @@ discard block |
||
| 1049 | 1049 | * @return String success or false |
| 1050 | 1050 | * |
| 1051 | 1051 | */ |
| 1052 | - public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL) |
|
| 1052 | + public function updateIdentMarineData($fammarine_id = '', $ident = '', $fromsource = NULL) |
|
| 1053 | 1053 | { |
| 1054 | 1054 | $query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id'; |
| 1055 | - $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident); |
|
| 1055 | + $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident); |
|
| 1056 | 1056 | try { |
| 1057 | 1057 | $sth = $this->db->prepare($query); |
| 1058 | 1058 | $sth->execute($query_values); |
@@ -1070,10 +1070,10 @@ discard block |
||
| 1070 | 1070 | * @return String success or false |
| 1071 | 1071 | * |
| 1072 | 1072 | */ |
| 1073 | - public function updateArrivalPortNameMarineData($fammarine_id = '', $arrival_code = '',$fromsource = NULL) |
|
| 1073 | + public function updateArrivalPortNameMarineData($fammarine_id = '', $arrival_code = '', $fromsource = NULL) |
|
| 1074 | 1074 | { |
| 1075 | 1075 | $query = 'UPDATE marine_output SET arrival_port_name = :arrival_code WHERE fammarine_id = :fammarine_id'; |
| 1076 | - $query_values = array(':fammarine_id' => $fammarine_id,':arrival_code' => $arrival_code); |
|
| 1076 | + $query_values = array(':fammarine_id' => $fammarine_id, ':arrival_code' => $arrival_code); |
|
| 1077 | 1077 | try { |
| 1078 | 1078 | $sth = $this->db->prepare($query); |
| 1079 | 1079 | $sth->execute($query_values); |
@@ -1092,11 +1092,11 @@ discard block |
||
| 1092 | 1092 | * @return String success or false |
| 1093 | 1093 | * |
| 1094 | 1094 | */ |
| 1095 | - public function updateStatusMarineData($fammarine_id = '', $status_id = '',$status = '') |
|
| 1095 | + public function updateStatusMarineData($fammarine_id = '', $status_id = '', $status = '') |
|
| 1096 | 1096 | { |
| 1097 | 1097 | |
| 1098 | 1098 | $query = 'UPDATE marine_output SET status = :status, status_id = :status_id WHERE fammarine_id = :fammarine_id'; |
| 1099 | - $query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id); |
|
| 1099 | + $query_values = array(':fammarine_id' => $fammarine_id, ':status' => $status, ':status_id' => $status_id); |
|
| 1100 | 1100 | |
| 1101 | 1101 | try { |
| 1102 | 1102 | $sth = $this->db->prepare($query); |
@@ -1125,17 +1125,17 @@ discard block |
||
| 1125 | 1125 | * @param string $race_begin |
| 1126 | 1126 | * @return String success or false |
| 1127 | 1127 | */ |
| 1128 | - public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '',$distance = NULL,$race_rank = NULL, $race_time = NULL, $status = '', $race_begin = '') |
|
| 1128 | + public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '', $distance = NULL, $race_rank = NULL, $race_time = NULL, $status = '', $race_begin = '') |
|
| 1129 | 1129 | { |
| 1130 | 1130 | if ($latitude == '') $latitude = NULL; |
| 1131 | 1131 | if ($longitude == '') $longitude = NULL; |
| 1132 | 1132 | $groundspeed = round($groundspeed); |
| 1133 | 1133 | if ($race_begin != '') { |
| 1134 | 1134 | $query = 'UPDATE marine_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed, distance = :distance, race_rank = :race_rank, race_time = :race_time, status = :status, date = :race_begin WHERE fammarine_id = :fammarine_id'; |
| 1135 | - $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident,':distance' => $distance,':race_rank' => $race_rank,':race_time' => $race_time,':status' => $status,':race_begin' => $race_begin); |
|
| 1135 | + $query_values = array(':fammarine_id' => $fammarine_id, ':last_latitude' => $latitude, ':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed, ':last_seen' => $date, ':ident' => $ident, ':distance' => $distance, ':race_rank' => $race_rank, ':race_time' => $race_time, ':status' => $status, ':race_begin' => $race_begin); |
|
| 1136 | 1136 | } else { |
| 1137 | 1137 | $query = 'UPDATE marine_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed, distance = :distance, race_rank = :race_rank, race_time = :race_time, status = :status WHERE fammarine_id = :fammarine_id'; |
| 1138 | - $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident,':distance' => $distance,':race_rank' => $race_rank,':race_time' => $race_time,':status' => $status); |
|
| 1138 | + $query_values = array(':fammarine_id' => $fammarine_id, ':last_latitude' => $latitude, ':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed, ':last_seen' => $date, ':ident' => $ident, ':distance' => $distance, ':race_rank' => $race_rank, ':race_time' => $race_time, ':status' => $status); |
|
| 1139 | 1139 | } |
| 1140 | 1140 | try { |
| 1141 | 1141 | $sth = $this->db->prepare($query); |
@@ -1179,7 +1179,7 @@ discard block |
||
| 1179 | 1179 | * @param string $race_time |
| 1180 | 1180 | * @return String success or false |
| 1181 | 1181 | */ |
| 1182 | - public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '',$type = '',$typeid = '',$imo = '',$callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$format_source = '', $source_name = '', $captain_id = '',$captain_name = '',$race_id = '', $race_name = '', $distance = '',$race_rank = '', $race_time = '') |
|
| 1182 | + public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $statusid = '', $format_source = '', $source_name = '', $captain_id = '', $captain_name = '', $race_id = '', $race_name = '', $distance = '', $race_rank = '', $race_time = '') |
|
| 1183 | 1183 | { |
| 1184 | 1184 | global $globalURL, $globalMarineImageFetch; |
| 1185 | 1185 | |
@@ -1251,34 +1251,34 @@ discard block |
||
| 1251 | 1251 | $date = date("Y-m-d H:i:s", time()); |
| 1252 | 1252 | } |
| 1253 | 1253 | |
| 1254 | - $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
|
| 1255 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
| 1256 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1257 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1258 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
| 1259 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1260 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
| 1261 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
|
| 1262 | - $type = filter_var($type,FILTER_SANITIZE_STRING); |
|
| 1263 | - $status = filter_var($status,FILTER_SANITIZE_STRING); |
|
| 1264 | - $type_id = filter_var($typeid,FILTER_SANITIZE_NUMBER_INT); |
|
| 1265 | - $status_id = filter_var($statusid,FILTER_SANITIZE_NUMBER_INT); |
|
| 1266 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
| 1267 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 1268 | - $arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING); |
|
| 1269 | - $arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING); |
|
| 1270 | - $captain_id = filter_var($captain_id,FILTER_SANITIZE_STRING); |
|
| 1271 | - $captain_name = filter_var($captain_name,FILTER_SANITIZE_STRING); |
|
| 1272 | - $race_id = filter_var($race_id,FILTER_SANITIZE_STRING); |
|
| 1273 | - $race_name = filter_var($race_name,FILTER_SANITIZE_STRING); |
|
| 1274 | - $race_rank = filter_var($race_rank,FILTER_SANITIZE_NUMBER_INT); |
|
| 1275 | - $race_time = filter_var($race_time,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1276 | - $distance = filter_var($distance,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1254 | + $fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING); |
|
| 1255 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 1256 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1257 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1258 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
| 1259 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1260 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
| 1261 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); |
|
| 1262 | + $type = filter_var($type, FILTER_SANITIZE_STRING); |
|
| 1263 | + $status = filter_var($status, FILTER_SANITIZE_STRING); |
|
| 1264 | + $type_id = filter_var($typeid, FILTER_SANITIZE_NUMBER_INT); |
|
| 1265 | + $status_id = filter_var($statusid, FILTER_SANITIZE_NUMBER_INT); |
|
| 1266 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
| 1267 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
| 1268 | + $arrival_code = filter_var($arrival_code, FILTER_SANITIZE_STRING); |
|
| 1269 | + $arrival_date = filter_var($arrival_date, FILTER_SANITIZE_STRING); |
|
| 1270 | + $captain_id = filter_var($captain_id, FILTER_SANITIZE_STRING); |
|
| 1271 | + $captain_name = filter_var($captain_name, FILTER_SANITIZE_STRING); |
|
| 1272 | + $race_id = filter_var($race_id, FILTER_SANITIZE_STRING); |
|
| 1273 | + $race_name = filter_var($race_name, FILTER_SANITIZE_STRING); |
|
| 1274 | + $race_rank = filter_var($race_rank, FILTER_SANITIZE_NUMBER_INT); |
|
| 1275 | + $race_time = filter_var($race_time, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1276 | + $distance = filter_var($distance, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1277 | 1277 | if (isset($globalMarineImageFetch) && $globalMarineImageFetch === TRUE) { |
| 1278 | 1278 | $Image = new Image($this->db); |
| 1279 | - $image_array = $Image->getMarineImage($mmsi,$imo,$ident); |
|
| 1279 | + $image_array = $Image->getMarineImage($mmsi, $imo, $ident); |
|
| 1280 | 1280 | if (!isset($image_array[0]['mmsi'])) { |
| 1281 | - $Image->addMarineImage($mmsi,$imo,$ident); |
|
| 1281 | + $Image->addMarineImage($mmsi, $imo, $ident); |
|
| 1282 | 1282 | } |
| 1283 | 1283 | unset($Image); |
| 1284 | 1284 | } |
@@ -1294,10 +1294,10 @@ discard block |
||
| 1294 | 1294 | if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
| 1295 | 1295 | //if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
| 1296 | 1296 | if ($arrival_date == '') $arrival_date = NULL; |
| 1297 | - $query = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, type_id, status,status_id,imo,arrival_port_name,arrival_port_date,captain_id,captain_name,race_id,race_name, distance, race_rank,race_time) |
|
| 1297 | + $query = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, type_id, status,status_id,imo,arrival_port_name,arrival_port_date,captain_id,captain_name,race_id,race_name, distance, race_rank,race_time) |
|
| 1298 | 1298 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:type_id,:status,:status_id,:imo,:arrival_port_name,:arrival_port_date,:captain_id,:captain_name,:race_id,:race_name, :distance, :race_rank,:race_time)"; |
| 1299 | 1299 | |
| 1300 | - $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':heading' => $heading,':speed' => $groundspeed,':date' => $date,':format_source' => $format_source, ':source_name' => $source_name,':mmsi' => $mmsi,':type' => $type,':type_id' => $type_id,':status' => $status,':status_id' => $status_id,':imo' => $imo,':arrival_port_name' => $arrival_code,':arrival_port_date' => $arrival_date,':captain_id' => $captain_id,':captain_name' => $captain_name,':race_id' => $race_id,':race_name' => $race_name,':distance' => $distance,':race_rank' => $race_rank,':race_time' => $race_time); |
|
| 1300 | + $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':heading' => $heading, ':speed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':mmsi' => $mmsi, ':type' => $type, ':type_id' => $type_id, ':status' => $status, ':status_id' => $status_id, ':imo' => $imo, ':arrival_port_name' => $arrival_code, ':arrival_port_date' => $arrival_date, ':captain_id' => $captain_id, ':captain_name' => $captain_name, ':race_id' => $race_id, ':race_name' => $race_name, ':distance' => $distance, ':race_rank' => $race_rank, ':race_time' => $race_time); |
|
| 1301 | 1301 | try { |
| 1302 | 1302 | $sth = $this->db->prepare($query); |
| 1303 | 1303 | $sth->execute($query_values); |
@@ -1321,13 +1321,13 @@ discard block |
||
| 1321 | 1321 | { |
| 1322 | 1322 | global $globalDBdriver, $globalTimezone; |
| 1323 | 1323 | if ($globalDBdriver == 'mysql') { |
| 1324 | - $query = "SELECT marine_output.ident FROM marine_output |
|
| 1324 | + $query = "SELECT marine_output.ident FROM marine_output |
|
| 1325 | 1325 | WHERE marine_output.ident = :ident |
| 1326 | 1326 | AND marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
| 1327 | 1327 | AND marine_output.date < UTC_TIMESTAMP()"; |
| 1328 | 1328 | $query_data = array(':ident' => $ident); |
| 1329 | 1329 | } else { |
| 1330 | - $query = "SELECT marine_output.ident FROM marine_output |
|
| 1330 | + $query = "SELECT marine_output.ident FROM marine_output |
|
| 1331 | 1331 | WHERE marine_output.ident = :ident |
| 1332 | 1332 | AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
| 1333 | 1333 | AND marine_output.date < now() AT TIME ZONE 'UTC'"; |
@@ -1336,8 +1336,8 @@ discard block |
||
| 1336 | 1336 | |
| 1337 | 1337 | $sth = $this->db->prepare($query); |
| 1338 | 1338 | $sth->execute($query_data); |
| 1339 | - $ident_result=''; |
|
| 1340 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1339 | + $ident_result = ''; |
|
| 1340 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1341 | 1341 | { |
| 1342 | 1342 | $ident_result = $row['ident']; |
| 1343 | 1343 | } |
@@ -1363,8 +1363,8 @@ discard block |
||
| 1363 | 1363 | return false; |
| 1364 | 1364 | } else { |
| 1365 | 1365 | $q_array = explode(" ", $q); |
| 1366 | - foreach ($q_array as $q_item){ |
|
| 1367 | - $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
|
| 1366 | + foreach ($q_array as $q_item) { |
|
| 1367 | + $q_item = filter_var($q_item, FILTER_SANITIZE_STRING); |
|
| 1368 | 1368 | $additional_query .= " AND ("; |
| 1369 | 1369 | $additional_query .= "(marine_output.ident like '%".$q_item."%')"; |
| 1370 | 1370 | $additional_query .= ")"; |
@@ -1372,11 +1372,11 @@ discard block |
||
| 1372 | 1372 | } |
| 1373 | 1373 | } |
| 1374 | 1374 | if ($globalDBdriver == 'mysql') { |
| 1375 | - $query = "SELECT marine_output.* FROM marine_output |
|
| 1375 | + $query = "SELECT marine_output.* FROM marine_output |
|
| 1376 | 1376 | WHERE marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." |
| 1377 | 1377 | AND marine_output.date < UTC_TIMESTAMP()"; |
| 1378 | 1378 | } else { |
| 1379 | - $query = "SELECT marine_output.* FROM marine_output |
|
| 1379 | + $query = "SELECT marine_output.* FROM marine_output |
|
| 1380 | 1380 | WHERE marine_output.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." |
| 1381 | 1381 | AND marine_output.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'"; |
| 1382 | 1382 | } |
@@ -1396,16 +1396,16 @@ discard block |
||
| 1396 | 1396 | * @return array the airline country list |
| 1397 | 1397 | */ |
| 1398 | 1398 | |
| 1399 | - public function countAllMarineOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) |
|
| 1399 | + public function countAllMarineOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array()) |
|
| 1400 | 1400 | { |
| 1401 | 1401 | global $globalDBdriver, $globalArchive; |
| 1402 | 1402 | //$filter_query = $this->getFilter($filters,true,true); |
| 1403 | - $Connection= new Connection($this->db); |
|
| 1403 | + $Connection = new Connection($this->db); |
|
| 1404 | 1404 | if (!$Connection->tableExists('countries')) return array(); |
| 1405 | 1405 | require_once('class.SpotterLive.php'); |
| 1406 | 1406 | if (!isset($globalArchive) || $globalArchive !== TRUE) { |
| 1407 | 1407 | $MarineLive = new MarineLive($this->db); |
| 1408 | - $filter_query = $MarineLive->getFilter($filters,true,true); |
|
| 1408 | + $filter_query = $MarineLive->getFilter($filters, true, true); |
|
| 1409 | 1409 | $filter_query .= " over_country IS NOT NULL AND over_country <> ''"; |
| 1410 | 1410 | if ($olderthanmonths > 0) { |
| 1411 | 1411 | if ($globalDBdriver == 'mysql') { |
@@ -1425,7 +1425,7 @@ discard block |
||
| 1425 | 1425 | } else { |
| 1426 | 1426 | require_once(dirname(__FILE__)."/class.MarineArchive.php"); |
| 1427 | 1427 | $MarineArchive = new MarineArchive($this->db); |
| 1428 | - $filter_query = $MarineArchive->getFilter($filters,true,true); |
|
| 1428 | + $filter_query = $MarineArchive->getFilter($filters, true, true); |
|
| 1429 | 1429 | $filter_query .= " over_country <> ''"; |
| 1430 | 1430 | if ($olderthanmonths > 0) { |
| 1431 | 1431 | if ($globalDBdriver == 'mysql') { |
@@ -1453,7 +1453,7 @@ discard block |
||
| 1453 | 1453 | $flight_array = array(); |
| 1454 | 1454 | $temp_array = array(); |
| 1455 | 1455 | |
| 1456 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1456 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1457 | 1457 | { |
| 1458 | 1458 | $temp_array['marine_count'] = $row['nb']; |
| 1459 | 1459 | $temp_array['marine_country'] = $row['name']; |
@@ -1477,11 +1477,11 @@ discard block |
||
| 1477 | 1477 | * @param string $day |
| 1478 | 1478 | * @return array the callsign list |
| 1479 | 1479 | */ |
| 1480 | - public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '') |
|
| 1480 | + public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '') |
|
| 1481 | 1481 | { |
| 1482 | 1482 | global $globalDBdriver; |
| 1483 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1484 | - $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
|
| 1483 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1484 | + $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
|
| 1485 | 1485 | FROM marine_output".$filter_query." marine_output.ident <> ''"; |
| 1486 | 1486 | if ($olderthanmonths > 0) { |
| 1487 | 1487 | if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
@@ -1495,28 +1495,28 @@ discard block |
||
| 1495 | 1495 | if ($year != '') { |
| 1496 | 1496 | if ($globalDBdriver == 'mysql') { |
| 1497 | 1497 | $query .= " AND YEAR(marine_output.date) = :year"; |
| 1498 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 1498 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 1499 | 1499 | } else { |
| 1500 | 1500 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
| 1501 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 1501 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 1502 | 1502 | } |
| 1503 | 1503 | } |
| 1504 | 1504 | if ($month != '') { |
| 1505 | 1505 | if ($globalDBdriver == 'mysql') { |
| 1506 | 1506 | $query .= " AND MONTH(marine_output.date) = :month"; |
| 1507 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 1507 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 1508 | 1508 | } else { |
| 1509 | 1509 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
| 1510 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 1510 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 1511 | 1511 | } |
| 1512 | 1512 | } |
| 1513 | 1513 | if ($day != '') { |
| 1514 | 1514 | if ($globalDBdriver == 'mysql') { |
| 1515 | 1515 | $query .= " AND DAY(marine_output.date) = :day"; |
| 1516 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 1516 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 1517 | 1517 | } else { |
| 1518 | 1518 | $query .= " AND EXTRACT(DAY FROM marine_output.date) = :day"; |
| 1519 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 1519 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 1520 | 1520 | } |
| 1521 | 1521 | } |
| 1522 | 1522 | $query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC"; |
@@ -1528,7 +1528,7 @@ discard block |
||
| 1528 | 1528 | $callsign_array = array(); |
| 1529 | 1529 | $temp_array = array(); |
| 1530 | 1530 | |
| 1531 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1531 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1532 | 1532 | { |
| 1533 | 1533 | $temp_array['callsign_icao'] = $row['ident']; |
| 1534 | 1534 | $temp_array['airline_name'] = $row['airline_name']; |
@@ -1580,7 +1580,7 @@ discard block |
||
| 1580 | 1580 | $date_array = array(); |
| 1581 | 1581 | $temp_array = array(); |
| 1582 | 1582 | |
| 1583 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1583 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1584 | 1584 | { |
| 1585 | 1585 | $temp_array['date_name'] = $row['date_name']; |
| 1586 | 1586 | $temp_array['date_count'] = $row['date_count']; |
@@ -1606,7 +1606,7 @@ discard block |
||
| 1606 | 1606 | $datetime = new DateTime(); |
| 1607 | 1607 | $offset = $datetime->format('P'); |
| 1608 | 1608 | } else $offset = '+00:00'; |
| 1609 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1609 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1610 | 1610 | if ($globalDBdriver == 'mysql') { |
| 1611 | 1611 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
| 1612 | 1612 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)"; |
@@ -1627,7 +1627,7 @@ discard block |
||
| 1627 | 1627 | $date_array = array(); |
| 1628 | 1628 | $temp_array = array(); |
| 1629 | 1629 | |
| 1630 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1630 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1631 | 1631 | { |
| 1632 | 1632 | $temp_array['date_name'] = $row['date_name']; |
| 1633 | 1633 | $temp_array['date_count'] = $row['date_count']; |
@@ -1652,7 +1652,7 @@ discard block |
||
| 1652 | 1652 | $datetime = new DateTime(); |
| 1653 | 1653 | $offset = $datetime->format('P'); |
| 1654 | 1654 | } else $offset = '+00:00'; |
| 1655 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1655 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1656 | 1656 | if ($globalDBdriver == 'mysql') { |
| 1657 | 1657 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
| 1658 | 1658 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)"; |
@@ -1673,7 +1673,7 @@ discard block |
||
| 1673 | 1673 | $date_array = array(); |
| 1674 | 1674 | $temp_array = array(); |
| 1675 | 1675 | |
| 1676 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1676 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1677 | 1677 | { |
| 1678 | 1678 | $temp_array['date_name'] = $row['date_name']; |
| 1679 | 1679 | $temp_array['date_count'] = $row['date_count']; |
@@ -1720,7 +1720,7 @@ discard block |
||
| 1720 | 1720 | $date_array = array(); |
| 1721 | 1721 | $temp_array = array(); |
| 1722 | 1722 | |
| 1723 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1723 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1724 | 1724 | { |
| 1725 | 1725 | $temp_array['month_name'] = $row['month_name']; |
| 1726 | 1726 | $temp_array['year_name'] = $row['year_name']; |
@@ -1747,7 +1747,7 @@ discard block |
||
| 1747 | 1747 | $datetime = new DateTime(); |
| 1748 | 1748 | $offset = $datetime->format('P'); |
| 1749 | 1749 | } else $offset = '+00:00'; |
| 1750 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1750 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1751 | 1751 | if ($globalDBdriver == 'mysql') { |
| 1752 | 1752 | $query = "SELECT MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count |
| 1753 | 1753 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)"; |
@@ -1768,7 +1768,7 @@ discard block |
||
| 1768 | 1768 | $date_array = array(); |
| 1769 | 1769 | $temp_array = array(); |
| 1770 | 1770 | |
| 1771 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1771 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1772 | 1772 | { |
| 1773 | 1773 | $temp_array['year_name'] = $row['year_name']; |
| 1774 | 1774 | $temp_array['month_name'] = $row['month_name']; |
@@ -1788,7 +1788,7 @@ discard block |
||
| 1788 | 1788 | * @param array $filters |
| 1789 | 1789 | * @return array the hour list |
| 1790 | 1790 | */ |
| 1791 | - public function countAllHours($orderby,$filters = array()) |
|
| 1791 | + public function countAllHours($orderby, $filters = array()) |
|
| 1792 | 1792 | { |
| 1793 | 1793 | global $globalTimezone, $globalDBdriver; |
| 1794 | 1794 | if ($globalTimezone != '') { |
@@ -1836,7 +1836,7 @@ discard block |
||
| 1836 | 1836 | $hour_array = array(); |
| 1837 | 1837 | $temp_array = array(); |
| 1838 | 1838 | |
| 1839 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1839 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1840 | 1840 | { |
| 1841 | 1841 | $temp_array['hour_name'] = $row['hour_name']; |
| 1842 | 1842 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1858,8 +1858,8 @@ discard block |
||
| 1858 | 1858 | public function countAllHoursByDate($date, $filters = array()) |
| 1859 | 1859 | { |
| 1860 | 1860 | global $globalTimezone, $globalDBdriver; |
| 1861 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1862 | - $date = filter_var($date,FILTER_SANITIZE_STRING); |
|
| 1861 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1862 | + $date = filter_var($date, FILTER_SANITIZE_STRING); |
|
| 1863 | 1863 | if ($globalTimezone != '') { |
| 1864 | 1864 | date_default_timezone_set($globalTimezone); |
| 1865 | 1865 | $datetime = new DateTime($date); |
@@ -1867,12 +1867,12 @@ discard block |
||
| 1867 | 1867 | } else $offset = '+00:00'; |
| 1868 | 1868 | |
| 1869 | 1869 | if ($globalDBdriver == 'mysql') { |
| 1870 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1870 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1871 | 1871 | FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = :date |
| 1872 | 1872 | GROUP BY hour_name |
| 1873 | 1873 | ORDER BY hour_name ASC"; |
| 1874 | 1874 | } else { |
| 1875 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1875 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1876 | 1876 | FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset, 'YYYY-mm-dd') = :date |
| 1877 | 1877 | GROUP BY hour_name |
| 1878 | 1878 | ORDER BY hour_name ASC"; |
@@ -1884,7 +1884,7 @@ discard block |
||
| 1884 | 1884 | $hour_array = array(); |
| 1885 | 1885 | $temp_array = array(); |
| 1886 | 1886 | |
| 1887 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1887 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1888 | 1888 | { |
| 1889 | 1889 | $temp_array['hour_name'] = $row['hour_name']; |
| 1890 | 1890 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1906,8 +1906,8 @@ discard block |
||
| 1906 | 1906 | public function countAllHoursByIdent($ident, $filters = array()) |
| 1907 | 1907 | { |
| 1908 | 1908 | global $globalTimezone, $globalDBdriver; |
| 1909 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1910 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
| 1909 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1910 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 1911 | 1911 | if ($globalTimezone != '') { |
| 1912 | 1912 | date_default_timezone_set($globalTimezone); |
| 1913 | 1913 | $datetime = new DateTime(); |
@@ -1915,12 +1915,12 @@ discard block |
||
| 1915 | 1915 | } else $offset = '+00:00'; |
| 1916 | 1916 | |
| 1917 | 1917 | if ($globalDBdriver == 'mysql') { |
| 1918 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1918 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1919 | 1919 | FROM marine_output".$filter_query." marine_output.ident = :ident |
| 1920 | 1920 | GROUP BY hour_name |
| 1921 | 1921 | ORDER BY hour_name ASC"; |
| 1922 | 1922 | } else { |
| 1923 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1923 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1924 | 1924 | FROM marine_output".$filter_query." marine_output.ident = :ident |
| 1925 | 1925 | GROUP BY hour_name |
| 1926 | 1926 | ORDER BY hour_name ASC"; |
@@ -1928,12 +1928,12 @@ discard block |
||
| 1928 | 1928 | |
| 1929 | 1929 | |
| 1930 | 1930 | $sth = $this->db->prepare($query); |
| 1931 | - $sth->execute(array(':ident' => $ident,':offset' => $offset)); |
|
| 1931 | + $sth->execute(array(':ident' => $ident, ':offset' => $offset)); |
|
| 1932 | 1932 | |
| 1933 | 1933 | $hour_array = array(); |
| 1934 | 1934 | $temp_array = array(); |
| 1935 | 1935 | |
| 1936 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1936 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1937 | 1937 | { |
| 1938 | 1938 | $temp_array['hour_name'] = $row['hour_name']; |
| 1939 | 1939 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1953,11 +1953,11 @@ discard block |
||
| 1953 | 1953 | * @param array $filters |
| 1954 | 1954 | * @return array the aircraft list |
| 1955 | 1955 | */ |
| 1956 | - public function countAllCaptainsByRaces($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) |
|
| 1956 | + public function countAllCaptainsByRaces($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array()) |
|
| 1957 | 1957 | { |
| 1958 | 1958 | global $globalDBdriver; |
| 1959 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1960 | - $query = "SELECT DISTINCT marine_output.race_id, marine_output.race_name, COUNT(marine_output.captain_id) AS captain_count |
|
| 1959 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1960 | + $query = "SELECT DISTINCT marine_output.race_id, marine_output.race_name, COUNT(marine_output.captain_id) AS captain_count |
|
| 1961 | 1961 | FROM marine_output".$filter_query." race_id IS NOT NULL"; |
| 1962 | 1962 | if ($olderthanmonths > 0) { |
| 1963 | 1963 | if ($globalDBdriver == 'mysql') { |
@@ -1980,7 +1980,7 @@ discard block |
||
| 1980 | 1980 | $marine_array = array(); |
| 1981 | 1981 | $temp_array = array(); |
| 1982 | 1982 | |
| 1983 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1983 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1984 | 1984 | { |
| 1985 | 1985 | $temp_array['marine_race_id'] = $row['race_id']; |
| 1986 | 1986 | $temp_array['marine_race_name'] = $row['race_name']; |
@@ -1998,33 +1998,33 @@ discard block |
||
| 1998 | 1998 | * @param string $month |
| 1999 | 1999 | * @return Integer the number of vessels |
| 2000 | 2000 | */ |
| 2001 | - public function countOverallMarine($filters = array(),$year = '',$month = '') |
|
| 2001 | + public function countOverallMarine($filters = array(), $year = '', $month = '') |
|
| 2002 | 2002 | { |
| 2003 | 2003 | global $globalDBdriver; |
| 2004 | 2004 | //$queryi = "SELECT COUNT(marine_output.marine_id) AS flight_count FROM marine_output"; |
| 2005 | - $queryi = "SELECT COUNT(DISTINCT marine_output.mmsi) AS flight_count FROM marine_output"; |
|
| 2005 | + $queryi = "SELECT COUNT(DISTINCT marine_output.mmsi) AS flight_count FROM marine_output"; |
|
| 2006 | 2006 | $query_values = array(); |
| 2007 | 2007 | $query = ''; |
| 2008 | 2008 | if ($year != '') { |
| 2009 | 2009 | if ($globalDBdriver == 'mysql') { |
| 2010 | 2010 | $query .= " AND YEAR(marine_output.date) = :year"; |
| 2011 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 2011 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 2012 | 2012 | } else { |
| 2013 | 2013 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
| 2014 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 2014 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 2015 | 2015 | } |
| 2016 | 2016 | } |
| 2017 | 2017 | if ($month != '') { |
| 2018 | 2018 | if ($globalDBdriver == 'mysql') { |
| 2019 | 2019 | $query .= " AND MONTH(marine_output.date) = :month"; |
| 2020 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 2020 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 2021 | 2021 | } else { |
| 2022 | 2022 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
| 2023 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 2023 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 2024 | 2024 | } |
| 2025 | 2025 | } |
| 2026 | 2026 | if (empty($query_values)) $queryi .= $this->getFilter($filters); |
| 2027 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 2027 | + else $queryi .= $this->getFilter($filters, true, true).substr($query, 4); |
|
| 2028 | 2028 | |
| 2029 | 2029 | $sth = $this->db->prepare($queryi); |
| 2030 | 2030 | $sth->execute($query_values); |
@@ -2039,32 +2039,32 @@ discard block |
||
| 2039 | 2039 | * @param string $month |
| 2040 | 2040 | * @return Integer the number of vessels |
| 2041 | 2041 | */ |
| 2042 | - public function countOverallMarineTypes($filters = array(),$year = '',$month = '') |
|
| 2042 | + public function countOverallMarineTypes($filters = array(), $year = '', $month = '') |
|
| 2043 | 2043 | { |
| 2044 | 2044 | global $globalDBdriver; |
| 2045 | - $queryi = "SELECT COUNT(DISTINCT marine_output.type) AS marine_count FROM marine_output"; |
|
| 2045 | + $queryi = "SELECT COUNT(DISTINCT marine_output.type) AS marine_count FROM marine_output"; |
|
| 2046 | 2046 | $query_values = array(); |
| 2047 | 2047 | $query = ''; |
| 2048 | 2048 | if ($year != '') { |
| 2049 | 2049 | if ($globalDBdriver == 'mysql') { |
| 2050 | 2050 | $query .= " AND YEAR(marine_output.date) = :year"; |
| 2051 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 2051 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 2052 | 2052 | } else { |
| 2053 | 2053 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
| 2054 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 2054 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 2055 | 2055 | } |
| 2056 | 2056 | } |
| 2057 | 2057 | if ($month != '') { |
| 2058 | 2058 | if ($globalDBdriver == 'mysql') { |
| 2059 | 2059 | $query .= " AND MONTH(marine_output.date) = :month"; |
| 2060 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 2060 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 2061 | 2061 | } else { |
| 2062 | 2062 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
| 2063 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 2063 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 2064 | 2064 | } |
| 2065 | 2065 | } |
| 2066 | 2066 | if (empty($query_values)) $queryi .= $this->getFilter($filters); |
| 2067 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 2067 | + else $queryi .= $this->getFilter($filters, true, true).substr($query, 4); |
|
| 2068 | 2068 | |
| 2069 | 2069 | $sth = $this->db->prepare($queryi); |
| 2070 | 2070 | $sth->execute($query_values); |
@@ -2079,32 +2079,32 @@ discard block |
||
| 2079 | 2079 | * @param string $month |
| 2080 | 2080 | * @return Integer number of races |
| 2081 | 2081 | */ |
| 2082 | - public function countOverallMarineRaces($filters = array(),$year = '',$month = '') |
|
| 2082 | + public function countOverallMarineRaces($filters = array(), $year = '', $month = '') |
|
| 2083 | 2083 | { |
| 2084 | 2084 | global $globalDBdriver; |
| 2085 | - $queryi = "SELECT COUNT(DISTINCT marine_output.race_id) AS marine_count FROM marine_output"; |
|
| 2085 | + $queryi = "SELECT COUNT(DISTINCT marine_output.race_id) AS marine_count FROM marine_output"; |
|
| 2086 | 2086 | $query_values = array(); |
| 2087 | 2087 | $query = ''; |
| 2088 | 2088 | if ($year != '') { |
| 2089 | 2089 | if ($globalDBdriver == 'mysql') { |
| 2090 | 2090 | $query .= " AND YEAR(marine_output.date) = :year"; |
| 2091 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 2091 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 2092 | 2092 | } else { |
| 2093 | 2093 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
| 2094 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 2094 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 2095 | 2095 | } |
| 2096 | 2096 | } |
| 2097 | 2097 | if ($month != '') { |
| 2098 | 2098 | if ($globalDBdriver == 'mysql') { |
| 2099 | 2099 | $query .= " AND MONTH(marine_output.date) = :month"; |
| 2100 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 2100 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 2101 | 2101 | } else { |
| 2102 | 2102 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
| 2103 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 2103 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 2104 | 2104 | } |
| 2105 | 2105 | } |
| 2106 | 2106 | if (empty($query_values)) $queryi .= $this->getFilter($filters); |
| 2107 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 2107 | + else $queryi .= $this->getFilter($filters, true, true).substr($query, 4); |
|
| 2108 | 2108 | |
| 2109 | 2109 | $sth = $this->db->prepare($queryi); |
| 2110 | 2110 | $sth->execute($query_values); |
@@ -2119,32 +2119,32 @@ discard block |
||
| 2119 | 2119 | * @param string $month |
| 2120 | 2120 | * @return Integer number of captain |
| 2121 | 2121 | */ |
| 2122 | - public function countOverallMarineCaptains($filters = array(),$year = '',$month = '') |
|
| 2122 | + public function countOverallMarineCaptains($filters = array(), $year = '', $month = '') |
|
| 2123 | 2123 | { |
| 2124 | 2124 | global $globalDBdriver; |
| 2125 | - $queryi = "SELECT COUNT(DISTINCT marine_output.captain_id) AS marine_count FROM marine_output"; |
|
| 2125 | + $queryi = "SELECT COUNT(DISTINCT marine_output.captain_id) AS marine_count FROM marine_output"; |
|
| 2126 | 2126 | $query_values = array(); |
| 2127 | 2127 | $query = ''; |
| 2128 | 2128 | if ($year != '') { |
| 2129 | 2129 | if ($globalDBdriver == 'mysql') { |
| 2130 | 2130 | $query .= " AND YEAR(marine_output.date) = :year"; |
| 2131 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 2131 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 2132 | 2132 | } else { |
| 2133 | 2133 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
| 2134 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 2134 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 2135 | 2135 | } |
| 2136 | 2136 | } |
| 2137 | 2137 | if ($month != '') { |
| 2138 | 2138 | if ($globalDBdriver == 'mysql') { |
| 2139 | 2139 | $query .= " AND MONTH(marine_output.date) = :month"; |
| 2140 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 2140 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 2141 | 2141 | } else { |
| 2142 | 2142 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
| 2143 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 2143 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 2144 | 2144 | } |
| 2145 | 2145 | } |
| 2146 | 2146 | if (empty($query_values)) $queryi .= $this->getFilter($filters); |
| 2147 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 2147 | + else $queryi .= $this->getFilter($filters, true, true).substr($query, 4); |
|
| 2148 | 2148 | |
| 2149 | 2149 | $sth = $this->db->prepare($queryi); |
| 2150 | 2150 | $sth->execute($query_values); |
@@ -2160,7 +2160,7 @@ discard block |
||
| 2160 | 2160 | public function countAllHoursFromToday($filters = array()) |
| 2161 | 2161 | { |
| 2162 | 2162 | global $globalTimezone, $globalDBdriver; |
| 2163 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 2163 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 2164 | 2164 | if ($globalTimezone != '') { |
| 2165 | 2165 | date_default_timezone_set($globalTimezone); |
| 2166 | 2166 | $datetime = new DateTime(); |
@@ -2168,12 +2168,12 @@ discard block |
||
| 2168 | 2168 | } else $offset = '+00:00'; |
| 2169 | 2169 | |
| 2170 | 2170 | if ($globalDBdriver == 'mysql') { |
| 2171 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 2171 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 2172 | 2172 | FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = CURDATE() |
| 2173 | 2173 | GROUP BY hour_name |
| 2174 | 2174 | ORDER BY hour_name ASC"; |
| 2175 | 2175 | } else { |
| 2176 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 2176 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 2177 | 2177 | FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = CAST(NOW() AS date) |
| 2178 | 2178 | GROUP BY hour_name |
| 2179 | 2179 | ORDER BY hour_name ASC"; |
@@ -2185,7 +2185,7 @@ discard block |
||
| 2185 | 2185 | $hour_array = array(); |
| 2186 | 2186 | $temp_array = array(); |
| 2187 | 2187 | |
| 2188 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 2188 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 2189 | 2189 | { |
| 2190 | 2190 | $temp_array['hour_name'] = $row['hour_name']; |
| 2191 | 2191 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -2204,9 +2204,9 @@ discard block |
||
| 2204 | 2204 | */ |
| 2205 | 2205 | public function getMarineIDBasedOnFamMarineID($fammarine_id) |
| 2206 | 2206 | { |
| 2207 | - $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
|
| 2207 | + $fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING); |
|
| 2208 | 2208 | |
| 2209 | - $query = "SELECT marine_output.marine_id |
|
| 2209 | + $query = "SELECT marine_output.marine_id |
|
| 2210 | 2210 | FROM marine_output |
| 2211 | 2211 | WHERE marine_output.fammarine_id = '".$fammarine_id."'"; |
| 2212 | 2212 | |
@@ -2214,7 +2214,7 @@ discard block |
||
| 2214 | 2214 | $sth = $this->db->prepare($query); |
| 2215 | 2215 | $sth->execute(); |
| 2216 | 2216 | |
| 2217 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 2217 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 2218 | 2218 | { |
| 2219 | 2219 | return $row['marine_id']; |
| 2220 | 2220 | } |
@@ -2239,23 +2239,23 @@ discard block |
||
| 2239 | 2239 | } |
| 2240 | 2240 | |
| 2241 | 2241 | $current_date = date("Y-m-d H:i:s"); |
| 2242 | - $date = date("Y-m-d H:i:s",strtotime($dateString." UTC")); |
|
| 2242 | + $date = date("Y-m-d H:i:s", strtotime($dateString." UTC")); |
|
| 2243 | 2243 | |
| 2244 | 2244 | $diff = abs(strtotime($current_date) - strtotime($date)); |
| 2245 | 2245 | |
| 2246 | - $time_array['years'] = floor($diff / (365*60*60*24)); |
|
| 2246 | + $time_array['years'] = floor($diff/(365*60*60*24)); |
|
| 2247 | 2247 | $years = $time_array['years']; |
| 2248 | 2248 | |
| 2249 | - $time_array['months'] = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); |
|
| 2249 | + $time_array['months'] = floor(($diff - $years*365*60*60*24)/(30*60*60*24)); |
|
| 2250 | 2250 | $months = $time_array['months']; |
| 2251 | 2251 | |
| 2252 | - $time_array['days'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); |
|
| 2252 | + $time_array['days'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24)/(60*60*24)); |
|
| 2253 | 2253 | $days = $time_array['days']; |
| 2254 | - $time_array['hours'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60)); |
|
| 2254 | + $time_array['hours'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/(60*60)); |
|
| 2255 | 2255 | $hours = $time_array['hours']; |
| 2256 | - $time_array['minutes'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/ 60); |
|
| 2256 | + $time_array['minutes'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/60); |
|
| 2257 | 2257 | $minutes = $time_array['minutes']; |
| 2258 | - $time_array['seconds'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60)); |
|
| 2258 | + $time_array['seconds'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60)); |
|
| 2259 | 2259 | |
| 2260 | 2260 | return $time_array; |
| 2261 | 2261 | } |
@@ -2278,63 +2278,63 @@ discard block |
||
| 2278 | 2278 | $temp_array['direction_degree'] = $direction; |
| 2279 | 2279 | $temp_array['direction_shortname'] = "N"; |
| 2280 | 2280 | $temp_array['direction_fullname'] = "North"; |
| 2281 | - } elseif ($direction >= 22.5 && $direction < 45){ |
|
| 2281 | + } elseif ($direction >= 22.5 && $direction < 45) { |
|
| 2282 | 2282 | $temp_array['direction_degree'] = $direction; |
| 2283 | 2283 | $temp_array['direction_shortname'] = "NNE"; |
| 2284 | 2284 | $temp_array['direction_fullname'] = "North-Northeast"; |
| 2285 | - } elseif ($direction >= 45 && $direction < 67.5){ |
|
| 2285 | + } elseif ($direction >= 45 && $direction < 67.5) { |
|
| 2286 | 2286 | $temp_array['direction_degree'] = $direction; |
| 2287 | 2287 | $temp_array['direction_shortname'] = "NE"; |
| 2288 | 2288 | $temp_array['direction_fullname'] = "Northeast"; |
| 2289 | - } elseif ($direction >= 67.5 && $direction < 90){ |
|
| 2289 | + } elseif ($direction >= 67.5 && $direction < 90) { |
|
| 2290 | 2290 | $temp_array['direction_degree'] = $direction; |
| 2291 | 2291 | $temp_array['direction_shortname'] = "ENE"; |
| 2292 | 2292 | $temp_array['direction_fullname'] = "East-Northeast"; |
| 2293 | - } elseif ($direction >= 90 && $direction < 112.5){ |
|
| 2293 | + } elseif ($direction >= 90 && $direction < 112.5) { |
|
| 2294 | 2294 | $temp_array['direction_degree'] = $direction; |
| 2295 | 2295 | $temp_array['direction_shortname'] = "E"; |
| 2296 | 2296 | $temp_array['direction_fullname'] = "East"; |
| 2297 | - } elseif ($direction >= 112.5 && $direction < 135){ |
|
| 2297 | + } elseif ($direction >= 112.5 && $direction < 135) { |
|
| 2298 | 2298 | $temp_array['direction_degree'] = $direction; |
| 2299 | 2299 | $temp_array['direction_shortname'] = "ESE"; |
| 2300 | 2300 | $temp_array['direction_fullname'] = "East-Southeast"; |
| 2301 | - } elseif ($direction >= 135 && $direction < 157.5){ |
|
| 2301 | + } elseif ($direction >= 135 && $direction < 157.5) { |
|
| 2302 | 2302 | $temp_array['direction_degree'] = $direction; |
| 2303 | 2303 | $temp_array['direction_shortname'] = "SE"; |
| 2304 | 2304 | $temp_array['direction_fullname'] = "Southeast"; |
| 2305 | - } elseif ($direction >= 157.5 && $direction < 180){ |
|
| 2305 | + } elseif ($direction >= 157.5 && $direction < 180) { |
|
| 2306 | 2306 | $temp_array['direction_degree'] = $direction; |
| 2307 | 2307 | $temp_array['direction_shortname'] = "SSE"; |
| 2308 | 2308 | $temp_array['direction_fullname'] = "South-Southeast"; |
| 2309 | - } elseif ($direction >= 180 && $direction < 202.5){ |
|
| 2309 | + } elseif ($direction >= 180 && $direction < 202.5) { |
|
| 2310 | 2310 | $temp_array['direction_degree'] = $direction; |
| 2311 | 2311 | $temp_array['direction_shortname'] = "S"; |
| 2312 | 2312 | $temp_array['direction_fullname'] = "South"; |
| 2313 | - } elseif ($direction >= 202.5 && $direction < 225){ |
|
| 2313 | + } elseif ($direction >= 202.5 && $direction < 225) { |
|
| 2314 | 2314 | $temp_array['direction_degree'] = $direction; |
| 2315 | 2315 | $temp_array['direction_shortname'] = "SSW"; |
| 2316 | 2316 | $temp_array['direction_fullname'] = "South-Southwest"; |
| 2317 | - } elseif ($direction >= 225 && $direction < 247.5){ |
|
| 2317 | + } elseif ($direction >= 225 && $direction < 247.5) { |
|
| 2318 | 2318 | $temp_array['direction_degree'] = $direction; |
| 2319 | 2319 | $temp_array['direction_shortname'] = "SW"; |
| 2320 | 2320 | $temp_array['direction_fullname'] = "Southwest"; |
| 2321 | - } elseif ($direction >= 247.5 && $direction < 270){ |
|
| 2321 | + } elseif ($direction >= 247.5 && $direction < 270) { |
|
| 2322 | 2322 | $temp_array['direction_degree'] = $direction; |
| 2323 | 2323 | $temp_array['direction_shortname'] = "WSW"; |
| 2324 | 2324 | $temp_array['direction_fullname'] = "West-Southwest"; |
| 2325 | - } elseif ($direction >= 270 && $direction < 292.5){ |
|
| 2325 | + } elseif ($direction >= 270 && $direction < 292.5) { |
|
| 2326 | 2326 | $temp_array['direction_degree'] = $direction; |
| 2327 | 2327 | $temp_array['direction_shortname'] = "W"; |
| 2328 | 2328 | $temp_array['direction_fullname'] = "West"; |
| 2329 | - } elseif ($direction >= 292.5 && $direction < 315){ |
|
| 2329 | + } elseif ($direction >= 292.5 && $direction < 315) { |
|
| 2330 | 2330 | $temp_array['direction_degree'] = $direction; |
| 2331 | 2331 | $temp_array['direction_shortname'] = "WNW"; |
| 2332 | 2332 | $temp_array['direction_fullname'] = "West-Northwest"; |
| 2333 | - } elseif ($direction >= 315 && $direction < 337.5){ |
|
| 2333 | + } elseif ($direction >= 315 && $direction < 337.5) { |
|
| 2334 | 2334 | $temp_array['direction_degree'] = $direction; |
| 2335 | 2335 | $temp_array['direction_shortname'] = "NW"; |
| 2336 | 2336 | $temp_array['direction_fullname'] = "Northwest"; |
| 2337 | - } elseif ($direction >= 337.5 && $direction < 360){ |
|
| 2337 | + } elseif ($direction >= 337.5 && $direction < 360) { |
|
| 2338 | 2338 | $temp_array['direction_degree'] = $direction; |
| 2339 | 2339 | $temp_array['direction_shortname'] = "NNW"; |
| 2340 | 2340 | $temp_array['direction_fullname'] = "North-Northwest"; |
@@ -2351,11 +2351,11 @@ discard block |
||
| 2351 | 2351 | * @param Float $longitude longitute of the flight |
| 2352 | 2352 | * @return String the countries |
| 2353 | 2353 | */ |
| 2354 | - public function getCountryFromLatitudeLongitude($latitude,$longitude) |
|
| 2354 | + public function getCountryFromLatitudeLongitude($latitude, $longitude) |
|
| 2355 | 2355 | { |
| 2356 | 2356 | global $globalDBdriver, $globalDebug; |
| 2357 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 2358 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 2357 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 2358 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 2359 | 2359 | |
| 2360 | 2360 | $Connection = new Connection($this->db); |
| 2361 | 2361 | if (!$Connection->tableExists('countries')) return ''; |
@@ -2395,7 +2395,7 @@ discard block |
||
| 2395 | 2395 | public function getCountryFromISO2($iso2) |
| 2396 | 2396 | { |
| 2397 | 2397 | global $globalDBdriver, $globalDebug; |
| 2398 | - $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); |
|
| 2398 | + $iso2 = filter_var($iso2, FILTER_SANITIZE_STRING); |
|
| 2399 | 2399 | |
| 2400 | 2400 | $Connection = new Connection($this->db); |
| 2401 | 2401 | if (!$Connection->tableExists('countries')) return ''; |
@@ -2443,7 +2443,7 @@ discard block |
||
| 2443 | 2443 | |
| 2444 | 2444 | $bitly_data = json_decode($bitly_data); |
| 2445 | 2445 | $bitly_url = ''; |
| 2446 | - if ($bitly_data->status_txt = "OK"){ |
|
| 2446 | + if ($bitly_data->status_txt = "OK") { |
|
| 2447 | 2447 | $bitly_url = $bitly_data->data->url; |
| 2448 | 2448 | } |
| 2449 | 2449 | |
@@ -2463,11 +2463,11 @@ discard block |
||
| 2463 | 2463 | * @param string $day |
| 2464 | 2464 | * @return array the vessel type list |
| 2465 | 2465 | */ |
| 2466 | - public function countAllMarineTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '') |
|
| 2466 | + public function countAllMarineTypes($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '') |
|
| 2467 | 2467 | { |
| 2468 | 2468 | global $globalDBdriver; |
| 2469 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 2470 | - $query = "SELECT marine_output.type AS marine_type, COUNT(marine_output.type) AS marine_type_count, marine_output.type_id AS marine_type_id |
|
| 2469 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 2470 | + $query = "SELECT marine_output.type AS marine_type, COUNT(marine_output.type) AS marine_type_count, marine_output.type_id AS marine_type_id |
|
| 2471 | 2471 | FROM marine_output ".$filter_query." marine_output.type <> '' AND marine_output.type_id IS NOT NULL"; |
| 2472 | 2472 | if ($olderthanmonths > 0) { |
| 2473 | 2473 | if ($globalDBdriver == 'mysql') { |
@@ -2487,28 +2487,28 @@ discard block |
||
| 2487 | 2487 | if ($year != '') { |
| 2488 | 2488 | if ($globalDBdriver == 'mysql') { |
| 2489 | 2489 | $query .= " AND YEAR(marine_output.date) = :year"; |
| 2490 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 2490 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 2491 | 2491 | } else { |
| 2492 | 2492 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
| 2493 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 2493 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 2494 | 2494 | } |
| 2495 | 2495 | } |
| 2496 | 2496 | if ($month != '') { |
| 2497 | 2497 | if ($globalDBdriver == 'mysql') { |
| 2498 | 2498 | $query .= " AND MONTH(marine_output.date) = :month"; |
| 2499 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 2499 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 2500 | 2500 | } else { |
| 2501 | 2501 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
| 2502 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 2502 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 2503 | 2503 | } |
| 2504 | 2504 | } |
| 2505 | 2505 | if ($day != '') { |
| 2506 | 2506 | if ($globalDBdriver == 'mysql') { |
| 2507 | 2507 | $query .= " AND DAY(marine_output.date) = :day"; |
| 2508 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 2508 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 2509 | 2509 | } else { |
| 2510 | 2510 | $query .= " AND EXTRACT(DAY FROM marine_output.date) = :day"; |
| 2511 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 2511 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 2512 | 2512 | } |
| 2513 | 2513 | } |
| 2514 | 2514 | $query .= " GROUP BY marine_output.type, marine_output.type_id ORDER BY marine_type_count DESC"; |
@@ -2517,9 +2517,9 @@ discard block |
||
| 2517 | 2517 | $sth->execute($query_values); |
| 2518 | 2518 | $marine_array = array(); |
| 2519 | 2519 | $temp_array = array(); |
| 2520 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 2520 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 2521 | 2521 | { |
| 2522 | - $temp_array['marine_type'] = html_entity_decode($row['marine_type'],ENT_QUOTES); |
|
| 2522 | + $temp_array['marine_type'] = html_entity_decode($row['marine_type'], ENT_QUOTES); |
|
| 2523 | 2523 | $temp_array['marine_type_id'] = $row['marine_type_id']; |
| 2524 | 2524 | $temp_array['marine_type_count'] = $row['marine_type_count']; |
| 2525 | 2525 | $marine_array[] = $temp_array; |
@@ -2548,13 +2548,13 @@ discard block |
||
| 2548 | 2548 | * @param array $filters |
| 2549 | 2549 | * @return array the tracker information |
| 2550 | 2550 | */ |
| 2551 | - public function searchMarineData($q = '', $callsign = '',$mmsi = '', $imo = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '',$captain_id = '',$captain_name = '',$race_id = '',$race_name = '',$filters = array()) |
|
| 2551 | + public function searchMarineData($q = '', $callsign = '', $mmsi = '', $imo = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $captain_id = '', $captain_name = '', $race_id = '', $race_name = '', $filters = array()) |
|
| 2552 | 2552 | { |
| 2553 | 2553 | global $globalTimezone, $globalDBdriver; |
| 2554 | 2554 | date_default_timezone_set('UTC'); |
| 2555 | 2555 | $query_values = array(); |
| 2556 | 2556 | $additional_query = ''; |
| 2557 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 2557 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 2558 | 2558 | if ($q != "") |
| 2559 | 2559 | { |
| 2560 | 2560 | if (!is_string($q)) |
@@ -2562,8 +2562,8 @@ discard block |
||
| 2562 | 2562 | return array(); |
| 2563 | 2563 | } else { |
| 2564 | 2564 | $q_array = explode(" ", $q); |
| 2565 | - foreach ($q_array as $q_item){ |
|
| 2566 | - $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
|
| 2565 | + foreach ($q_array as $q_item) { |
|
| 2566 | + $q_item = filter_var($q_item, FILTER_SANITIZE_STRING); |
|
| 2567 | 2567 | $additional_query .= " AND ("; |
| 2568 | 2568 | if (is_int($q_item)) $additional_query .= "(marine_output.marine_id = '".$q_item."') OR "; |
| 2569 | 2569 | if (is_int($q_item)) $additional_query .= "(marine_output.mmsi = '".$q_item."') OR "; |
@@ -2579,86 +2579,86 @@ discard block |
||
| 2579 | 2579 | } |
| 2580 | 2580 | if ($callsign != "") |
| 2581 | 2581 | { |
| 2582 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 2582 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
| 2583 | 2583 | if (!is_string($callsign)) |
| 2584 | 2584 | { |
| 2585 | 2585 | return array(); |
| 2586 | 2586 | } else { |
| 2587 | 2587 | $additional_query .= " AND marine_output.ident = :callsign"; |
| 2588 | - $query_values = array_merge($query_values,array(':callsign' => $callsign)); |
|
| 2588 | + $query_values = array_merge($query_values, array(':callsign' => $callsign)); |
|
| 2589 | 2589 | } |
| 2590 | 2590 | } |
| 2591 | 2591 | if ($mmsi != "") |
| 2592 | 2592 | { |
| 2593 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
|
| 2593 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); |
|
| 2594 | 2594 | if (!is_numeric($mmsi)) |
| 2595 | 2595 | { |
| 2596 | 2596 | return array(); |
| 2597 | 2597 | } else { |
| 2598 | 2598 | $additional_query .= " AND marine_output.mmsi = :mmsi"; |
| 2599 | - $query_values = array_merge($query_values,array(':mmsi' => $mmsi)); |
|
| 2599 | + $query_values = array_merge($query_values, array(':mmsi' => $mmsi)); |
|
| 2600 | 2600 | } |
| 2601 | 2601 | } |
| 2602 | 2602 | if ($imo != "") |
| 2603 | 2603 | { |
| 2604 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
| 2604 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
| 2605 | 2605 | if (!is_numeric($imo)) |
| 2606 | 2606 | { |
| 2607 | 2607 | return array(); |
| 2608 | 2608 | } else { |
| 2609 | 2609 | $additional_query .= " AND marine_output.imo = :imo"; |
| 2610 | - $query_values = array_merge($query_values,array(':imo' => $imo)); |
|
| 2610 | + $query_values = array_merge($query_values, array(':imo' => $imo)); |
|
| 2611 | 2611 | } |
| 2612 | 2612 | } |
| 2613 | 2613 | if ($captain_id != "") |
| 2614 | 2614 | { |
| 2615 | - $captain_id = filter_var($captain_id,FILTER_SANITIZE_STRING); |
|
| 2615 | + $captain_id = filter_var($captain_id, FILTER_SANITIZE_STRING); |
|
| 2616 | 2616 | if (!is_numeric($captain_id)) |
| 2617 | 2617 | { |
| 2618 | 2618 | return array(); |
| 2619 | 2619 | } else { |
| 2620 | 2620 | $additional_query .= " AND marine_output.captain_id = :captain_id"; |
| 2621 | - $query_values = array_merge($query_values,array(':captain_id' => $captain_id)); |
|
| 2621 | + $query_values = array_merge($query_values, array(':captain_id' => $captain_id)); |
|
| 2622 | 2622 | } |
| 2623 | 2623 | } |
| 2624 | 2624 | if ($race_id != "") |
| 2625 | 2625 | { |
| 2626 | - $race_id = filter_var($race_id,FILTER_SANITIZE_STRING); |
|
| 2626 | + $race_id = filter_var($race_id, FILTER_SANITIZE_STRING); |
|
| 2627 | 2627 | if (!is_numeric($race_id)) |
| 2628 | 2628 | { |
| 2629 | 2629 | return array(); |
| 2630 | 2630 | } else { |
| 2631 | 2631 | $additional_query .= " AND marine_output.race_id = :race_id"; |
| 2632 | - $query_values = array_merge($query_values,array(':race_id' => $race_id)); |
|
| 2632 | + $query_values = array_merge($query_values, array(':race_id' => $race_id)); |
|
| 2633 | 2633 | } |
| 2634 | 2634 | } |
| 2635 | 2635 | if ($captain_name != "") |
| 2636 | 2636 | { |
| 2637 | - $captain_name = filter_var($captain_name,FILTER_SANITIZE_STRING); |
|
| 2637 | + $captain_name = filter_var($captain_name, FILTER_SANITIZE_STRING); |
|
| 2638 | 2638 | if (!is_string($captain_name)) |
| 2639 | 2639 | { |
| 2640 | 2640 | return array(); |
| 2641 | 2641 | } else { |
| 2642 | 2642 | $additional_query .= " AND marine_output.captain_name = :captain_name"; |
| 2643 | - $query_values = array_merge($query_values,array(':captain_name' => $captain_name)); |
|
| 2643 | + $query_values = array_merge($query_values, array(':captain_name' => $captain_name)); |
|
| 2644 | 2644 | } |
| 2645 | 2645 | } |
| 2646 | 2646 | if ($race_name != "") |
| 2647 | 2647 | { |
| 2648 | - $race_name = filter_var($race_name,FILTER_SANITIZE_STRING); |
|
| 2648 | + $race_name = filter_var($race_name, FILTER_SANITIZE_STRING); |
|
| 2649 | 2649 | if (!is_numeric($race_name)) |
| 2650 | 2650 | { |
| 2651 | 2651 | return array(); |
| 2652 | 2652 | } else { |
| 2653 | 2653 | $additional_query .= " AND marine_output.race_name = :race_name"; |
| 2654 | - $query_values = array_merge($query_values,array(':race_name' => $race_name)); |
|
| 2654 | + $query_values = array_merge($query_values, array(':race_name' => $race_name)); |
|
| 2655 | 2655 | } |
| 2656 | 2656 | } |
| 2657 | 2657 | if ($date_posted != "") |
| 2658 | 2658 | { |
| 2659 | 2659 | $date_array = explode(",", $date_posted); |
| 2660 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
| 2661 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
| 2660 | + $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING); |
|
| 2661 | + $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING); |
|
| 2662 | 2662 | if ($globalTimezone != '') { |
| 2663 | 2663 | date_default_timezone_set($globalTimezone); |
| 2664 | 2664 | $datetime = new DateTime(); |
@@ -2685,8 +2685,8 @@ discard block |
||
| 2685 | 2685 | if ($limit != "") |
| 2686 | 2686 | { |
| 2687 | 2687 | $limit_array = explode(",", $limit); |
| 2688 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 2689 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 2688 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 2689 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 2690 | 2690 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 2691 | 2691 | { |
| 2692 | 2692 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
@@ -2704,22 +2704,22 @@ discard block |
||
| 2704 | 2704 | } |
| 2705 | 2705 | } |
| 2706 | 2706 | if ($origLat != "" && $origLon != "" && $dist != "") { |
| 2707 | - $dist = number_format($dist*0.621371,2,'.',''); // convert km to mile |
|
| 2707 | + $dist = number_format($dist*0.621371, 2, '.', ''); // convert km to mile |
|
| 2708 | 2708 | if ($globalDBdriver == 'mysql') { |
| 2709 | - $query="SELECT marine_output.*, 1.60935*3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - marine_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(marine_archive.latitude*pi()/180)*POWER(SIN(($origLon-marine_archive.longitude)*pi()/180/2),2))) as distance |
|
| 2709 | + $query = "SELECT marine_output.*, 1.60935*3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - marine_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(marine_archive.latitude*pi()/180)*POWER(SIN(($origLon-marine_archive.longitude)*pi()/180/2),2))) as distance |
|
| 2710 | 2710 | FROM marine_archive,marine_output".$filter_query." marine_output.fammarine_id = marine_archive.fammarine_id AND marine_output.ident <> '' ".$additional_query."AND marine_archive.longitude between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat)*69)) and marine_archive.latitude between ($origLat-($dist/69)) and ($origLat+($dist/69)) |
| 2711 | 2711 | AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - marine_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(marine_archive.latitude*pi()/180)*POWER(SIN(($origLon-marine_archive.longitude)*pi()/180/2),2)))) < $dist".$orderby_query; |
| 2712 | 2712 | } else { |
| 2713 | - $query="SELECT marine_output.*, 1.60935 * 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(marine_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(marine_archive.latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
| 2713 | + $query = "SELECT marine_output.*, 1.60935 * 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(marine_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(marine_archive.latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
| 2714 | 2714 | FROM marine_archive,marine_output".$filter_query." marine_output.fammarine_id = marine_archive.fammarine_id AND marine_output.ident <> '' ".$additional_query."AND CAST(marine_archive.longitude as double precision) between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat))*69) and CAST(marine_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) |
| 2715 | 2715 | AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(marine_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(marine_archive.latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query.$orderby_query; |
| 2716 | 2716 | } |
| 2717 | 2717 | } else { |
| 2718 | - $query = "SELECT marine_output.* FROM marine_output".$filter_query." marine_output.ident <> '' |
|
| 2718 | + $query = "SELECT marine_output.* FROM marine_output".$filter_query." marine_output.ident <> '' |
|
| 2719 | 2719 | ".$additional_query." |
| 2720 | 2720 | ".$orderby_query; |
| 2721 | 2721 | } |
| 2722 | - $marine_array = $this->getDataFromDB($query, $query_values,$limit_query); |
|
| 2722 | + $marine_array = $this->getDataFromDB($query, $query_values, $limit_query); |
|
| 2723 | 2723 | return $marine_array; |
| 2724 | 2724 | } |
| 2725 | 2725 | |
@@ -2732,12 +2732,12 @@ discard block |
||
| 2732 | 2732 | public function checkId($id) |
| 2733 | 2733 | { |
| 2734 | 2734 | global $globalDBdriver, $globalTimezone; |
| 2735 | - $query = 'SELECT marine_output.ident, marine_output.fammarine_id FROM marine_output WHERE marine_output.fammarine_id = :id'; |
|
| 2735 | + $query = 'SELECT marine_output.ident, marine_output.fammarine_id FROM marine_output WHERE marine_output.fammarine_id = :id'; |
|
| 2736 | 2736 | $query_data = array(':id' => $id); |
| 2737 | 2737 | $sth = $this->db->prepare($query); |
| 2738 | 2738 | $sth->execute($query_data); |
| 2739 | - $ident_result=''; |
|
| 2740 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 2739 | + $ident_result = ''; |
|
| 2740 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 2741 | 2741 | { |
| 2742 | 2742 | $ident_result = $row['fammarine_id']; |
| 2743 | 2743 | } |
@@ -2752,7 +2752,7 @@ discard block |
||
| 2752 | 2752 | */ |
| 2753 | 2753 | public function getRaceByName($race_name) |
| 2754 | 2754 | { |
| 2755 | - $race_name = filter_var($race_name,FILTER_SANITIZE_STRING); |
|
| 2755 | + $race_name = filter_var($race_name, FILTER_SANITIZE_STRING); |
|
| 2756 | 2756 | $query = "SELECT * FROM marine_race WHERE race_name = :race_name LIMIT 1"; |
| 2757 | 2757 | $sth = $this->db->prepare($query); |
| 2758 | 2758 | $sth->execute(array(':race_name' => $race_name)); |
@@ -2769,7 +2769,7 @@ discard block |
||
| 2769 | 2769 | */ |
| 2770 | 2770 | public function getRace($race_id) |
| 2771 | 2771 | { |
| 2772 | - $race_id = filter_var($race_id,FILTER_SANITIZE_NUMBER_INT); |
|
| 2772 | + $race_id = filter_var($race_id, FILTER_SANITIZE_NUMBER_INT); |
|
| 2773 | 2773 | $query = "SELECT * FROM marine_race WHERE race_id = :race_id LIMIT 1"; |
| 2774 | 2774 | $sth = $this->db->prepare($query); |
| 2775 | 2775 | $sth->execute(array(':race_id' => $race_id)); |
@@ -2787,24 +2787,24 @@ discard block |
||
| 2787 | 2787 | * @param $race_startdate |
| 2788 | 2788 | * @param $race_markers |
| 2789 | 2789 | */ |
| 2790 | - public function addRace($race_id,$race_name,$race_creator,$race_desc,$race_startdate,$race_markers) |
|
| 2790 | + public function addRace($race_id, $race_name, $race_creator, $race_desc, $race_startdate, $race_markers) |
|
| 2791 | 2791 | { |
| 2792 | - $race_id = filter_var($race_id,FILTER_SANITIZE_NUMBER_INT); |
|
| 2792 | + $race_id = filter_var($race_id, FILTER_SANITIZE_NUMBER_INT); |
|
| 2793 | 2793 | if ($race_id != '') { |
| 2794 | - $race_name = filter_var($race_name,FILTER_SANITIZE_STRING); |
|
| 2795 | - $race_creator = filter_var($race_creator,FILTER_SANITIZE_STRING); |
|
| 2796 | - $race_desc = filter_var($race_desc,FILTER_SANITIZE_STRING); |
|
| 2797 | - $race_startdate = filter_var($race_startdate,FILTER_SANITIZE_STRING); |
|
| 2794 | + $race_name = filter_var($race_name, FILTER_SANITIZE_STRING); |
|
| 2795 | + $race_creator = filter_var($race_creator, FILTER_SANITIZE_STRING); |
|
| 2796 | + $race_desc = filter_var($race_desc, FILTER_SANITIZE_STRING); |
|
| 2797 | + $race_startdate = filter_var($race_startdate, FILTER_SANITIZE_STRING); |
|
| 2798 | 2798 | //$race_markers = filter_var($race_markers,FILTER_SANITIZE_STRING); |
| 2799 | 2799 | $allrace = $this->getRace($race_id); |
| 2800 | 2800 | if (empty($allrace)) { |
| 2801 | 2801 | $query = "INSERT INTO marine_race (race_id,race_name,race_creator,race_desc,race_startdate,race_markers) VALUES (:race_id,:race_name,:race_creator,:race_desc,:race_startdate,:race_markers)"; |
| 2802 | 2802 | $sth = $this->db->prepare($query); |
| 2803 | - $sth->execute(array(':race_id' => $race_id,':race_name' => $race_name,':race_creator' => $race_creator,':race_desc' => $race_desc,':race_startdate' => $race_startdate,':race_markers' => $race_markers)); |
|
| 2803 | + $sth->execute(array(':race_id' => $race_id, ':race_name' => $race_name, ':race_creator' => $race_creator, ':race_desc' => $race_desc, ':race_startdate' => $race_startdate, ':race_markers' => $race_markers)); |
|
| 2804 | 2804 | } elseif ($race_id != '') { |
| 2805 | - $query = "UPDATE marine_race SET race_name = :race_name,race_desc = :race_desc,race_startdate = :race_startdate,race_markers = :race_markers WHERE race_id = :race_id"; |
|
| 2805 | + $query = "UPDATE marine_race SET race_name = :race_name,race_desc = :race_desc,race_startdate = :race_startdate,race_markers = :race_markers WHERE race_id = :race_id"; |
|
| 2806 | 2806 | $sth = $this->db->prepare($query); |
| 2807 | - $sth->execute(array(':race_id' => $race_id,':race_name' => $race_name,':race_desc' => $race_desc,':race_startdate' => $race_startdate,':race_markers' => $race_markers)); |
|
| 2807 | + $sth->execute(array(':race_id' => $race_id, ':race_name' => $race_name, ':race_desc' => $race_desc, ':race_startdate' => $race_startdate, ':race_markers' => $race_markers)); |
|
| 2808 | 2808 | } |
| 2809 | 2809 | } |
| 2810 | 2810 | } |
@@ -2813,7 +2813,7 @@ discard block |
||
| 2813 | 2813 | |
| 2814 | 2814 | public function getOrderBy() |
| 2815 | 2815 | { |
| 2816 | - $orderby = array("type_asc" => array("key" => "type_asc", "value" => "Type - ASC", "sql" => "ORDER BY marine_output.type ASC"), "type_desc" => array("key" => "type_desc", "value" => "Type - DESC", "sql" => "ORDER BY marine_output.type DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_output.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure port - ASC", "sql" => "ORDER BY marine_output.departure_port_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_output.date DESC"),"distance_asc" => array("key" => "distance_asc","value" => "Distance - ASC","sql" => "ORDER BY distance ASC"),"distance_desc" => array("key" => "distance_desc","value" => "Distance - DESC","sql" => "ORDER BY distance DESC")); |
|
| 2816 | + $orderby = array("type_asc" => array("key" => "type_asc", "value" => "Type - ASC", "sql" => "ORDER BY marine_output.type ASC"), "type_desc" => array("key" => "type_desc", "value" => "Type - DESC", "sql" => "ORDER BY marine_output.type DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_output.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure port - ASC", "sql" => "ORDER BY marine_output.departure_port_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_output.date DESC"), "distance_asc" => array("key" => "distance_asc", "value" => "Distance - ASC", "sql" => "ORDER BY distance ASC"), "distance_desc" => array("key" => "distance_desc", "value" => "Distance - DESC", "sql" => "ORDER BY distance DESC")); |
|
| 2817 | 2817 | return $orderby; |
| 2818 | 2818 | } |
| 2819 | 2819 | |
@@ -15,7 +15,9 @@ discard block |
||
| 15 | 15 | public function __construct($dbc = null) { |
| 16 | 16 | $Connection = new Connection($dbc); |
| 17 | 17 | $this->db = $Connection->db(); |
| 18 | - if ($this->db === null) die('Error: No DB connection. (Marine)'); |
|
| 18 | + if ($this->db === null) { |
|
| 19 | + die('Error: No DB connection. (Marine)'); |
|
| 20 | + } |
|
| 19 | 21 | } |
| 20 | 22 | |
| 21 | 23 | /** |
@@ -38,7 +40,9 @@ discard block |
||
| 38 | 40 | if (isset($filter[0]['source'])) { |
| 39 | 41 | $filters = array_merge($filters,$filter); |
| 40 | 42 | } |
| 41 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 43 | + if (is_array($globalFilter)) { |
|
| 44 | + $filter = array_merge($filter,$globalFilter); |
|
| 45 | + } |
|
| 42 | 46 | $filter_query_join = ''; |
| 43 | 47 | $filter_query_where = ''; |
| 44 | 48 | foreach($filters as $flt) { |
@@ -86,8 +90,11 @@ discard block |
||
| 86 | 90 | $filter_query_where .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'"; |
| 87 | 91 | } |
| 88 | 92 | } |
| 89 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
| 90 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
| 93 | + if ($filter_query_where == '' && $where) { |
|
| 94 | + $filter_query_where = ' WHERE'; |
|
| 95 | + } elseif ($filter_query_where != '' && $and) { |
|
| 96 | + $filter_query_where .= ' AND'; |
|
| 97 | + } |
|
| 91 | 98 | if ($filter_query_where != '') { |
| 92 | 99 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
| 93 | 100 | } |
@@ -142,42 +149,84 @@ discard block |
||
| 142 | 149 | $temp_array['spotter_id'] = $row['spotter_archive_id']; |
| 143 | 150 | } elseif (isset($row['spotter_archive_output_id'])) { |
| 144 | 151 | $temp_array['spotter_id'] = $row['spotter_archive_output_id']; |
| 145 | - */} |
|
| 146 | - elseif (isset($row['marineid'])) { |
|
| 152 | + */} elseif (isset($row['marineid'])) { |
|
| 147 | 153 | $temp_array['marine_id'] = $row['marineid']; |
| 148 | 154 | } else { |
| 149 | 155 | $temp_array['marine_id'] = ''; |
| 150 | 156 | } |
| 151 | - if (isset($row['fammarine_id'])) $temp_array['fammarine_id'] = $row['fammarine_id']; |
|
| 152 | - if (isset($row['mmsi'])) $temp_array['mmsi'] = $row['mmsi']; |
|
| 153 | - if (isset($row['type'])) $temp_array['type'] = html_entity_decode($row['type'],ENT_QUOTES); |
|
| 154 | - if (isset($row['type_id'])) $temp_array['type_id'] = $row['type_id']; |
|
| 155 | - if (isset($row['status'])) $temp_array['status'] = $row['status']; |
|
| 156 | - if (isset($row['status_id'])) $temp_array['status_id'] = $row['status_id']; |
|
| 157 | - if (isset($row['captain_id'])) $temp_array['captain_id'] = $row['captain_id']; |
|
| 158 | - if (isset($row['captain_name'])) $temp_array['captain_name'] = $row['captain_name']; |
|
| 159 | - if (isset($row['race_id'])) $temp_array['race_id'] = $row['race_id']; |
|
| 160 | - if (isset($row['race_name'])) $temp_array['race_name'] = $row['race_name']; |
|
| 161 | - if (isset($row['race_time']) && isset($row['status']) && $row['status'] != 'Racing' && $row['race_time'] > 0) $temp_array['race_time'] = $row['race_time']; |
|
| 162 | - if (isset($row['race_rank'])) $temp_array['race_rank'] = $row['race_rank']; |
|
| 163 | - if (isset($row['ident'])) $temp_array['ident'] = $row['ident']; |
|
| 164 | - if (isset($row['arrival_port_name'])) $temp_array['arrival_port_name'] = $row['arrival_port_name']; |
|
| 165 | - if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude']; |
|
| 166 | - if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude']; |
|
| 167 | - if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance']; |
|
| 168 | - if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source']; |
|
| 157 | + if (isset($row['fammarine_id'])) { |
|
| 158 | + $temp_array['fammarine_id'] = $row['fammarine_id']; |
|
| 159 | + } |
|
| 160 | + if (isset($row['mmsi'])) { |
|
| 161 | + $temp_array['mmsi'] = $row['mmsi']; |
|
| 162 | + } |
|
| 163 | + if (isset($row['type'])) { |
|
| 164 | + $temp_array['type'] = html_entity_decode($row['type'],ENT_QUOTES); |
|
| 165 | + } |
|
| 166 | + if (isset($row['type_id'])) { |
|
| 167 | + $temp_array['type_id'] = $row['type_id']; |
|
| 168 | + } |
|
| 169 | + if (isset($row['status'])) { |
|
| 170 | + $temp_array['status'] = $row['status']; |
|
| 171 | + } |
|
| 172 | + if (isset($row['status_id'])) { |
|
| 173 | + $temp_array['status_id'] = $row['status_id']; |
|
| 174 | + } |
|
| 175 | + if (isset($row['captain_id'])) { |
|
| 176 | + $temp_array['captain_id'] = $row['captain_id']; |
|
| 177 | + } |
|
| 178 | + if (isset($row['captain_name'])) { |
|
| 179 | + $temp_array['captain_name'] = $row['captain_name']; |
|
| 180 | + } |
|
| 181 | + if (isset($row['race_id'])) { |
|
| 182 | + $temp_array['race_id'] = $row['race_id']; |
|
| 183 | + } |
|
| 184 | + if (isset($row['race_name'])) { |
|
| 185 | + $temp_array['race_name'] = $row['race_name']; |
|
| 186 | + } |
|
| 187 | + if (isset($row['race_time']) && isset($row['status']) && $row['status'] != 'Racing' && $row['race_time'] > 0) { |
|
| 188 | + $temp_array['race_time'] = $row['race_time']; |
|
| 189 | + } |
|
| 190 | + if (isset($row['race_rank'])) { |
|
| 191 | + $temp_array['race_rank'] = $row['race_rank']; |
|
| 192 | + } |
|
| 193 | + if (isset($row['ident'])) { |
|
| 194 | + $temp_array['ident'] = $row['ident']; |
|
| 195 | + } |
|
| 196 | + if (isset($row['arrival_port_name'])) { |
|
| 197 | + $temp_array['arrival_port_name'] = $row['arrival_port_name']; |
|
| 198 | + } |
|
| 199 | + if (isset($row['latitude'])) { |
|
| 200 | + $temp_array['latitude'] = $row['latitude']; |
|
| 201 | + } |
|
| 202 | + if (isset($row['longitude'])) { |
|
| 203 | + $temp_array['longitude'] = $row['longitude']; |
|
| 204 | + } |
|
| 205 | + if (isset($row['distance']) && $row['distance'] != '') { |
|
| 206 | + $temp_array['distance'] = $row['distance']; |
|
| 207 | + } |
|
| 208 | + if (isset($row['format_source'])) { |
|
| 209 | + $temp_array['format_source'] = $row['format_source']; |
|
| 210 | + } |
|
| 169 | 211 | if (isset($row['heading'])) { |
| 170 | 212 | $temp_array['heading'] = $row['heading']; |
| 171 | 213 | $heading_direction = $this->parseDirection($row['heading']); |
| 172 | - if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
| 214 | + if (isset($heading_direction[0]['direction_fullname'])) { |
|
| 215 | + $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
| 216 | + } |
|
| 217 | + } |
|
| 218 | + if (isset($row['ground_speed'])) { |
|
| 219 | + $temp_array['ground_speed'] = $row['ground_speed']; |
|
| 173 | 220 | } |
| 174 | - if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed']; |
|
| 175 | 221 | |
| 176 | 222 | if(isset($temp_array['mmsi']) && $temp_array['mmsi'] != "") |
| 177 | 223 | { |
| 178 | 224 | $Image = new Image($this->db); |
| 179 | - if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']); |
|
| 180 | - else $image_array = $Image->getMarineImage($temp_array['mmsi']); |
|
| 225 | + if (isset($temp_array['ident']) && $temp_array['ident'] != '') { |
|
| 226 | + $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']); |
|
| 227 | + } else { |
|
| 228 | + $image_array = $Image->getMarineImage($temp_array['mmsi']); |
|
| 229 | + } |
|
| 181 | 230 | unset($Image); |
| 182 | 231 | if (count($image_array) > 0) { |
| 183 | 232 | $temp_array['image'] = $image_array[0]['image']; |
@@ -241,13 +290,21 @@ discard block |
||
| 241 | 290 | } |
| 242 | 291 | |
| 243 | 292 | $fromsource = NULL; |
| 244 | - if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name']; |
|
| 245 | - if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country']; |
|
| 246 | - if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance']; |
|
| 293 | + if (isset($row['source_name']) && $row['source_name'] != '') { |
|
| 294 | + $temp_array['source_name'] = $row['source_name']; |
|
| 295 | + } |
|
| 296 | + if (isset($row['over_country']) && $row['over_country'] != '') { |
|
| 297 | + $temp_array['over_country'] = $row['over_country']; |
|
| 298 | + } |
|
| 299 | + if (isset($row['distance']) && $row['distance'] != '') { |
|
| 300 | + $temp_array['distance'] = $row['distance']; |
|
| 301 | + } |
|
| 247 | 302 | $temp_array['query_number_rows'] = $num_rows; |
| 248 | 303 | $spotter_array[] = $temp_array; |
| 249 | 304 | } |
| 250 | - if ($num_rows == 0) return array(); |
|
| 305 | + if ($num_rows == 0) { |
|
| 306 | + return array(); |
|
| 307 | + } |
|
| 251 | 308 | $spotter_array[0]['query_number_rows'] = $num_rows; |
| 252 | 309 | return $spotter_array; |
| 253 | 310 | } |
@@ -275,8 +332,12 @@ discard block |
||
| 275 | 332 | { |
| 276 | 333 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 277 | 334 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 278 | - } else $limit_query = ""; |
|
| 279 | - } else $limit_query = ""; |
|
| 335 | + } else { |
|
| 336 | + $limit_query = ""; |
|
| 337 | + } |
|
| 338 | + } else { |
|
| 339 | + $limit_query = ""; |
|
| 340 | + } |
|
| 280 | 341 | if ($sort != "") |
| 281 | 342 | { |
| 282 | 343 | $search_orderby_array = $this->getOrderBy(); |
@@ -300,7 +361,9 @@ discard block |
||
| 300 | 361 | global $global_marine_query; |
| 301 | 362 | |
| 302 | 363 | date_default_timezone_set('UTC'); |
| 303 | - if ($id == '') return array(); |
|
| 364 | + if ($id == '') { |
|
| 365 | + return array(); |
|
| 366 | + } |
|
| 304 | 367 | $additional_query = "marine_output.fammarine_id = :id"; |
| 305 | 368 | $query_values = array(':id' => $id); |
| 306 | 369 | $query = $global_marine_query." WHERE ".$additional_query." "; |
@@ -781,8 +844,11 @@ discard block |
||
| 781 | 844 | $sth = $this->db->prepare($query); |
| 782 | 845 | $sth->execute($query_values); |
| 783 | 846 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 784 | - if (is_int($result[0]['duration'])) return gmdate('H:i:s',$result[0]['duration']); |
|
| 785 | - else return $result[0]['duration']; |
|
| 847 | + if (is_int($result[0]['duration'])) { |
|
| 848 | + return gmdate('H:i:s',$result[0]['duration']); |
|
| 849 | + } else { |
|
| 850 | + return $result[0]['duration']; |
|
| 851 | + } |
|
| 786 | 852 | } |
| 787 | 853 | |
| 788 | 854 | /** |
@@ -830,7 +896,9 @@ discard block |
||
| 830 | 896 | } |
| 831 | 897 | } |
| 832 | 898 | $query .= " GROUP BY marine_output.captain_id,marine_output.captain_name ORDER BY duration DESC"; |
| 833 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
| 899 | + if ($limit) { |
|
| 900 | + $query .= " LIMIT 10 OFFSET 0"; |
|
| 901 | + } |
|
| 834 | 902 | $sth = $this->db->prepare($query); |
| 835 | 903 | $sth->execute($query_values); |
| 836 | 904 | //if (is_int($result[0]['duration'])) return gmdate('H:i:s',$result[0]['duration']); |
@@ -909,8 +977,11 @@ discard block |
||
| 909 | 977 | $query .= " ORDER BY marine_output.source_name ASC"; |
| 910 | 978 | |
| 911 | 979 | $sth = $this->db->prepare($query); |
| 912 | - if (!empty($query_values)) $sth->execute($query_values); |
|
| 913 | - else $sth->execute(); |
|
| 980 | + if (!empty($query_values)) { |
|
| 981 | + $sth->execute($query_values); |
|
| 982 | + } else { |
|
| 983 | + $sth->execute(); |
|
| 984 | + } |
|
| 914 | 985 | |
| 915 | 986 | $source_array = array(); |
| 916 | 987 | $temp_array = array(); |
@@ -965,8 +1036,11 @@ discard block |
||
| 965 | 1036 | $sth = $this->db->prepare($query); |
| 966 | 1037 | $sth->execute(array(':mmsi' => $mmsi)); |
| 967 | 1038 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 968 | - if (isset($result[0])) return $result[0]; |
|
| 969 | - else return array(); |
|
| 1039 | + if (isset($result[0])) { |
|
| 1040 | + return $result[0]; |
|
| 1041 | + } else { |
|
| 1042 | + return array(); |
|
| 1043 | + } |
|
| 970 | 1044 | } |
| 971 | 1045 | |
| 972 | 1046 | /** |
@@ -1011,7 +1085,9 @@ discard block |
||
| 1011 | 1085 | date_default_timezone_set($globalTimezone); |
| 1012 | 1086 | $datetime = new DateTime(); |
| 1013 | 1087 | $offset = $datetime->format('P'); |
| 1014 | - } else $offset = '+00:00'; |
|
| 1088 | + } else { |
|
| 1089 | + $offset = '+00:00'; |
|
| 1090 | + } |
|
| 1015 | 1091 | |
| 1016 | 1092 | if ($globalDBdriver == 'mysql') { |
| 1017 | 1093 | $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
@@ -1127,8 +1203,12 @@ discard block |
||
| 1127 | 1203 | */ |
| 1128 | 1204 | public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '',$distance = NULL,$race_rank = NULL, $race_time = NULL, $status = '', $race_begin = '') |
| 1129 | 1205 | { |
| 1130 | - if ($latitude == '') $latitude = NULL; |
|
| 1131 | - if ($longitude == '') $longitude = NULL; |
|
| 1206 | + if ($latitude == '') { |
|
| 1207 | + $latitude = NULL; |
|
| 1208 | + } |
|
| 1209 | + if ($longitude == '') { |
|
| 1210 | + $longitude = NULL; |
|
| 1211 | + } |
|
| 1132 | 1212 | $groundspeed = round($groundspeed); |
| 1133 | 1213 | if ($race_begin != '') { |
| 1134 | 1214 | $query = 'UPDATE marine_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed, distance = :distance, race_rank = :race_rank, race_time = :race_time, status = :status, date = :race_begin WHERE fammarine_id = :fammarine_id'; |
@@ -1286,14 +1366,28 @@ discard block |
||
| 1286 | 1366 | $latitude = 0; |
| 1287 | 1367 | $longitude = 0; |
| 1288 | 1368 | } |
| 1289 | - if ($type_id == '') $type_id = NULL; |
|
| 1290 | - if ($status_id == '') $status_id = NULL; |
|
| 1291 | - if ($distance == '') $distance = NULL; |
|
| 1292 | - if ($race_rank == '') $race_rank = NULL; |
|
| 1293 | - if ($race_time == '') $race_time = NULL; |
|
| 1294 | - if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
| 1369 | + if ($type_id == '') { |
|
| 1370 | + $type_id = NULL; |
|
| 1371 | + } |
|
| 1372 | + if ($status_id == '') { |
|
| 1373 | + $status_id = NULL; |
|
| 1374 | + } |
|
| 1375 | + if ($distance == '') { |
|
| 1376 | + $distance = NULL; |
|
| 1377 | + } |
|
| 1378 | + if ($race_rank == '') { |
|
| 1379 | + $race_rank = NULL; |
|
| 1380 | + } |
|
| 1381 | + if ($race_time == '') { |
|
| 1382 | + $race_time = NULL; |
|
| 1383 | + } |
|
| 1384 | + if ($heading == '' || $Common->isInteger($heading) === false) { |
|
| 1385 | + $heading = 0; |
|
| 1386 | + } |
|
| 1295 | 1387 | //if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
| 1296 | - if ($arrival_date == '') $arrival_date = NULL; |
|
| 1388 | + if ($arrival_date == '') { |
|
| 1389 | + $arrival_date = NULL; |
|
| 1390 | + } |
|
| 1297 | 1391 | $query = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, type_id, status,status_id,imo,arrival_port_name,arrival_port_date,captain_id,captain_name,race_id,race_name, distance, race_rank,race_time) |
| 1298 | 1392 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:type_id,:status,:status_id,:imo,:arrival_port_name,:arrival_port_date,:captain_id,:captain_name,:race_id,:race_name, :distance, :race_rank,:race_time)"; |
| 1299 | 1393 | |
@@ -1401,7 +1495,9 @@ discard block |
||
| 1401 | 1495 | global $globalDBdriver, $globalArchive; |
| 1402 | 1496 | //$filter_query = $this->getFilter($filters,true,true); |
| 1403 | 1497 | $Connection= new Connection($this->db); |
| 1404 | - if (!$Connection->tableExists('countries')) return array(); |
|
| 1498 | + if (!$Connection->tableExists('countries')) { |
|
| 1499 | + return array(); |
|
| 1500 | + } |
|
| 1405 | 1501 | require_once('class.SpotterLive.php'); |
| 1406 | 1502 | if (!isset($globalArchive) || $globalArchive !== TRUE) { |
| 1407 | 1503 | $MarineLive = new MarineLive($this->db); |
@@ -1445,7 +1541,9 @@ discard block |
||
| 1445 | 1541 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb FROM countries c INNER JOIN (SELECT DISTINCT fammarine_id,over_country FROM marine_archive".$filter_query.") l ON c.iso2 = l.over_country "; |
| 1446 | 1542 | } |
| 1447 | 1543 | $query .= "GROUP BY c.name,c.iso3,c.iso2 ORDER BY nb DESC"; |
| 1448 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
| 1544 | + if ($limit) { |
|
| 1545 | + $query .= " LIMIT 10 OFFSET 0"; |
|
| 1546 | + } |
|
| 1449 | 1547 | |
| 1450 | 1548 | $sth = $this->db->prepare($query); |
| 1451 | 1549 | $sth->execute(); |
@@ -1484,12 +1582,18 @@ discard block |
||
| 1484 | 1582 | $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
| 1485 | 1583 | FROM marine_output".$filter_query." marine_output.ident <> ''"; |
| 1486 | 1584 | if ($olderthanmonths > 0) { |
| 1487 | - if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
| 1488 | - else $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
| 1585 | + if ($globalDBdriver == 'mysql') { |
|
| 1586 | + $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
| 1587 | + } else { |
|
| 1588 | + $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
| 1589 | + } |
|
| 1489 | 1590 | } |
| 1490 | 1591 | if ($sincedate != '') { |
| 1491 | - if ($globalDBdriver == 'mysql') $query .= " AND marine_output.date > '".$sincedate."'"; |
|
| 1492 | - else $query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
| 1592 | + if ($globalDBdriver == 'mysql') { |
|
| 1593 | + $query .= " AND marine_output.date > '".$sincedate."'"; |
|
| 1594 | + } else { |
|
| 1595 | + $query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
| 1596 | + } |
|
| 1493 | 1597 | } |
| 1494 | 1598 | $query_values = array(); |
| 1495 | 1599 | if ($year != '') { |
@@ -1520,7 +1624,9 @@ discard block |
||
| 1520 | 1624 | } |
| 1521 | 1625 | } |
| 1522 | 1626 | $query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC"; |
| 1523 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
| 1627 | + if ($limit) { |
|
| 1628 | + $query .= " LIMIT 10 OFFSET 0"; |
|
| 1629 | + } |
|
| 1524 | 1630 | |
| 1525 | 1631 | $sth = $this->db->prepare($query); |
| 1526 | 1632 | $sth->execute($query_values); |
@@ -1555,7 +1661,9 @@ discard block |
||
| 1555 | 1661 | date_default_timezone_set($globalTimezone); |
| 1556 | 1662 | $datetime = new DateTime(); |
| 1557 | 1663 | $offset = $datetime->format('P'); |
| 1558 | - } else $offset = '+00:00'; |
|
| 1664 | + } else { |
|
| 1665 | + $offset = '+00:00'; |
|
| 1666 | + } |
|
| 1559 | 1667 | |
| 1560 | 1668 | if ($globalDBdriver == 'mysql') { |
| 1561 | 1669 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1605,7 +1713,9 @@ discard block |
||
| 1605 | 1713 | date_default_timezone_set($globalTimezone); |
| 1606 | 1714 | $datetime = new DateTime(); |
| 1607 | 1715 | $offset = $datetime->format('P'); |
| 1608 | - } else $offset = '+00:00'; |
|
| 1716 | + } else { |
|
| 1717 | + $offset = '+00:00'; |
|
| 1718 | + } |
|
| 1609 | 1719 | $filter_query = $this->getFilter($filters,true,true); |
| 1610 | 1720 | if ($globalDBdriver == 'mysql') { |
| 1611 | 1721 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1651,7 +1761,9 @@ discard block |
||
| 1651 | 1761 | date_default_timezone_set($globalTimezone); |
| 1652 | 1762 | $datetime = new DateTime(); |
| 1653 | 1763 | $offset = $datetime->format('P'); |
| 1654 | - } else $offset = '+00:00'; |
|
| 1764 | + } else { |
|
| 1765 | + $offset = '+00:00'; |
|
| 1766 | + } |
|
| 1655 | 1767 | $filter_query = $this->getFilter($filters,true,true); |
| 1656 | 1768 | if ($globalDBdriver == 'mysql') { |
| 1657 | 1769 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1699,7 +1811,9 @@ discard block |
||
| 1699 | 1811 | date_default_timezone_set($globalTimezone); |
| 1700 | 1812 | $datetime = new DateTime(); |
| 1701 | 1813 | $offset = $datetime->format('P'); |
| 1702 | - } else $offset = '+00:00'; |
|
| 1814 | + } else { |
|
| 1815 | + $offset = '+00:00'; |
|
| 1816 | + } |
|
| 1703 | 1817 | |
| 1704 | 1818 | if ($globalDBdriver == 'mysql') { |
| 1705 | 1819 | $query = "SELECT YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count |
@@ -1746,7 +1860,9 @@ discard block |
||
| 1746 | 1860 | date_default_timezone_set($globalTimezone); |
| 1747 | 1861 | $datetime = new DateTime(); |
| 1748 | 1862 | $offset = $datetime->format('P'); |
| 1749 | - } else $offset = '+00:00'; |
|
| 1863 | + } else { |
|
| 1864 | + $offset = '+00:00'; |
|
| 1865 | + } |
|
| 1750 | 1866 | $filter_query = $this->getFilter($filters,true,true); |
| 1751 | 1867 | if ($globalDBdriver == 'mysql') { |
| 1752 | 1868 | $query = "SELECT MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count |
@@ -1795,7 +1911,9 @@ discard block |
||
| 1795 | 1911 | date_default_timezone_set($globalTimezone); |
| 1796 | 1912 | $datetime = new DateTime(); |
| 1797 | 1913 | $offset = $datetime->format('P'); |
| 1798 | - } else $offset = '+00:00'; |
|
| 1914 | + } else { |
|
| 1915 | + $offset = '+00:00'; |
|
| 1916 | + } |
|
| 1799 | 1917 | |
| 1800 | 1918 | $orderby_sql = ''; |
| 1801 | 1919 | if ($orderby == "hour") |
@@ -1864,7 +1982,9 @@ discard block |
||
| 1864 | 1982 | date_default_timezone_set($globalTimezone); |
| 1865 | 1983 | $datetime = new DateTime($date); |
| 1866 | 1984 | $offset = $datetime->format('P'); |
| 1867 | - } else $offset = '+00:00'; |
|
| 1985 | + } else { |
|
| 1986 | + $offset = '+00:00'; |
|
| 1987 | + } |
|
| 1868 | 1988 | |
| 1869 | 1989 | if ($globalDBdriver == 'mysql') { |
| 1870 | 1990 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1912,7 +2032,9 @@ discard block |
||
| 1912 | 2032 | date_default_timezone_set($globalTimezone); |
| 1913 | 2033 | $datetime = new DateTime(); |
| 1914 | 2034 | $offset = $datetime->format('P'); |
| 1915 | - } else $offset = '+00:00'; |
|
| 2035 | + } else { |
|
| 2036 | + $offset = '+00:00'; |
|
| 2037 | + } |
|
| 1916 | 2038 | |
| 1917 | 2039 | if ($globalDBdriver == 'mysql') { |
| 1918 | 2040 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1974,7 +2096,9 @@ discard block |
||
| 1974 | 2096 | } |
| 1975 | 2097 | } |
| 1976 | 2098 | $query .= " GROUP BY marine_output.race_id,marine_output.race_name ORDER BY captain_count DESC"; |
| 1977 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
| 2099 | + if ($limit) { |
|
| 2100 | + $query .= " LIMIT 10 OFFSET 0"; |
|
| 2101 | + } |
|
| 1978 | 2102 | $sth = $this->db->prepare($query); |
| 1979 | 2103 | $sth->execute(); |
| 1980 | 2104 | $marine_array = array(); |
@@ -2023,8 +2147,11 @@ discard block |
||
| 2023 | 2147 | $query_values = array_merge($query_values,array(':month' => $month)); |
| 2024 | 2148 | } |
| 2025 | 2149 | } |
| 2026 | - if (empty($query_values)) $queryi .= $this->getFilter($filters); |
|
| 2027 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 2150 | + if (empty($query_values)) { |
|
| 2151 | + $queryi .= $this->getFilter($filters); |
|
| 2152 | + } else { |
|
| 2153 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 2154 | + } |
|
| 2028 | 2155 | |
| 2029 | 2156 | $sth = $this->db->prepare($queryi); |
| 2030 | 2157 | $sth->execute($query_values); |
@@ -2063,8 +2190,11 @@ discard block |
||
| 2063 | 2190 | $query_values = array_merge($query_values,array(':month' => $month)); |
| 2064 | 2191 | } |
| 2065 | 2192 | } |
| 2066 | - if (empty($query_values)) $queryi .= $this->getFilter($filters); |
|
| 2067 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 2193 | + if (empty($query_values)) { |
|
| 2194 | + $queryi .= $this->getFilter($filters); |
|
| 2195 | + } else { |
|
| 2196 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 2197 | + } |
|
| 2068 | 2198 | |
| 2069 | 2199 | $sth = $this->db->prepare($queryi); |
| 2070 | 2200 | $sth->execute($query_values); |
@@ -2103,8 +2233,11 @@ discard block |
||
| 2103 | 2233 | $query_values = array_merge($query_values,array(':month' => $month)); |
| 2104 | 2234 | } |
| 2105 | 2235 | } |
| 2106 | - if (empty($query_values)) $queryi .= $this->getFilter($filters); |
|
| 2107 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 2236 | + if (empty($query_values)) { |
|
| 2237 | + $queryi .= $this->getFilter($filters); |
|
| 2238 | + } else { |
|
| 2239 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 2240 | + } |
|
| 2108 | 2241 | |
| 2109 | 2242 | $sth = $this->db->prepare($queryi); |
| 2110 | 2243 | $sth->execute($query_values); |
@@ -2143,8 +2276,11 @@ discard block |
||
| 2143 | 2276 | $query_values = array_merge($query_values,array(':month' => $month)); |
| 2144 | 2277 | } |
| 2145 | 2278 | } |
| 2146 | - if (empty($query_values)) $queryi .= $this->getFilter($filters); |
|
| 2147 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 2279 | + if (empty($query_values)) { |
|
| 2280 | + $queryi .= $this->getFilter($filters); |
|
| 2281 | + } else { |
|
| 2282 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 2283 | + } |
|
| 2148 | 2284 | |
| 2149 | 2285 | $sth = $this->db->prepare($queryi); |
| 2150 | 2286 | $sth->execute($query_values); |
@@ -2165,7 +2301,9 @@ discard block |
||
| 2165 | 2301 | date_default_timezone_set($globalTimezone); |
| 2166 | 2302 | $datetime = new DateTime(); |
| 2167 | 2303 | $offset = $datetime->format('P'); |
| 2168 | - } else $offset = '+00:00'; |
|
| 2304 | + } else { |
|
| 2305 | + $offset = '+00:00'; |
|
| 2306 | + } |
|
| 2169 | 2307 | |
| 2170 | 2308 | if ($globalDBdriver == 'mysql') { |
| 2171 | 2309 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -2269,7 +2407,9 @@ discard block |
||
| 2269 | 2407 | */ |
| 2270 | 2408 | public function parseDirection($direction = 0) |
| 2271 | 2409 | { |
| 2272 | - if ($direction == '') $direction = 0; |
|
| 2410 | + if ($direction == '') { |
|
| 2411 | + $direction = 0; |
|
| 2412 | + } |
|
| 2273 | 2413 | $direction_array = array(); |
| 2274 | 2414 | $temp_array = array(); |
| 2275 | 2415 | |
@@ -2358,7 +2498,9 @@ discard block |
||
| 2358 | 2498 | $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 2359 | 2499 | |
| 2360 | 2500 | $Connection = new Connection($this->db); |
| 2361 | - if (!$Connection->tableExists('countries')) return ''; |
|
| 2501 | + if (!$Connection->tableExists('countries')) { |
|
| 2502 | + return ''; |
|
| 2503 | + } |
|
| 2362 | 2504 | |
| 2363 | 2505 | try { |
| 2364 | 2506 | /* |
@@ -2378,9 +2520,13 @@ discard block |
||
| 2378 | 2520 | $sth->closeCursor(); |
| 2379 | 2521 | if (count($row) > 0) { |
| 2380 | 2522 | return $row; |
| 2381 | - } else return ''; |
|
| 2523 | + } else { |
|
| 2524 | + return ''; |
|
| 2525 | + } |
|
| 2382 | 2526 | } catch (PDOException $e) { |
| 2383 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
| 2527 | + if (isset($globalDebug) && $globalDebug) { |
|
| 2528 | + echo 'Error : '.$e->getMessage()."\n"; |
|
| 2529 | + } |
|
| 2384 | 2530 | return ''; |
| 2385 | 2531 | } |
| 2386 | 2532 | |
@@ -2398,7 +2544,9 @@ discard block |
||
| 2398 | 2544 | $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); |
| 2399 | 2545 | |
| 2400 | 2546 | $Connection = new Connection($this->db); |
| 2401 | - if (!$Connection->tableExists('countries')) return ''; |
|
| 2547 | + if (!$Connection->tableExists('countries')) { |
|
| 2548 | + return ''; |
|
| 2549 | + } |
|
| 2402 | 2550 | |
| 2403 | 2551 | try { |
| 2404 | 2552 | $query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1"; |
@@ -2410,9 +2558,13 @@ discard block |
||
| 2410 | 2558 | $sth->closeCursor(); |
| 2411 | 2559 | if (count($row) > 0) { |
| 2412 | 2560 | return $row; |
| 2413 | - } else return ''; |
|
| 2561 | + } else { |
|
| 2562 | + return ''; |
|
| 2563 | + } |
|
| 2414 | 2564 | } catch (PDOException $e) { |
| 2415 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
| 2565 | + if (isset($globalDebug) && $globalDebug) { |
|
| 2566 | + echo 'Error : '.$e->getMessage()."\n"; |
|
| 2567 | + } |
|
| 2416 | 2568 | return ''; |
| 2417 | 2569 | } |
| 2418 | 2570 | |
@@ -2430,7 +2582,9 @@ discard block |
||
| 2430 | 2582 | { |
| 2431 | 2583 | global $globalBitlyAccessToken; |
| 2432 | 2584 | |
| 2433 | - if ($globalBitlyAccessToken == '') return $url; |
|
| 2585 | + if ($globalBitlyAccessToken == '') { |
|
| 2586 | + return $url; |
|
| 2587 | + } |
|
| 2434 | 2588 | |
| 2435 | 2589 | $google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url; |
| 2436 | 2590 | |
@@ -2512,7 +2666,9 @@ discard block |
||
| 2512 | 2666 | } |
| 2513 | 2667 | } |
| 2514 | 2668 | $query .= " GROUP BY marine_output.type, marine_output.type_id ORDER BY marine_type_count DESC"; |
| 2515 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
| 2669 | + if ($limit) { |
|
| 2670 | + $query .= " LIMIT 10 OFFSET 0"; |
|
| 2671 | + } |
|
| 2516 | 2672 | $sth = $this->db->prepare($query); |
| 2517 | 2673 | $sth->execute($query_values); |
| 2518 | 2674 | $marine_array = array(); |
@@ -2565,13 +2721,27 @@ discard block |
||
| 2565 | 2721 | foreach ($q_array as $q_item){ |
| 2566 | 2722 | $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
| 2567 | 2723 | $additional_query .= " AND ("; |
| 2568 | - if (is_int($q_item)) $additional_query .= "(marine_output.marine_id = '".$q_item."') OR "; |
|
| 2569 | - if (is_int($q_item)) $additional_query .= "(marine_output.mmsi = '".$q_item."') OR "; |
|
| 2570 | - if (is_int($q_item)) $additional_query .= "(marine_output.imo = '".$q_item."') OR "; |
|
| 2571 | - if (is_int($q_item)) $additional_query .= "(marine_output.captain_id = '".$q_item."') OR "; |
|
| 2572 | - if (is_int($q_item)) $additional_query .= "(marine_output.race_id = '".$q_item."') OR "; |
|
| 2573 | - if (!is_int($q_item)) $additional_query .= "(marine_output.captain_name = '".$q_item."') OR "; |
|
| 2574 | - if (!is_int($q_item)) $additional_query .= "(marine_output.race_name = '".$q_item."') OR "; |
|
| 2724 | + if (is_int($q_item)) { |
|
| 2725 | + $additional_query .= "(marine_output.marine_id = '".$q_item."') OR "; |
|
| 2726 | + } |
|
| 2727 | + if (is_int($q_item)) { |
|
| 2728 | + $additional_query .= "(marine_output.mmsi = '".$q_item."') OR "; |
|
| 2729 | + } |
|
| 2730 | + if (is_int($q_item)) { |
|
| 2731 | + $additional_query .= "(marine_output.imo = '".$q_item."') OR "; |
|
| 2732 | + } |
|
| 2733 | + if (is_int($q_item)) { |
|
| 2734 | + $additional_query .= "(marine_output.captain_id = '".$q_item."') OR "; |
|
| 2735 | + } |
|
| 2736 | + if (is_int($q_item)) { |
|
| 2737 | + $additional_query .= "(marine_output.race_id = '".$q_item."') OR "; |
|
| 2738 | + } |
|
| 2739 | + if (!is_int($q_item)) { |
|
| 2740 | + $additional_query .= "(marine_output.captain_name = '".$q_item."') OR "; |
|
| 2741 | + } |
|
| 2742 | + if (!is_int($q_item)) { |
|
| 2743 | + $additional_query .= "(marine_output.race_name = '".$q_item."') OR "; |
|
| 2744 | + } |
|
| 2575 | 2745 | $additional_query .= "(marine_output.ident like '%".$q_item."%')"; |
| 2576 | 2746 | $additional_query .= ")"; |
| 2577 | 2747 | } |
@@ -2663,7 +2833,9 @@ discard block |
||
| 2663 | 2833 | date_default_timezone_set($globalTimezone); |
| 2664 | 2834 | $datetime = new DateTime(); |
| 2665 | 2835 | $offset = $datetime->format('P'); |
| 2666 | - } else $offset = '+00:00'; |
|
| 2836 | + } else { |
|
| 2837 | + $offset = '+00:00'; |
|
| 2838 | + } |
|
| 2667 | 2839 | if ($date_array[1] != "") |
| 2668 | 2840 | { |
| 2669 | 2841 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
@@ -2690,8 +2862,12 @@ discard block |
||
| 2690 | 2862 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 2691 | 2863 | { |
| 2692 | 2864 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 2693 | - } else $limit_query = ""; |
|
| 2694 | - } else $limit_query = ""; |
|
| 2865 | + } else { |
|
| 2866 | + $limit_query = ""; |
|
| 2867 | + } |
|
| 2868 | + } else { |
|
| 2869 | + $limit_query = ""; |
|
| 2870 | + } |
|
| 2695 | 2871 | if ($sort != "") |
| 2696 | 2872 | { |
| 2697 | 2873 | $search_orderby_array = $this->getOrderBy(); |
@@ -2757,8 +2933,11 @@ discard block |
||
| 2757 | 2933 | $sth = $this->db->prepare($query); |
| 2758 | 2934 | $sth->execute(array(':race_name' => $race_name)); |
| 2759 | 2935 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 2760 | - if (isset($result[0])) return $result[0]; |
|
| 2761 | - else return array(); |
|
| 2936 | + if (isset($result[0])) { |
|
| 2937 | + return $result[0]; |
|
| 2938 | + } else { |
|
| 2939 | + return array(); |
|
| 2940 | + } |
|
| 2762 | 2941 | } |
| 2763 | 2942 | |
| 2764 | 2943 | /** |
@@ -2774,8 +2953,11 @@ discard block |
||
| 2774 | 2953 | $sth = $this->db->prepare($query); |
| 2775 | 2954 | $sth->execute(array(':race_id' => $race_id)); |
| 2776 | 2955 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 2777 | - if (isset($result[0])) return $result[0]; |
|
| 2778 | - else return array(); |
|
| 2956 | + if (isset($result[0])) { |
|
| 2957 | + return $result[0]; |
|
| 2958 | + } else { |
|
| 2959 | + return array(); |
|
| 2960 | + } |
|
| 2779 | 2961 | } |
| 2780 | 2962 | |
| 2781 | 2963 | /** |
@@ -13,10 +13,10 @@ discard block |
||
| 13 | 13 | |
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | - * Get SQL query part for filter used |
|
| 17 | - * @param array $filter the filter |
|
| 18 | - * @return string the SQL part |
|
| 19 | - */ |
|
| 16 | + * Get SQL query part for filter used |
|
| 17 | + * @param array $filter the filter |
|
| 18 | + * @return string the SQL part |
|
| 19 | + */ |
|
| 20 | 20 | public function getFilter($filter = array(),$where = false,$and = false) { |
| 21 | 21 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
| 22 | 22 | $filters = array(); |
@@ -138,14 +138,14 @@ discard block |
||
| 138 | 138 | return $filter_query; |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - /** |
|
| 142 | - * Gets all the spotter information based on the latest data entry |
|
| 143 | - * |
|
| 144 | - * @param string $limit |
|
| 145 | - * @param string $sort |
|
| 146 | - * @param array $filter |
|
| 147 | - * @return array the spotter information |
|
| 148 | - */ |
|
| 141 | + /** |
|
| 142 | + * Gets all the spotter information based on the latest data entry |
|
| 143 | + * |
|
| 144 | + * @param string $limit |
|
| 145 | + * @param string $sort |
|
| 146 | + * @param array $filter |
|
| 147 | + * @return array the spotter information |
|
| 148 | + */ |
|
| 149 | 149 | public function getLiveSpotterData($limit = '', $sort = '', $filter = array()) |
| 150 | 150 | { |
| 151 | 151 | global $globalDBdriver, $globalLiveInterval; |
@@ -187,13 +187,13 @@ discard block |
||
| 187 | 187 | return $spotter_array; |
| 188 | 188 | } |
| 189 | 189 | |
| 190 | - /** |
|
| 191 | - * Gets Minimal Live Spotter data |
|
| 192 | - * |
|
| 193 | - * @param int $limit |
|
| 194 | - * @param array $filter |
|
| 195 | - * @return array the spotter information |
|
| 196 | - */ |
|
| 190 | + /** |
|
| 191 | + * Gets Minimal Live Spotter data |
|
| 192 | + * |
|
| 193 | + * @param int $limit |
|
| 194 | + * @param array $filter |
|
| 195 | + * @return array the spotter information |
|
| 196 | + */ |
|
| 197 | 197 | public function getMinLiveSpotterData($limit = 0,$filter = array()) |
| 198 | 198 | { |
| 199 | 199 | global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap2DAircraftsLimit; |
@@ -244,15 +244,15 @@ discard block |
||
| 244 | 244 | return $spotter_array; |
| 245 | 245 | } |
| 246 | 246 | |
| 247 | - /** |
|
| 248 | - * Gets Minimal Live Spotter data since xx seconds |
|
| 249 | - * |
|
| 250 | - * @param array $coord |
|
| 251 | - * @param array $filter |
|
| 252 | - * @param int $limit |
|
| 253 | - * @param string $id |
|
| 254 | - * @return array the spotter information |
|
| 255 | - */ |
|
| 247 | + /** |
|
| 248 | + * Gets Minimal Live Spotter data since xx seconds |
|
| 249 | + * |
|
| 250 | + * @param array $coord |
|
| 251 | + * @param array $filter |
|
| 252 | + * @param int $limit |
|
| 253 | + * @param string $id |
|
| 254 | + * @return array the spotter information |
|
| 255 | + */ |
|
| 256 | 256 | public function getMinLastLiveSpotterData($coord = array(),$filter = array(), $limit = 0, $id = '') |
| 257 | 257 | { |
| 258 | 258 | global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap3DAircraftsLimit; |
@@ -354,14 +354,14 @@ discard block |
||
| 354 | 354 | return $spotter_array; |
| 355 | 355 | } |
| 356 | 356 | |
| 357 | - /** |
|
| 358 | - * Gets Minimal Live Spotter data since xx seconds |
|
| 359 | - * |
|
| 360 | - * @param string $id |
|
| 361 | - * @param array $filter |
|
| 362 | - * @param int $limit |
|
| 363 | - * @return array the spotter information |
|
| 364 | - */ |
|
| 357 | + /** |
|
| 358 | + * Gets Minimal Live Spotter data since xx seconds |
|
| 359 | + * |
|
| 360 | + * @param string $id |
|
| 361 | + * @param array $filter |
|
| 362 | + * @param int $limit |
|
| 363 | + * @return array the spotter information |
|
| 364 | + */ |
|
| 365 | 365 | public function getMinLastLiveSpotterDataByID($id = '',$filter = array(), $limit = 0) |
| 366 | 366 | { |
| 367 | 367 | global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap3DAircraftsLimit; |
@@ -426,12 +426,12 @@ discard block |
||
| 426 | 426 | return $spotter_array; |
| 427 | 427 | } |
| 428 | 428 | |
| 429 | - /** |
|
| 430 | - * Gets number of latest data entry |
|
| 431 | - * |
|
| 432 | - * @param array $filter |
|
| 433 | - * @return String number of entry |
|
| 434 | - */ |
|
| 429 | + /** |
|
| 430 | + * Gets number of latest data entry |
|
| 431 | + * |
|
| 432 | + * @param array $filter |
|
| 433 | + * @return String number of entry |
|
| 434 | + */ |
|
| 435 | 435 | public function getLiveSpotterCount($filter = array()) |
| 436 | 436 | { |
| 437 | 437 | global $globalDBdriver, $globalLiveInterval; |
@@ -457,13 +457,13 @@ discard block |
||
| 457 | 457 | return $result['nb']; |
| 458 | 458 | } |
| 459 | 459 | |
| 460 | - /** |
|
| 461 | - * Gets all the spotter information based on the latest data entry and coord |
|
| 462 | - * |
|
| 463 | - * @param $coord |
|
| 464 | - * @param array $filter |
|
| 465 | - * @return array the spotter information |
|
| 466 | - */ |
|
| 460 | + /** |
|
| 461 | + * Gets all the spotter information based on the latest data entry and coord |
|
| 462 | + * |
|
| 463 | + * @param $coord |
|
| 464 | + * @param array $filter |
|
| 465 | + * @return array the spotter information |
|
| 466 | + */ |
|
| 467 | 467 | public function getLiveSpotterDatabyCoord($coord, $filter = array()) |
| 468 | 468 | { |
| 469 | 469 | global $globalDBdriver, $globalLiveInterval,$globalMap2DAircraftsLimit; |
@@ -490,14 +490,14 @@ discard block |
||
| 490 | 490 | return $spotter_array; |
| 491 | 491 | } |
| 492 | 492 | |
| 493 | - /** |
|
| 494 | - * Gets all the spotter information based on the latest data entry and coord |
|
| 495 | - * |
|
| 496 | - * @param $coord |
|
| 497 | - * @param int $limit |
|
| 498 | - * @param array $filter |
|
| 499 | - * @return array the spotter information |
|
| 500 | - */ |
|
| 493 | + /** |
|
| 494 | + * Gets all the spotter information based on the latest data entry and coord |
|
| 495 | + * |
|
| 496 | + * @param $coord |
|
| 497 | + * @param int $limit |
|
| 498 | + * @param array $filter |
|
| 499 | + * @return array the spotter information |
|
| 500 | + */ |
|
| 501 | 501 | public function getMinLiveSpotterDatabyCoord($coord,$limit = 0, $filter = array()) |
| 502 | 502 | { |
| 503 | 503 | global $globalDBdriver, $globalLiveInterval, $globalArchive,$globalMap2DAircraftsLimit; |
@@ -587,15 +587,15 @@ discard block |
||
| 587 | 587 | return $spotter_array; |
| 588 | 588 | } |
| 589 | 589 | |
| 590 | - /** |
|
| 591 | - * Gets all the spotter information based on a user's latitude and longitude |
|
| 592 | - * |
|
| 593 | - * @param $lat |
|
| 594 | - * @param $lng |
|
| 595 | - * @param $radius |
|
| 596 | - * @param $interval |
|
| 597 | - * @return array the spotter information |
|
| 598 | - */ |
|
| 590 | + /** |
|
| 591 | + * Gets all the spotter information based on a user's latitude and longitude |
|
| 592 | + * |
|
| 593 | + * @param $lat |
|
| 594 | + * @param $lng |
|
| 595 | + * @param $radius |
|
| 596 | + * @param $interval |
|
| 597 | + * @return array the spotter information |
|
| 598 | + */ |
|
| 599 | 599 | public function getLatestSpotterForLayar($lat, $lng, $radius, $interval) |
| 600 | 600 | { |
| 601 | 601 | $Spotter = new Spotter($this->db); |
@@ -605,95 +605,95 @@ discard block |
||
| 605 | 605 | return array(); |
| 606 | 606 | } |
| 607 | 607 | } |
| 608 | - if ($lng != '') |
|
| 609 | - { |
|
| 610 | - if (!is_numeric($lng)) |
|
| 611 | - { |
|
| 612 | - return array(); |
|
| 613 | - } |
|
| 614 | - } |
|
| 615 | - if ($radius != '') |
|
| 616 | - { |
|
| 617 | - if (!is_numeric($radius)) |
|
| 618 | - { |
|
| 619 | - return array(); |
|
| 620 | - } |
|
| 621 | - } |
|
| 608 | + if ($lng != '') |
|
| 609 | + { |
|
| 610 | + if (!is_numeric($lng)) |
|
| 611 | + { |
|
| 612 | + return array(); |
|
| 613 | + } |
|
| 614 | + } |
|
| 615 | + if ($radius != '') |
|
| 616 | + { |
|
| 617 | + if (!is_numeric($radius)) |
|
| 618 | + { |
|
| 619 | + return array(); |
|
| 620 | + } |
|
| 621 | + } |
|
| 622 | 622 | $additional_query = ''; |
| 623 | - if ($interval != '') |
|
| 624 | - { |
|
| 625 | - if (!is_string($interval)) |
|
| 626 | - { |
|
| 627 | - return array(); |
|
| 628 | - } else { |
|
| 629 | - if ($interval == '1m') |
|
| 630 | - { |
|
| 631 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
| 632 | - } else if ($interval == '15m'){ |
|
| 633 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date '; |
|
| 634 | - } |
|
| 635 | - } |
|
| 636 | - } else { |
|
| 637 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
| 638 | - } |
|
| 639 | - $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 |
|
| 623 | + if ($interval != '') |
|
| 624 | + { |
|
| 625 | + if (!is_string($interval)) |
|
| 626 | + { |
|
| 627 | + return array(); |
|
| 628 | + } else { |
|
| 629 | + if ($interval == '1m') |
|
| 630 | + { |
|
| 631 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
| 632 | + } else if ($interval == '15m'){ |
|
| 633 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date '; |
|
| 634 | + } |
|
| 635 | + } |
|
| 636 | + } else { |
|
| 637 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
| 638 | + } |
|
| 639 | + $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 |
|
| 640 | 640 | WHERE spotter_live.latitude <> '' |
| 641 | 641 | AND spotter_live.longitude <> '' |
| 642 | 642 | ".$additional_query." |
| 643 | 643 | HAVING distance < :radius |
| 644 | 644 | ORDER BY distance"; |
| 645 | 645 | |
| 646 | - $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
| 647 | - return $spotter_array; |
|
| 648 | - } |
|
| 646 | + $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
| 647 | + return $spotter_array; |
|
| 648 | + } |
|
| 649 | 649 | |
| 650 | 650 | |
| 651 | - /** |
|
| 652 | - * Gets all the spotter information based on a particular callsign |
|
| 653 | - * |
|
| 654 | - * @param $ident |
|
| 655 | - * @return array the spotter information |
|
| 656 | - */ |
|
| 651 | + /** |
|
| 652 | + * Gets all the spotter information based on a particular callsign |
|
| 653 | + * |
|
| 654 | + * @param $ident |
|
| 655 | + * @return array the spotter information |
|
| 656 | + */ |
|
| 657 | 657 | public function getLastLiveSpotterDataByIdent($ident) |
| 658 | 658 | { |
| 659 | 659 | $Spotter = new Spotter($this->db); |
| 660 | 660 | date_default_timezone_set('UTC'); |
| 661 | 661 | |
| 662 | 662 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 663 | - $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'; |
|
| 663 | + $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'; |
|
| 664 | 664 | |
| 665 | 665 | $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true); |
| 666 | 666 | |
| 667 | 667 | return $spotter_array; |
| 668 | 668 | } |
| 669 | 669 | |
| 670 | - /** |
|
| 671 | - * Gets all the spotter information based on a particular callsign |
|
| 672 | - * |
|
| 673 | - * @param $ident |
|
| 674 | - * @param $date |
|
| 675 | - * @return array the spotter information |
|
| 676 | - */ |
|
| 670 | + /** |
|
| 671 | + * Gets all the spotter information based on a particular callsign |
|
| 672 | + * |
|
| 673 | + * @param $ident |
|
| 674 | + * @param $date |
|
| 675 | + * @return array the spotter information |
|
| 676 | + */ |
|
| 677 | 677 | public function getDateLiveSpotterDataByIdent($ident,$date) |
| 678 | 678 | { |
| 679 | 679 | $Spotter = new Spotter($this->db); |
| 680 | 680 | date_default_timezone_set('UTC'); |
| 681 | 681 | |
| 682 | 682 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 683 | - $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'; |
|
| 683 | + $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'; |
|
| 684 | 684 | |
| 685 | - $date = date('c',$date); |
|
| 685 | + $date = date('c',$date); |
|
| 686 | 686 | $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
| 687 | 687 | |
| 688 | 688 | return $spotter_array; |
| 689 | 689 | } |
| 690 | 690 | |
| 691 | - /** |
|
| 692 | - * Gets last spotter information based on a particular callsign |
|
| 693 | - * |
|
| 694 | - * @param $id |
|
| 695 | - * @return array the spotter information |
|
| 696 | - */ |
|
| 691 | + /** |
|
| 692 | + * Gets last spotter information based on a particular callsign |
|
| 693 | + * |
|
| 694 | + * @param $id |
|
| 695 | + * @return array the spotter information |
|
| 696 | + */ |
|
| 697 | 697 | public function getLastLiveSpotterDataById($id) |
| 698 | 698 | { |
| 699 | 699 | $Spotter = new Spotter($this->db); |
@@ -704,13 +704,13 @@ discard block |
||
| 704 | 704 | return $spotter_array; |
| 705 | 705 | } |
| 706 | 706 | |
| 707 | - /** |
|
| 708 | - * Gets last spotter information based on a particular callsign |
|
| 709 | - * |
|
| 710 | - * @param $id |
|
| 711 | - * @param $date |
|
| 712 | - * @return array the spotter information |
|
| 713 | - */ |
|
| 707 | + /** |
|
| 708 | + * Gets last spotter information based on a particular callsign |
|
| 709 | + * |
|
| 710 | + * @param $id |
|
| 711 | + * @param $date |
|
| 712 | + * @return array the spotter information |
|
| 713 | + */ |
|
| 714 | 714 | public function getDateLiveSpotterDataById($id,$date) |
| 715 | 715 | { |
| 716 | 716 | $Spotter = new Spotter($this->db); |
@@ -723,21 +723,21 @@ discard block |
||
| 723 | 723 | return $spotter_array; |
| 724 | 724 | } |
| 725 | 725 | |
| 726 | - /** |
|
| 727 | - * Gets altitude information based on a particular callsign |
|
| 728 | - * |
|
| 729 | - * @param $ident |
|
| 730 | - * @return array the spotter information |
|
| 731 | - */ |
|
| 726 | + /** |
|
| 727 | + * Gets altitude information based on a particular callsign |
|
| 728 | + * |
|
| 729 | + * @param $ident |
|
| 730 | + * @return array the spotter information |
|
| 731 | + */ |
|
| 732 | 732 | public function getAltitudeLiveSpotterDataByIdent($ident) |
| 733 | 733 | { |
| 734 | 734 | |
| 735 | 735 | date_default_timezone_set('UTC'); |
| 736 | 736 | |
| 737 | 737 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 738 | - $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
| 738 | + $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
| 739 | 739 | |
| 740 | - try { |
|
| 740 | + try { |
|
| 741 | 741 | |
| 742 | 742 | $sth = $this->db->prepare($query); |
| 743 | 743 | $sth->execute(array(':ident' => $ident)); |
@@ -750,13 +750,13 @@ discard block |
||
| 750 | 750 | return $spotter_array; |
| 751 | 751 | } |
| 752 | 752 | |
| 753 | - /** |
|
| 754 | - * Gets all the spotter information based on a particular id |
|
| 755 | - * |
|
| 756 | - * @param $id |
|
| 757 | - * @param bool $liveinterval |
|
| 758 | - * @return array the spotter information |
|
| 759 | - */ |
|
| 753 | + /** |
|
| 754 | + * Gets all the spotter information based on a particular id |
|
| 755 | + * |
|
| 756 | + * @param $id |
|
| 757 | + * @param bool $liveinterval |
|
| 758 | + * @return array the spotter information |
|
| 759 | + */ |
|
| 760 | 760 | public function getAllLiveSpotterDataById($id,$liveinterval = false) |
| 761 | 761 | { |
| 762 | 762 | global $globalDBdriver, $globalLiveInterval; |
@@ -784,18 +784,18 @@ discard block |
||
| 784 | 784 | return $spotter_array; |
| 785 | 785 | } |
| 786 | 786 | |
| 787 | - /** |
|
| 788 | - * Gets all the spotter information based on a particular ident |
|
| 789 | - * |
|
| 790 | - * @param $ident |
|
| 791 | - * @return array the spotter information |
|
| 792 | - */ |
|
| 787 | + /** |
|
| 788 | + * Gets all the spotter information based on a particular ident |
|
| 789 | + * |
|
| 790 | + * @param $ident |
|
| 791 | + * @return array the spotter information |
|
| 792 | + */ |
|
| 793 | 793 | public function getAllLiveSpotterDataByIdent($ident) |
| 794 | 794 | { |
| 795 | 795 | date_default_timezone_set('UTC'); |
| 796 | 796 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 797 | 797 | $query = self::$global_query.' WHERE spotter_live.ident = :ident'; |
| 798 | - try { |
|
| 798 | + try { |
|
| 799 | 799 | |
| 800 | 800 | $sth = $this->db->prepare($query); |
| 801 | 801 | $sth->execute(array(':ident' => $ident)); |
@@ -809,23 +809,23 @@ discard block |
||
| 809 | 809 | |
| 810 | 810 | |
| 811 | 811 | /** |
| 812 | - * Deletes all info in the table |
|
| 813 | - * |
|
| 814 | - * @return String success or false |
|
| 815 | - * |
|
| 816 | - */ |
|
| 812 | + * Deletes all info in the table |
|
| 813 | + * |
|
| 814 | + * @return String success or false |
|
| 815 | + * |
|
| 816 | + */ |
|
| 817 | 817 | public function deleteLiveSpotterData() |
| 818 | 818 | { |
| 819 | 819 | global $globalDBdriver; |
| 820 | 820 | if ($globalDBdriver == 'mysql') { |
| 821 | 821 | //$query = "DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= spotter_live.date"; |
| 822 | 822 | $query = 'DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= spotter_live.date'; |
| 823 | - //$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)"; |
|
| 823 | + //$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)"; |
|
| 824 | 824 | } else { |
| 825 | 825 | $query = "DELETE FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= spotter_live.date"; |
| 826 | 826 | } |
| 827 | 827 | |
| 828 | - try { |
|
| 828 | + try { |
|
| 829 | 829 | |
| 830 | 830 | $sth = $this->db->prepare($query); |
| 831 | 831 | $sth->execute(); |
@@ -837,18 +837,18 @@ discard block |
||
| 837 | 837 | } |
| 838 | 838 | |
| 839 | 839 | /** |
| 840 | - * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
| 841 | - * |
|
| 842 | - * @return String success or false |
|
| 843 | - * |
|
| 844 | - */ |
|
| 840 | + * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
| 841 | + * |
|
| 842 | + * @return String success or false |
|
| 843 | + * |
|
| 844 | + */ |
|
| 845 | 845 | public function deleteLiveSpotterDataNotUpdated() |
| 846 | 846 | { |
| 847 | 847 | global $globalDBdriver, $globalDebug; |
| 848 | 848 | if ($globalDBdriver == 'mysql') { |
| 849 | 849 | //$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'; |
| 850 | - $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 2000 OFFSET 0"; |
|
| 851 | - try { |
|
| 850 | + $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 2000 OFFSET 0"; |
|
| 851 | + try { |
|
| 852 | 852 | |
| 853 | 853 | $sth = $this->db->prepare($query); |
| 854 | 854 | $sth->execute(); |
@@ -856,8 +856,8 @@ discard block |
||
| 856 | 856 | return "error"; |
| 857 | 857 | } |
| 858 | 858 | $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
| 859 | - $i = 0; |
|
| 860 | - $j =0; |
|
| 859 | + $i = 0; |
|
| 860 | + $j =0; |
|
| 861 | 861 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 862 | 862 | foreach($all as $row) |
| 863 | 863 | { |
@@ -865,20 +865,20 @@ discard block |
||
| 865 | 865 | $j++; |
| 866 | 866 | if ($j == 30) { |
| 867 | 867 | if ($globalDebug) echo "."; |
| 868 | - try { |
|
| 868 | + try { |
|
| 869 | 869 | |
| 870 | 870 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
| 871 | 871 | $sth->execute(); |
| 872 | 872 | } catch(PDOException $e) { |
| 873 | 873 | return "error"; |
| 874 | 874 | } |
| 875 | - $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
|
| 876 | - $j = 0; |
|
| 875 | + $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
|
| 876 | + $j = 0; |
|
| 877 | 877 | } |
| 878 | 878 | $query_delete .= "'".$row['flightaware_id']."',"; |
| 879 | 879 | } |
| 880 | 880 | if ($i > 0) { |
| 881 | - try { |
|
| 881 | + try { |
|
| 882 | 882 | |
| 883 | 883 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
| 884 | 884 | $sth->execute(); |
@@ -889,9 +889,9 @@ discard block |
||
| 889 | 889 | return "success"; |
| 890 | 890 | } elseif ($globalDBdriver == 'pgsql') { |
| 891 | 891 | //$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"; |
| 892 | - //$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"; |
|
| 893 | - $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 2000 OFFSET 0)"; |
|
| 894 | - try { |
|
| 892 | + //$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"; |
|
| 893 | + $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 2000 OFFSET 0)"; |
|
| 894 | + try { |
|
| 895 | 895 | |
| 896 | 896 | $sth = $this->db->prepare($query); |
| 897 | 897 | $sth->execute(); |
@@ -934,18 +934,18 @@ discard block |
||
| 934 | 934 | } |
| 935 | 935 | } |
| 936 | 936 | |
| 937 | - /** |
|
| 938 | - * Deletes all info in the table for an ident |
|
| 939 | - * |
|
| 940 | - * @param $ident |
|
| 941 | - * @return String success or false |
|
| 942 | - */ |
|
| 937 | + /** |
|
| 938 | + * Deletes all info in the table for an ident |
|
| 939 | + * |
|
| 940 | + * @param $ident |
|
| 941 | + * @return String success or false |
|
| 942 | + */ |
|
| 943 | 943 | public function deleteLiveSpotterDataByIdent($ident) |
| 944 | 944 | { |
| 945 | 945 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 946 | 946 | $query = 'DELETE FROM spotter_live WHERE ident = :ident'; |
| 947 | 947 | |
| 948 | - try { |
|
| 948 | + try { |
|
| 949 | 949 | |
| 950 | 950 | $sth = $this->db->prepare($query); |
| 951 | 951 | $sth->execute(array(':ident' => $ident)); |
@@ -956,18 +956,18 @@ discard block |
||
| 956 | 956 | return "success"; |
| 957 | 957 | } |
| 958 | 958 | |
| 959 | - /** |
|
| 960 | - * Deletes all info in the table for an id |
|
| 961 | - * |
|
| 962 | - * @param $id |
|
| 963 | - * @return String success or false |
|
| 964 | - */ |
|
| 959 | + /** |
|
| 960 | + * Deletes all info in the table for an id |
|
| 961 | + * |
|
| 962 | + * @param $id |
|
| 963 | + * @return String success or false |
|
| 964 | + */ |
|
| 965 | 965 | public function deleteLiveSpotterDataById($id) |
| 966 | 966 | { |
| 967 | 967 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 968 | 968 | $query = 'DELETE FROM spotter_live WHERE flightaware_id = :id'; |
| 969 | 969 | |
| 970 | - try { |
|
| 970 | + try { |
|
| 971 | 971 | |
| 972 | 972 | $sth = $this->db->prepare($query); |
| 973 | 973 | $sth->execute(array(':id' => $id)); |
@@ -979,12 +979,12 @@ discard block |
||
| 979 | 979 | } |
| 980 | 980 | |
| 981 | 981 | |
| 982 | - /** |
|
| 983 | - * Gets the aircraft ident within the last hour |
|
| 984 | - * |
|
| 985 | - * @param $ident |
|
| 986 | - * @return String the ident |
|
| 987 | - */ |
|
| 982 | + /** |
|
| 983 | + * Gets the aircraft ident within the last hour |
|
| 984 | + * |
|
| 985 | + * @param $ident |
|
| 986 | + * @return String the ident |
|
| 987 | + */ |
|
| 988 | 988 | public function getIdentFromLastHour($ident) |
| 989 | 989 | { |
| 990 | 990 | global $globalDBdriver, $globalTimezone; |
@@ -1010,14 +1010,14 @@ discard block |
||
| 1010 | 1010 | $ident_result = $row['ident']; |
| 1011 | 1011 | } |
| 1012 | 1012 | return $ident_result; |
| 1013 | - } |
|
| 1014 | - |
|
| 1015 | - /** |
|
| 1016 | - * Check recent aircraft |
|
| 1017 | - * |
|
| 1018 | - * @param $ident |
|
| 1019 | - * @return String the ident |
|
| 1020 | - */ |
|
| 1013 | + } |
|
| 1014 | + |
|
| 1015 | + /** |
|
| 1016 | + * Check recent aircraft |
|
| 1017 | + * |
|
| 1018 | + * @param $ident |
|
| 1019 | + * @return String the ident |
|
| 1020 | + */ |
|
| 1021 | 1021 | public function checkIdentRecent($ident) |
| 1022 | 1022 | { |
| 1023 | 1023 | global $globalDBdriver, $globalTimezone; |
@@ -1043,14 +1043,14 @@ discard block |
||
| 1043 | 1043 | $ident_result = $row['flightaware_id']; |
| 1044 | 1044 | } |
| 1045 | 1045 | return $ident_result; |
| 1046 | - } |
|
| 1047 | - |
|
| 1048 | - /** |
|
| 1049 | - * Check recent aircraft by id |
|
| 1050 | - * |
|
| 1051 | - * @param $id |
|
| 1052 | - * @return String the ident |
|
| 1053 | - */ |
|
| 1046 | + } |
|
| 1047 | + |
|
| 1048 | + /** |
|
| 1049 | + * Check recent aircraft by id |
|
| 1050 | + * |
|
| 1051 | + * @param $id |
|
| 1052 | + * @return String the ident |
|
| 1053 | + */ |
|
| 1054 | 1054 | public function checkIdRecent($id) |
| 1055 | 1055 | { |
| 1056 | 1056 | global $globalDBdriver, $globalTimezone; |
@@ -1076,14 +1076,14 @@ discard block |
||
| 1076 | 1076 | $ident_result = $row['flightaware_id']; |
| 1077 | 1077 | } |
| 1078 | 1078 | return $ident_result; |
| 1079 | - } |
|
| 1080 | - |
|
| 1081 | - /** |
|
| 1082 | - * Check recent aircraft by ModeS |
|
| 1083 | - * |
|
| 1084 | - * @param $modes |
|
| 1085 | - * @return String the ModeS |
|
| 1086 | - */ |
|
| 1079 | + } |
|
| 1080 | + |
|
| 1081 | + /** |
|
| 1082 | + * Check recent aircraft by ModeS |
|
| 1083 | + * |
|
| 1084 | + * @param $modes |
|
| 1085 | + * @return String the ModeS |
|
| 1086 | + */ |
|
| 1087 | 1087 | public function checkModeSRecent($modes) |
| 1088 | 1088 | { |
| 1089 | 1089 | global $globalDBdriver, $globalTimezone; |
@@ -1112,12 +1112,12 @@ discard block |
||
| 1112 | 1112 | return $ident_result; |
| 1113 | 1113 | } |
| 1114 | 1114 | |
| 1115 | - /** |
|
| 1116 | - * Gets the aircraft data from the last 20 seconds |
|
| 1117 | - * |
|
| 1118 | - * @param string $q |
|
| 1119 | - * @return array the spotter data |
|
| 1120 | - */ |
|
| 1115 | + /** |
|
| 1116 | + * Gets the aircraft data from the last 20 seconds |
|
| 1117 | + * |
|
| 1118 | + * @param string $q |
|
| 1119 | + * @return array the spotter data |
|
| 1120 | + */ |
|
| 1121 | 1121 | public function getRealTimeData($q = '') |
| 1122 | 1122 | { |
| 1123 | 1123 | global $globalDBdriver; |
@@ -1158,39 +1158,39 @@ discard block |
||
| 1158 | 1158 | return $spotter_array; |
| 1159 | 1159 | } |
| 1160 | 1160 | |
| 1161 | - /** |
|
| 1162 | - * Adds a new spotter data |
|
| 1163 | - * |
|
| 1164 | - * @param String $flightaware_id the ID from flightaware |
|
| 1165 | - * @param String $ident the flight ident |
|
| 1166 | - * @param String $aircraft_icao the aircraft type |
|
| 1167 | - * @param String $departure_airport_icao the departure airport |
|
| 1168 | - * @param String $arrival_airport_icao the arrival airport |
|
| 1169 | - * @param string $latitude |
|
| 1170 | - * @param string $longitude |
|
| 1171 | - * @param string $waypoints |
|
| 1172 | - * @param string $altitude |
|
| 1173 | - * @param string $altitude_real |
|
| 1174 | - * @param string $heading |
|
| 1175 | - * @param string $groundspeed |
|
| 1176 | - * @param string $date |
|
| 1177 | - * @param string $departure_airport_time |
|
| 1178 | - * @param string $arrival_airport_time |
|
| 1179 | - * @param string $squawk |
|
| 1180 | - * @param string $route_stop |
|
| 1181 | - * @param string $ModeS |
|
| 1182 | - * @param bool $putinarchive |
|
| 1183 | - * @param string $registration |
|
| 1184 | - * @param string $pilot_id |
|
| 1185 | - * @param string $pilot_name |
|
| 1186 | - * @param string $verticalrate |
|
| 1187 | - * @param bool $noarchive |
|
| 1188 | - * @param bool $ground |
|
| 1189 | - * @param string $format_source |
|
| 1190 | - * @param string $source_name |
|
| 1191 | - * @param string $over_country |
|
| 1192 | - * @return String success or false |
|
| 1193 | - */ |
|
| 1161 | + /** |
|
| 1162 | + * Adds a new spotter data |
|
| 1163 | + * |
|
| 1164 | + * @param String $flightaware_id the ID from flightaware |
|
| 1165 | + * @param String $ident the flight ident |
|
| 1166 | + * @param String $aircraft_icao the aircraft type |
|
| 1167 | + * @param String $departure_airport_icao the departure airport |
|
| 1168 | + * @param String $arrival_airport_icao the arrival airport |
|
| 1169 | + * @param string $latitude |
|
| 1170 | + * @param string $longitude |
|
| 1171 | + * @param string $waypoints |
|
| 1172 | + * @param string $altitude |
|
| 1173 | + * @param string $altitude_real |
|
| 1174 | + * @param string $heading |
|
| 1175 | + * @param string $groundspeed |
|
| 1176 | + * @param string $date |
|
| 1177 | + * @param string $departure_airport_time |
|
| 1178 | + * @param string $arrival_airport_time |
|
| 1179 | + * @param string $squawk |
|
| 1180 | + * @param string $route_stop |
|
| 1181 | + * @param string $ModeS |
|
| 1182 | + * @param bool $putinarchive |
|
| 1183 | + * @param string $registration |
|
| 1184 | + * @param string $pilot_id |
|
| 1185 | + * @param string $pilot_name |
|
| 1186 | + * @param string $verticalrate |
|
| 1187 | + * @param bool $noarchive |
|
| 1188 | + * @param bool $ground |
|
| 1189 | + * @param string $format_source |
|
| 1190 | + * @param string $source_name |
|
| 1191 | + * @param string $over_country |
|
| 1192 | + * @return String success or false |
|
| 1193 | + */ |
|
| 1194 | 1194 | public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $altitude_real = '',$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 = '') |
| 1195 | 1195 | { |
| 1196 | 1196 | global $globalURL, $globalArchive, $globalDebug; |
@@ -1333,10 +1333,10 @@ discard block |
||
| 1333 | 1333 | $arrival_airport_country = ''; |
| 1334 | 1334 | |
| 1335 | 1335 | |
| 1336 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
| 1337 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
| 1338 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 1339 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 1336 | + if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
| 1337 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
| 1338 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 1339 | + if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 1340 | 1340 | |
| 1341 | 1341 | $query = ''; |
| 1342 | 1342 | if ($globalArchive) { |
@@ -1357,10 +1357,10 @@ discard block |
||
| 1357 | 1357 | return "error : ".$e->getMessage(); |
| 1358 | 1358 | } |
| 1359 | 1359 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
| 1360 | - if ($globalDebug) echo '(Add to Spotter archive : '; |
|
| 1361 | - $SpotterArchive = new SpotterArchive($this->db); |
|
| 1362 | - $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, $altitude_real,$heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
|
| 1363 | - if ($globalDebug) echo $result.')'; |
|
| 1360 | + if ($globalDebug) echo '(Add to Spotter archive : '; |
|
| 1361 | + $SpotterArchive = new SpotterArchive($this->db); |
|
| 1362 | + $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, $altitude_real,$heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
|
| 1363 | + if ($globalDebug) echo $result.')'; |
|
| 1364 | 1364 | } elseif ($globalDebug && $putinarchive !== true) { |
| 1365 | 1365 | echo '(Not adding to archive)'; |
| 1366 | 1366 | } elseif ($globalDebug && $noarchive === true) { |
@@ -17,62 +17,62 @@ discard block |
||
| 17 | 17 | * @param array $filter the filter |
| 18 | 18 | * @return string the SQL part |
| 19 | 19 | */ |
| 20 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
| 20 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
| 21 | 21 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
| 22 | 22 | $filters = array(); |
| 23 | 23 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
| 24 | 24 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
| 25 | 25 | $filters = $globalStatsFilters[$globalFilterName]; |
| 26 | 26 | } else { |
| 27 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
| 27 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
| 28 | 28 | } |
| 29 | 29 | } |
| 30 | 30 | if (isset($filter[0]['source'])) { |
| 31 | - $filters = array_merge($filters,$filter); |
|
| 31 | + $filters = array_merge($filters, $filter); |
|
| 32 | 32 | } |
| 33 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 33 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
| 34 | 34 | $filter_query_join = ''; |
| 35 | 35 | $filter_query_where = ''; |
| 36 | - foreach($filters as $flt) { |
|
| 36 | + foreach ($filters as $flt) { |
|
| 37 | 37 | if (isset($flt['airlines']) && !empty($flt['airlines'])) { |
| 38 | 38 | if ($flt['airlines'][0] != '' && $flt['airlines'][0] != 'all') { |
| 39 | 39 | if (isset($flt['source'])) { |
| 40 | - $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'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id"; |
|
| 40 | + $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'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id"; |
|
| 41 | 41 | } else { |
| 42 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id"; |
|
| 42 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $flt['airlines'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id"; |
|
| 43 | 43 | } |
| 44 | 44 | } |
| 45 | 45 | } |
| 46 | 46 | if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) { |
| 47 | 47 | if (isset($flt['source'])) { |
| 48 | - $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'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id"; |
|
| 48 | + $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'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id"; |
|
| 49 | 49 | } else { |
| 50 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id"; |
|
| 50 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id"; |
|
| 51 | 51 | } |
| 52 | 52 | } |
| 53 | 53 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
| 54 | 54 | if (isset($flt['source'])) { |
| 55 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id"; |
|
| 55 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id"; |
|
| 56 | 56 | } else { |
| 57 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id"; |
|
| 57 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id"; |
|
| 58 | 58 | } |
| 59 | 59 | } |
| 60 | 60 | if (isset($flt['registrations']) && !empty($flt['registrations'])) { |
| 61 | 61 | if (isset($flt['source'])) { |
| 62 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','",$flt['registrations'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id"; |
|
| 62 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','", $flt['registrations'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id"; |
|
| 63 | 63 | } else { |
| 64 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','",$flt['registrations'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id"; |
|
| 64 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','", $flt['registrations'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id"; |
|
| 65 | 65 | } |
| 66 | 66 | } |
| 67 | 67 | if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id']) && isset($flt['idents']) && empty($flt['idents'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']) && !isset($flt['idents']) && !isset($flt['registrations']))) { |
| 68 | 68 | if (isset($flt['source'])) { |
| 69 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) ssf ON ssf.flightaware_id = spotter_live.flightaware_id"; |
|
| 69 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','", $flt['source'])."')) ssf ON ssf.flightaware_id = spotter_live.flightaware_id"; |
|
| 70 | 70 | } |
| 71 | 71 | } |
| 72 | 72 | } |
| 73 | 73 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 74 | 74 | if ($filter['airlines'][0] != '' && $filter['airlines'][0] != 'all') { |
| 75 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) sai ON sai.flightaware_id = spotter_live.flightaware_id"; |
|
| 75 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) sai ON sai.flightaware_id = spotter_live.flightaware_id"; |
|
| 76 | 76 | } |
| 77 | 77 | } |
| 78 | 78 | if (isset($filter['alliance']) && !empty($filter['alliance'])) { |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | $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 "; |
| 83 | 83 | } |
| 84 | 84 | if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) { |
| 85 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) sp ON sp.flightaware_id = spotter_live.flightaware_id"; |
|
| 85 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $filter['pilots_id'])."')) sp ON sp.flightaware_id = spotter_live.flightaware_id"; |
|
| 86 | 86 | } |
| 87 | 87 | if (isset($filter['blocked']) && $filter['blocked'] == true) { |
| 88 | 88 | $filter_query_join .= " INNER JOIN (SELECT callsign FROM aircraft_block) cblk ON cblk.callsign = spotter_live.ident"; |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | if (count($filter['source']) == 1) { |
| 92 | 92 | $filter_query_where .= " AND format_source = '".$filter['source'][0]."'"; |
| 93 | 93 | } else { |
| 94 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
| 94 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
| 95 | 95 | } |
| 96 | 96 | } |
| 97 | 97 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
@@ -124,15 +124,15 @@ discard block |
||
| 124 | 124 | $filter_query_date .= " AND EXTRACT(DAY FROM spotter_output.date) = '".$filter['day']."'"; |
| 125 | 125 | } |
| 126 | 126 | } |
| 127 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_live.flightaware_id"; |
|
| 127 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.flightaware_id = spotter_live.flightaware_id"; |
|
| 128 | 128 | } |
| 129 | 129 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 130 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 130 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 131 | 131 | } |
| 132 | 132 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
| 133 | 133 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
| 134 | 134 | if ($filter_query_where != '') { |
| 135 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
| 135 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
| 136 | 136 | } |
| 137 | 137 | $filter_query = $filter_query_join.$filter_query_where; |
| 138 | 138 | return $filter_query; |
@@ -157,8 +157,8 @@ discard block |
||
| 157 | 157 | if ($limit != '') |
| 158 | 158 | { |
| 159 | 159 | $limit_array = explode(',', $limit); |
| 160 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 161 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 160 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 161 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 162 | 162 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 163 | 163 | { |
| 164 | 164 | $limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0]; |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | } else { |
| 183 | 183 | $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; |
| 184 | 184 | } |
| 185 | - $spotter_array = $Spotter->getDataFromDB($query.$limit_query,array(),'',true); |
|
| 185 | + $spotter_array = $Spotter->getDataFromDB($query.$limit_query, array(), '', true); |
|
| 186 | 186 | |
| 187 | 187 | return $spotter_array; |
| 188 | 188 | } |
@@ -194,34 +194,34 @@ discard block |
||
| 194 | 194 | * @param array $filter |
| 195 | 195 | * @return array the spotter information |
| 196 | 196 | */ |
| 197 | - public function getMinLiveSpotterData($limit = 0,$filter = array()) |
|
| 197 | + public function getMinLiveSpotterData($limit = 0, $filter = array()) |
|
| 198 | 198 | { |
| 199 | 199 | global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap2DAircraftsLimit; |
| 200 | 200 | date_default_timezone_set('UTC'); |
| 201 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 201 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 202 | 202 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
| 203 | 203 | if ($globalDBdriver == 'mysql') { |
| 204 | 204 | if (isset($globalArchive) && $globalArchive === TRUE) { |
| 205 | 205 | // $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.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
| 206 | 206 | // FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= spotter_live.date AND'." spotter_live.latitude <> 0 AND spotter_live.longitude <> 0 ORDER BY date DESC"; |
| 207 | - $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.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
|
| 207 | + $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.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
|
| 208 | 208 | FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= spotter_live.date AND'." spotter_live.latitude <> 0 AND spotter_live.longitude <> 0"; |
| 209 | 209 | } else { |
| 210 | 210 | // $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.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
| 211 | 211 | // 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 ORDER BY date DESC"; |
| 212 | - $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.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
|
| 212 | + $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.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
|
| 213 | 213 | 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"; |
| 214 | 214 | } |
| 215 | 215 | } else { |
| 216 | 216 | if (isset($globalArchive) && $globalArchive === TRUE) { |
| 217 | 217 | // $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.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
| 218 | 218 | // FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' ORDER BY date DESC"; |
| 219 | - $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.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
|
| 219 | + $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.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
|
| 220 | 220 | FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0'"; |
| 221 | 221 | } else { |
| 222 | 222 | // $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.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
| 223 | 223 | // 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' ORDER BY date DESC"; |
| 224 | - $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.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
|
| 224 | + $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.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
|
| 225 | 225 | 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'"; |
| 226 | 226 | } |
| 227 | 227 | } |
@@ -229,14 +229,14 @@ discard block |
||
| 229 | 229 | if ($limit == 0 && isset($globalMap2DAircraftsLimit) && $globalMap2DAircraftsLimit != '') { |
| 230 | 230 | $limit = $globalMap2DAircraftsLimit; |
| 231 | 231 | } |
| 232 | - if ($limit != 0 && filter_var($limit,FILTER_VALIDATE_INT)) { |
|
| 232 | + if ($limit != 0 && filter_var($limit, FILTER_VALIDATE_INT)) { |
|
| 233 | 233 | $query .= ' LIMIT '.$limit; |
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | try { |
| 237 | 237 | $sth = $this->db->prepare($query); |
| 238 | 238 | $sth->execute(); |
| 239 | - } catch(PDOException $e) { |
|
| 239 | + } catch (PDOException $e) { |
|
| 240 | 240 | echo $e->getMessage(); |
| 241 | 241 | die; |
| 242 | 242 | } |
@@ -253,20 +253,20 @@ discard block |
||
| 253 | 253 | * @param string $id |
| 254 | 254 | * @return array the spotter information |
| 255 | 255 | */ |
| 256 | - public function getMinLastLiveSpotterData($coord = array(),$filter = array(), $limit = 0, $id = '') |
|
| 256 | + public function getMinLastLiveSpotterData($coord = array(), $filter = array(), $limit = 0, $id = '') |
|
| 257 | 257 | { |
| 258 | 258 | global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap3DAircraftsLimit; |
| 259 | 259 | date_default_timezone_set('UTC'); |
| 260 | 260 | $usecoord = false; |
| 261 | 261 | if (is_array($coord) && !empty($coord)) { |
| 262 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 263 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 264 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 265 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 262 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 263 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 264 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 265 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 266 | 266 | if ($minlong != '' && $minlat != '' && $maxlong != '' && $maxlat != '') $usecoord = true; |
| 267 | 267 | } |
| 268 | - $id = filter_var($id,FILTER_SANITIZE_STRING); |
|
| 269 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 268 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 269 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 270 | 270 | |
| 271 | 271 | if (!isset($globalLiveInterval) || $globalLiveInterval == '') $globalLiveInterval = '200'; |
| 272 | 272 | if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAircraftsLimit == '') $globalMap3DAircraftsLimit = '300'; |
@@ -296,7 +296,7 @@ discard block |
||
| 296 | 296 | ORDER BY flightaware_id, date"; |
| 297 | 297 | if ($limit > 0) $query .= " LIMIT ".$limit; |
| 298 | 298 | } else { |
| 299 | - $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, spotter_live.registration |
|
| 299 | + $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, spotter_live.registration |
|
| 300 | 300 | FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date "; |
| 301 | 301 | if ($usecoord) $query .= "AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
| 302 | 302 | if ($id != '') $query .= "OR spotter_live.flightaware_id = :id "; |
@@ -346,7 +346,7 @@ discard block |
||
| 346 | 346 | try { |
| 347 | 347 | $sth = $this->db->prepare($query); |
| 348 | 348 | $sth->execute($query_values); |
| 349 | - } catch(PDOException $e) { |
|
| 349 | + } catch (PDOException $e) { |
|
| 350 | 350 | echo $e->getMessage(); |
| 351 | 351 | die; |
| 352 | 352 | } |
@@ -362,12 +362,12 @@ discard block |
||
| 362 | 362 | * @param int $limit |
| 363 | 363 | * @return array the spotter information |
| 364 | 364 | */ |
| 365 | - public function getMinLastLiveSpotterDataByID($id = '',$filter = array(), $limit = 0) |
|
| 365 | + public function getMinLastLiveSpotterDataByID($id = '', $filter = array(), $limit = 0) |
|
| 366 | 366 | { |
| 367 | 367 | global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap3DAircraftsLimit; |
| 368 | 368 | date_default_timezone_set('UTC'); |
| 369 | - $id = filter_var($id,FILTER_SANITIZE_STRING); |
|
| 370 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 369 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 370 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 371 | 371 | |
| 372 | 372 | if (!isset($globalLiveInterval) || $globalLiveInterval == '') $globalLiveInterval = '200'; |
| 373 | 373 | if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAircraftsLimit == '') $globalMap3DAircraftsLimit = '300'; |
@@ -392,13 +392,13 @@ discard block |
||
| 392 | 392 | } |
| 393 | 393 | } else { |
| 394 | 394 | if (isset($globalArchive) && $globalArchive === TRUE) { |
| 395 | - $query = "SELECT * FROM ( |
|
| 395 | + $query = "SELECT * FROM ( |
|
| 396 | 396 | SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source, spotter_archive.registration |
| 397 | 397 | FROM spotter_archive |
| 398 | 398 | INNER JOIN ( |
| 399 | 399 | SELECT flightaware_id |
| 400 | 400 | FROM spotter_live".$filter_query." spotter_live.flightaware_id = :id"; |
| 401 | - $query.= ") l ON l.flightaware_id = spotter_archive.flightaware_id "; |
|
| 401 | + $query .= ") l ON l.flightaware_id = spotter_archive.flightaware_id "; |
|
| 402 | 402 | $query .= "UNION |
| 403 | 403 | 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, spotter_live.registration |
| 404 | 404 | FROM spotter_live".$filter_query." spotter_live.flightaware_id = :id"; |
@@ -418,7 +418,7 @@ discard block |
||
| 418 | 418 | try { |
| 419 | 419 | $sth = $this->db->prepare($query); |
| 420 | 420 | $sth->execute($query_values); |
| 421 | - } catch(PDOException $e) { |
|
| 421 | + } catch (PDOException $e) { |
|
| 422 | 422 | echo $e->getMessage(); |
| 423 | 423 | die; |
| 424 | 424 | } |
@@ -435,7 +435,7 @@ discard block |
||
| 435 | 435 | public function getLiveSpotterCount($filter = array()) |
| 436 | 436 | { |
| 437 | 437 | global $globalDBdriver, $globalLiveInterval; |
| 438 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 438 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 439 | 439 | |
| 440 | 440 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
| 441 | 441 | if ($globalDBdriver == 'mysql') { |
@@ -448,7 +448,7 @@ discard block |
||
| 448 | 448 | try { |
| 449 | 449 | $sth = $this->db->prepare($query); |
| 450 | 450 | $sth->execute(); |
| 451 | - } catch(PDOException $e) { |
|
| 451 | + } catch (PDOException $e) { |
|
| 452 | 452 | echo $e->getMessage(); |
| 453 | 453 | die; |
| 454 | 454 | } |
@@ -466,16 +466,16 @@ discard block |
||
| 466 | 466 | */ |
| 467 | 467 | public function getLiveSpotterDatabyCoord($coord, $filter = array()) |
| 468 | 468 | { |
| 469 | - global $globalDBdriver, $globalLiveInterval,$globalMap2DAircraftsLimit; |
|
| 469 | + global $globalDBdriver, $globalLiveInterval, $globalMap2DAircraftsLimit; |
|
| 470 | 470 | $Spotter = new Spotter($this->db); |
| 471 | 471 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
| 472 | 472 | $filter_query = $this->getFilter($filter); |
| 473 | 473 | |
| 474 | 474 | if (is_array($coord)) { |
| 475 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 476 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 477 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 478 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 475 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 476 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 477 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 478 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 479 | 479 | } else return array(); |
| 480 | 480 | if ($globalDBdriver == 'mysql') { |
| 481 | 481 | $query = 'SELECT spotter_live.* 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.' GROUP BY spotter_live.flightaware_id'.$filter_query; |
@@ -498,28 +498,28 @@ discard block |
||
| 498 | 498 | * @param array $filter |
| 499 | 499 | * @return array the spotter information |
| 500 | 500 | */ |
| 501 | - public function getMinLiveSpotterDatabyCoord($coord,$limit = 0, $filter = array()) |
|
| 501 | + public function getMinLiveSpotterDatabyCoord($coord, $limit = 0, $filter = array()) |
|
| 502 | 502 | { |
| 503 | - global $globalDBdriver, $globalLiveInterval, $globalArchive,$globalMap2DAircraftsLimit; |
|
| 503 | + global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap2DAircraftsLimit; |
|
| 504 | 504 | $Spotter = new Spotter($this->db); |
| 505 | 505 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
| 506 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 506 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 507 | 507 | |
| 508 | 508 | if (is_array($coord)) { |
| 509 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 510 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 511 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 512 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 509 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 510 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 511 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 512 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 513 | 513 | } else return array(); |
| 514 | 514 | if ($globalDBdriver == 'mysql') { |
| 515 | 515 | if (isset($globalArchive) && $globalArchive === TRUE) { |
| 516 | - $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.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
|
| 516 | + $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.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
|
| 517 | 517 | FROM spotter_live |
| 518 | 518 | '.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= spotter_live.date |
| 519 | 519 | AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' |
| 520 | 520 | AND spotter_live.latitude <> 0 AND spotter_live.longitude <> 0 ORDER BY date DESC'; |
| 521 | 521 | } else { |
| 522 | - $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.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
|
| 522 | + $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.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
|
| 523 | 523 | FROM spotter_live |
| 524 | 524 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate |
| 525 | 525 | FROM spotter_live l |
@@ -539,7 +539,7 @@ discard block |
||
| 539 | 539 | AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong." |
| 540 | 540 | AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' ORDER BY date DESC"; |
| 541 | 541 | */ |
| 542 | - $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.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
|
| 542 | + $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.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
|
| 543 | 543 | FROM spotter_live |
| 544 | 544 | ".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date |
| 545 | 545 | AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." |
@@ -558,7 +558,7 @@ discard block |
||
| 558 | 558 | ) s on spotter_live.flightaware_id = s.flightaware_id |
| 559 | 559 | AND spotter_live.date = s.maxdate".$filter_query." spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' ORDER BY date DESC"; |
| 560 | 560 | */ |
| 561 | - $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.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
|
| 561 | + $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.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
|
| 562 | 562 | FROM spotter_live |
| 563 | 563 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate |
| 564 | 564 | FROM spotter_live l |
@@ -573,13 +573,13 @@ discard block |
||
| 573 | 573 | if ($limit == 0 && isset($globalMap2DAircraftsLimit) && $globalMap2DAircraftsLimit != '') { |
| 574 | 574 | $limit = $globalMap2DAircraftsLimit; |
| 575 | 575 | } |
| 576 | - if ($limit != 0 && filter_var($limit,FILTER_VALIDATE_INT)) { |
|
| 576 | + if ($limit != 0 && filter_var($limit, FILTER_VALIDATE_INT)) { |
|
| 577 | 577 | $query .= ' LIMIT '.$limit; |
| 578 | 578 | } |
| 579 | 579 | try { |
| 580 | 580 | $sth = $this->db->prepare($query); |
| 581 | 581 | $sth->execute(); |
| 582 | - } catch(PDOException $e) { |
|
| 582 | + } catch (PDOException $e) { |
|
| 583 | 583 | echo $e->getMessage(); |
| 584 | 584 | die; |
| 585 | 585 | } |
@@ -629,21 +629,21 @@ discard block |
||
| 629 | 629 | if ($interval == '1m') |
| 630 | 630 | { |
| 631 | 631 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
| 632 | - } else if ($interval == '15m'){ |
|
| 632 | + } else if ($interval == '15m') { |
|
| 633 | 633 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date '; |
| 634 | 634 | } |
| 635 | 635 | } |
| 636 | 636 | } else { |
| 637 | 637 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
| 638 | 638 | } |
| 639 | - $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 |
|
| 639 | + $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 |
|
| 640 | 640 | WHERE spotter_live.latitude <> '' |
| 641 | 641 | AND spotter_live.longitude <> '' |
| 642 | 642 | ".$additional_query." |
| 643 | 643 | HAVING distance < :radius |
| 644 | 644 | ORDER BY distance"; |
| 645 | 645 | |
| 646 | - $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
| 646 | + $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius)); |
|
| 647 | 647 | return $spotter_array; |
| 648 | 648 | } |
| 649 | 649 | |
@@ -660,9 +660,9 @@ discard block |
||
| 660 | 660 | date_default_timezone_set('UTC'); |
| 661 | 661 | |
| 662 | 662 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 663 | - $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'; |
|
| 663 | + $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'; |
|
| 664 | 664 | |
| 665 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true); |
|
| 665 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident), '', true); |
|
| 666 | 666 | |
| 667 | 667 | return $spotter_array; |
| 668 | 668 | } |
@@ -674,16 +674,16 @@ discard block |
||
| 674 | 674 | * @param $date |
| 675 | 675 | * @return array the spotter information |
| 676 | 676 | */ |
| 677 | - public function getDateLiveSpotterDataByIdent($ident,$date) |
|
| 677 | + public function getDateLiveSpotterDataByIdent($ident, $date) |
|
| 678 | 678 | { |
| 679 | 679 | $Spotter = new Spotter($this->db); |
| 680 | 680 | date_default_timezone_set('UTC'); |
| 681 | 681 | |
| 682 | 682 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 683 | - $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'; |
|
| 683 | + $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'; |
|
| 684 | 684 | |
| 685 | - $date = date('c',$date); |
|
| 686 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
| 685 | + $date = date('c', $date); |
|
| 686 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
| 687 | 687 | |
| 688 | 688 | return $spotter_array; |
| 689 | 689 | } |
@@ -699,8 +699,8 @@ discard block |
||
| 699 | 699 | $Spotter = new Spotter($this->db); |
| 700 | 700 | date_default_timezone_set('UTC'); |
| 701 | 701 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 702 | - $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'; |
|
| 703 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id),'',true); |
|
| 702 | + $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'; |
|
| 703 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id), '', true); |
|
| 704 | 704 | return $spotter_array; |
| 705 | 705 | } |
| 706 | 706 | |
@@ -711,15 +711,15 @@ discard block |
||
| 711 | 711 | * @param $date |
| 712 | 712 | * @return array the spotter information |
| 713 | 713 | */ |
| 714 | - public function getDateLiveSpotterDataById($id,$date) |
|
| 714 | + public function getDateLiveSpotterDataById($id, $date) |
|
| 715 | 715 | { |
| 716 | 716 | $Spotter = new Spotter($this->db); |
| 717 | 717 | date_default_timezone_set('UTC'); |
| 718 | 718 | |
| 719 | 719 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 720 | - $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'; |
|
| 721 | - $date = date('c',$date); |
|
| 722 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
|
| 720 | + $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'; |
|
| 721 | + $date = date('c', $date); |
|
| 722 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true); |
|
| 723 | 723 | return $spotter_array; |
| 724 | 724 | } |
| 725 | 725 | |
@@ -735,13 +735,13 @@ discard block |
||
| 735 | 735 | date_default_timezone_set('UTC'); |
| 736 | 736 | |
| 737 | 737 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 738 | - $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
| 738 | + $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
| 739 | 739 | |
| 740 | 740 | try { |
| 741 | 741 | |
| 742 | 742 | $sth = $this->db->prepare($query); |
| 743 | 743 | $sth->execute(array(':ident' => $ident)); |
| 744 | - } catch(PDOException $e) { |
|
| 744 | + } catch (PDOException $e) { |
|
| 745 | 745 | echo $e->getMessage(); |
| 746 | 746 | die; |
| 747 | 747 | } |
@@ -757,7 +757,7 @@ discard block |
||
| 757 | 757 | * @param bool $liveinterval |
| 758 | 758 | * @return array the spotter information |
| 759 | 759 | */ |
| 760 | - public function getAllLiveSpotterDataById($id,$liveinterval = false) |
|
| 760 | + public function getAllLiveSpotterDataById($id, $liveinterval = false) |
|
| 761 | 761 | { |
| 762 | 762 | global $globalDBdriver, $globalLiveInterval; |
| 763 | 763 | date_default_timezone_set('UTC'); |
@@ -776,7 +776,7 @@ discard block |
||
| 776 | 776 | try { |
| 777 | 777 | $sth = $this->db->prepare($query); |
| 778 | 778 | $sth->execute(array(':id' => $id)); |
| 779 | - } catch(PDOException $e) { |
|
| 779 | + } catch (PDOException $e) { |
|
| 780 | 780 | echo $e->getMessage(); |
| 781 | 781 | die; |
| 782 | 782 | } |
@@ -794,12 +794,12 @@ discard block |
||
| 794 | 794 | { |
| 795 | 795 | date_default_timezone_set('UTC'); |
| 796 | 796 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 797 | - $query = self::$global_query.' WHERE spotter_live.ident = :ident'; |
|
| 797 | + $query = self::$global_query.' WHERE spotter_live.ident = :ident'; |
|
| 798 | 798 | try { |
| 799 | 799 | |
| 800 | 800 | $sth = $this->db->prepare($query); |
| 801 | 801 | $sth->execute(array(':ident' => $ident)); |
| 802 | - } catch(PDOException $e) { |
|
| 802 | + } catch (PDOException $e) { |
|
| 803 | 803 | echo $e->getMessage(); |
| 804 | 804 | die; |
| 805 | 805 | } |
@@ -829,7 +829,7 @@ discard block |
||
| 829 | 829 | |
| 830 | 830 | $sth = $this->db->prepare($query); |
| 831 | 831 | $sth->execute(); |
| 832 | - } catch(PDOException $e) { |
|
| 832 | + } catch (PDOException $e) { |
|
| 833 | 833 | return "error"; |
| 834 | 834 | } |
| 835 | 835 | |
@@ -852,14 +852,14 @@ discard block |
||
| 852 | 852 | |
| 853 | 853 | $sth = $this->db->prepare($query); |
| 854 | 854 | $sth->execute(); |
| 855 | - } catch(PDOException $e) { |
|
| 855 | + } catch (PDOException $e) { |
|
| 856 | 856 | return "error"; |
| 857 | 857 | } |
| 858 | 858 | $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
| 859 | 859 | $i = 0; |
| 860 | - $j =0; |
|
| 860 | + $j = 0; |
|
| 861 | 861 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 862 | - foreach($all as $row) |
|
| 862 | + foreach ($all as $row) |
|
| 863 | 863 | { |
| 864 | 864 | $i++; |
| 865 | 865 | $j++; |
@@ -867,9 +867,9 @@ discard block |
||
| 867 | 867 | if ($globalDebug) echo "."; |
| 868 | 868 | try { |
| 869 | 869 | |
| 870 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
| 870 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
| 871 | 871 | $sth->execute(); |
| 872 | - } catch(PDOException $e) { |
|
| 872 | + } catch (PDOException $e) { |
|
| 873 | 873 | return "error"; |
| 874 | 874 | } |
| 875 | 875 | $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
@@ -880,9 +880,9 @@ discard block |
||
| 880 | 880 | if ($i > 0) { |
| 881 | 881 | try { |
| 882 | 882 | |
| 883 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
| 883 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
| 884 | 884 | $sth->execute(); |
| 885 | - } catch(PDOException $e) { |
|
| 885 | + } catch (PDOException $e) { |
|
| 886 | 886 | return "error"; |
| 887 | 887 | } |
| 888 | 888 | } |
@@ -895,7 +895,7 @@ discard block |
||
| 895 | 895 | |
| 896 | 896 | $sth = $this->db->prepare($query); |
| 897 | 897 | $sth->execute(); |
| 898 | - } catch(PDOException $e) { |
|
| 898 | + } catch (PDOException $e) { |
|
| 899 | 899 | return "error"; |
| 900 | 900 | } |
| 901 | 901 | /* $query_delete = "DELETE FROM spotter_live WHERE flightaware_id IN ("; |
@@ -943,13 +943,13 @@ discard block |
||
| 943 | 943 | public function deleteLiveSpotterDataByIdent($ident) |
| 944 | 944 | { |
| 945 | 945 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 946 | - $query = 'DELETE FROM spotter_live WHERE ident = :ident'; |
|
| 946 | + $query = 'DELETE FROM spotter_live WHERE ident = :ident'; |
|
| 947 | 947 | |
| 948 | 948 | try { |
| 949 | 949 | |
| 950 | 950 | $sth = $this->db->prepare($query); |
| 951 | 951 | $sth->execute(array(':ident' => $ident)); |
| 952 | - } catch(PDOException $e) { |
|
| 952 | + } catch (PDOException $e) { |
|
| 953 | 953 | return "error"; |
| 954 | 954 | } |
| 955 | 955 | |
@@ -965,13 +965,13 @@ discard block |
||
| 965 | 965 | public function deleteLiveSpotterDataById($id) |
| 966 | 966 | { |
| 967 | 967 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 968 | - $query = 'DELETE FROM spotter_live WHERE flightaware_id = :id'; |
|
| 968 | + $query = 'DELETE FROM spotter_live WHERE flightaware_id = :id'; |
|
| 969 | 969 | |
| 970 | 970 | try { |
| 971 | 971 | |
| 972 | 972 | $sth = $this->db->prepare($query); |
| 973 | 973 | $sth->execute(array(':id' => $id)); |
| 974 | - } catch(PDOException $e) { |
|
| 974 | + } catch (PDOException $e) { |
|
| 975 | 975 | return "error"; |
| 976 | 976 | } |
| 977 | 977 | |
@@ -989,13 +989,13 @@ discard block |
||
| 989 | 989 | { |
| 990 | 990 | global $globalDBdriver, $globalTimezone; |
| 991 | 991 | if ($globalDBdriver == 'mysql') { |
| 992 | - $query = 'SELECT spotter_live.ident FROM spotter_live |
|
| 992 | + $query = 'SELECT spotter_live.ident FROM spotter_live |
|
| 993 | 993 | WHERE spotter_live.ident = :ident |
| 994 | 994 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
| 995 | 995 | AND spotter_live.date < UTC_TIMESTAMP()'; |
| 996 | 996 | $query_data = array(':ident' => $ident); |
| 997 | 997 | } else { |
| 998 | - $query = "SELECT spotter_live.ident FROM spotter_live |
|
| 998 | + $query = "SELECT spotter_live.ident FROM spotter_live |
|
| 999 | 999 | WHERE spotter_live.ident = :ident |
| 1000 | 1000 | AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
| 1001 | 1001 | AND spotter_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -1004,8 +1004,8 @@ discard block |
||
| 1004 | 1004 | |
| 1005 | 1005 | $sth = $this->db->prepare($query); |
| 1006 | 1006 | $sth->execute($query_data); |
| 1007 | - $ident_result=''; |
|
| 1008 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1007 | + $ident_result = ''; |
|
| 1008 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1009 | 1009 | { |
| 1010 | 1010 | $ident_result = $row['ident']; |
| 1011 | 1011 | } |
@@ -1022,13 +1022,13 @@ discard block |
||
| 1022 | 1022 | { |
| 1023 | 1023 | global $globalDBdriver, $globalTimezone; |
| 1024 | 1024 | if ($globalDBdriver == 'mysql') { |
| 1025 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 1025 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 1026 | 1026 | WHERE spotter_live.ident = :ident |
| 1027 | 1027 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 MINUTE)'; |
| 1028 | 1028 | // AND spotter_live.date < UTC_TIMESTAMP()"; |
| 1029 | 1029 | $query_data = array(':ident' => $ident); |
| 1030 | 1030 | } else { |
| 1031 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 1031 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 1032 | 1032 | WHERE spotter_live.ident = :ident |
| 1033 | 1033 | AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '20 MINUTES'"; |
| 1034 | 1034 | // AND spotter_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -1037,8 +1037,8 @@ discard block |
||
| 1037 | 1037 | |
| 1038 | 1038 | $sth = $this->db->prepare($query); |
| 1039 | 1039 | $sth->execute($query_data); |
| 1040 | - $ident_result=''; |
|
| 1041 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1040 | + $ident_result = ''; |
|
| 1041 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1042 | 1042 | { |
| 1043 | 1043 | $ident_result = $row['flightaware_id']; |
| 1044 | 1044 | } |
@@ -1055,13 +1055,13 @@ discard block |
||
| 1055 | 1055 | { |
| 1056 | 1056 | global $globalDBdriver, $globalTimezone; |
| 1057 | 1057 | if ($globalDBdriver == 'mysql') { |
| 1058 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 1058 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 1059 | 1059 | WHERE spotter_live.flightaware_id = :id |
| 1060 | 1060 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; |
| 1061 | 1061 | // AND spotter_live.date < UTC_TIMESTAMP()"; |
| 1062 | 1062 | $query_data = array(':id' => $id); |
| 1063 | 1063 | } else { |
| 1064 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 1064 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 1065 | 1065 | WHERE spotter_live.flightaware_id = :id |
| 1066 | 1066 | AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'"; |
| 1067 | 1067 | // AND spotter_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -1070,8 +1070,8 @@ discard block |
||
| 1070 | 1070 | |
| 1071 | 1071 | $sth = $this->db->prepare($query); |
| 1072 | 1072 | $sth->execute($query_data); |
| 1073 | - $ident_result=''; |
|
| 1074 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1073 | + $ident_result = ''; |
|
| 1074 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1075 | 1075 | { |
| 1076 | 1076 | $ident_result = $row['flightaware_id']; |
| 1077 | 1077 | } |
@@ -1088,13 +1088,13 @@ discard block |
||
| 1088 | 1088 | { |
| 1089 | 1089 | global $globalDBdriver, $globalTimezone; |
| 1090 | 1090 | if ($globalDBdriver == 'mysql') { |
| 1091 | - $query = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
| 1091 | + $query = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
| 1092 | 1092 | WHERE spotter_live.ModeS = :modes |
| 1093 | 1093 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 MINUTE)'; |
| 1094 | 1094 | // AND spotter_live.date < UTC_TIMESTAMP()"; |
| 1095 | 1095 | $query_data = array(':modes' => $modes); |
| 1096 | 1096 | } else { |
| 1097 | - $query = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
| 1097 | + $query = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
| 1098 | 1098 | WHERE spotter_live.ModeS = :modes |
| 1099 | 1099 | AND spotter_live.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 MINUTE'"; |
| 1100 | 1100 | // // AND spotter_live.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'"; |
@@ -1103,8 +1103,8 @@ discard block |
||
| 1103 | 1103 | |
| 1104 | 1104 | $sth = $this->db->prepare($query); |
| 1105 | 1105 | $sth->execute($query_data); |
| 1106 | - $ident_result=''; |
|
| 1107 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1106 | + $ident_result = ''; |
|
| 1107 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1108 | 1108 | { |
| 1109 | 1109 | //$ident_result = $row['spotter_live_id']; |
| 1110 | 1110 | $ident_result = $row['flightaware_id']; |
@@ -1129,8 +1129,8 @@ discard block |
||
| 1129 | 1129 | return array(); |
| 1130 | 1130 | } else { |
| 1131 | 1131 | $q_array = explode(" ", $q); |
| 1132 | - foreach ($q_array as $q_item){ |
|
| 1133 | - $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
|
| 1132 | + foreach ($q_array as $q_item) { |
|
| 1133 | + $q_item = filter_var($q_item, FILTER_SANITIZE_STRING); |
|
| 1134 | 1134 | $additional_query .= " AND ("; |
| 1135 | 1135 | $additional_query .= "(spotter_live.aircraft_icao like '%".$q_item."%') OR "; |
| 1136 | 1136 | $additional_query .= "(spotter_live.aircraft_name like '%".$q_item."%') OR "; |
@@ -1145,11 +1145,11 @@ discard block |
||
| 1145 | 1145 | } |
| 1146 | 1146 | } |
| 1147 | 1147 | if ($globalDBdriver == 'mysql') { |
| 1148 | - $query = "SELECT spotter_live.* FROM spotter_live |
|
| 1148 | + $query = "SELECT spotter_live.* FROM spotter_live |
|
| 1149 | 1149 | WHERE spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." |
| 1150 | 1150 | AND spotter_live.date < UTC_TIMESTAMP()"; |
| 1151 | 1151 | } else { |
| 1152 | - $query = "SELECT spotter_live.* FROM spotter_live |
|
| 1152 | + $query = "SELECT spotter_live.* FROM spotter_live |
|
| 1153 | 1153 | WHERE spotter_live.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." |
| 1154 | 1154 | AND spotter_live.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'"; |
| 1155 | 1155 | } |
@@ -1191,7 +1191,7 @@ discard block |
||
| 1191 | 1191 | * @param string $over_country |
| 1192 | 1192 | * @return String success or false |
| 1193 | 1193 | */ |
| 1194 | - public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $altitude_real = '',$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 = '') |
|
| 1194 | + public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $altitude_real = '', $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 = '') |
|
| 1195 | 1195 | { |
| 1196 | 1196 | global $globalURL, $globalArchive, $globalDebug; |
| 1197 | 1197 | $Common = new Common(); |
@@ -1291,27 +1291,27 @@ discard block |
||
| 1291 | 1291 | if ($date == '') $date = date("Y-m-d H:i:s", time()); |
| 1292 | 1292 | |
| 1293 | 1293 | |
| 1294 | - $flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING); |
|
| 1295 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
| 1296 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 1297 | - $departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING); |
|
| 1298 | - $arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING); |
|
| 1299 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1300 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1301 | - $waypoints = filter_var($waypoints,FILTER_SANITIZE_STRING); |
|
| 1302 | - $altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1303 | - $altitude_real = filter_var($altitude_real,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1304 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
| 1305 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1306 | - $squawk = filter_var($squawk,FILTER_SANITIZE_NUMBER_INT); |
|
| 1307 | - $route_stop = filter_var($route_stop,FILTER_SANITIZE_STRING); |
|
| 1308 | - $ModeS = filter_var($ModeS,FILTER_SANITIZE_STRING); |
|
| 1309 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_STRING); |
|
| 1310 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
| 1311 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
| 1312 | - $source_name = filter_var($source_name,FILTER_SANITIZE_STRING); |
|
| 1313 | - $over_country = filter_var($over_country,FILTER_SANITIZE_STRING); |
|
| 1314 | - $verticalrate = filter_var($verticalrate,FILTER_SANITIZE_NUMBER_INT); |
|
| 1294 | + $flightaware_id = filter_var($flightaware_id, FILTER_SANITIZE_STRING); |
|
| 1295 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 1296 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
| 1297 | + $departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING); |
|
| 1298 | + $arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING); |
|
| 1299 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1300 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1301 | + $waypoints = filter_var($waypoints, FILTER_SANITIZE_STRING); |
|
| 1302 | + $altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1303 | + $altitude_real = filter_var($altitude_real, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1304 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
| 1305 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1306 | + $squawk = filter_var($squawk, FILTER_SANITIZE_NUMBER_INT); |
|
| 1307 | + $route_stop = filter_var($route_stop, FILTER_SANITIZE_STRING); |
|
| 1308 | + $ModeS = filter_var($ModeS, FILTER_SANITIZE_STRING); |
|
| 1309 | + $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_STRING); |
|
| 1310 | + $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING); |
|
| 1311 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
| 1312 | + $source_name = filter_var($source_name, FILTER_SANITIZE_STRING); |
|
| 1313 | + $over_country = filter_var($over_country, FILTER_SANITIZE_STRING); |
|
| 1314 | + $verticalrate = filter_var($verticalrate, FILTER_SANITIZE_NUMBER_INT); |
|
| 1315 | 1315 | |
| 1316 | 1316 | $airline_name = ''; |
| 1317 | 1317 | $airline_icao = ''; |
@@ -1333,10 +1333,10 @@ discard block |
||
| 1333 | 1333 | $arrival_airport_country = ''; |
| 1334 | 1334 | |
| 1335 | 1335 | |
| 1336 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
| 1337 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
| 1338 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 1339 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 1336 | + if ($squawk == '' || $Common->isInteger($squawk) === false) $squawk = NULL; |
|
| 1337 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) $verticalrate = NULL; |
|
| 1338 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
| 1339 | + if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
| 1340 | 1340 | |
| 1341 | 1341 | $query = ''; |
| 1342 | 1342 | if ($globalArchive) { |
@@ -1347,19 +1347,19 @@ discard block |
||
| 1347 | 1347 | $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, real_altitude) |
| 1348 | 1348 | 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, :real_altitude)'; |
| 1349 | 1349 | |
| 1350 | - $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,':real_altitude' => $altitude_real); |
|
| 1350 | + $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, ':real_altitude' => $altitude_real); |
|
| 1351 | 1351 | try { |
| 1352 | 1352 | |
| 1353 | 1353 | $sth = $this->db->prepare($query); |
| 1354 | 1354 | $sth->execute($query_values); |
| 1355 | 1355 | $sth->closeCursor(); |
| 1356 | - } catch(PDOException $e) { |
|
| 1356 | + } catch (PDOException $e) { |
|
| 1357 | 1357 | return "error : ".$e->getMessage(); |
| 1358 | 1358 | } |
| 1359 | 1359 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
| 1360 | 1360 | if ($globalDebug) echo '(Add to Spotter archive : '; |
| 1361 | 1361 | $SpotterArchive = new SpotterArchive($this->db); |
| 1362 | - $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, $altitude_real,$heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
|
| 1362 | + $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, $altitude_real, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name, $verticalrate, $format_source, $source_name, $over_country); |
|
| 1363 | 1363 | if ($globalDebug) echo $result.')'; |
| 1364 | 1364 | } elseif ($globalDebug && $putinarchive !== true) { |
| 1365 | 1365 | echo '(Not adding to archive)'; |
@@ -1372,7 +1372,7 @@ discard block |
||
| 1372 | 1372 | |
| 1373 | 1373 | public function getOrderBy() |
| 1374 | 1374 | { |
| 1375 | - $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")); |
|
| 1375 | + $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")); |
|
| 1376 | 1376 | return $orderby; |
| 1377 | 1377 | } |
| 1378 | 1378 | |
@@ -8,7 +8,9 @@ discard block |
||
| 8 | 8 | public function __construct($dbc = null) { |
| 9 | 9 | $Connection = new Connection($dbc); |
| 10 | 10 | $this->db = $Connection->db(); |
| 11 | - if ($this->db === null) die('Error: No DB connection. (SpotterLive)'); |
|
| 11 | + if ($this->db === null) { |
|
| 12 | + die('Error: No DB connection. (SpotterLive)'); |
|
| 13 | + } |
|
| 12 | 14 | } |
| 13 | 15 | |
| 14 | 16 | |
@@ -30,7 +32,9 @@ discard block |
||
| 30 | 32 | if (isset($filter[0]['source'])) { |
| 31 | 33 | $filters = array_merge($filters,$filter); |
| 32 | 34 | } |
| 33 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 35 | + if (is_array($globalFilter)) { |
|
| 36 | + $filter = array_merge($filter,$globalFilter); |
|
| 37 | + } |
|
| 34 | 38 | $filter_query_join = ''; |
| 35 | 39 | $filter_query_where = ''; |
| 36 | 40 | foreach($filters as $flt) { |
@@ -129,8 +133,11 @@ discard block |
||
| 129 | 133 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 130 | 134 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
| 131 | 135 | } |
| 132 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
| 133 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
| 136 | + if ($filter_query_where == '' && $where) { |
|
| 137 | + $filter_query_where = ' WHERE'; |
|
| 138 | + } elseif ($filter_query_where != '' && $and) { |
|
| 139 | + $filter_query_where .= ' AND'; |
|
| 140 | + } |
|
| 134 | 141 | if ($filter_query_where != '') { |
| 135 | 142 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
| 136 | 143 | } |
@@ -173,9 +180,13 @@ discard block |
||
| 173 | 180 | $orderby_query = ' '.$search_orderby_array[$sort]['sql']; |
| 174 | 181 | } |
| 175 | 182 | } |
| 176 | - if ($orderby_query == '') $orderby_query = ' ORDER BY date DESC'; |
|
| 183 | + if ($orderby_query == '') { |
|
| 184 | + $orderby_query = ' ORDER BY date DESC'; |
|
| 185 | + } |
|
| 177 | 186 | |
| 178 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 187 | + if (!isset($globalLiveInterval)) { |
|
| 188 | + $globalLiveInterval = '200'; |
|
| 189 | + } |
|
| 179 | 190 | if ($globalDBdriver == 'mysql') { |
| 180 | 191 | //$query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate"; |
| 181 | 192 | $query = 'SELECT spotter_live.* 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.$orderby_query; |
@@ -199,7 +210,9 @@ discard block |
||
| 199 | 210 | global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap2DAircraftsLimit; |
| 200 | 211 | date_default_timezone_set('UTC'); |
| 201 | 212 | $filter_query = $this->getFilter($filter,true,true); |
| 202 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 213 | + if (!isset($globalLiveInterval)) { |
|
| 214 | + $globalLiveInterval = '200'; |
|
| 215 | + } |
|
| 203 | 216 | if ($globalDBdriver == 'mysql') { |
| 204 | 217 | if (isset($globalArchive) && $globalArchive === TRUE) { |
| 205 | 218 | // $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.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
@@ -263,14 +276,22 @@ discard block |
||
| 263 | 276 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 264 | 277 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 265 | 278 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 266 | - if ($minlong != '' && $minlat != '' && $maxlong != '' && $maxlat != '') $usecoord = true; |
|
| 279 | + if ($minlong != '' && $minlat != '' && $maxlong != '' && $maxlat != '') { |
|
| 280 | + $usecoord = true; |
|
| 281 | + } |
|
| 267 | 282 | } |
| 268 | 283 | $id = filter_var($id,FILTER_SANITIZE_STRING); |
| 269 | 284 | $filter_query = $this->getFilter($filter,true,true); |
| 270 | 285 | |
| 271 | - if (!isset($globalLiveInterval) || $globalLiveInterval == '') $globalLiveInterval = '200'; |
|
| 272 | - if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAircraftsLimit == '') $globalMap3DAircraftsLimit = '300'; |
|
| 273 | - if ($limit == 0 || $limit == '') $limit = $globalMap3DAircraftsLimit; |
|
| 286 | + if (!isset($globalLiveInterval) || $globalLiveInterval == '') { |
|
| 287 | + $globalLiveInterval = '200'; |
|
| 288 | + } |
|
| 289 | + if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAircraftsLimit == '') { |
|
| 290 | + $globalMap3DAircraftsLimit = '300'; |
|
| 291 | + } |
|
| 292 | + if ($limit == 0 || $limit == '') { |
|
| 293 | + $limit = $globalMap3DAircraftsLimit; |
|
| 294 | + } |
|
| 274 | 295 | if ($globalDBdriver == 'mysql') { |
| 275 | 296 | if (isset($globalArchive) && $globalArchive === TRUE) { |
| 276 | 297 | /* |
@@ -283,26 +304,42 @@ discard block |
||
| 283 | 304 | FROM spotter_archive INNER JOIN (SELECT flightaware_id FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date"; |
| 284 | 305 | //if ($limit > 0) $query .= " LIMIT ".$limit; |
| 285 | 306 | $query .= ") l ON l.flightaware_id = spotter_archive.flightaware_id "; |
| 286 | - if ($usecoord) $query .= "AND (spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
| 287 | - if ($id != '') $query .= "OR spotter_archive.flightaware_id = :id "; |
|
| 307 | + if ($usecoord) { |
|
| 308 | + $query .= "AND (spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
| 309 | + } |
|
| 310 | + if ($id != '') { |
|
| 311 | + $query .= "OR spotter_archive.flightaware_id = :id "; |
|
| 312 | + } |
|
| 288 | 313 | $query .= "UNION |
| 289 | 314 | 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, spotter_live.registration |
| 290 | 315 | FROM spotter_live".$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date"; |
| 291 | - if ($usecoord) $query .= " AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")"; |
|
| 292 | - if ($id != '') $query .= " OR spotter_live.flightaware_id = :id"; |
|
| 316 | + if ($usecoord) { |
|
| 317 | + $query .= " AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")"; |
|
| 318 | + } |
|
| 319 | + if ($id != '') { |
|
| 320 | + $query .= " OR spotter_live.flightaware_id = :id"; |
|
| 321 | + } |
|
| 293 | 322 | //if ($limit > 0) $query .= " LIMIT ".$limit; |
| 294 | 323 | $query .= ") AS spotter |
| 295 | 324 | WHERE latitude <> '0' AND longitude <> '0' |
| 296 | 325 | ORDER BY flightaware_id, date"; |
| 297 | - if ($limit > 0) $query .= " LIMIT ".$limit; |
|
| 326 | + if ($limit > 0) { |
|
| 327 | + $query .= " LIMIT ".$limit; |
|
| 328 | + } |
|
| 298 | 329 | } else { |
| 299 | 330 | $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, spotter_live.registration |
| 300 | 331 | FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date "; |
| 301 | - if ($usecoord) $query .= "AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
| 302 | - if ($id != '') $query .= "OR spotter_live.flightaware_id = :id "; |
|
| 332 | + if ($usecoord) { |
|
| 333 | + $query .= "AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
| 334 | + } |
|
| 335 | + if ($id != '') { |
|
| 336 | + $query .= "OR spotter_live.flightaware_id = :id "; |
|
| 337 | + } |
|
| 303 | 338 | $query .= "AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
| 304 | 339 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
| 305 | - if ($limit > 0) $query .= " LIMIT ".$limit; |
|
| 340 | + if ($limit > 0) { |
|
| 341 | + $query .= " LIMIT ".$limit; |
|
| 342 | + } |
|
| 306 | 343 | } |
| 307 | 344 | } else { |
| 308 | 345 | if (isset($globalArchive) && $globalArchive === TRUE) { |
@@ -320,29 +357,47 @@ discard block |
||
| 320 | 357 | FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date"; |
| 321 | 358 | //if ($limit > 0) $query .= " ORDER BY spotter_live.date ASC LIMIT ".$limit; |
| 322 | 359 | $query .= ") l ON l.flightaware_id = spotter_archive.flightaware_id "; |
| 323 | - if ($usecoord) $query .= "AND (spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
| 324 | - if ($id != '') $query .= "OR spotter_archive.flightaware_id = :id "; |
|
| 360 | + if ($usecoord) { |
|
| 361 | + $query .= "AND (spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
| 362 | + } |
|
| 363 | + if ($id != '') { |
|
| 364 | + $query .= "OR spotter_archive.flightaware_id = :id "; |
|
| 365 | + } |
|
| 325 | 366 | $query .= "UNION |
| 326 | 367 | 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, spotter_live.registration |
| 327 | 368 | FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date"; |
| 328 | - if ($usecoord) $query .= " AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")"; |
|
| 329 | - if ($id != '') $query .= " OR spotter_live.flightaware_id = :id"; |
|
| 369 | + if ($usecoord) { |
|
| 370 | + $query .= " AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")"; |
|
| 371 | + } |
|
| 372 | + if ($id != '') { |
|
| 373 | + $query .= " OR spotter_live.flightaware_id = :id"; |
|
| 374 | + } |
|
| 330 | 375 | //if ($limit > 0) $query .= " ORDER BY date ASC LIMIT ".$limit; |
| 331 | 376 | $query .= ") AS spotter WHERE latitude <> '0' AND longitude <> '0' "; |
| 332 | 377 | $query .= "ORDER BY flightaware_id, date"; |
| 333 | - if ($limit > 0) $query .= " LIMIT ".$limit; |
|
| 378 | + if ($limit > 0) { |
|
| 379 | + $query .= " LIMIT ".$limit; |
|
| 380 | + } |
|
| 334 | 381 | } else { |
| 335 | 382 | $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, spotter_live.registration |
| 336 | 383 | FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date "; |
| 337 | - if ($usecoord) $query .= "AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
| 338 | - if ($id != '') $query .= "OR spotter_live.flightaware_id = :id "; |
|
| 384 | + if ($usecoord) { |
|
| 385 | + $query .= "AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
| 386 | + } |
|
| 387 | + if ($id != '') { |
|
| 388 | + $query .= "OR spotter_live.flightaware_id = :id "; |
|
| 389 | + } |
|
| 339 | 390 | $query .= "AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
| 340 | 391 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
| 341 | - if ($limit > 0) $query .= " LIMIT ".$limit; |
|
| 392 | + if ($limit > 0) { |
|
| 393 | + $query .= " LIMIT ".$limit; |
|
| 394 | + } |
|
| 342 | 395 | } |
| 343 | 396 | } |
| 344 | 397 | $query_values = array(); |
| 345 | - if ($id != '') $query_values = array(':id' => $id); |
|
| 398 | + if ($id != '') { |
|
| 399 | + $query_values = array(':id' => $id); |
|
| 400 | + } |
|
| 346 | 401 | try { |
| 347 | 402 | $sth = $this->db->prepare($query); |
| 348 | 403 | $sth->execute($query_values); |
@@ -369,9 +424,15 @@ discard block |
||
| 369 | 424 | $id = filter_var($id,FILTER_SANITIZE_STRING); |
| 370 | 425 | $filter_query = $this->getFilter($filter,true,true); |
| 371 | 426 | |
| 372 | - if (!isset($globalLiveInterval) || $globalLiveInterval == '') $globalLiveInterval = '200'; |
|
| 373 | - if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAircraftsLimit == '') $globalMap3DAircraftsLimit = '300'; |
|
| 374 | - if ($limit == 0 || $limit == '') $limit = $globalMap3DAircraftsLimit; |
|
| 427 | + if (!isset($globalLiveInterval) || $globalLiveInterval == '') { |
|
| 428 | + $globalLiveInterval = '200'; |
|
| 429 | + } |
|
| 430 | + if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAircraftsLimit == '') { |
|
| 431 | + $globalMap3DAircraftsLimit = '300'; |
|
| 432 | + } |
|
| 433 | + if ($limit == 0 || $limit == '') { |
|
| 434 | + $limit = $globalMap3DAircraftsLimit; |
|
| 435 | + } |
|
| 375 | 436 | if ($globalDBdriver == 'mysql') { |
| 376 | 437 | if (isset($globalArchive) && $globalArchive === TRUE) { |
| 377 | 438 | $query = 'SELECT * FROM (SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source, spotter_archive.registration |
@@ -382,13 +443,17 @@ discard block |
||
| 382 | 443 | $query .= ") AS spotter |
| 383 | 444 | WHERE latitude <> '0' AND longitude <> '0' |
| 384 | 445 | ORDER BY flightaware_id, date"; |
| 385 | - if ($limit > 0) $query .= " LIMIT ".$limit; |
|
| 446 | + if ($limit > 0) { |
|
| 447 | + $query .= " LIMIT ".$limit; |
|
| 448 | + } |
|
| 386 | 449 | } else { |
| 387 | 450 | $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, spotter_live.registration |
| 388 | 451 | FROM spotter_live'.$filter_query.' spotter_live.flightaware_id = :id '; |
| 389 | 452 | $query .= "AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
| 390 | 453 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
| 391 | - if ($limit > 0) $query .= " LIMIT ".$limit; |
|
| 454 | + if ($limit > 0) { |
|
| 455 | + $query .= " LIMIT ".$limit; |
|
| 456 | + } |
|
| 392 | 457 | } |
| 393 | 458 | } else { |
| 394 | 459 | if (isset($globalArchive) && $globalArchive === TRUE) { |
@@ -404,13 +469,17 @@ discard block |
||
| 404 | 469 | FROM spotter_live".$filter_query." spotter_live.flightaware_id = :id"; |
| 405 | 470 | $query .= ") AS spotter WHERE latitude <> '0' AND longitude <> '0' "; |
| 406 | 471 | $query .= "ORDER BY flightaware_id, date"; |
| 407 | - if ($limit > 0) $query .= " LIMIT ".$limit; |
|
| 472 | + if ($limit > 0) { |
|
| 473 | + $query .= " LIMIT ".$limit; |
|
| 474 | + } |
|
| 408 | 475 | } else { |
| 409 | 476 | $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, spotter_live.registration |
| 410 | 477 | FROM spotter_live".$filter_query." spotter_live.flightaware_id = :id "; |
| 411 | 478 | $query .= "AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
| 412 | 479 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
| 413 | - if ($limit > 0) $query .= " LIMIT ".$limit; |
|
| 480 | + if ($limit > 0) { |
|
| 481 | + $query .= " LIMIT ".$limit; |
|
| 482 | + } |
|
| 414 | 483 | } |
| 415 | 484 | } |
| 416 | 485 | $query_values = array(); |
@@ -437,7 +506,9 @@ discard block |
||
| 437 | 506 | global $globalDBdriver, $globalLiveInterval; |
| 438 | 507 | $filter_query = $this->getFilter($filter,true,true); |
| 439 | 508 | |
| 440 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 509 | + if (!isset($globalLiveInterval)) { |
|
| 510 | + $globalLiveInterval = '200'; |
|
| 511 | + } |
|
| 441 | 512 | if ($globalDBdriver == 'mysql') { |
| 442 | 513 | //$query = 'SELECT COUNT(*) as nb 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; |
| 443 | 514 | $query = 'SELECT COUNT(DISTINCT spotter_live.flightaware_id) as nb FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
@@ -468,7 +539,9 @@ discard block |
||
| 468 | 539 | { |
| 469 | 540 | global $globalDBdriver, $globalLiveInterval,$globalMap2DAircraftsLimit; |
| 470 | 541 | $Spotter = new Spotter($this->db); |
| 471 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 542 | + if (!isset($globalLiveInterval)) { |
|
| 543 | + $globalLiveInterval = '200'; |
|
| 544 | + } |
|
| 472 | 545 | $filter_query = $this->getFilter($filter); |
| 473 | 546 | |
| 474 | 547 | if (is_array($coord)) { |
@@ -476,7 +549,9 @@ discard block |
||
| 476 | 549 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 477 | 550 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 478 | 551 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 479 | - } else return array(); |
|
| 552 | + } else { |
|
| 553 | + return array(); |
|
| 554 | + } |
|
| 480 | 555 | if ($globalDBdriver == 'mysql') { |
| 481 | 556 | $query = 'SELECT spotter_live.* 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.' GROUP BY spotter_live.flightaware_id'.$filter_query; |
| 482 | 557 | } else { |
@@ -502,7 +577,9 @@ discard block |
||
| 502 | 577 | { |
| 503 | 578 | global $globalDBdriver, $globalLiveInterval, $globalArchive,$globalMap2DAircraftsLimit; |
| 504 | 579 | $Spotter = new Spotter($this->db); |
| 505 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 580 | + if (!isset($globalLiveInterval)) { |
|
| 581 | + $globalLiveInterval = '200'; |
|
| 582 | + } |
|
| 506 | 583 | $filter_query = $this->getFilter($filter,true,true); |
| 507 | 584 | |
| 508 | 585 | if (is_array($coord)) { |
@@ -510,7 +587,9 @@ discard block |
||
| 510 | 587 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 511 | 588 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 512 | 589 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 513 | - } else return array(); |
|
| 590 | + } else { |
|
| 591 | + return array(); |
|
| 592 | + } |
|
| 514 | 593 | if ($globalDBdriver == 'mysql') { |
| 515 | 594 | if (isset($globalArchive) && $globalArchive === TRUE) { |
| 516 | 595 | $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.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
@@ -765,11 +844,15 @@ discard block |
||
| 765 | 844 | //$query = self::$global_query.' WHERE spotter_live.flightaware_id = :id ORDER BY date'; |
| 766 | 845 | if ($globalDBdriver == 'mysql') { |
| 767 | 846 | $query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id'; |
| 768 | - if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
| 847 | + if ($liveinterval) { |
|
| 848 | + $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
| 849 | + } |
|
| 769 | 850 | $query .= ' ORDER BY date'; |
| 770 | 851 | } else { |
| 771 | 852 | $query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id'; |
| 772 | - if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
| 853 | + if ($liveinterval) { |
|
| 854 | + $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
| 855 | + } |
|
| 773 | 856 | $query .= ' ORDER BY date'; |
| 774 | 857 | } |
| 775 | 858 | |
@@ -864,7 +947,9 @@ discard block |
||
| 864 | 947 | $i++; |
| 865 | 948 | $j++; |
| 866 | 949 | if ($j == 30) { |
| 867 | - if ($globalDebug) echo "."; |
|
| 950 | + if ($globalDebug) { |
|
| 951 | + echo "."; |
|
| 952 | + } |
|
| 868 | 953 | try { |
| 869 | 954 | |
| 870 | 955 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
@@ -1239,7 +1324,9 @@ discard block |
||
| 1239 | 1324 | { |
| 1240 | 1325 | return false; |
| 1241 | 1326 | } |
| 1242 | - } else return ''; |
|
| 1327 | + } else { |
|
| 1328 | + return ''; |
|
| 1329 | + } |
|
| 1243 | 1330 | |
| 1244 | 1331 | if ($longitude != '') |
| 1245 | 1332 | { |
@@ -1247,7 +1334,9 @@ discard block |
||
| 1247 | 1334 | { |
| 1248 | 1335 | return false; |
| 1249 | 1336 | } |
| 1250 | - } else return ''; |
|
| 1337 | + } else { |
|
| 1338 | + return ''; |
|
| 1339 | + } |
|
| 1251 | 1340 | |
| 1252 | 1341 | if ($waypoints != '') |
| 1253 | 1342 | { |
@@ -1263,14 +1352,18 @@ discard block |
||
| 1263 | 1352 | { |
| 1264 | 1353 | return false; |
| 1265 | 1354 | } |
| 1266 | - } else $altitude = 0; |
|
| 1355 | + } else { |
|
| 1356 | + $altitude = 0; |
|
| 1357 | + } |
|
| 1267 | 1358 | if ($altitude_real != '') |
| 1268 | 1359 | { |
| 1269 | 1360 | if (!is_numeric($altitude_real)) |
| 1270 | 1361 | { |
| 1271 | 1362 | return false; |
| 1272 | 1363 | } |
| 1273 | - } else $altitude_real = 0; |
|
| 1364 | + } else { |
|
| 1365 | + $altitude_real = 0; |
|
| 1366 | + } |
|
| 1274 | 1367 | |
| 1275 | 1368 | if ($heading != '') |
| 1276 | 1369 | { |
@@ -1278,7 +1371,9 @@ discard block |
||
| 1278 | 1371 | { |
| 1279 | 1372 | return false; |
| 1280 | 1373 | } |
| 1281 | - } else $heading = 0; |
|
| 1374 | + } else { |
|
| 1375 | + $heading = 0; |
|
| 1376 | + } |
|
| 1282 | 1377 | |
| 1283 | 1378 | if ($groundspeed != '') |
| 1284 | 1379 | { |
@@ -1286,9 +1381,13 @@ discard block |
||
| 1286 | 1381 | { |
| 1287 | 1382 | return false; |
| 1288 | 1383 | } |
| 1289 | - } else $groundspeed = 0; |
|
| 1384 | + } else { |
|
| 1385 | + $groundspeed = 0; |
|
| 1386 | + } |
|
| 1290 | 1387 | date_default_timezone_set('UTC'); |
| 1291 | - if ($date == '') $date = date("Y-m-d H:i:s", time()); |
|
| 1388 | + if ($date == '') { |
|
| 1389 | + $date = date("Y-m-d H:i:s", time()); |
|
| 1390 | + } |
|
| 1292 | 1391 | |
| 1293 | 1392 | |
| 1294 | 1393 | $flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING); |
@@ -1333,14 +1432,24 @@ discard block |
||
| 1333 | 1432 | $arrival_airport_country = ''; |
| 1334 | 1433 | |
| 1335 | 1434 | |
| 1336 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
| 1337 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
| 1338 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 1339 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 1435 | + if ($squawk == '' || $Common->isInteger($squawk) === false ) { |
|
| 1436 | + $squawk = NULL; |
|
| 1437 | + } |
|
| 1438 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) { |
|
| 1439 | + $verticalrate = NULL; |
|
| 1440 | + } |
|
| 1441 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) { |
|
| 1442 | + $groundspeed = 0; |
|
| 1443 | + } |
|
| 1444 | + if ($heading == '' || $Common->isInteger($heading) === false ) { |
|
| 1445 | + $heading = 0; |
|
| 1446 | + } |
|
| 1340 | 1447 | |
| 1341 | 1448 | $query = ''; |
| 1342 | 1449 | if ($globalArchive) { |
| 1343 | - if ($globalDebug) echo '-- Delete previous data -- '; |
|
| 1450 | + if ($globalDebug) { |
|
| 1451 | + echo '-- Delete previous data -- '; |
|
| 1452 | + } |
|
| 1344 | 1453 | $query .= 'DELETE FROM spotter_live WHERE flightaware_id = :flightaware_id;'; |
| 1345 | 1454 | } |
| 1346 | 1455 | |
@@ -1357,10 +1466,14 @@ discard block |
||
| 1357 | 1466 | return "error : ".$e->getMessage(); |
| 1358 | 1467 | } |
| 1359 | 1468 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
| 1360 | - if ($globalDebug) echo '(Add to Spotter archive : '; |
|
| 1469 | + if ($globalDebug) { |
|
| 1470 | + echo '(Add to Spotter archive : '; |
|
| 1471 | + } |
|
| 1361 | 1472 | $SpotterArchive = new SpotterArchive($this->db); |
| 1362 | 1473 | $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, $altitude_real,$heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
| 1363 | - if ($globalDebug) echo $result.')'; |
|
| 1474 | + if ($globalDebug) { |
|
| 1475 | + echo $result.')'; |
|
| 1476 | + } |
|
| 1364 | 1477 | } elseif ($globalDebug && $putinarchive !== true) { |
| 1365 | 1478 | echo '(Not adding to archive)'; |
| 1366 | 1479 | } elseif ($globalDebug && $noarchive === true) { |
@@ -9,13 +9,13 @@ discard block |
||
| 9 | 9 | if ($this->db === null) die('Error: No DB connection. (SpotterArchive)'); |
| 10 | 10 | } |
| 11 | 11 | |
| 12 | - /** |
|
| 13 | - * Get SQL query part for filter used |
|
| 14 | - * @param array $filter the filter |
|
| 15 | - * @param bool $where |
|
| 16 | - * @param bool $and |
|
| 17 | - * @return string the SQL part |
|
| 18 | - */ |
|
| 12 | + /** |
|
| 13 | + * Get SQL query part for filter used |
|
| 14 | + * @param array $filter the filter |
|
| 15 | + * @param bool $where |
|
| 16 | + * @param bool $and |
|
| 17 | + * @return string the SQL part |
|
| 18 | + */ |
|
| 19 | 19 | public function getFilter($filter = array(),$where = false,$and = false) { |
| 20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
| 21 | 21 | $filters = array(); |
@@ -160,12 +160,12 @@ discard block |
||
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | |
| 163 | - /** |
|
| 164 | - * Gets all the spotter information based on a particular callsign |
|
| 165 | - * |
|
| 166 | - * @param $ident |
|
| 167 | - * @return array the spotter information |
|
| 168 | - */ |
|
| 163 | + /** |
|
| 164 | + * Gets all the spotter information based on a particular callsign |
|
| 165 | + * |
|
| 166 | + * @param $ident |
|
| 167 | + * @return array the spotter information |
|
| 168 | + */ |
|
| 169 | 169 | public function getLastArchiveSpotterDataByIdent($ident) { |
| 170 | 170 | $Spotter = new Spotter($this->db); |
| 171 | 171 | date_default_timezone_set('UTC'); |
@@ -180,12 +180,12 @@ discard block |
||
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | |
| 183 | - /** |
|
| 184 | - * Gets last the spotter information based on a particular id |
|
| 185 | - * |
|
| 186 | - * @param $id |
|
| 187 | - * @return array the spotter information |
|
| 188 | - */ |
|
| 183 | + /** |
|
| 184 | + * Gets last the spotter information based on a particular id |
|
| 185 | + * |
|
| 186 | + * @param $id |
|
| 187 | + * @return array the spotter information |
|
| 188 | + */ |
|
| 189 | 189 | public function getLastArchiveSpotterDataById($id) { |
| 190 | 190 | $Spotter = new Spotter($this->db); |
| 191 | 191 | date_default_timezone_set('UTC'); |
@@ -210,12 +210,12 @@ discard block |
||
| 210 | 210 | return $spotter_array; |
| 211 | 211 | } |
| 212 | 212 | |
| 213 | - /** |
|
| 214 | - * Gets all the spotter information based on a particular id |
|
| 215 | - * |
|
| 216 | - * @param $id |
|
| 217 | - * @return array the spotter information |
|
| 218 | - */ |
|
| 213 | + /** |
|
| 214 | + * Gets all the spotter information based on a particular id |
|
| 215 | + * |
|
| 216 | + * @param $id |
|
| 217 | + * @return array the spotter information |
|
| 218 | + */ |
|
| 219 | 219 | public function getAllArchiveSpotterDataById($id) { |
| 220 | 220 | date_default_timezone_set('UTC'); |
| 221 | 221 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
@@ -235,12 +235,12 @@ discard block |
||
| 235 | 235 | return $spotter_array; |
| 236 | 236 | } |
| 237 | 237 | |
| 238 | - /** |
|
| 239 | - * Gets coordinate & time spotter information based on a particular id |
|
| 240 | - * |
|
| 241 | - * @param $id |
|
| 242 | - * @return array the spotter information |
|
| 243 | - */ |
|
| 238 | + /** |
|
| 239 | + * Gets coordinate & time spotter information based on a particular id |
|
| 240 | + * |
|
| 241 | + * @param $id |
|
| 242 | + * @return array the spotter information |
|
| 243 | + */ |
|
| 244 | 244 | public function getCoordArchiveSpotterDataById($id) { |
| 245 | 245 | date_default_timezone_set('UTC'); |
| 246 | 246 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
@@ -256,14 +256,14 @@ discard block |
||
| 256 | 256 | return $spotter_array; |
| 257 | 257 | } |
| 258 | 258 | |
| 259 | - /** |
|
| 260 | - * Gets coordinate & time spotter information based on a particular id |
|
| 261 | - * |
|
| 262 | - * @param $id |
|
| 263 | - * @param $begindate |
|
| 264 | - * @param $enddate |
|
| 265 | - * @return array the spotter information |
|
| 266 | - */ |
|
| 259 | + /** |
|
| 260 | + * Gets coordinate & time spotter information based on a particular id |
|
| 261 | + * |
|
| 262 | + * @param $id |
|
| 263 | + * @param $begindate |
|
| 264 | + * @param $enddate |
|
| 265 | + * @return array the spotter information |
|
| 266 | + */ |
|
| 267 | 267 | public function getCoordArchiveSpotterDataByIdDate($id,$begindate,$enddate) { |
| 268 | 268 | date_default_timezone_set('UTC'); |
| 269 | 269 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
@@ -280,12 +280,12 @@ discard block |
||
| 280 | 280 | } |
| 281 | 281 | |
| 282 | 282 | |
| 283 | - /** |
|
| 284 | - * Gets altitude information based on a particular callsign |
|
| 285 | - * |
|
| 286 | - * @param $ident |
|
| 287 | - * @return array the spotter information |
|
| 288 | - */ |
|
| 283 | + /** |
|
| 284 | + * Gets altitude information based on a particular callsign |
|
| 285 | + * |
|
| 286 | + * @param $ident |
|
| 287 | + * @return array the spotter information |
|
| 288 | + */ |
|
| 289 | 289 | public function getAltitudeArchiveSpotterDataByIdent($ident) { |
| 290 | 290 | |
| 291 | 291 | date_default_timezone_set('UTC'); |
@@ -305,12 +305,12 @@ discard block |
||
| 305 | 305 | return $spotter_array; |
| 306 | 306 | } |
| 307 | 307 | |
| 308 | - /** |
|
| 309 | - * Gets altitude information based on a particular id |
|
| 310 | - * |
|
| 311 | - * @param $id |
|
| 312 | - * @return array the spotter information |
|
| 313 | - */ |
|
| 308 | + /** |
|
| 309 | + * Gets altitude information based on a particular id |
|
| 310 | + * |
|
| 311 | + * @param $id |
|
| 312 | + * @return array the spotter information |
|
| 313 | + */ |
|
| 314 | 314 | public function getAltitudeArchiveSpotterDataById($id) { |
| 315 | 315 | |
| 316 | 316 | date_default_timezone_set('UTC'); |
@@ -330,12 +330,12 @@ discard block |
||
| 330 | 330 | return $spotter_array; |
| 331 | 331 | } |
| 332 | 332 | |
| 333 | - /** |
|
| 334 | - * Gets altitude & speed information based on a particular id |
|
| 335 | - * |
|
| 336 | - * @param $id |
|
| 337 | - * @return array the spotter information |
|
| 338 | - */ |
|
| 333 | + /** |
|
| 334 | + * Gets altitude & speed information based on a particular id |
|
| 335 | + * |
|
| 336 | + * @param $id |
|
| 337 | + * @return array the spotter information |
|
| 338 | + */ |
|
| 339 | 339 | public function getAltitudeSpeedArchiveSpotterDataById($id) { |
| 340 | 340 | date_default_timezone_set('UTC'); |
| 341 | 341 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
@@ -351,12 +351,12 @@ discard block |
||
| 351 | 351 | return $spotter_array; |
| 352 | 352 | } |
| 353 | 353 | |
| 354 | - /** |
|
| 355 | - * Gets altitude information based on a particular callsign |
|
| 356 | - * |
|
| 357 | - * @param $ident |
|
| 358 | - * @return array the spotter information |
|
| 359 | - */ |
|
| 354 | + /** |
|
| 355 | + * Gets altitude information based on a particular callsign |
|
| 356 | + * |
|
| 357 | + * @param $ident |
|
| 358 | + * @return array the spotter information |
|
| 359 | + */ |
|
| 360 | 360 | public function getLastAltitudeArchiveSpotterDataByIdent($ident) { |
| 361 | 361 | date_default_timezone_set('UTC'); |
| 362 | 362 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
@@ -374,14 +374,14 @@ discard block |
||
| 374 | 374 | } |
| 375 | 375 | |
| 376 | 376 | |
| 377 | - /** |
|
| 378 | - * Gets all the archive spotter information |
|
| 379 | - * |
|
| 380 | - * @param $ident |
|
| 381 | - * @param $flightaware_id |
|
| 382 | - * @param $date |
|
| 383 | - * @return array the spotter information |
|
| 384 | - */ |
|
| 377 | + /** |
|
| 378 | + * Gets all the archive spotter information |
|
| 379 | + * |
|
| 380 | + * @param $ident |
|
| 381 | + * @param $flightaware_id |
|
| 382 | + * @param $date |
|
| 383 | + * @return array the spotter information |
|
| 384 | + */ |
|
| 385 | 385 | public function getSpotterArchiveData($ident,$flightaware_id,$date) { |
| 386 | 386 | $Spotter = new Spotter($this->db); |
| 387 | 387 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
@@ -406,11 +406,11 @@ discard block |
||
| 406 | 406 | } |
| 407 | 407 | } |
| 408 | 408 | |
| 409 | - /** |
|
| 410 | - * Delete row in spotter_archive table based on flightaware_id |
|
| 411 | - * @param $id flightaware_id |
|
| 412 | - */ |
|
| 413 | - public function deleteSpotterArchiveTrackDataByID($id) { |
|
| 409 | + /** |
|
| 410 | + * Delete row in spotter_archive table based on flightaware_id |
|
| 411 | + * @param $id flightaware_id |
|
| 412 | + */ |
|
| 413 | + public function deleteSpotterArchiveTrackDataByID($id) { |
|
| 414 | 414 | global $globalArchiveKeepTrackMonths, $globalDBdriver; |
| 415 | 415 | $query = 'DELETE FROM spotter_archive WHERE spotter_archive.flightaware_id = :id'; |
| 416 | 416 | try { |
@@ -422,15 +422,15 @@ discard block |
||
| 422 | 422 | } |
| 423 | 423 | } |
| 424 | 424 | |
| 425 | - /** |
|
| 426 | - * Gets Minimal Live Spotter data |
|
| 427 | - * |
|
| 428 | - * @param $begindate |
|
| 429 | - * @param $enddate |
|
| 430 | - * @param array $filter |
|
| 431 | - * @param int $part |
|
| 432 | - * @return array the spotter information |
|
| 433 | - */ |
|
| 425 | + /** |
|
| 426 | + * Gets Minimal Live Spotter data |
|
| 427 | + * |
|
| 428 | + * @param $begindate |
|
| 429 | + * @param $enddate |
|
| 430 | + * @param array $filter |
|
| 431 | + * @param int $part |
|
| 432 | + * @return array the spotter information |
|
| 433 | + */ |
|
| 434 | 434 | public function getMinLiveSpotterData($begindate,$enddate,$filter = array(),$part = 0) { |
| 435 | 435 | global $globalDBdriver; |
| 436 | 436 | date_default_timezone_set('UTC'); |
@@ -481,14 +481,14 @@ discard block |
||
| 481 | 481 | return $spotter_array; |
| 482 | 482 | } |
| 483 | 483 | |
| 484 | - /** |
|
| 485 | - * Gets Minimal Live Spotter data |
|
| 486 | - * |
|
| 487 | - * @param $begindate |
|
| 488 | - * @param $enddate |
|
| 489 | - * @param array $filter |
|
| 490 | - * @return array the spotter information |
|
| 491 | - */ |
|
| 484 | + /** |
|
| 485 | + * Gets Minimal Live Spotter data |
|
| 486 | + * |
|
| 487 | + * @param $begindate |
|
| 488 | + * @param $enddate |
|
| 489 | + * @param array $filter |
|
| 490 | + * @return array the spotter information |
|
| 491 | + */ |
|
| 492 | 492 | public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array()) { |
| 493 | 493 | global $globalDBdriver; |
| 494 | 494 | date_default_timezone_set('UTC'); |
@@ -554,14 +554,14 @@ discard block |
||
| 554 | 554 | return $spotter_array; |
| 555 | 555 | } |
| 556 | 556 | |
| 557 | - /** |
|
| 558 | - * Gets count Live Spotter data |
|
| 559 | - * |
|
| 560 | - * @param $begindate |
|
| 561 | - * @param $enddate |
|
| 562 | - * @param array $filter |
|
| 563 | - * @return array the spotter information |
|
| 564 | - */ |
|
| 557 | + /** |
|
| 558 | + * Gets count Live Spotter data |
|
| 559 | + * |
|
| 560 | + * @param $begindate |
|
| 561 | + * @param $enddate |
|
| 562 | + * @param array $filter |
|
| 563 | + * @return array the spotter information |
|
| 564 | + */ |
|
| 565 | 565 | public function getLiveSpotterCount($begindate,$enddate,$filter = array()) { |
| 566 | 566 | global $globalDBdriver, $globalLiveInterval; |
| 567 | 567 | date_default_timezone_set('UTC'); |
@@ -606,36 +606,36 @@ discard block |
||
| 606 | 606 | |
| 607 | 607 | // Spotter_Archive_output |
| 608 | 608 | |
| 609 | - /** |
|
| 610 | - * Gets all the spotter information |
|
| 611 | - * |
|
| 612 | - * @param string $q |
|
| 613 | - * @param string $registration |
|
| 614 | - * @param string $aircraft_icao |
|
| 615 | - * @param string $aircraft_manufacturer |
|
| 616 | - * @param string $highlights |
|
| 617 | - * @param string $airline_icao |
|
| 618 | - * @param string $airline_country |
|
| 619 | - * @param string $airline_type |
|
| 620 | - * @param string $airport |
|
| 621 | - * @param string $airport_country |
|
| 622 | - * @param string $callsign |
|
| 623 | - * @param string $departure_airport_route |
|
| 624 | - * @param string $arrival_airport_route |
|
| 625 | - * @param string $owner |
|
| 626 | - * @param string $pilot_id |
|
| 627 | - * @param string $pilot_name |
|
| 628 | - * @param string $altitude |
|
| 629 | - * @param string $date_posted |
|
| 630 | - * @param string $limit |
|
| 631 | - * @param string $sort |
|
| 632 | - * @param string $includegeodata |
|
| 633 | - * @param string $origLat |
|
| 634 | - * @param string $origLon |
|
| 635 | - * @param string $dist |
|
| 636 | - * @param array $filters |
|
| 637 | - * @return array the spotter information |
|
| 638 | - */ |
|
| 609 | + /** |
|
| 610 | + * Gets all the spotter information |
|
| 611 | + * |
|
| 612 | + * @param string $q |
|
| 613 | + * @param string $registration |
|
| 614 | + * @param string $aircraft_icao |
|
| 615 | + * @param string $aircraft_manufacturer |
|
| 616 | + * @param string $highlights |
|
| 617 | + * @param string $airline_icao |
|
| 618 | + * @param string $airline_country |
|
| 619 | + * @param string $airline_type |
|
| 620 | + * @param string $airport |
|
| 621 | + * @param string $airport_country |
|
| 622 | + * @param string $callsign |
|
| 623 | + * @param string $departure_airport_route |
|
| 624 | + * @param string $arrival_airport_route |
|
| 625 | + * @param string $owner |
|
| 626 | + * @param string $pilot_id |
|
| 627 | + * @param string $pilot_name |
|
| 628 | + * @param string $altitude |
|
| 629 | + * @param string $date_posted |
|
| 630 | + * @param string $limit |
|
| 631 | + * @param string $sort |
|
| 632 | + * @param string $includegeodata |
|
| 633 | + * @param string $origLat |
|
| 634 | + * @param string $origLon |
|
| 635 | + * @param string $dist |
|
| 636 | + * @param array $filters |
|
| 637 | + * @return array the spotter information |
|
| 638 | + */ |
|
| 639 | 639 | public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array()) { |
| 640 | 640 | global $globalTimezone, $globalDBdriver; |
| 641 | 641 | require_once(dirname(__FILE__).'/class.Translation.php'); |
@@ -927,14 +927,14 @@ discard block |
||
| 927 | 927 | } |
| 928 | 928 | } |
| 929 | 929 | |
| 930 | - /** |
|
| 931 | - * Gets all the spotter information based on the callsign |
|
| 932 | - * |
|
| 933 | - * @param string $ident |
|
| 934 | - * @param string $limit |
|
| 935 | - * @param string $sort |
|
| 936 | - * @return array the spotter information |
|
| 937 | - */ |
|
| 930 | + /** |
|
| 931 | + * Gets all the spotter information based on the callsign |
|
| 932 | + * |
|
| 933 | + * @param string $ident |
|
| 934 | + * @param string $limit |
|
| 935 | + * @param string $sort |
|
| 936 | + * @return array the spotter information |
|
| 937 | + */ |
|
| 938 | 938 | public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '') { |
| 939 | 939 | $global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output"; |
| 940 | 940 | |
@@ -981,15 +981,15 @@ discard block |
||
| 981 | 981 | } |
| 982 | 982 | |
| 983 | 983 | |
| 984 | - /** |
|
| 985 | - * Gets all the spotter information based on the owner |
|
| 986 | - * |
|
| 987 | - * @param string $owner |
|
| 988 | - * @param string $limit |
|
| 989 | - * @param string $sort |
|
| 990 | - * @param array $filter |
|
| 991 | - * @return array the spotter information |
|
| 992 | - */ |
|
| 984 | + /** |
|
| 985 | + * Gets all the spotter information based on the owner |
|
| 986 | + * |
|
| 987 | + * @param string $owner |
|
| 988 | + * @param string $limit |
|
| 989 | + * @param string $sort |
|
| 990 | + * @param array $filter |
|
| 991 | + * @return array the spotter information |
|
| 992 | + */ |
|
| 993 | 993 | public function getSpotterDataByOwner($owner = '', $limit = '', $sort = '', $filter = array()) { |
| 994 | 994 | $global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output"; |
| 995 | 995 | |
@@ -1036,15 +1036,15 @@ discard block |
||
| 1036 | 1036 | return $spotter_array; |
| 1037 | 1037 | } |
| 1038 | 1038 | |
| 1039 | - /** |
|
| 1040 | - * Gets all the spotter information based on the pilot |
|
| 1041 | - * |
|
| 1042 | - * @param string $pilot |
|
| 1043 | - * @param string $limit |
|
| 1044 | - * @param string $sort |
|
| 1045 | - * @param array $filter |
|
| 1046 | - * @return array the spotter information |
|
| 1047 | - */ |
|
| 1039 | + /** |
|
| 1040 | + * Gets all the spotter information based on the pilot |
|
| 1041 | + * |
|
| 1042 | + * @param string $pilot |
|
| 1043 | + * @param string $limit |
|
| 1044 | + * @param string $sort |
|
| 1045 | + * @param array $filter |
|
| 1046 | + * @return array the spotter information |
|
| 1047 | + */ |
|
| 1048 | 1048 | public function getSpotterDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array()) { |
| 1049 | 1049 | $global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output"; |
| 1050 | 1050 | |
@@ -1087,14 +1087,14 @@ discard block |
||
| 1087 | 1087 | return $spotter_array; |
| 1088 | 1088 | } |
| 1089 | 1089 | |
| 1090 | - /** |
|
| 1091 | - * Gets all number of flight over countries |
|
| 1092 | - * |
|
| 1093 | - * @param bool $limit |
|
| 1094 | - * @param int $olderthanmonths |
|
| 1095 | - * @param string $sincedate |
|
| 1096 | - * @return array the airline country list |
|
| 1097 | - */ |
|
| 1090 | + /** |
|
| 1091 | + * Gets all number of flight over countries |
|
| 1092 | + * |
|
| 1093 | + * @param bool $limit |
|
| 1094 | + * @param int $olderthanmonths |
|
| 1095 | + * @param string $sincedate |
|
| 1096 | + * @return array the airline country list |
|
| 1097 | + */ |
|
| 1098 | 1098 | public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') { |
| 1099 | 1099 | global $globalDBdriver; |
| 1100 | 1100 | /* |
@@ -1133,14 +1133,14 @@ discard block |
||
| 1133 | 1133 | return $flight_array; |
| 1134 | 1134 | } |
| 1135 | 1135 | |
| 1136 | - /** |
|
| 1137 | - * Gets all number of flight over countries |
|
| 1138 | - * |
|
| 1139 | - * @param bool $limit |
|
| 1140 | - * @param int $olderthanmonths |
|
| 1141 | - * @param string $sincedate |
|
| 1142 | - * @return array the airline country list |
|
| 1143 | - */ |
|
| 1136 | + /** |
|
| 1137 | + * Gets all number of flight over countries |
|
| 1138 | + * |
|
| 1139 | + * @param bool $limit |
|
| 1140 | + * @param int $olderthanmonths |
|
| 1141 | + * @param string $sincedate |
|
| 1142 | + * @return array the airline country list |
|
| 1143 | + */ |
|
| 1144 | 1144 | public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') { |
| 1145 | 1145 | global $globalDBdriver; |
| 1146 | 1146 | /* |
@@ -1180,13 +1180,13 @@ discard block |
||
| 1180 | 1180 | return $flight_array; |
| 1181 | 1181 | } |
| 1182 | 1182 | |
| 1183 | - /** |
|
| 1184 | - * Gets all aircraft types that have flown over by owner |
|
| 1185 | - * |
|
| 1186 | - * @param $owner |
|
| 1187 | - * @param array $filters |
|
| 1188 | - * @return array the aircraft list |
|
| 1189 | - */ |
|
| 1183 | + /** |
|
| 1184 | + * Gets all aircraft types that have flown over by owner |
|
| 1185 | + * |
|
| 1186 | + * @param $owner |
|
| 1187 | + * @param array $filters |
|
| 1188 | + * @return array the aircraft list |
|
| 1189 | + */ |
|
| 1190 | 1190 | public function countAllAircraftTypesByOwner($owner,$filters = array()) |
| 1191 | 1191 | { |
| 1192 | 1192 | $filter_query = $this->getFilter($filters,true,true); |
@@ -1202,13 +1202,13 @@ discard block |
||
| 1202 | 1202 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1203 | 1203 | } |
| 1204 | 1204 | |
| 1205 | - /** |
|
| 1206 | - * Gets all airlines by owner |
|
| 1207 | - * |
|
| 1208 | - * @param $owner |
|
| 1209 | - * @param array $filters |
|
| 1210 | - * @return array the airline list |
|
| 1211 | - */ |
|
| 1205 | + /** |
|
| 1206 | + * Gets all airlines by owner |
|
| 1207 | + * |
|
| 1208 | + * @param $owner |
|
| 1209 | + * @param array $filters |
|
| 1210 | + * @return array the airline list |
|
| 1211 | + */ |
|
| 1212 | 1212 | public function countAllAirlinesByOwner($owner,$filters = array()) |
| 1213 | 1213 | { |
| 1214 | 1214 | $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
@@ -1223,13 +1223,13 @@ discard block |
||
| 1223 | 1223 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1224 | 1224 | } |
| 1225 | 1225 | |
| 1226 | - /** |
|
| 1227 | - * Gets all arrival airports by country of the airplanes that have flown over based on a owner |
|
| 1228 | - * |
|
| 1229 | - * @param $owner |
|
| 1230 | - * @param array $filters |
|
| 1231 | - * @return array the airport list |
|
| 1232 | - */ |
|
| 1226 | + /** |
|
| 1227 | + * Gets all arrival airports by country of the airplanes that have flown over based on a owner |
|
| 1228 | + * |
|
| 1229 | + * @param $owner |
|
| 1230 | + * @param array $filters |
|
| 1231 | + * @return array the airport list |
|
| 1232 | + */ |
|
| 1233 | 1233 | public function countAllArrivalAirportCountriesByOwner($owner, $filters = array()) |
| 1234 | 1234 | { |
| 1235 | 1235 | $filter_query = $this->getFilter($filters,true,true); |
@@ -1243,13 +1243,13 @@ discard block |
||
| 1243 | 1243 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1244 | 1244 | } |
| 1245 | 1245 | |
| 1246 | - /** |
|
| 1247 | - * Gets all arrival airports of the airplanes that have flown over based on a owner |
|
| 1248 | - * |
|
| 1249 | - * @param $owner |
|
| 1250 | - * @param array $filters |
|
| 1251 | - * @return array the airport list |
|
| 1252 | - */ |
|
| 1246 | + /** |
|
| 1247 | + * Gets all arrival airports of the airplanes that have flown over based on a owner |
|
| 1248 | + * |
|
| 1249 | + * @param $owner |
|
| 1250 | + * @param array $filters |
|
| 1251 | + * @return array the airport list |
|
| 1252 | + */ |
|
| 1253 | 1253 | public function countAllArrivalAirportsByOwner($owner,$filters = array()) |
| 1254 | 1254 | { |
| 1255 | 1255 | $filter_query = $this->getFilter($filters,true,true); |
@@ -1274,13 +1274,13 @@ discard block |
||
| 1274 | 1274 | return $airport_array; |
| 1275 | 1275 | } |
| 1276 | 1276 | |
| 1277 | - /** |
|
| 1278 | - * Gets all departure airports by country of the airplanes that have flown over based on owner |
|
| 1279 | - * |
|
| 1280 | - * @param $owner |
|
| 1281 | - * @param array $filters |
|
| 1282 | - * @return array the airport list |
|
| 1283 | - */ |
|
| 1277 | + /** |
|
| 1278 | + * Gets all departure airports by country of the airplanes that have flown over based on owner |
|
| 1279 | + * |
|
| 1280 | + * @param $owner |
|
| 1281 | + * @param array $filters |
|
| 1282 | + * @return array the airport list |
|
| 1283 | + */ |
|
| 1284 | 1284 | public function countAllDepartureAirportCountriesByOwner($owner,$filters = array()) |
| 1285 | 1285 | { |
| 1286 | 1286 | $filter_query = $this->getFilter($filters,true,true); |
@@ -1294,13 +1294,13 @@ discard block |
||
| 1294 | 1294 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1295 | 1295 | } |
| 1296 | 1296 | |
| 1297 | - /** |
|
| 1298 | - * Gets all departure airports of the airplanes that have flown over based on a owner |
|
| 1299 | - * |
|
| 1300 | - * @param $owner |
|
| 1301 | - * @param array $filters |
|
| 1302 | - * @return array the airport list |
|
| 1303 | - */ |
|
| 1297 | + /** |
|
| 1298 | + * Gets all departure airports of the airplanes that have flown over based on a owner |
|
| 1299 | + * |
|
| 1300 | + * @param $owner |
|
| 1301 | + * @param array $filters |
|
| 1302 | + * @return array the airport list |
|
| 1303 | + */ |
|
| 1304 | 1304 | public function countAllDepartureAirportsByOwner($owner,$filters = array()) |
| 1305 | 1305 | { |
| 1306 | 1306 | $filter_query = $this->getFilter($filters,true,true); |
@@ -1327,13 +1327,13 @@ discard block |
||
| 1327 | 1327 | return $airport_array; |
| 1328 | 1328 | } |
| 1329 | 1329 | |
| 1330 | - /** |
|
| 1331 | - * Gets all aircraft manufacturer that have flown over by owner |
|
| 1332 | - * |
|
| 1333 | - * @param $owner |
|
| 1334 | - * @param array $filters |
|
| 1335 | - * @return array the aircraft manufacturer list |
|
| 1336 | - */ |
|
| 1330 | + /** |
|
| 1331 | + * Gets all aircraft manufacturer that have flown over by owner |
|
| 1332 | + * |
|
| 1333 | + * @param $owner |
|
| 1334 | + * @param array $filters |
|
| 1335 | + * @return array the aircraft manufacturer list |
|
| 1336 | + */ |
|
| 1337 | 1337 | public function countAllAircraftManufacturerByOwner($owner,$filters = array()) |
| 1338 | 1338 | { |
| 1339 | 1339 | $filter_query = $this->getFilter($filters,true,true); |
@@ -1349,13 +1349,13 @@ discard block |
||
| 1349 | 1349 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1350 | 1350 | } |
| 1351 | 1351 | |
| 1352 | - /** |
|
| 1353 | - * Gets all aircraft registration that have flown over by owner |
|
| 1354 | - * |
|
| 1355 | - * @param $owner |
|
| 1356 | - * @param array $filters |
|
| 1357 | - * @return array the aircraft list |
|
| 1358 | - */ |
|
| 1352 | + /** |
|
| 1353 | + * Gets all aircraft registration that have flown over by owner |
|
| 1354 | + * |
|
| 1355 | + * @param $owner |
|
| 1356 | + * @param array $filters |
|
| 1357 | + * @return array the aircraft list |
|
| 1358 | + */ |
|
| 1359 | 1359 | public function countAllAircraftRegistrationByOwner($owner,$filters = array()) |
| 1360 | 1360 | { |
| 1361 | 1361 | $filter_query = $this->getFilter($filters,true,true); |
@@ -1391,13 +1391,13 @@ discard block |
||
| 1391 | 1391 | return $aircraft_array; |
| 1392 | 1392 | } |
| 1393 | 1393 | |
| 1394 | - /** |
|
| 1395 | - * Gets all route combinations based on an owner |
|
| 1396 | - * |
|
| 1397 | - * @param $owner |
|
| 1398 | - * @param array $filters |
|
| 1399 | - * @return array the route list |
|
| 1400 | - */ |
|
| 1394 | + /** |
|
| 1395 | + * Gets all route combinations based on an owner |
|
| 1396 | + * |
|
| 1397 | + * @param $owner |
|
| 1398 | + * @param array $filters |
|
| 1399 | + * @return array the route list |
|
| 1400 | + */ |
|
| 1401 | 1401 | public function countAllRoutesByOwner($owner,$filters = array()) |
| 1402 | 1402 | { |
| 1403 | 1403 | $filter_query = $this->getFilter($filters,true,true); |
@@ -1426,13 +1426,13 @@ discard block |
||
| 1426 | 1426 | return $routes_array; |
| 1427 | 1427 | } |
| 1428 | 1428 | |
| 1429 | - /** |
|
| 1430 | - * Counts all hours by a owner |
|
| 1431 | - * |
|
| 1432 | - * @param $owner |
|
| 1433 | - * @param array $filters |
|
| 1434 | - * @return array the hour list |
|
| 1435 | - */ |
|
| 1429 | + /** |
|
| 1430 | + * Counts all hours by a owner |
|
| 1431 | + * |
|
| 1432 | + * @param $owner |
|
| 1433 | + * @param array $filters |
|
| 1434 | + * @return array the hour list |
|
| 1435 | + */ |
|
| 1436 | 1436 | public function countAllHoursByOwner($owner, $filters = array()) |
| 1437 | 1437 | { |
| 1438 | 1438 | global $globalTimezone, $globalDBdriver; |
@@ -1467,13 +1467,13 @@ discard block |
||
| 1467 | 1467 | return $hour_array; |
| 1468 | 1468 | } |
| 1469 | 1469 | |
| 1470 | - /** |
|
| 1471 | - * Gets last spotter information based on a particular callsign |
|
| 1472 | - * |
|
| 1473 | - * @param $id |
|
| 1474 | - * @param $date |
|
| 1475 | - * @return array the spotter information |
|
| 1476 | - */ |
|
| 1470 | + /** |
|
| 1471 | + * Gets last spotter information based on a particular callsign |
|
| 1472 | + * |
|
| 1473 | + * @param $id |
|
| 1474 | + * @param $date |
|
| 1475 | + * @return array the spotter information |
|
| 1476 | + */ |
|
| 1477 | 1477 | public function getDateArchiveSpotterDataById($id,$date) { |
| 1478 | 1478 | $Spotter = new Spotter($this->db); |
| 1479 | 1479 | date_default_timezone_set('UTC'); |
@@ -1484,13 +1484,13 @@ discard block |
||
| 1484 | 1484 | return $spotter_array; |
| 1485 | 1485 | } |
| 1486 | 1486 | |
| 1487 | - /** |
|
| 1488 | - * Gets all the spotter information based on a particular callsign |
|
| 1489 | - * |
|
| 1490 | - * @param $ident |
|
| 1491 | - * @param $date |
|
| 1492 | - * @return array the spotter information |
|
| 1493 | - */ |
|
| 1487 | + /** |
|
| 1488 | + * Gets all the spotter information based on a particular callsign |
|
| 1489 | + * |
|
| 1490 | + * @param $ident |
|
| 1491 | + * @param $date |
|
| 1492 | + * @return array the spotter information |
|
| 1493 | + */ |
|
| 1494 | 1494 | public function getDateArchiveSpotterDataByIdent($ident,$date) { |
| 1495 | 1495 | $Spotter = new Spotter($this->db); |
| 1496 | 1496 | date_default_timezone_set('UTC'); |
@@ -1501,15 +1501,15 @@ discard block |
||
| 1501 | 1501 | return $spotter_array; |
| 1502 | 1502 | } |
| 1503 | 1503 | |
| 1504 | - /** |
|
| 1505 | - * Gets all the spotter information based on the airport |
|
| 1506 | - * |
|
| 1507 | - * @param string $airport |
|
| 1508 | - * @param string $limit |
|
| 1509 | - * @param string $sort |
|
| 1510 | - * @param array $filters |
|
| 1511 | - * @return array the spotter information |
|
| 1512 | - */ |
|
| 1504 | + /** |
|
| 1505 | + * Gets all the spotter information based on the airport |
|
| 1506 | + * |
|
| 1507 | + * @param string $airport |
|
| 1508 | + * @param string $limit |
|
| 1509 | + * @param string $sort |
|
| 1510 | + * @param array $filters |
|
| 1511 | + * @return array the spotter information |
|
| 1512 | + */ |
|
| 1513 | 1513 | public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) { |
| 1514 | 1514 | global $global_query; |
| 1515 | 1515 | $Spotter = new Spotter($this->db); |
@@ -16,75 +16,75 @@ discard block |
||
| 16 | 16 | * @param bool $and |
| 17 | 17 | * @return string 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, $globalDBdriver; |
| 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 | 29 | if (isset($filter[0]['source'])) { |
| 30 | - $filters = array_merge($filters,$filter); |
|
| 30 | + $filters = array_merge($filters, $filter); |
|
| 31 | 31 | } |
| 32 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 32 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
| 33 | 33 | $filter_query_join = ''; |
| 34 | 34 | $filter_query_where = ''; |
| 35 | - foreach($filters as $flt) { |
|
| 35 | + foreach ($filters as $flt) { |
|
| 36 | 36 | if (isset($flt['airlines']) && !empty($flt['airlines'])) { |
| 37 | 37 | if ($flt['airlines'][0] != '' && $flt['airlines'][0] != 'all') { |
| 38 | 38 | if (isset($flt['source'])) { |
| 39 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 39 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $flt['airlines'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 40 | 40 | } else { |
| 41 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 41 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $flt['airlines'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | 44 | } |
| 45 | 45 | if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) { |
| 46 | 46 | if (isset($flt['source'])) { |
| 47 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 47 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 48 | 48 | } else { |
| 49 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 49 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 50 | 50 | } |
| 51 | 51 | } |
| 52 | 52 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
| 53 | 53 | if (isset($flt['source'])) { |
| 54 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 54 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 55 | 55 | } else { |
| 56 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 56 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','", $flt['idents'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 57 | 57 | } |
| 58 | 58 | } |
| 59 | 59 | if (isset($flt['registrations']) && !empty($flt['registrations'])) { |
| 60 | 60 | if (isset($flt['source'])) { |
| 61 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 61 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','", $flt['registrations'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 62 | 62 | } else { |
| 63 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 63 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','", $flt['registrations'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 64 | 64 | } |
| 65 | 65 | } |
| 66 | 66 | if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id']) && isset($flt['idents']) && empty($flt['idents']) && isset($flt['registrations']) && empty($flt['registrations'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']) && !isset($flt['idents']) && !isset($flt['registrations']))) { |
| 67 | 67 | if (isset($flt['source'])) { |
| 68 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) saa ON saa.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 68 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.format_source IN ('".implode("','", $flt['source'])."')) saa ON saa.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 69 | 69 | } |
| 70 | 70 | } |
| 71 | 71 | } |
| 72 | 72 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 73 | 73 | if ($filter['airlines'][0] != '' && $filter['airlines'][0] != 'all') { |
| 74 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) saf ON saf.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 74 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) saf ON saf.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 75 | 75 | } |
| 76 | 76 | } |
| 77 | 77 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
| 78 | 78 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive_output.flightaware_id "; |
| 79 | 79 | } |
| 80 | 80 | if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) { |
| 81 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 81 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','", $filter['pilots_id'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 82 | 82 | } |
| 83 | 83 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 84 | 84 | if (count($filter['source']) == 1) { |
| 85 | 85 | $filter_query_where .= " AND format_source = '".$filter['source'][0]."'"; |
| 86 | 86 | } else { |
| 87 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
| 87 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
| 88 | 88 | } |
| 89 | 89 | } |
| 90 | 90 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | $filter_query_where .= " AND flightaware_id = '".$filter['id']."'"; |
| 95 | 95 | } |
| 96 | 96 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 97 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 97 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 98 | 98 | } |
| 99 | 99 | if ((isset($filter['year']) && $filter['year'] != '') || (isset($filter['month']) && $filter['month'] != '') || (isset($filter['day']) && $filter['day'] != '')) { |
| 100 | 100 | $filter_query_date = ''; |
@@ -119,41 +119,41 @@ discard block |
||
| 119 | 119 | $filter_query_date .= " AND EXTRACT(DAY FROM spotter_archive_output.date) = '".$filter['day']."'"; |
| 120 | 120 | } |
| 121 | 121 | } |
| 122 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 122 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 123 | 123 | } |
| 124 | 124 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
| 125 | 125 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
| 126 | 126 | if ($filter_query_where != '') { |
| 127 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
| 127 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
| 128 | 128 | } |
| 129 | 129 | $filter_query = $filter_query_join.$filter_query_where; |
| 130 | 130 | return $filter_query; |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | // Spotter_archive |
| 134 | - public function addSpotterArchiveData($flightaware_id = '', $ident = '', $registration = '', $airline_name = '', $airline_icao = '', $airline_country = '', $airline_type = '', $aircraft_icao = '', $aircraft_shadow = '', $aircraft_name = '', $aircraft_manufacturer = '', $departure_airport_icao = '', $departure_airport_name = '', $departure_airport_city = '', $departure_airport_country = '', $departure_airport_time = '',$arrival_airport_icao = '', $arrival_airport_name = '', $arrival_airport_city ='', $arrival_airport_country = '', $arrival_airport_time = '', $route_stop = '', $date = '',$latitude = '', $longitude = '', $waypoints = '', $altitude = '', $real_altitude = '',$heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '',$verticalrate = '',$format_source = '', $source_name = '', $over_country = '') { |
|
| 134 | + public function addSpotterArchiveData($flightaware_id = '', $ident = '', $registration = '', $airline_name = '', $airline_icao = '', $airline_country = '', $airline_type = '', $aircraft_icao = '', $aircraft_shadow = '', $aircraft_name = '', $aircraft_manufacturer = '', $departure_airport_icao = '', $departure_airport_name = '', $departure_airport_city = '', $departure_airport_country = '', $departure_airport_time = '', $arrival_airport_icao = '', $arrival_airport_name = '', $arrival_airport_city = '', $arrival_airport_country = '', $arrival_airport_time = '', $route_stop = '', $date = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $real_altitude = '', $heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '', $verticalrate = '', $format_source = '', $source_name = '', $over_country = '') { |
|
| 135 | 135 | require_once(dirname(__FILE__).'/class.Spotter.php'); |
| 136 | 136 | if ($over_country == '') { |
| 137 | 137 | $Spotter = new Spotter($this->db); |
| 138 | - $data_country = $Spotter->getCountryFromLatitudeLongitude($latitude,$longitude); |
|
| 138 | + $data_country = $Spotter->getCountryFromLatitudeLongitude($latitude, $longitude); |
|
| 139 | 139 | if (!empty($data_country)) $country = $data_country['iso2']; |
| 140 | 140 | else $country = ''; |
| 141 | 141 | } else $country = $over_country; |
| 142 | - if ($airline_type === NULL) $airline_type =''; |
|
| 142 | + if ($airline_type === NULL) $airline_type = ''; |
|
| 143 | 143 | |
| 144 | 144 | //if ($country == '') echo "\n".'************ UNKNOW COUNTRY ****************'."\n"; |
| 145 | 145 | //else echo "\n".'*/*/*/*/*/*/*/ Country : '.$country.' */*/*/*/*/*/*/*/*/'."\n"; |
| 146 | 146 | |
| 147 | 147 | // Route is not added in spotter_archive |
| 148 | - $query = "INSERT INTO spotter_archive (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, departure_airport_time,arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, arrival_airport_time, route_stop, date,latitude, longitude, waypoints, altitude, heading, ground_speed, squawk, ModeS, pilot_id, pilot_name, verticalrate,format_source,over_country,source_name,real_altitude) |
|
| 148 | + $query = "INSERT INTO spotter_archive (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, departure_airport_time,arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, arrival_airport_time, route_stop, date,latitude, longitude, waypoints, altitude, heading, ground_speed, squawk, ModeS, pilot_id, pilot_name, verticalrate,format_source,over_country,source_name,real_altitude) |
|
| 149 | 149 | VALUES (:flightaware_id, :ident, :registration, :airline_name, :airline_icao, :airline_country, :airline_type, :aircraft_icao, :aircraft_shadow, :aircraft_name, :aircraft_manufacturer, :departure_airport_icao, :departure_airport_name, :departure_airport_city, :departure_airport_country, :departure_airport_time,:arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :arrival_airport_time, :route_stop, :date,:latitude, :longitude, :waypoints, :altitude, :heading, :ground_speed, :squawk, :ModeS, :pilot_id, :pilot_name, :verticalrate, :format_source, :over_country, :source_name,:real_altitude)"; |
| 150 | 150 | |
| 151 | - $query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':registration' => $registration, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type, ':aircraft_icao' => $aircraft_icao, ':aircraft_shadow' => $aircraft_shadow, ':aircraft_name' => $aircraft_name, ':aircraft_manufacturer' => $aircraft_manufacturer, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_name' => $departure_airport_name, ':departure_airport_city' => $departure_airport_city, ':departure_airport_country' => $departure_airport_country, ':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':arrival_airport_time' => $arrival_airport_time, ':route_stop' => $route_stop, ':date' => $date,':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':ground_speed' => $ground_speed, ':squawk' => $squawk, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':over_country' => $country, ':source_name' => $source_name,':real_altitude' => $real_altitude); |
|
| 151 | + $query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':registration' => $registration, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type, ':aircraft_icao' => $aircraft_icao, ':aircraft_shadow' => $aircraft_shadow, ':aircraft_name' => $aircraft_name, ':aircraft_manufacturer' => $aircraft_manufacturer, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_name' => $departure_airport_name, ':departure_airport_city' => $departure_airport_city, ':departure_airport_country' => $departure_airport_country, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':arrival_airport_time' => $arrival_airport_time, ':route_stop' => $route_stop, ':date' => $date, ':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':ground_speed' => $ground_speed, ':squawk' => $squawk, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':over_country' => $country, ':source_name' => $source_name, ':real_altitude' => $real_altitude); |
|
| 152 | 152 | try { |
| 153 | 153 | $sth = $this->db->prepare($query); |
| 154 | 154 | $sth->execute($query_values); |
| 155 | 155 | $sth->closeCursor(); |
| 156 | - } catch(PDOException $e) { |
|
| 156 | + } catch (PDOException $e) { |
|
| 157 | 157 | return "error : ".$e->getMessage(); |
| 158 | 158 | } |
| 159 | 159 | return "success"; |
@@ -172,9 +172,9 @@ discard block |
||
| 172 | 172 | |
| 173 | 173 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 174 | 174 | //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
| 175 | - $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
| 175 | + $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
| 176 | 176 | |
| 177 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident)); |
|
| 177 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident)); |
|
| 178 | 178 | |
| 179 | 179 | return $spotter_array; |
| 180 | 180 | } |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 193 | 193 | //$query = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id"; |
| 194 | 194 | //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
| 195 | - $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
| 195 | + $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
| 196 | 196 | |
| 197 | 197 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
| 198 | 198 | /* |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | } |
| 206 | 206 | $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC); |
| 207 | 207 | */ |
| 208 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id)); |
|
| 208 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id)); |
|
| 209 | 209 | |
| 210 | 210 | return $spotter_array; |
| 211 | 211 | } |
@@ -219,14 +219,14 @@ discard block |
||
| 219 | 219 | public function getAllArchiveSpotterDataById($id) { |
| 220 | 220 | date_default_timezone_set('UTC'); |
| 221 | 221 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 222 | - $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
| 222 | + $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
| 223 | 223 | |
| 224 | 224 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
| 225 | 225 | |
| 226 | 226 | try { |
| 227 | 227 | $sth = $this->db->prepare($query); |
| 228 | 228 | $sth->execute(array(':id' => $id)); |
| 229 | - } catch(PDOException $e) { |
|
| 229 | + } catch (PDOException $e) { |
|
| 230 | 230 | echo $e->getMessage(); |
| 231 | 231 | die; |
| 232 | 232 | } |
@@ -244,11 +244,11 @@ discard block |
||
| 244 | 244 | public function getCoordArchiveSpotterDataById($id) { |
| 245 | 245 | date_default_timezone_set('UTC'); |
| 246 | 246 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 247 | - $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER by spotter_archive.date ASC"; |
|
| 247 | + $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER by spotter_archive.date ASC"; |
|
| 248 | 248 | try { |
| 249 | 249 | $sth = $this->db->prepare($query); |
| 250 | 250 | $sth->execute(array(':id' => $id)); |
| 251 | - } catch(PDOException $e) { |
|
| 251 | + } catch (PDOException $e) { |
|
| 252 | 252 | echo $e->getMessage(); |
| 253 | 253 | die; |
| 254 | 254 | } |
@@ -264,14 +264,14 @@ discard block |
||
| 264 | 264 | * @param $enddate |
| 265 | 265 | * @return array the spotter information |
| 266 | 266 | */ |
| 267 | - public function getCoordArchiveSpotterDataByIdDate($id,$begindate,$enddate) { |
|
| 267 | + public function getCoordArchiveSpotterDataByIdDate($id, $begindate, $enddate) { |
|
| 268 | 268 | date_default_timezone_set('UTC'); |
| 269 | 269 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 270 | - $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.date BETWEEN :begindate AND :enddate ORDER by spotter_archive.date ASC"; |
|
| 270 | + $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.date BETWEEN :begindate AND :enddate ORDER by spotter_archive.date ASC"; |
|
| 271 | 271 | try { |
| 272 | 272 | $sth = $this->db->prepare($query); |
| 273 | - $sth->execute(array(':id' => $id,':begindate' => $begindate,':enddate' => $enddate)); |
|
| 274 | - } catch(PDOException $e) { |
|
| 273 | + $sth->execute(array(':id' => $id, ':begindate' => $begindate, ':enddate' => $enddate)); |
|
| 274 | + } catch (PDOException $e) { |
|
| 275 | 275 | echo $e->getMessage(); |
| 276 | 276 | die; |
| 277 | 277 | } |
@@ -291,12 +291,12 @@ discard block |
||
| 291 | 291 | date_default_timezone_set('UTC'); |
| 292 | 292 | |
| 293 | 293 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 294 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
| 294 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
| 295 | 295 | |
| 296 | 296 | try { |
| 297 | 297 | $sth = $this->db->prepare($query); |
| 298 | 298 | $sth->execute(array(':ident' => $ident)); |
| 299 | - } catch(PDOException $e) { |
|
| 299 | + } catch (PDOException $e) { |
|
| 300 | 300 | echo $e->getMessage(); |
| 301 | 301 | die; |
| 302 | 302 | } |
@@ -316,12 +316,12 @@ discard block |
||
| 316 | 316 | date_default_timezone_set('UTC'); |
| 317 | 317 | |
| 318 | 318 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 319 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
| 319 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
| 320 | 320 | |
| 321 | 321 | try { |
| 322 | 322 | $sth = $this->db->prepare($query); |
| 323 | 323 | $sth->execute(array(':id' => $id)); |
| 324 | - } catch(PDOException $e) { |
|
| 324 | + } catch (PDOException $e) { |
|
| 325 | 325 | echo $e->getMessage(); |
| 326 | 326 | die; |
| 327 | 327 | } |
@@ -339,11 +339,11 @@ discard block |
||
| 339 | 339 | public function getAltitudeSpeedArchiveSpotterDataById($id) { |
| 340 | 340 | date_default_timezone_set('UTC'); |
| 341 | 341 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 342 | - $query = "SELECT spotter_archive.altitude, spotter_archive.real_altitude,spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
| 342 | + $query = "SELECT spotter_archive.altitude, spotter_archive.real_altitude,spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
| 343 | 343 | try { |
| 344 | 344 | $sth = $this->db->prepare($query); |
| 345 | 345 | $sth->execute(array(':id' => $id)); |
| 346 | - } catch(PDOException $e) { |
|
| 346 | + } catch (PDOException $e) { |
|
| 347 | 347 | echo $e->getMessage(); |
| 348 | 348 | die; |
| 349 | 349 | } |
@@ -360,12 +360,12 @@ discard block |
||
| 360 | 360 | public function getLastAltitudeArchiveSpotterDataByIdent($ident) { |
| 361 | 361 | date_default_timezone_set('UTC'); |
| 362 | 362 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 363 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
| 363 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
| 364 | 364 | // $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident"; |
| 365 | 365 | try { |
| 366 | 366 | $sth = $this->db->prepare($query); |
| 367 | 367 | $sth->execute(array(':ident' => $ident)); |
| 368 | - } catch(PDOException $e) { |
|
| 368 | + } catch (PDOException $e) { |
|
| 369 | 369 | echo $e->getMessage(); |
| 370 | 370 | die; |
| 371 | 371 | } |
@@ -382,11 +382,11 @@ discard block |
||
| 382 | 382 | * @param $date |
| 383 | 383 | * @return array the spotter information |
| 384 | 384 | */ |
| 385 | - public function getSpotterArchiveData($ident,$flightaware_id,$date) { |
|
| 385 | + public function getSpotterArchiveData($ident, $flightaware_id, $date) { |
|
| 386 | 386 | $Spotter = new Spotter($this->db); |
| 387 | 387 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 388 | - $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate"; |
|
| 389 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%')); |
|
| 388 | + $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate"; |
|
| 389 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':flightaware_id' => $flightaware_id, ':date' => $date.'%')); |
|
| 390 | 390 | return $spotter_array; |
| 391 | 391 | } |
| 392 | 392 | |
@@ -400,7 +400,7 @@ discard block |
||
| 400 | 400 | try { |
| 401 | 401 | $sth = $this->db->prepare($query); |
| 402 | 402 | $sth->execute(); |
| 403 | - } catch(PDOException $e) { |
|
| 403 | + } catch (PDOException $e) { |
|
| 404 | 404 | echo $e->getMessage(); |
| 405 | 405 | die; |
| 406 | 406 | } |
@@ -416,7 +416,7 @@ discard block |
||
| 416 | 416 | try { |
| 417 | 417 | $sth = $this->db->prepare($query); |
| 418 | 418 | $sth->execute(array(':id' => $id)); |
| 419 | - } catch(PDOException $e) { |
|
| 419 | + } catch (PDOException $e) { |
|
| 420 | 420 | echo $e->getMessage(); |
| 421 | 421 | die; |
| 422 | 422 | } |
@@ -431,39 +431,39 @@ discard block |
||
| 431 | 431 | * @param int $part |
| 432 | 432 | * @return array the spotter information |
| 433 | 433 | */ |
| 434 | - public function getMinLiveSpotterData($begindate,$enddate,$filter = array(),$part = 0) { |
|
| 434 | + public function getMinLiveSpotterData($begindate, $enddate, $filter = array(), $part = 0) { |
|
| 435 | 435 | global $globalDBdriver; |
| 436 | 436 | date_default_timezone_set('UTC'); |
| 437 | 437 | //$filter_query = $this->getFilter($filter,true,true); |
| 438 | 438 | |
| 439 | 439 | $filter_query = ''; |
| 440 | 440 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 441 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 441 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
| 442 | 442 | } |
| 443 | 443 | // Use spotter_output also ? |
| 444 | 444 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 445 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 445 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 446 | 446 | } |
| 447 | 447 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
| 448 | 448 | $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
| 449 | 449 | } |
| 450 | 450 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 451 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 451 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 452 | 452 | } |
| 453 | 453 | |
| 454 | 454 | $limit = ''; |
| 455 | 455 | if ($part != 0) { |
| 456 | - $limit = ' LIMIT 100 OFFSET '.($part-1)*100; |
|
| 456 | + $limit = ' LIMIT 100 OFFSET '.($part - 1)*100; |
|
| 457 | 457 | } |
| 458 | 458 | if ($globalDBdriver == 'mysql') { |
| 459 | - $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 459 | + $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 460 | 460 | FROM spotter_archive |
| 461 | 461 | INNER JOIN aircraft a on spotter_archive.aircraft_icao = a.icao |
| 462 | 462 | WHERE spotter_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".' |
| 463 | 463 | '.$filter_query.' ORDER BY flightaware_id'.$limit; |
| 464 | 464 | } else { |
| 465 | 465 | |
| 466 | - $query = 'SELECT spotter_archive.flightaware_id, spotter_archive.date, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 466 | + $query = 'SELECT spotter_archive.flightaware_id, spotter_archive.date, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 467 | 467 | FROM spotter_archive |
| 468 | 468 | INNER JOIN aircraft a on spotter_archive.aircraft_icao = a.icao |
| 469 | 469 | WHERE spotter_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".' |
@@ -473,7 +473,7 @@ discard block |
||
| 473 | 473 | try { |
| 474 | 474 | $sth = $this->db->prepare($query); |
| 475 | 475 | $sth->execute(); |
| 476 | - } catch(PDOException $e) { |
|
| 476 | + } catch (PDOException $e) { |
|
| 477 | 477 | echo $e->getMessage(); |
| 478 | 478 | die; |
| 479 | 479 | } |
@@ -489,7 +489,7 @@ discard block |
||
| 489 | 489 | * @param array $filter |
| 490 | 490 | * @return array the spotter information |
| 491 | 491 | */ |
| 492 | - public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array()) { |
|
| 492 | + public function getMinLiveSpotterDataPlayback($begindate, $enddate, $filter = array()) { |
|
| 493 | 493 | global $globalDBdriver; |
| 494 | 494 | date_default_timezone_set('UTC'); |
| 495 | 495 | |
@@ -497,17 +497,17 @@ discard block |
||
| 497 | 497 | |
| 498 | 498 | $filter_query = ''; |
| 499 | 499 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 500 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 500 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
| 501 | 501 | } |
| 502 | 502 | // Use spotter_output also ? |
| 503 | 503 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 504 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 504 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 505 | 505 | } |
| 506 | 506 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
| 507 | 507 | $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
| 508 | 508 | } |
| 509 | 509 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 510 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 510 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 511 | 511 | } |
| 512 | 512 | |
| 513 | 513 | |
@@ -518,7 +518,7 @@ discard block |
||
| 518 | 518 | FROM spotter_archive |
| 519 | 519 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao'; |
| 520 | 520 | */ |
| 521 | - $query = 'SELECT a.aircraft_shadow, spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk |
|
| 521 | + $query = 'SELECT a.aircraft_shadow, spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk |
|
| 522 | 522 | FROM spotter_archive_output |
| 523 | 523 | LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive_output.aircraft_icao = a.icao |
| 524 | 524 | WHERE (spotter_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
@@ -533,7 +533,7 @@ discard block |
||
| 533 | 533 | WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".' |
| 534 | 534 | '.$filter_query.' GROUP BY spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao, spotter_archive_output.arrival_airport_icao, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow'; |
| 535 | 535 | */ |
| 536 | - $query = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow |
|
| 536 | + $query = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow |
|
| 537 | 537 | FROM spotter_archive_output |
| 538 | 538 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao |
| 539 | 539 | WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".' |
@@ -545,7 +545,7 @@ discard block |
||
| 545 | 545 | try { |
| 546 | 546 | $sth = $this->db->prepare($query); |
| 547 | 547 | $sth->execute(); |
| 548 | - } catch(PDOException $e) { |
|
| 548 | + } catch (PDOException $e) { |
|
| 549 | 549 | echo $e->getMessage(); |
| 550 | 550 | die; |
| 551 | 551 | } |
@@ -562,22 +562,22 @@ discard block |
||
| 562 | 562 | * @param array $filter |
| 563 | 563 | * @return array the spotter information |
| 564 | 564 | */ |
| 565 | - public function getLiveSpotterCount($begindate,$enddate,$filter = array()) { |
|
| 565 | + public function getLiveSpotterCount($begindate, $enddate, $filter = array()) { |
|
| 566 | 566 | global $globalDBdriver, $globalLiveInterval; |
| 567 | 567 | date_default_timezone_set('UTC'); |
| 568 | 568 | |
| 569 | 569 | $filter_query = ''; |
| 570 | 570 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 571 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 571 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
| 572 | 572 | } |
| 573 | 573 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 574 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 574 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 575 | 575 | } |
| 576 | 576 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
| 577 | 577 | $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
| 578 | 578 | } |
| 579 | 579 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 580 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 580 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 581 | 581 | } |
| 582 | 582 | |
| 583 | 583 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -592,7 +592,7 @@ discard block |
||
| 592 | 592 | try { |
| 593 | 593 | $sth = $this->db->prepare($query); |
| 594 | 594 | $sth->execute(); |
| 595 | - } catch(PDOException $e) { |
|
| 595 | + } catch (PDOException $e) { |
|
| 596 | 596 | echo $e->getMessage(); |
| 597 | 597 | die; |
| 598 | 598 | } |
@@ -636,7 +636,7 @@ discard block |
||
| 636 | 636 | * @param array $filters |
| 637 | 637 | * @return array the spotter information |
| 638 | 638 | */ |
| 639 | - public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array()) { |
|
| 639 | + public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '', $pilot_id = '', $pilot_name = '', $altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $filters = array()) { |
|
| 640 | 640 | global $globalTimezone, $globalDBdriver; |
| 641 | 641 | require_once(dirname(__FILE__).'/class.Translation.php'); |
| 642 | 642 | $Translation = new Translation($this->db); |
@@ -686,7 +686,7 @@ discard block |
||
| 686 | 686 | } |
| 687 | 687 | |
| 688 | 688 | if ($registration != "") { |
| 689 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 689 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
| 690 | 690 | if (!is_string($registration)) { |
| 691 | 691 | return array(); |
| 692 | 692 | } else { |
@@ -695,7 +695,7 @@ discard block |
||
| 695 | 695 | } |
| 696 | 696 | |
| 697 | 697 | if ($aircraft_icao != "") { |
| 698 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 698 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
| 699 | 699 | if (!is_string($aircraft_icao)) { |
| 700 | 700 | return array(); |
| 701 | 701 | } else { |
@@ -704,7 +704,7 @@ discard block |
||
| 704 | 704 | } |
| 705 | 705 | |
| 706 | 706 | if ($aircraft_manufacturer != "") { |
| 707 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
| 707 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING); |
|
| 708 | 708 | if (!is_string($aircraft_manufacturer)) { |
| 709 | 709 | return array(); |
| 710 | 710 | } else { |
@@ -721,7 +721,7 @@ discard block |
||
| 721 | 721 | } |
| 722 | 722 | |
| 723 | 723 | if ($airline_icao != "") { |
| 724 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
| 724 | + $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING); |
|
| 725 | 725 | if (!is_string($airline_icao)) { |
| 726 | 726 | return array(); |
| 727 | 727 | } else { |
@@ -730,7 +730,7 @@ discard block |
||
| 730 | 730 | } |
| 731 | 731 | |
| 732 | 732 | if ($airline_country != "") { |
| 733 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
| 733 | + $airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING); |
|
| 734 | 734 | if (!is_string($airline_country)) { |
| 735 | 735 | return array(); |
| 736 | 736 | } else { |
@@ -739,7 +739,7 @@ discard block |
||
| 739 | 739 | } |
| 740 | 740 | |
| 741 | 741 | if ($airline_type != "") { |
| 742 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
| 742 | + $airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING); |
|
| 743 | 743 | if (!is_string($airline_type)) { |
| 744 | 744 | return array(); |
| 745 | 745 | } else { |
@@ -756,7 +756,7 @@ discard block |
||
| 756 | 756 | } |
| 757 | 757 | |
| 758 | 758 | if ($airport != "") { |
| 759 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
| 759 | + $airport = filter_var($airport, FILTER_SANITIZE_STRING); |
|
| 760 | 760 | if (!is_string($airport)) { |
| 761 | 761 | return array(); |
| 762 | 762 | } else { |
@@ -765,7 +765,7 @@ discard block |
||
| 765 | 765 | } |
| 766 | 766 | |
| 767 | 767 | if ($airport_country != "") { |
| 768 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
| 768 | + $airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING); |
|
| 769 | 769 | if (!is_string($airport_country)) { |
| 770 | 770 | return array(); |
| 771 | 771 | } else { |
@@ -774,14 +774,14 @@ discard block |
||
| 774 | 774 | } |
| 775 | 775 | |
| 776 | 776 | if ($callsign != "") { |
| 777 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 777 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
| 778 | 778 | if (!is_string($callsign)) { |
| 779 | 779 | return array(); |
| 780 | 780 | } else { |
| 781 | 781 | $translate = $Translation->ident2icao($callsign); |
| 782 | 782 | if ($translate != $callsign) { |
| 783 | 783 | $additional_query .= " AND (spotter_archive_output.ident = :callsign OR spotter_archive_output.ident = :translate)"; |
| 784 | - $query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate)); |
|
| 784 | + $query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate)); |
|
| 785 | 785 | } else { |
| 786 | 786 | $additional_query .= " AND (spotter_archive_output.ident = '".$callsign."')"; |
| 787 | 787 | } |
@@ -789,7 +789,7 @@ discard block |
||
| 789 | 789 | } |
| 790 | 790 | |
| 791 | 791 | if ($owner != "") { |
| 792 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 792 | + $owner = filter_var($owner, FILTER_SANITIZE_STRING); |
|
| 793 | 793 | if (!is_string($owner)) { |
| 794 | 794 | return array(); |
| 795 | 795 | } else { |
@@ -798,7 +798,7 @@ discard block |
||
| 798 | 798 | } |
| 799 | 799 | |
| 800 | 800 | if ($pilot_name != "") { |
| 801 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
| 801 | + $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING); |
|
| 802 | 802 | if (!is_string($pilot_name)) { |
| 803 | 803 | return array(); |
| 804 | 804 | } else { |
@@ -807,7 +807,7 @@ discard block |
||
| 807 | 807 | } |
| 808 | 808 | |
| 809 | 809 | if ($pilot_id != "") { |
| 810 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
| 810 | + $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT); |
|
| 811 | 811 | if (!is_string($pilot_id)) { |
| 812 | 812 | return array(); |
| 813 | 813 | } else { |
@@ -816,7 +816,7 @@ discard block |
||
| 816 | 816 | } |
| 817 | 817 | |
| 818 | 818 | if ($departure_airport_route != "") { |
| 819 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
| 819 | + $departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING); |
|
| 820 | 820 | if (!is_string($departure_airport_route)) { |
| 821 | 821 | return array(); |
| 822 | 822 | } else { |
@@ -825,7 +825,7 @@ discard block |
||
| 825 | 825 | } |
| 826 | 826 | |
| 827 | 827 | if ($arrival_airport_route != "") { |
| 828 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
| 828 | + $arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING); |
|
| 829 | 829 | if (!is_string($arrival_airport_route)) { |
| 830 | 830 | return array(); |
| 831 | 831 | } else { |
@@ -836,8 +836,8 @@ discard block |
||
| 836 | 836 | if ($altitude != "") { |
| 837 | 837 | $altitude_array = explode(",", $altitude); |
| 838 | 838 | |
| 839 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 840 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 839 | + $altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 840 | + $altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 841 | 841 | |
| 842 | 842 | |
| 843 | 843 | if ($altitude_array[1] != "") { |
@@ -852,8 +852,8 @@ discard block |
||
| 852 | 852 | |
| 853 | 853 | if ($date_posted != "") { |
| 854 | 854 | $date_array = explode(",", $date_posted); |
| 855 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
| 856 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
| 855 | + $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING); |
|
| 856 | + $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING); |
|
| 857 | 857 | if ($globalTimezone != '') { |
| 858 | 858 | date_default_timezone_set($globalTimezone); |
| 859 | 859 | $datetime = new DateTime(); |
@@ -878,16 +878,16 @@ discard block |
||
| 878 | 878 | } |
| 879 | 879 | if ($limit != "") { |
| 880 | 880 | $limit_array = explode(",", $limit); |
| 881 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 882 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 881 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 882 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 883 | 883 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) { |
| 884 | 884 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 885 | 885 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 886 | 886 | } |
| 887 | 887 | } |
| 888 | 888 | if ($origLat != "" && $origLon != "" && $dist != "") { |
| 889 | - $dist = number_format($dist*0.621371,2,'.',''); |
|
| 890 | - $query="SELECT spotter_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
| 889 | + $dist = number_format($dist*0.621371, 2, '.', ''); |
|
| 890 | + $query = "SELECT spotter_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
| 891 | 891 | FROM spotter_archive_output, spotter_archive WHERE spotter_output_archive.flightaware_id = spotter_archive.flightaware_id AND spotter_output.ident <> '' ".$additional_query."AND CAST(spotter_archive.longitude as double precision) between ($origLon-$dist/ABS(cos(radians($origLat))*69)) and ($origLon+$dist/ABS(cos(radians($origLat))*69)) and CAST(spotter_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) |
| 892 | 892 | AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query." ORDER BY distance"; |
| 893 | 893 | } else { |
@@ -901,12 +901,12 @@ discard block |
||
| 901 | 901 | $additional_query .= " AND (spotter_archive_output.waypoints <> '')"; |
| 902 | 902 | } |
| 903 | 903 | |
| 904 | - $query = "SELECT spotter_archive_output.* FROM spotter_archive_output |
|
| 904 | + $query = "SELECT spotter_archive_output.* FROM spotter_archive_output |
|
| 905 | 905 | WHERE spotter_archive_output.ident <> '' |
| 906 | 906 | ".$additional_query." |
| 907 | 907 | ".$filter_query.$orderby_query; |
| 908 | 908 | } |
| 909 | - $spotter_array = $Spotter->getDataFromDB($query, $query_values,$limit_query); |
|
| 909 | + $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
|
| 910 | 910 | return $spotter_array; |
| 911 | 911 | } |
| 912 | 912 | |
@@ -922,7 +922,7 @@ discard block |
||
| 922 | 922 | $sth = $this->db->prepare($query); |
| 923 | 923 | $sth->execute(); |
| 924 | 924 | return ''; |
| 925 | - } catch(PDOException $e) { |
|
| 925 | + } catch (PDOException $e) { |
|
| 926 | 926 | return "error"; |
| 927 | 927 | } |
| 928 | 928 | } |
@@ -957,8 +957,8 @@ discard block |
||
| 957 | 957 | if ($limit != "") { |
| 958 | 958 | $limit_array = explode(",", $limit); |
| 959 | 959 | |
| 960 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 961 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 960 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 961 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 962 | 962 | |
| 963 | 963 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) { |
| 964 | 964 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
@@ -999,7 +999,7 @@ discard block |
||
| 999 | 999 | $query_values = array(); |
| 1000 | 1000 | $limit_query = ''; |
| 1001 | 1001 | $additional_query = ''; |
| 1002 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 1002 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 1003 | 1003 | |
| 1004 | 1004 | if ($owner != "") { |
| 1005 | 1005 | if (!is_string($owner)) { |
@@ -1013,8 +1013,8 @@ discard block |
||
| 1013 | 1013 | if ($limit != "") { |
| 1014 | 1014 | $limit_array = explode(",", $limit); |
| 1015 | 1015 | |
| 1016 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1017 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1016 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1017 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1018 | 1018 | |
| 1019 | 1019 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0 && $limit_array[0] != '' && $limit_array[1] != '') { |
| 1020 | 1020 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
@@ -1054,7 +1054,7 @@ discard block |
||
| 1054 | 1054 | $query_values = array(); |
| 1055 | 1055 | $limit_query = ''; |
| 1056 | 1056 | $additional_query = ''; |
| 1057 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 1057 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 1058 | 1058 | |
| 1059 | 1059 | if ($pilot != "") { |
| 1060 | 1060 | $additional_query = " AND (spotter_archive_output.pilot_id = :pilot OR spotter_archive_output.pilot_name = :pilot)"; |
@@ -1064,8 +1064,8 @@ discard block |
||
| 1064 | 1064 | if ($limit != "") { |
| 1065 | 1065 | $limit_array = explode(",", $limit); |
| 1066 | 1066 | |
| 1067 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1068 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1067 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1068 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1069 | 1069 | |
| 1070 | 1070 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) { |
| 1071 | 1071 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
@@ -1095,7 +1095,7 @@ discard block |
||
| 1095 | 1095 | * @param string $sincedate |
| 1096 | 1096 | * @return array the airline country list |
| 1097 | 1097 | */ |
| 1098 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') { |
|
| 1098 | + public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '') { |
|
| 1099 | 1099 | global $globalDBdriver; |
| 1100 | 1100 | /* |
| 1101 | 1101 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
@@ -1123,7 +1123,7 @@ discard block |
||
| 1123 | 1123 | $flight_array = array(); |
| 1124 | 1124 | $temp_array = array(); |
| 1125 | 1125 | |
| 1126 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
| 1126 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
| 1127 | 1127 | $temp_array['flight_count'] = $row['nb']; |
| 1128 | 1128 | $temp_array['flight_country'] = $row['name']; |
| 1129 | 1129 | $temp_array['flight_country_iso3'] = $row['iso3']; |
@@ -1141,7 +1141,7 @@ discard block |
||
| 1141 | 1141 | * @param string $sincedate |
| 1142 | 1142 | * @return array the airline country list |
| 1143 | 1143 | */ |
| 1144 | - public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') { |
|
| 1144 | + public function countAllFlightOverCountriesByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '') { |
|
| 1145 | 1145 | global $globalDBdriver; |
| 1146 | 1146 | /* |
| 1147 | 1147 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
@@ -1169,7 +1169,7 @@ discard block |
||
| 1169 | 1169 | $flight_array = array(); |
| 1170 | 1170 | $temp_array = array(); |
| 1171 | 1171 | |
| 1172 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
| 1172 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
| 1173 | 1173 | $temp_array['airline_icao'] = $row['airline_icao']; |
| 1174 | 1174 | $temp_array['flight_count'] = $row['nb']; |
| 1175 | 1175 | $temp_array['flight_country'] = $row['name']; |
@@ -1187,16 +1187,16 @@ discard block |
||
| 1187 | 1187 | * @param array $filters |
| 1188 | 1188 | * @return array the aircraft list |
| 1189 | 1189 | */ |
| 1190 | - public function countAllAircraftTypesByOwner($owner,$filters = array()) |
|
| 1190 | + public function countAllAircraftTypesByOwner($owner, $filters = array()) |
|
| 1191 | 1191 | { |
| 1192 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1193 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 1192 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1193 | + $owner = filter_var($owner, FILTER_SANITIZE_STRING); |
|
| 1194 | 1194 | $query = "SELECT DISTINCT spotter_archive_output.aircraft_icao, COUNT(spotter_archive_output.aircraft_icao) AS aircraft_icao_count, spotter_archive_output.aircraft_name, spotter_archive_output.aircraft_manufacturer |
| 1195 | 1195 | FROM spotter_archive_output".$filter_query." spotter_archive_output.owner_name = :owner"; |
| 1196 | 1196 | $query_values = array(); |
| 1197 | 1197 | $query .= " GROUP BY spotter_archive_output.aircraft_name, spotter_archive_output.aircraft_manufacturer, spotter_archive_output.aircraft_icao |
| 1198 | 1198 | ORDER BY aircraft_icao_count DESC"; |
| 1199 | - $query_values = array_merge($query_values,array(':owner' => $owner)); |
|
| 1199 | + $query_values = array_merge($query_values, array(':owner' => $owner)); |
|
| 1200 | 1200 | $sth = $this->db->prepare($query); |
| 1201 | 1201 | $sth->execute($query_values); |
| 1202 | 1202 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1209,11 +1209,11 @@ discard block |
||
| 1209 | 1209 | * @param array $filters |
| 1210 | 1210 | * @return array the airline list |
| 1211 | 1211 | */ |
| 1212 | - public function countAllAirlinesByOwner($owner,$filters = array()) |
|
| 1212 | + public function countAllAirlinesByOwner($owner, $filters = array()) |
|
| 1213 | 1213 | { |
| 1214 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 1215 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1216 | - $query = "SELECT DISTINCT spotter_archive_output.airline_name, spotter_archive_output.airline_icao, spotter_archive_output.airline_country, COUNT(spotter_archive_output.airline_name) AS airline_count |
|
| 1214 | + $owner = filter_var($owner, FILTER_SANITIZE_STRING); |
|
| 1215 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1216 | + $query = "SELECT DISTINCT spotter_archive_output.airline_name, spotter_archive_output.airline_icao, spotter_archive_output.airline_country, COUNT(spotter_archive_output.airline_name) AS airline_count |
|
| 1217 | 1217 | FROM spotter_archive_output".$filter_query." spotter_archive_output.owner_name = :owner |
| 1218 | 1218 | GROUP BY spotter_archive_output.airline_icao, spotter_archive_output.airline_name, spotter_archive_output.airline_country |
| 1219 | 1219 | ORDER BY airline_count DESC"; |
@@ -1232,9 +1232,9 @@ discard block |
||
| 1232 | 1232 | */ |
| 1233 | 1233 | public function countAllArrivalAirportCountriesByOwner($owner, $filters = array()) |
| 1234 | 1234 | { |
| 1235 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1236 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 1237 | - $query = "SELECT DISTINCT spotter_archive_output.arrival_airport_country, COUNT(spotter_archive_output.arrival_airport_country) AS airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 |
|
| 1235 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1236 | + $owner = filter_var($owner, FILTER_SANITIZE_STRING); |
|
| 1237 | + $query = "SELECT DISTINCT spotter_archive_output.arrival_airport_country, COUNT(spotter_archive_output.arrival_airport_country) AS airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 |
|
| 1238 | 1238 | FROM countries, spotter_archive_output".$filter_query." spotter_archive_output.arrival_airport_country <> '' AND spotter_archive_output.owner_name = :owner AND countries.name = spotter_archive_output.arrival_airport_country |
| 1239 | 1239 | GROUP BY spotter_archive_output.arrival_airport_country, countries.iso3 |
| 1240 | 1240 | ORDER BY airport_arrival_country_count DESC"; |
@@ -1250,11 +1250,11 @@ discard block |
||
| 1250 | 1250 | * @param array $filters |
| 1251 | 1251 | * @return array the airport list |
| 1252 | 1252 | */ |
| 1253 | - public function countAllArrivalAirportsByOwner($owner,$filters = array()) |
|
| 1253 | + public function countAllArrivalAirportsByOwner($owner, $filters = array()) |
|
| 1254 | 1254 | { |
| 1255 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1256 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 1257 | - $query = "SELECT DISTINCT spotter_archive_output.arrival_airport_icao, COUNT(spotter_archive_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_archive_output.arrival_airport_name, spotter_archive_output.arrival_airport_city, spotter_archive_output.arrival_airport_country |
|
| 1255 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1256 | + $owner = filter_var($owner, FILTER_SANITIZE_STRING); |
|
| 1257 | + $query = "SELECT DISTINCT spotter_archive_output.arrival_airport_icao, COUNT(spotter_archive_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_archive_output.arrival_airport_name, spotter_archive_output.arrival_airport_city, spotter_archive_output.arrival_airport_country |
|
| 1258 | 1258 | FROM spotter_archive_output".$filter_query." spotter_archive_output.arrival_airport_name <> '' AND spotter_archive_output.arrival_airport_icao <> 'NA' AND spotter_archive_output.arrival_airport_icao <> '' AND spotter_archive_output.owner_name = :owner |
| 1259 | 1259 | GROUP BY spotter_archive_output.arrival_airport_icao, spotter_archive_output.arrival_airport_name, spotter_archive_output.arrival_airport_city, spotter_archive_output.arrival_airport_country |
| 1260 | 1260 | ORDER BY airport_arrival_icao_count DESC"; |
@@ -1262,7 +1262,7 @@ discard block |
||
| 1262 | 1262 | $sth->execute(array(':owner' => $owner)); |
| 1263 | 1263 | $airport_array = array(); |
| 1264 | 1264 | $temp_array = array(); |
| 1265 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1265 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1266 | 1266 | { |
| 1267 | 1267 | $temp_array['airport_arrival_icao'] = $row['arrival_airport_icao']; |
| 1268 | 1268 | $temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count']; |
@@ -1281,11 +1281,11 @@ discard block |
||
| 1281 | 1281 | * @param array $filters |
| 1282 | 1282 | * @return array the airport list |
| 1283 | 1283 | */ |
| 1284 | - public function countAllDepartureAirportCountriesByOwner($owner,$filters = array()) |
|
| 1284 | + public function countAllDepartureAirportCountriesByOwner($owner, $filters = array()) |
|
| 1285 | 1285 | { |
| 1286 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1287 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 1288 | - $query = "SELECT DISTINCT spotter_archive_output.departure_airport_country, COUNT(spotter_archive_output.departure_airport_country) AS airport_departure_country_count, countries.iso3 AS airport_departure_country_iso3 |
|
| 1286 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1287 | + $owner = filter_var($owner, FILTER_SANITIZE_STRING); |
|
| 1288 | + $query = "SELECT DISTINCT spotter_archive_output.departure_airport_country, COUNT(spotter_archive_output.departure_airport_country) AS airport_departure_country_count, countries.iso3 AS airport_departure_country_iso3 |
|
| 1289 | 1289 | FROM spotter_archive_output,countries".$filter_query." spotter_archive_output.departure_airport_country <> '' AND spotter_archive_output.owner_name = :owner AND countries.name = spotter_archive_output.departure_airport_country |
| 1290 | 1290 | GROUP BY spotter_archive_output.departure_airport_country, countries.iso3 |
| 1291 | 1291 | ORDER BY airport_departure_country_count DESC"; |
@@ -1301,11 +1301,11 @@ discard block |
||
| 1301 | 1301 | * @param array $filters |
| 1302 | 1302 | * @return array the airport list |
| 1303 | 1303 | */ |
| 1304 | - public function countAllDepartureAirportsByOwner($owner,$filters = array()) |
|
| 1304 | + public function countAllDepartureAirportsByOwner($owner, $filters = array()) |
|
| 1305 | 1305 | { |
| 1306 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1307 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 1308 | - $query = "SELECT DISTINCT spotter_archive_output.departure_airport_icao, COUNT(spotter_archive_output.departure_airport_icao) AS airport_departure_icao_count, spotter_archive_output.departure_airport_name, spotter_archive_output.departure_airport_city, spotter_archive_output.departure_airport_country, airport.latitude, airport.longitude |
|
| 1306 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1307 | + $owner = filter_var($owner, FILTER_SANITIZE_STRING); |
|
| 1308 | + $query = "SELECT DISTINCT spotter_archive_output.departure_airport_icao, COUNT(spotter_archive_output.departure_airport_icao) AS airport_departure_icao_count, spotter_archive_output.departure_airport_name, spotter_archive_output.departure_airport_city, spotter_archive_output.departure_airport_country, airport.latitude, airport.longitude |
|
| 1309 | 1309 | FROM spotter_archive_output,airport".$filter_query." spotter_archive_output.departure_airport_name <> '' AND spotter_archive_output.departure_airport_icao <> 'NA' AND spotter_archive_output.departure_airport_icao <> '' AND spotter_archive_output.owner_name = :owner AND airport.icao = spotter_archive_output.departure_airport_icao |
| 1310 | 1310 | GROUP BY spotter_archive_output.departure_airport_icao, spotter_archive_output.departure_airport_name, spotter_archive_output.departure_airport_city, spotter_archive_output.departure_airport_country, airport.latitude, airport.longitude |
| 1311 | 1311 | ORDER BY airport_departure_icao_count DESC"; |
@@ -1313,7 +1313,7 @@ discard block |
||
| 1313 | 1313 | $sth->execute(array(':owner' => $owner)); |
| 1314 | 1314 | $airport_array = array(); |
| 1315 | 1315 | $temp_array = array(); |
| 1316 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1316 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1317 | 1317 | { |
| 1318 | 1318 | $temp_array['airport_departure_icao'] = $row['departure_airport_icao']; |
| 1319 | 1319 | $temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count']; |
@@ -1334,14 +1334,14 @@ discard block |
||
| 1334 | 1334 | * @param array $filters |
| 1335 | 1335 | * @return array the aircraft manufacturer list |
| 1336 | 1336 | */ |
| 1337 | - public function countAllAircraftManufacturerByOwner($owner,$filters = array()) |
|
| 1337 | + public function countAllAircraftManufacturerByOwner($owner, $filters = array()) |
|
| 1338 | 1338 | { |
| 1339 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1340 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 1341 | - $query = "SELECT DISTINCT spotter_archive_output.aircraft_manufacturer, COUNT(spotter_archive_output.aircraft_manufacturer) AS aircraft_manufacturer_count |
|
| 1339 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1340 | + $owner = filter_var($owner, FILTER_SANITIZE_STRING); |
|
| 1341 | + $query = "SELECT DISTINCT spotter_archive_output.aircraft_manufacturer, COUNT(spotter_archive_output.aircraft_manufacturer) AS aircraft_manufacturer_count |
|
| 1342 | 1342 | FROM spotter_archive_output".$filter_query." spotter_archive_output.aircraft_manufacturer <> '' AND spotter_archive_output.owner_name = :owner"; |
| 1343 | 1343 | $query_values = array(); |
| 1344 | - $query_values = array_merge($query_values,array(':owner' => $owner)); |
|
| 1344 | + $query_values = array_merge($query_values, array(':owner' => $owner)); |
|
| 1345 | 1345 | $query .= " GROUP BY spotter_archive_output.aircraft_manufacturer |
| 1346 | 1346 | ORDER BY aircraft_manufacturer_count DESC"; |
| 1347 | 1347 | $sth = $this->db->prepare($query); |
@@ -1356,22 +1356,22 @@ discard block |
||
| 1356 | 1356 | * @param array $filters |
| 1357 | 1357 | * @return array the aircraft list |
| 1358 | 1358 | */ |
| 1359 | - public function countAllAircraftRegistrationByOwner($owner,$filters = array()) |
|
| 1359 | + public function countAllAircraftRegistrationByOwner($owner, $filters = array()) |
|
| 1360 | 1360 | { |
| 1361 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1361 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1362 | 1362 | $Image = new Image($this->db); |
| 1363 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 1364 | - $query = "SELECT DISTINCT spotter_archive_output.aircraft_icao, COUNT(spotter_archive_output.registration) AS registration_count, spotter_archive_output.aircraft_name, spotter_archive_output.aircraft_manufacturer, spotter_archive_output.registration, spotter_archive_output.airline_name |
|
| 1363 | + $owner = filter_var($owner, FILTER_SANITIZE_STRING); |
|
| 1364 | + $query = "SELECT DISTINCT spotter_archive_output.aircraft_icao, COUNT(spotter_archive_output.registration) AS registration_count, spotter_archive_output.aircraft_name, spotter_archive_output.aircraft_manufacturer, spotter_archive_output.registration, spotter_archive_output.airline_name |
|
| 1365 | 1365 | FROM spotter_archive_output".$filter_query." spotter_archive_output.registration <> '' AND spotter_archive_output.owner_name = :owner"; |
| 1366 | 1366 | $query_values = array(); |
| 1367 | - $query_values = array_merge($query_values,array(':owner' => $owner)); |
|
| 1367 | + $query_values = array_merge($query_values, array(':owner' => $owner)); |
|
| 1368 | 1368 | $query .= " GROUP BY spotter_archive_output.registration,spotter_archive_output.aircraft_icao, spotter_archive_output.aircraft_name, spotter_archive_output.aircraft_manufacturer, spotter_archive_output.airline_name |
| 1369 | 1369 | ORDER BY registration_count DESC"; |
| 1370 | 1370 | $sth = $this->db->prepare($query); |
| 1371 | 1371 | $sth->execute($query_values); |
| 1372 | 1372 | $aircraft_array = array(); |
| 1373 | 1373 | $temp_array = array(); |
| 1374 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1374 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1375 | 1375 | { |
| 1376 | 1376 | $temp_array['aircraft_icao'] = $row['aircraft_icao']; |
| 1377 | 1377 | $temp_array['aircraft_name'] = $row['aircraft_name']; |
@@ -1379,7 +1379,7 @@ discard block |
||
| 1379 | 1379 | $temp_array['registration'] = $row['registration']; |
| 1380 | 1380 | $temp_array['airline_name'] = $row['airline_name']; |
| 1381 | 1381 | $temp_array['image_thumbnail'] = ""; |
| 1382 | - if($row['registration'] != "") |
|
| 1382 | + if ($row['registration'] != "") |
|
| 1383 | 1383 | { |
| 1384 | 1384 | $image_array = $Image->getSpotterImage($row['registration']); |
| 1385 | 1385 | if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
@@ -1398,11 +1398,11 @@ discard block |
||
| 1398 | 1398 | * @param array $filters |
| 1399 | 1399 | * @return array the route list |
| 1400 | 1400 | */ |
| 1401 | - public function countAllRoutesByOwner($owner,$filters = array()) |
|
| 1401 | + public function countAllRoutesByOwner($owner, $filters = array()) |
|
| 1402 | 1402 | { |
| 1403 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1404 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 1405 | - $query = "SELECT DISTINCT concat(spotter_archive_output.departure_airport_icao, ' - ', spotter_archive_output.arrival_airport_icao) AS route, count(concat(spotter_archive_output.departure_airport_icao, ' - ', spotter_archive_output.arrival_airport_icao)) AS route_count, spotter_archive_output.departure_airport_icao, spotter_archive_output.departure_airport_name AS airport_departure_name, spotter_archive_output.departure_airport_city AS airport_departure_city, spotter_archive_output.departure_airport_country AS airport_departure_country, spotter_archive_output.arrival_airport_icao, spotter_archive_output.arrival_airport_name AS airport_arrival_name, spotter_archive_output.arrival_airport_city AS airport_arrival_city, spotter_archive_output.arrival_airport_country AS airport_arrival_country |
|
| 1403 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1404 | + $owner = filter_var($owner, FILTER_SANITIZE_STRING); |
|
| 1405 | + $query = "SELECT DISTINCT concat(spotter_archive_output.departure_airport_icao, ' - ', spotter_archive_output.arrival_airport_icao) AS route, count(concat(spotter_archive_output.departure_airport_icao, ' - ', spotter_archive_output.arrival_airport_icao)) AS route_count, spotter_archive_output.departure_airport_icao, spotter_archive_output.departure_airport_name AS airport_departure_name, spotter_archive_output.departure_airport_city AS airport_departure_city, spotter_archive_output.departure_airport_country AS airport_departure_country, spotter_archive_output.arrival_airport_icao, spotter_archive_output.arrival_airport_name AS airport_arrival_name, spotter_archive_output.arrival_airport_city AS airport_arrival_city, spotter_archive_output.arrival_airport_country AS airport_arrival_country |
|
| 1406 | 1406 | FROM spotter_archive_output".$filter_query." spotter_archive_output.ident <> '' AND spotter_archive_output.owner_name = :owner |
| 1407 | 1407 | GROUP BY route, spotter_archive_output.departure_airport_icao, spotter_archive_output.departure_airport_name, spotter_archive_output.departure_airport_city, spotter_archive_output.departure_airport_country, spotter_archive_output.arrival_airport_icao, spotter_archive_output.arrival_airport_name, spotter_archive_output.arrival_airport_city, spotter_archive_output.arrival_airport_country |
| 1408 | 1408 | ORDER BY route_count DESC"; |
@@ -1410,7 +1410,7 @@ discard block |
||
| 1410 | 1410 | $sth->execute(array(':owner' => $owner)); |
| 1411 | 1411 | $routes_array = array(); |
| 1412 | 1412 | $temp_array = array(); |
| 1413 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1413 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1414 | 1414 | { |
| 1415 | 1415 | $temp_array['route_count'] = $row['route_count']; |
| 1416 | 1416 | $temp_array['airport_departure_icao'] = $row['departure_airport_icao']; |
@@ -1436,8 +1436,8 @@ discard block |
||
| 1436 | 1436 | public function countAllHoursByOwner($owner, $filters = array()) |
| 1437 | 1437 | { |
| 1438 | 1438 | global $globalTimezone, $globalDBdriver; |
| 1439 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1440 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 1439 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1440 | + $owner = filter_var($owner, FILTER_SANITIZE_STRING); |
|
| 1441 | 1441 | if ($globalTimezone != '') { |
| 1442 | 1442 | date_default_timezone_set($globalTimezone); |
| 1443 | 1443 | $datetime = new DateTime(); |
@@ -1449,16 +1449,16 @@ discard block |
||
| 1449 | 1449 | GROUP BY hour_name |
| 1450 | 1450 | ORDER BY hour_name ASC"; |
| 1451 | 1451 | } else { |
| 1452 | - $query = "SELECT EXTRACT(HOUR FROM spotter_archive_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1452 | + $query = "SELECT EXTRACT(HOUR FROM spotter_archive_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1453 | 1453 | FROM spotter_archive_output".$filter_query." spotter_archive_output.owner_name = :owner |
| 1454 | 1454 | GROUP BY hour_name |
| 1455 | 1455 | ORDER BY hour_name ASC"; |
| 1456 | 1456 | } |
| 1457 | 1457 | $sth = $this->db->prepare($query); |
| 1458 | - $sth->execute(array(':owner' => $owner,':offset' => $offset)); |
|
| 1458 | + $sth->execute(array(':owner' => $owner, ':offset' => $offset)); |
|
| 1459 | 1459 | $hour_array = array(); |
| 1460 | 1460 | $temp_array = array(); |
| 1461 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1461 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1462 | 1462 | { |
| 1463 | 1463 | $temp_array['hour_name'] = $row['hour_name']; |
| 1464 | 1464 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1474,13 +1474,13 @@ discard block |
||
| 1474 | 1474 | * @param $date |
| 1475 | 1475 | * @return array the spotter information |
| 1476 | 1476 | */ |
| 1477 | - public function getDateArchiveSpotterDataById($id,$date) { |
|
| 1477 | + public function getDateArchiveSpotterDataById($id, $date) { |
|
| 1478 | 1478 | $Spotter = new Spotter($this->db); |
| 1479 | 1479 | date_default_timezone_set('UTC'); |
| 1480 | 1480 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 1481 | - $query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC'; |
|
| 1482 | - $date = date('c',$date); |
|
| 1483 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
|
| 1481 | + $query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC'; |
|
| 1482 | + $date = date('c', $date); |
|
| 1483 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date)); |
|
| 1484 | 1484 | return $spotter_array; |
| 1485 | 1485 | } |
| 1486 | 1486 | |
@@ -1491,13 +1491,13 @@ discard block |
||
| 1491 | 1491 | * @param $date |
| 1492 | 1492 | * @return array the spotter information |
| 1493 | 1493 | */ |
| 1494 | - public function getDateArchiveSpotterDataByIdent($ident,$date) { |
|
| 1494 | + public function getDateArchiveSpotterDataByIdent($ident, $date) { |
|
| 1495 | 1495 | $Spotter = new Spotter($this->db); |
| 1496 | 1496 | date_default_timezone_set('UTC'); |
| 1497 | 1497 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 1498 | - $query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC'; |
|
| 1499 | - $date = date('c',$date); |
|
| 1500 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
| 1498 | + $query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC'; |
|
| 1499 | + $date = date('c', $date); |
|
| 1500 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
| 1501 | 1501 | return $spotter_array; |
| 1502 | 1502 | } |
| 1503 | 1503 | |
@@ -1510,14 +1510,14 @@ discard block |
||
| 1510 | 1510 | * @param array $filters |
| 1511 | 1511 | * @return array the spotter information |
| 1512 | 1512 | */ |
| 1513 | - public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) { |
|
| 1513 | + public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '', $filters = array()) { |
|
| 1514 | 1514 | global $global_query; |
| 1515 | 1515 | $Spotter = new Spotter($this->db); |
| 1516 | 1516 | date_default_timezone_set('UTC'); |
| 1517 | 1517 | $query_values = array(); |
| 1518 | 1518 | $limit_query = ''; |
| 1519 | 1519 | $additional_query = ''; |
| 1520 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1520 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1521 | 1521 | |
| 1522 | 1522 | if ($airport != "") { |
| 1523 | 1523 | if (!is_string($airport)) { |
@@ -1531,8 +1531,8 @@ discard block |
||
| 1531 | 1531 | if ($limit != "") { |
| 1532 | 1532 | $limit_array = explode(",", $limit); |
| 1533 | 1533 | |
| 1534 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1535 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1534 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1535 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1536 | 1536 | |
| 1537 | 1537 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) { |
| 1538 | 1538 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
@@ -6,7 +6,9 @@ discard block |
||
| 6 | 6 | public function __construct($dbc = null) { |
| 7 | 7 | $Connection = new Connection($dbc); |
| 8 | 8 | $this->db = $Connection->db; |
| 9 | - if ($this->db === null) die('Error: No DB connection. (SpotterArchive)'); |
|
| 9 | + if ($this->db === null) { |
|
| 10 | + die('Error: No DB connection. (SpotterArchive)'); |
|
| 11 | + } |
|
| 10 | 12 | } |
| 11 | 13 | |
| 12 | 14 | /** |
@@ -29,7 +31,9 @@ discard block |
||
| 29 | 31 | if (isset($filter[0]['source'])) { |
| 30 | 32 | $filters = array_merge($filters,$filter); |
| 31 | 33 | } |
| 32 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 34 | + if (is_array($globalFilter)) { |
|
| 35 | + $filter = array_merge($filter,$globalFilter); |
|
| 36 | + } |
|
| 33 | 37 | $filter_query_join = ''; |
| 34 | 38 | $filter_query_where = ''; |
| 35 | 39 | foreach($filters as $flt) { |
@@ -121,8 +125,11 @@ discard block |
||
| 121 | 125 | } |
| 122 | 126 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id"; |
| 123 | 127 | } |
| 124 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
| 125 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
| 128 | + if ($filter_query_where == '' && $where) { |
|
| 129 | + $filter_query_where = ' WHERE'; |
|
| 130 | + } elseif ($filter_query_where != '' && $and) { |
|
| 131 | + $filter_query_where .= ' AND'; |
|
| 132 | + } |
|
| 126 | 133 | if ($filter_query_where != '') { |
| 127 | 134 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
| 128 | 135 | } |
@@ -136,10 +143,17 @@ discard block |
||
| 136 | 143 | if ($over_country == '') { |
| 137 | 144 | $Spotter = new Spotter($this->db); |
| 138 | 145 | $data_country = $Spotter->getCountryFromLatitudeLongitude($latitude,$longitude); |
| 139 | - if (!empty($data_country)) $country = $data_country['iso2']; |
|
| 140 | - else $country = ''; |
|
| 141 | - } else $country = $over_country; |
|
| 142 | - if ($airline_type === NULL) $airline_type =''; |
|
| 146 | + if (!empty($data_country)) { |
|
| 147 | + $country = $data_country['iso2']; |
|
| 148 | + } else { |
|
| 149 | + $country = ''; |
|
| 150 | + } |
|
| 151 | + } else { |
|
| 152 | + $country = $over_country; |
|
| 153 | + } |
|
| 154 | + if ($airline_type === NULL) { |
|
| 155 | + $airline_type =''; |
|
| 156 | + } |
|
| 143 | 157 | |
| 144 | 158 | //if ($country == '') echo "\n".'************ UNKNOW COUNTRY ****************'."\n"; |
| 145 | 159 | //else echo "\n".'*/*/*/*/*/*/*/ Country : '.$country.' */*/*/*/*/*/*/*/*/'."\n"; |
@@ -678,7 +692,9 @@ discard block |
||
| 678 | 692 | $additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR "; |
| 679 | 693 | $additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR "; |
| 680 | 694 | $translate = $Translation->ident2icao($q_item); |
| 681 | - if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR "; |
|
| 695 | + if ($translate != $q_item) { |
|
| 696 | + $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR "; |
|
| 697 | + } |
|
| 682 | 698 | $additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')"; |
| 683 | 699 | $additional_query .= ")"; |
| 684 | 700 | } |
@@ -858,7 +874,9 @@ discard block |
||
| 858 | 874 | date_default_timezone_set($globalTimezone); |
| 859 | 875 | $datetime = new DateTime(); |
| 860 | 876 | $offset = $datetime->format('P'); |
| 861 | - } else $offset = '+00:00'; |
|
| 877 | + } else { |
|
| 878 | + $offset = '+00:00'; |
|
| 879 | + } |
|
| 862 | 880 | if ($date_array[1] != "") { |
| 863 | 881 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
| 864 | 882 | $date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1])); |
@@ -1112,9 +1130,13 @@ discard block |
||
| 1112 | 1130 | $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
| 1113 | 1131 | } |
| 1114 | 1132 | } |
| 1115 | - if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
| 1133 | + if ($sincedate != '') { |
|
| 1134 | + $query .= "AND date > '".$sincedate."' "; |
|
| 1135 | + } |
|
| 1116 | 1136 | $query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
| 1117 | - if ($limit) $query .= " LIMIT 0,10"; |
|
| 1137 | + if ($limit) { |
|
| 1138 | + $query .= " LIMIT 0,10"; |
|
| 1139 | + } |
|
| 1118 | 1140 | |
| 1119 | 1141 | |
| 1120 | 1142 | $sth = $this->db->prepare($query); |
@@ -1158,9 +1180,13 @@ discard block |
||
| 1158 | 1180 | $query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
| 1159 | 1181 | } |
| 1160 | 1182 | } |
| 1161 | - if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
| 1183 | + if ($sincedate != '') { |
|
| 1184 | + $query .= "AND s.date > '".$sincedate."' "; |
|
| 1185 | + } |
|
| 1162 | 1186 | $query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
| 1163 | - if ($limit) $query .= " LIMIT 0,10"; |
|
| 1187 | + if ($limit) { |
|
| 1188 | + $query .= " LIMIT 0,10"; |
|
| 1189 | + } |
|
| 1164 | 1190 | |
| 1165 | 1191 | |
| 1166 | 1192 | $sth = $this->db->prepare($query); |
@@ -1382,8 +1408,11 @@ discard block |
||
| 1382 | 1408 | if($row['registration'] != "") |
| 1383 | 1409 | { |
| 1384 | 1410 | $image_array = $Image->getSpotterImage($row['registration']); |
| 1385 | - if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
| 1386 | - else $temp_array['image_thumbnail'] = ''; |
|
| 1411 | + if (isset($image_array[0]['image_thumbnail'])) { |
|
| 1412 | + $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
| 1413 | + } else { |
|
| 1414 | + $temp_array['image_thumbnail'] = ''; |
|
| 1415 | + } |
|
| 1387 | 1416 | } |
| 1388 | 1417 | $temp_array['registration_count'] = $row['registration_count']; |
| 1389 | 1418 | $aircraft_array[] = $temp_array; |
@@ -1442,7 +1471,9 @@ discard block |
||
| 1442 | 1471 | date_default_timezone_set($globalTimezone); |
| 1443 | 1472 | $datetime = new DateTime(); |
| 1444 | 1473 | $offset = $datetime->format('P'); |
| 1445 | - } else $offset = '+00:00'; |
|
| 1474 | + } else { |
|
| 1475 | + $offset = '+00:00'; |
|
| 1476 | + } |
|
| 1446 | 1477 | if ($globalDBdriver == 'mysql') { |
| 1447 | 1478 | $query = "SELECT HOUR(CONVERT_TZ(spotter_archive_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
| 1448 | 1479 | FROM spotter_archive_output".$filter_query." spotter_archive_output.owner_name = :owner |
@@ -21,13 +21,13 @@ discard block |
||
| 21 | 21 | if ($this->db === null) die('Error: No DB connection. (ATC)'); |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * Get SQL query part for filter used |
|
| 26 | - * @param array $filter the filter |
|
| 27 | - * @param bool $where |
|
| 28 | - * @param bool $and |
|
| 29 | - * @return String the SQL part |
|
| 30 | - */ |
|
| 24 | + /** |
|
| 25 | + * Get SQL query part for filter used |
|
| 26 | + * @param array $filter the filter |
|
| 27 | + * @param bool $where |
|
| 28 | + * @param bool $and |
|
| 29 | + * @return String the SQL part |
|
| 30 | + */ |
|
| 31 | 31 | public function getFilter($filter = array(),$where = false,$and = false) { |
| 32 | 32 | global $globalFilter, $globalStatsFilters, $globalFilterName; |
| 33 | 33 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | * Get all ATC from atc table |
| 56 | 56 | * @return array Return all ATC |
| 57 | 57 | */ |
| 58 | - public function getAll() { |
|
| 58 | + public function getAll() { |
|
| 59 | 59 | $filter_query = $this->getFilter(array()); |
| 60 | 60 | $query = "SELECT * FROM atc".$filter_query; |
| 61 | 61 | $query_values = array(); |
@@ -28,22 +28,22 @@ discard block |
||
| 28 | 28 | * @param bool $and |
| 29 | 29 | * @return String the SQL part |
| 30 | 30 | */ |
| 31 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
| 31 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
| 32 | 32 | global $globalFilter, $globalStatsFilters, $globalFilterName; |
| 33 | 33 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
| 34 | 34 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
| 35 | - foreach($globalStatsFilters[$globalFilterName] as $source) { |
|
| 35 | + foreach ($globalStatsFilters[$globalFilterName] as $source) { |
|
| 36 | 36 | if (isset($source['source'])) $filter['source'][] = $source['source']; |
| 37 | 37 | } |
| 38 | 38 | } else { |
| 39 | 39 | $filter = $globalStatsFilters[$globalFilterName]; |
| 40 | 40 | } |
| 41 | 41 | } |
| 42 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 42 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
| 43 | 43 | $filter_query_join = ''; |
| 44 | 44 | $filter_query_where = ''; |
| 45 | 45 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 46 | - $filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')"; |
|
| 46 | + $filter_query_where = " WHERE format_source IN ('".implode("','", $filter['source'])."')"; |
|
| 47 | 47 | } |
| 48 | 48 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
| 49 | 49 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | try { |
| 63 | 63 | $sth = $this->db->prepare($query); |
| 64 | 64 | $sth->execute($query_values); |
| 65 | - } catch(PDOException $e) { |
|
| 65 | + } catch (PDOException $e) { |
|
| 66 | 66 | return "error : ".$e->getMessage(); |
| 67 | 67 | } |
| 68 | 68 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -75,13 +75,13 @@ discard block |
||
| 75 | 75 | * @return Array Return ATC |
| 76 | 76 | */ |
| 77 | 77 | public function getById($id) { |
| 78 | - $filter_query = $this->getFilter(array(),true,true); |
|
| 78 | + $filter_query = $this->getFilter(array(), true, true); |
|
| 79 | 79 | $query = "SELECT * FROM atc".$filter_query." atc_id = :id"; |
| 80 | 80 | $query_values = array(':id' => $id); |
| 81 | 81 | try { |
| 82 | 82 | $sth = $this->db->prepare($query); |
| 83 | 83 | $sth->execute($query_values); |
| 84 | - } catch(PDOException $e) { |
|
| 84 | + } catch (PDOException $e) { |
|
| 85 | 85 | return "error : ".$e->getMessage(); |
| 86 | 86 | } |
| 87 | 87 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -94,19 +94,19 @@ discard block |
||
| 94 | 94 | * @param String $format_source Format source |
| 95 | 95 | * @return Array Return ATC |
| 96 | 96 | */ |
| 97 | - public function getByIdent($ident,$format_source = '') { |
|
| 98 | - $filter_query = $this->getFilter(array(),true,true); |
|
| 97 | + public function getByIdent($ident, $format_source = '') { |
|
| 98 | + $filter_query = $this->getFilter(array(), true, true); |
|
| 99 | 99 | if ($format_source == '') { |
| 100 | 100 | $query = "SELECT * FROM atc".$filter_query." ident = :ident"; |
| 101 | 101 | $query_values = array(':ident' => $ident); |
| 102 | 102 | } else { |
| 103 | 103 | $query = "SELECT * FROM atc".$filter_query." ident = :ident AND format_source = :format_source"; |
| 104 | - $query_values = array(':ident' => $ident,':format_source' => $format_source); |
|
| 104 | + $query_values = array(':ident' => $ident, ':format_source' => $format_source); |
|
| 105 | 105 | } |
| 106 | 106 | try { |
| 107 | 107 | $sth = $this->db->prepare($query); |
| 108 | 108 | $sth->execute($query_values); |
| 109 | - } catch(PDOException $e) { |
|
| 109 | + } catch (PDOException $e) { |
|
| 110 | 110 | return "error : ".$e->getMessage(); |
| 111 | 111 | } |
| 112 | 112 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -128,18 +128,18 @@ discard block |
||
| 128 | 128 | * @param String $format_source Format source |
| 129 | 129 | * @param String $source_name Source name |
| 130 | 130 | */ |
| 131 | - public function add($ident,$frequency,$latitude,$longitude,$range,$info,$date,$type = '',$ivao_id = '',$ivao_name = '',$format_source = '',$source_name = '') { |
|
| 132 | - $info = preg_replace('/[^(\x20-\x7F)]*/','',$info); |
|
| 133 | - $info = str_replace('^','<br />',$info); |
|
| 134 | - $info = str_replace('&sect;','',$info); |
|
| 135 | - $info = str_replace('"','',$info); |
|
| 131 | + public function add($ident, $frequency, $latitude, $longitude, $range, $info, $date, $type = '', $ivao_id = '', $ivao_name = '', $format_source = '', $source_name = '') { |
|
| 132 | + $info = preg_replace('/[^(\x20-\x7F)]*/', '', $info); |
|
| 133 | + $info = str_replace('^', '<br />', $info); |
|
| 134 | + $info = str_replace('&sect;', '', $info); |
|
| 135 | + $info = str_replace('"', '', $info); |
|
| 136 | 136 | if ($type == '') $type = NULL; |
| 137 | 137 | $query = "INSERT INTO atc (ident,frequency,latitude,longitude,atc_range,info,atc_lastseen,type,ivao_id,ivao_name,format_source,source_name) VALUES (:ident,:frequency,:latitude,:longitude,:range,:info,:date,:type,:ivao_id,:ivao_name,:format_source,:source_name)"; |
| 138 | - $query_values = array(':ident' => $ident,':frequency' => $frequency,':latitude' => $latitude,':longitude' => $longitude,':range' => $range,':info' => $info,':date' => $date,':ivao_id' => $ivao_id,':ivao_name' => $ivao_name, ':type' => $type,':format_source' => $format_source,':source_name' => $source_name); |
|
| 138 | + $query_values = array(':ident' => $ident, ':frequency' => $frequency, ':latitude' => $latitude, ':longitude' => $longitude, ':range' => $range, ':info' => $info, ':date' => $date, ':ivao_id' => $ivao_id, ':ivao_name' => $ivao_name, ':type' => $type, ':format_source' => $format_source, ':source_name' => $source_name); |
|
| 139 | 139 | try { |
| 140 | 140 | $sth = $this->db->prepare($query); |
| 141 | 141 | $sth->execute($query_values); |
| 142 | - } catch(PDOException $e) { |
|
| 142 | + } catch (PDOException $e) { |
|
| 143 | 143 | return "error : ".$e->getMessage(); |
| 144 | 144 | } |
| 145 | 145 | } |
@@ -159,18 +159,18 @@ discard block |
||
| 159 | 159 | * @param String $format_source Format source |
| 160 | 160 | * @param String $source_name Source name |
| 161 | 161 | */ |
| 162 | - public function update($ident,$frequency,$latitude,$longitude,$range,$info,$date,$type = '',$ivao_id = '',$ivao_name = '',$format_source = '',$source_name = '') { |
|
| 163 | - $info = preg_replace('/[^(\x20-\x7F)]*/','',$info); |
|
| 164 | - $info = str_replace('^','<br />',$info); |
|
| 165 | - $info = str_replace('&sect;','',$info); |
|
| 166 | - $info = str_replace('"','',$info); |
|
| 162 | + public function update($ident, $frequency, $latitude, $longitude, $range, $info, $date, $type = '', $ivao_id = '', $ivao_name = '', $format_source = '', $source_name = '') { |
|
| 163 | + $info = preg_replace('/[^(\x20-\x7F)]*/', '', $info); |
|
| 164 | + $info = str_replace('^', '<br />', $info); |
|
| 165 | + $info = str_replace('&sect;', '', $info); |
|
| 166 | + $info = str_replace('"', '', $info); |
|
| 167 | 167 | if ($type == '') $type = NULL; |
| 168 | 168 | $query = "UPDATE atc SET frequency = :frequency,latitude = :latitude,longitude = :longitude,atc_range = :range,info = :info,atc_lastseen = :date,type = :type,ivao_id = :ivao_id,ivao_name = :ivao_name WHERE ident = :ident AND format_source = :format_source AND source_name = :source_name"; |
| 169 | - $query_values = array(':ident' => $ident,':frequency' => $frequency,':latitude' => $latitude,':longitude' => $longitude,':range' => $range,':info' => $info,':date' => $date,':ivao_id' => $ivao_id,':ivao_name' => $ivao_name, ':type' => $type,':format_source' => $format_source,':source_name' => $source_name); |
|
| 169 | + $query_values = array(':ident' => $ident, ':frequency' => $frequency, ':latitude' => $latitude, ':longitude' => $longitude, ':range' => $range, ':info' => $info, ':date' => $date, ':ivao_id' => $ivao_id, ':ivao_name' => $ivao_name, ':type' => $type, ':format_source' => $format_source, ':source_name' => $source_name); |
|
| 170 | 170 | try { |
| 171 | 171 | $sth = $this->db->prepare($query); |
| 172 | 172 | $sth->execute($query_values); |
| 173 | - } catch(PDOException $e) { |
|
| 173 | + } catch (PDOException $e) { |
|
| 174 | 174 | return "error : ".$e->getMessage(); |
| 175 | 175 | } |
| 176 | 176 | } |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | try { |
| 186 | 186 | $sth = $this->db->prepare($query); |
| 187 | 187 | $sth->execute($query_values); |
| 188 | - } catch(PDOException $e) { |
|
| 188 | + } catch (PDOException $e) { |
|
| 189 | 189 | return "error : ".$e->getMessage(); |
| 190 | 190 | } |
| 191 | 191 | } |
@@ -195,13 +195,13 @@ discard block |
||
| 195 | 195 | * @param String $ident Flight ident |
| 196 | 196 | * @param String $format_source Format source |
| 197 | 197 | */ |
| 198 | - public function deleteByIdent($ident,$format_source) { |
|
| 198 | + public function deleteByIdent($ident, $format_source) { |
|
| 199 | 199 | $query = "DELETE FROM atc WHERE ident = :ident AND format_source = :format_source"; |
| 200 | - $query_values = array(':ident' => $ident,':format_source' => $format_source); |
|
| 200 | + $query_values = array(':ident' => $ident, ':format_source' => $format_source); |
|
| 201 | 201 | try { |
| 202 | 202 | $sth = $this->db->prepare($query); |
| 203 | 203 | $sth->execute($query_values); |
| 204 | - } catch(PDOException $e) { |
|
| 204 | + } catch (PDOException $e) { |
|
| 205 | 205 | return "error : ".$e->getMessage(); |
| 206 | 206 | } |
| 207 | 207 | } |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | try { |
| 216 | 216 | $sth = $this->db->prepare($query); |
| 217 | 217 | $sth->execute($query_values); |
| 218 | - } catch(PDOException $e) { |
|
| 218 | + } catch (PDOException $e) { |
|
| 219 | 219 | return "error : ".$e->getMessage(); |
| 220 | 220 | } |
| 221 | 221 | } |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | try { |
| 234 | 234 | $sth = $this->db->prepare($query); |
| 235 | 235 | $sth->execute(); |
| 236 | - } catch(PDOException $e) { |
|
| 236 | + } catch (PDOException $e) { |
|
| 237 | 237 | return "error"; |
| 238 | 238 | } |
| 239 | 239 | return "success"; |
@@ -18,7 +18,9 @@ discard block |
||
| 18 | 18 | public function __construct($dbc = null) { |
| 19 | 19 | $Connection = new Connection($dbc); |
| 20 | 20 | $this->db = $Connection->db; |
| 21 | - if ($this->db === null) die('Error: No DB connection. (ATC)'); |
|
| 21 | + if ($this->db === null) { |
|
| 22 | + die('Error: No DB connection. (ATC)'); |
|
| 23 | + } |
|
| 22 | 24 | } |
| 23 | 25 | |
| 24 | 26 | /** |
@@ -33,20 +35,27 @@ discard block |
||
| 33 | 35 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
| 34 | 36 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
| 35 | 37 | foreach($globalStatsFilters[$globalFilterName] as $source) { |
| 36 | - if (isset($source['source'])) $filter['source'][] = $source['source']; |
|
| 38 | + if (isset($source['source'])) { |
|
| 39 | + $filter['source'][] = $source['source']; |
|
| 40 | + } |
|
| 37 | 41 | } |
| 38 | 42 | } else { |
| 39 | 43 | $filter = $globalStatsFilters[$globalFilterName]; |
| 40 | 44 | } |
| 41 | 45 | } |
| 42 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 46 | + if (is_array($globalFilter)) { |
|
| 47 | + $filter = array_merge($filter,$globalFilter); |
|
| 48 | + } |
|
| 43 | 49 | $filter_query_join = ''; |
| 44 | 50 | $filter_query_where = ''; |
| 45 | 51 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 46 | 52 | $filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')"; |
| 47 | 53 | } |
| 48 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
| 49 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
| 54 | + if ($filter_query_where == '' && $where) { |
|
| 55 | + $filter_query_where = ' WHERE'; |
|
| 56 | + } elseif ($filter_query_where != '' && $and) { |
|
| 57 | + $filter_query_where .= ' AND'; |
|
| 58 | + } |
|
| 50 | 59 | $filter_query = $filter_query_join.$filter_query_where; |
| 51 | 60 | return $filter_query; |
| 52 | 61 | } |
@@ -133,7 +142,9 @@ discard block |
||
| 133 | 142 | $info = str_replace('^','<br />',$info); |
| 134 | 143 | $info = str_replace('&sect;','',$info); |
| 135 | 144 | $info = str_replace('"','',$info); |
| 136 | - if ($type == '') $type = NULL; |
|
| 145 | + if ($type == '') { |
|
| 146 | + $type = NULL; |
|
| 147 | + } |
|
| 137 | 148 | $query = "INSERT INTO atc (ident,frequency,latitude,longitude,atc_range,info,atc_lastseen,type,ivao_id,ivao_name,format_source,source_name) VALUES (:ident,:frequency,:latitude,:longitude,:range,:info,:date,:type,:ivao_id,:ivao_name,:format_source,:source_name)"; |
| 138 | 149 | $query_values = array(':ident' => $ident,':frequency' => $frequency,':latitude' => $latitude,':longitude' => $longitude,':range' => $range,':info' => $info,':date' => $date,':ivao_id' => $ivao_id,':ivao_name' => $ivao_name, ':type' => $type,':format_source' => $format_source,':source_name' => $source_name); |
| 139 | 150 | try { |
@@ -164,7 +175,9 @@ discard block |
||
| 164 | 175 | $info = str_replace('^','<br />',$info); |
| 165 | 176 | $info = str_replace('&sect;','',$info); |
| 166 | 177 | $info = str_replace('"','',$info); |
| 167 | - if ($type == '') $type = NULL; |
|
| 178 | + if ($type == '') { |
|
| 179 | + $type = NULL; |
|
| 180 | + } |
|
| 168 | 181 | $query = "UPDATE atc SET frequency = :frequency,latitude = :latitude,longitude = :longitude,atc_range = :range,info = :info,atc_lastseen = :date,type = :type,ivao_id = :ivao_id,ivao_name = :ivao_name WHERE ident = :ident AND format_source = :format_source AND source_name = :source_name"; |
| 169 | 182 | $query_values = array(':ident' => $ident,':frequency' => $frequency,':latitude' => $latitude,':longitude' => $longitude,':range' => $range,':info' => $info,':date' => $date,':ivao_id' => $ivao_id,':ivao_name' => $ivao_name, ':type' => $type,':format_source' => $format_source,':source_name' => $source_name); |
| 170 | 183 | try { |
@@ -16,13 +16,13 @@ discard block |
||
| 16 | 16 | if ($this->db === null) die('Error: No DB connection. (MarineArchive)'); |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * Get SQL query part for filter used |
|
| 21 | - * @param array $filter the filter |
|
| 22 | - * @param bool $where |
|
| 23 | - * @param bool $and |
|
| 24 | - * @return string the SQL part |
|
| 25 | - */ |
|
| 19 | + /** |
|
| 20 | + * Get SQL query part for filter used |
|
| 21 | + * @param array $filter the filter |
|
| 22 | + * @param bool $where |
|
| 23 | + * @param bool $and |
|
| 24 | + * @return string the SQL part |
|
| 25 | + */ |
|
| 26 | 26 | public function getFilter($filter = array(),$where = false,$and = false) { |
| 27 | 27 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
| 28 | 28 | $filters = array(); |
@@ -91,40 +91,40 @@ discard block |
||
| 91 | 91 | return $filter_query; |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - /** |
|
| 95 | - * Add to Mariche archive |
|
| 96 | - * |
|
| 97 | - * @param string $fammarine_id |
|
| 98 | - * @param string $ident |
|
| 99 | - * @param string $latitude |
|
| 100 | - * @param string $longitude |
|
| 101 | - * @param string $heading |
|
| 102 | - * @param string $groundspeed |
|
| 103 | - * @param string $date |
|
| 104 | - * @param bool $putinarchive |
|
| 105 | - * @param string $mmsi |
|
| 106 | - * @param string $type |
|
| 107 | - * @param string $typeid |
|
| 108 | - * @param string $imo |
|
| 109 | - * @param string $callsign |
|
| 110 | - * @param string $arrival_code |
|
| 111 | - * @param string $arrival_date |
|
| 112 | - * @param string $status |
|
| 113 | - * @param string $statusid |
|
| 114 | - * @param bool $noarchive |
|
| 115 | - * @param string $format_source |
|
| 116 | - * @param string $source_name |
|
| 117 | - * @param string $over_country |
|
| 118 | - * @param string $captain_id |
|
| 119 | - * @param string $captain_name |
|
| 120 | - * @param string $race_id |
|
| 121 | - * @param string $race_name |
|
| 122 | - * @param string $distance |
|
| 123 | - * @param string $race_rank |
|
| 124 | - * @param string $race_time |
|
| 125 | - * @return string |
|
| 126 | - */ |
|
| 127 | - public function addMarineArchiveData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $statusid = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '', $captain_id = '', $captain_name = '', $race_id = '', $race_name = '', $distance = '', $race_rank = '', $race_time = '') { |
|
| 94 | + /** |
|
| 95 | + * Add to Mariche archive |
|
| 96 | + * |
|
| 97 | + * @param string $fammarine_id |
|
| 98 | + * @param string $ident |
|
| 99 | + * @param string $latitude |
|
| 100 | + * @param string $longitude |
|
| 101 | + * @param string $heading |
|
| 102 | + * @param string $groundspeed |
|
| 103 | + * @param string $date |
|
| 104 | + * @param bool $putinarchive |
|
| 105 | + * @param string $mmsi |
|
| 106 | + * @param string $type |
|
| 107 | + * @param string $typeid |
|
| 108 | + * @param string $imo |
|
| 109 | + * @param string $callsign |
|
| 110 | + * @param string $arrival_code |
|
| 111 | + * @param string $arrival_date |
|
| 112 | + * @param string $status |
|
| 113 | + * @param string $statusid |
|
| 114 | + * @param bool $noarchive |
|
| 115 | + * @param string $format_source |
|
| 116 | + * @param string $source_name |
|
| 117 | + * @param string $over_country |
|
| 118 | + * @param string $captain_id |
|
| 119 | + * @param string $captain_name |
|
| 120 | + * @param string $race_id |
|
| 121 | + * @param string $race_name |
|
| 122 | + * @param string $distance |
|
| 123 | + * @param string $race_rank |
|
| 124 | + * @param string $race_time |
|
| 125 | + * @return string |
|
| 126 | + */ |
|
| 127 | + public function addMarineArchiveData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $statusid = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '', $captain_id = '', $captain_name = '', $race_id = '', $race_name = '', $distance = '', $race_rank = '', $race_time = '') { |
|
| 128 | 128 | require_once(dirname(__FILE__).'/class.Marine.php'); |
| 129 | 129 | if ($over_country == '') { |
| 130 | 130 | $Marine = new Marine($this->db); |
@@ -149,42 +149,42 @@ discard block |
||
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | |
| 152 | - /** |
|
| 153 | - * Gets all the spotter information based on a particular callsign |
|
| 154 | - * |
|
| 155 | - * @param $ident |
|
| 156 | - * @return array the spotter information |
|
| 157 | - */ |
|
| 158 | - public function getLastArchiveMarineDataByIdent($ident) |
|
| 159 | - { |
|
| 160 | - $Marine = new Marine($this->db); |
|
| 161 | - date_default_timezone_set('UTC'); |
|
| 162 | - |
|
| 163 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 164 | - //$query = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
|
| 165 | - $query = "SELECT marine_archive.* FROM marine_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
| 166 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident)); |
|
| 167 | - return $spotter_array; |
|
| 168 | - } |
|
| 169 | - |
|
| 170 | - |
|
| 171 | - /** |
|
| 172 | - * Gets last the spotter information based on a particular id |
|
| 173 | - * |
|
| 174 | - * @param $id |
|
| 175 | - * @return array the spotter information |
|
| 176 | - */ |
|
| 177 | - public function getLastArchiveMarineDataById($id) |
|
| 178 | - { |
|
| 179 | - $Marine = new Marine($this->db); |
|
| 180 | - date_default_timezone_set('UTC'); |
|
| 181 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 182 | - //$query = MarineArchive->$global_query." WHERE marine_archive.fammarine_id = :id"; |
|
| 183 | - //$query = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
|
| 184 | - $query = "SELECT * FROM marine_archive WHERE fammarine_id = :id ORDER BY date DESC LIMIT 1"; |
|
| 152 | + /** |
|
| 153 | + * Gets all the spotter information based on a particular callsign |
|
| 154 | + * |
|
| 155 | + * @param $ident |
|
| 156 | + * @return array the spotter information |
|
| 157 | + */ |
|
| 158 | + public function getLastArchiveMarineDataByIdent($ident) |
|
| 159 | + { |
|
| 160 | + $Marine = new Marine($this->db); |
|
| 161 | + date_default_timezone_set('UTC'); |
|
| 162 | + |
|
| 163 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 164 | + //$query = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
|
| 165 | + $query = "SELECT marine_archive.* FROM marine_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
| 166 | + $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident)); |
|
| 167 | + return $spotter_array; |
|
| 168 | + } |
|
| 169 | + |
|
| 170 | + |
|
| 171 | + /** |
|
| 172 | + * Gets last the spotter information based on a particular id |
|
| 173 | + * |
|
| 174 | + * @param $id |
|
| 175 | + * @return array the spotter information |
|
| 176 | + */ |
|
| 177 | + public function getLastArchiveMarineDataById($id) |
|
| 178 | + { |
|
| 179 | + $Marine = new Marine($this->db); |
|
| 180 | + date_default_timezone_set('UTC'); |
|
| 181 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 182 | + //$query = MarineArchive->$global_query." WHERE marine_archive.fammarine_id = :id"; |
|
| 183 | + //$query = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
|
| 184 | + $query = "SELECT * FROM marine_archive WHERE fammarine_id = :id ORDER BY date DESC LIMIT 1"; |
|
| 185 | 185 | |
| 186 | 186 | // $spotter_array = Marine->getDataFromDB($query,array(':id' => $id)); |
| 187 | - /* |
|
| 187 | + /* |
|
| 188 | 188 | try { |
| 189 | 189 | $Connection = new Connection(); |
| 190 | 190 | $sth = Connection->$db->prepare($query); |
@@ -194,196 +194,196 @@ discard block |
||
| 194 | 194 | } |
| 195 | 195 | $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC); |
| 196 | 196 | */ |
| 197 | - $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id)); |
|
| 198 | - return $spotter_array; |
|
| 199 | - } |
|
| 200 | - |
|
| 201 | - /** |
|
| 202 | - * Gets all the spotter information based on a particular id |
|
| 203 | - * |
|
| 204 | - * @param $id |
|
| 205 | - * @return array the spotter information |
|
| 206 | - */ |
|
| 207 | - public function getAllArchiveMarineDataById($id) |
|
| 197 | + $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id)); |
|
| 198 | + return $spotter_array; |
|
| 199 | + } |
|
| 200 | + |
|
| 201 | + /** |
|
| 202 | + * Gets all the spotter information based on a particular id |
|
| 203 | + * |
|
| 204 | + * @param $id |
|
| 205 | + * @return array the spotter information |
|
| 206 | + */ |
|
| 207 | + public function getAllArchiveMarineDataById($id) |
|
| 208 | 208 | { |
| 209 | - date_default_timezone_set('UTC'); |
|
| 210 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 211 | - $query = $this->global_query." WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
| 209 | + date_default_timezone_set('UTC'); |
|
| 210 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 211 | + $query = $this->global_query." WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
| 212 | 212 | |
| 213 | 213 | // $spotter_array = Marine->getDataFromDB($query,array(':id' => $id)); |
| 214 | 214 | |
| 215 | - try { |
|
| 216 | - $sth = $this->db->prepare($query); |
|
| 217 | - $sth->execute(array(':id' => $id)); |
|
| 218 | - } catch(PDOException $e) { |
|
| 219 | - echo $e->getMessage(); |
|
| 220 | - die; |
|
| 221 | - } |
|
| 222 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 223 | - return $spotter_array; |
|
| 215 | + try { |
|
| 216 | + $sth = $this->db->prepare($query); |
|
| 217 | + $sth->execute(array(':id' => $id)); |
|
| 218 | + } catch(PDOException $e) { |
|
| 219 | + echo $e->getMessage(); |
|
| 220 | + die; |
|
| 221 | + } |
|
| 222 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 223 | + return $spotter_array; |
|
| 224 | 224 | } |
| 225 | 225 | |
| 226 | - /** |
|
| 227 | - * Gets coordinate & time spotter information based on a particular id |
|
| 228 | - * |
|
| 229 | - * @param $id |
|
| 230 | - * @return array the spotter information |
|
| 231 | - */ |
|
| 232 | - public function getCoordArchiveMarineDataById($id) |
|
| 233 | - { |
|
| 234 | - date_default_timezone_set('UTC'); |
|
| 235 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 236 | - $query = "SELECT marine_archive.latitude, marine_archive.longitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id"; |
|
| 226 | + /** |
|
| 227 | + * Gets coordinate & time spotter information based on a particular id |
|
| 228 | + * |
|
| 229 | + * @param $id |
|
| 230 | + * @return array the spotter information |
|
| 231 | + */ |
|
| 232 | + public function getCoordArchiveMarineDataById($id) |
|
| 233 | + { |
|
| 234 | + date_default_timezone_set('UTC'); |
|
| 235 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 236 | + $query = "SELECT marine_archive.latitude, marine_archive.longitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id"; |
|
| 237 | 237 | |
| 238 | 238 | // $spotter_array = Marine->getDataFromDB($query,array(':id' => $id)); |
| 239 | 239 | |
| 240 | - try { |
|
| 241 | - $sth = $this->db->prepare($query); |
|
| 242 | - $sth->execute(array(':id' => $id)); |
|
| 243 | - } catch(PDOException $e) { |
|
| 244 | - echo $e->getMessage(); |
|
| 245 | - die; |
|
| 246 | - } |
|
| 247 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 248 | - |
|
| 249 | - return $spotter_array; |
|
| 250 | - } |
|
| 251 | - |
|
| 252 | - |
|
| 253 | - /** |
|
| 254 | - * Gets altitude information based on a particular callsign |
|
| 255 | - * |
|
| 256 | - * @param $ident |
|
| 257 | - * @return array the spotter information |
|
| 258 | - */ |
|
| 259 | - public function getAltitudeArchiveMarineDataByIdent($ident) |
|
| 260 | - { |
|
| 261 | - |
|
| 262 | - date_default_timezone_set('UTC'); |
|
| 263 | - |
|
| 264 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 265 | - $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date"; |
|
| 266 | - |
|
| 267 | - try { |
|
| 268 | - $sth = $this->db->prepare($query); |
|
| 269 | - $sth->execute(array(':ident' => $ident)); |
|
| 270 | - } catch(PDOException $e) { |
|
| 271 | - echo $e->getMessage(); |
|
| 272 | - die; |
|
| 273 | - } |
|
| 274 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 275 | - |
|
| 276 | - return $spotter_array; |
|
| 277 | - } |
|
| 278 | - |
|
| 279 | - /** |
|
| 280 | - * Gets altitude information based on a particular id |
|
| 281 | - * |
|
| 282 | - * @return array the spotter information |
|
| 283 | - * |
|
| 284 | - */ |
|
| 285 | - public function getAltitudeArchiveMarineDataById($id) |
|
| 286 | - { |
|
| 287 | - |
|
| 288 | - date_default_timezone_set('UTC'); |
|
| 289 | - |
|
| 290 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 291 | - $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date"; |
|
| 292 | - |
|
| 293 | - try { |
|
| 294 | - $sth = $this->db->prepare($query); |
|
| 295 | - $sth->execute(array(':id' => $id)); |
|
| 296 | - } catch(PDOException $e) { |
|
| 297 | - echo $e->getMessage(); |
|
| 298 | - die; |
|
| 299 | - } |
|
| 300 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 301 | - |
|
| 302 | - return $spotter_array; |
|
| 303 | - } |
|
| 304 | - |
|
| 305 | - /** |
|
| 306 | - * Gets altitude & speed information based on a particular id |
|
| 307 | - * |
|
| 308 | - * @param $id |
|
| 309 | - * @return array the spotter information |
|
| 310 | - */ |
|
| 311 | - public function getAltitudeSpeedArchiveMarineDataById($id) |
|
| 312 | - { |
|
| 313 | - date_default_timezone_set('UTC'); |
|
| 314 | - |
|
| 315 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 316 | - $query = "SELECT marine_archive.altitude, marine_archive.ground_speed, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
| 317 | - |
|
| 318 | - try { |
|
| 319 | - $sth = $this->db->prepare($query); |
|
| 320 | - $sth->execute(array(':id' => $id)); |
|
| 321 | - } catch(PDOException $e) { |
|
| 322 | - echo $e->getMessage(); |
|
| 323 | - die; |
|
| 324 | - } |
|
| 325 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 326 | - |
|
| 327 | - return $spotter_array; |
|
| 328 | - } |
|
| 329 | - |
|
| 330 | - |
|
| 331 | - /** |
|
| 332 | - * Gets altitude information based on a particular callsign |
|
| 333 | - * |
|
| 334 | - * @param $ident |
|
| 335 | - * @return array the spotter information |
|
| 336 | - */ |
|
| 337 | - public function getLastAltitudeArchiveMarineDataByIdent($ident) |
|
| 338 | - { |
|
| 339 | - |
|
| 340 | - date_default_timezone_set('UTC'); |
|
| 341 | - |
|
| 342 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 343 | - $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
|
| 240 | + try { |
|
| 241 | + $sth = $this->db->prepare($query); |
|
| 242 | + $sth->execute(array(':id' => $id)); |
|
| 243 | + } catch(PDOException $e) { |
|
| 244 | + echo $e->getMessage(); |
|
| 245 | + die; |
|
| 246 | + } |
|
| 247 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 248 | + |
|
| 249 | + return $spotter_array; |
|
| 250 | + } |
|
| 251 | + |
|
| 252 | + |
|
| 253 | + /** |
|
| 254 | + * Gets altitude information based on a particular callsign |
|
| 255 | + * |
|
| 256 | + * @param $ident |
|
| 257 | + * @return array the spotter information |
|
| 258 | + */ |
|
| 259 | + public function getAltitudeArchiveMarineDataByIdent($ident) |
|
| 260 | + { |
|
| 261 | + |
|
| 262 | + date_default_timezone_set('UTC'); |
|
| 263 | + |
|
| 264 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 265 | + $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date"; |
|
| 266 | + |
|
| 267 | + try { |
|
| 268 | + $sth = $this->db->prepare($query); |
|
| 269 | + $sth->execute(array(':ident' => $ident)); |
|
| 270 | + } catch(PDOException $e) { |
|
| 271 | + echo $e->getMessage(); |
|
| 272 | + die; |
|
| 273 | + } |
|
| 274 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 275 | + |
|
| 276 | + return $spotter_array; |
|
| 277 | + } |
|
| 278 | + |
|
| 279 | + /** |
|
| 280 | + * Gets altitude information based on a particular id |
|
| 281 | + * |
|
| 282 | + * @return array the spotter information |
|
| 283 | + * |
|
| 284 | + */ |
|
| 285 | + public function getAltitudeArchiveMarineDataById($id) |
|
| 286 | + { |
|
| 287 | + |
|
| 288 | + date_default_timezone_set('UTC'); |
|
| 289 | + |
|
| 290 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 291 | + $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date"; |
|
| 292 | + |
|
| 293 | + try { |
|
| 294 | + $sth = $this->db->prepare($query); |
|
| 295 | + $sth->execute(array(':id' => $id)); |
|
| 296 | + } catch(PDOException $e) { |
|
| 297 | + echo $e->getMessage(); |
|
| 298 | + die; |
|
| 299 | + } |
|
| 300 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 301 | + |
|
| 302 | + return $spotter_array; |
|
| 303 | + } |
|
| 304 | + |
|
| 305 | + /** |
|
| 306 | + * Gets altitude & speed information based on a particular id |
|
| 307 | + * |
|
| 308 | + * @param $id |
|
| 309 | + * @return array the spotter information |
|
| 310 | + */ |
|
| 311 | + public function getAltitudeSpeedArchiveMarineDataById($id) |
|
| 312 | + { |
|
| 313 | + date_default_timezone_set('UTC'); |
|
| 314 | + |
|
| 315 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 316 | + $query = "SELECT marine_archive.altitude, marine_archive.ground_speed, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
| 317 | + |
|
| 318 | + try { |
|
| 319 | + $sth = $this->db->prepare($query); |
|
| 320 | + $sth->execute(array(':id' => $id)); |
|
| 321 | + } catch(PDOException $e) { |
|
| 322 | + echo $e->getMessage(); |
|
| 323 | + die; |
|
| 324 | + } |
|
| 325 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 326 | + |
|
| 327 | + return $spotter_array; |
|
| 328 | + } |
|
| 329 | + |
|
| 330 | + |
|
| 331 | + /** |
|
| 332 | + * Gets altitude information based on a particular callsign |
|
| 333 | + * |
|
| 334 | + * @param $ident |
|
| 335 | + * @return array the spotter information |
|
| 336 | + */ |
|
| 337 | + public function getLastAltitudeArchiveMarineDataByIdent($ident) |
|
| 338 | + { |
|
| 339 | + |
|
| 340 | + date_default_timezone_set('UTC'); |
|
| 341 | + |
|
| 342 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 343 | + $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
|
| 344 | 344 | // $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident"; |
| 345 | 345 | |
| 346 | - try { |
|
| 347 | - $sth = $this->db->prepare($query); |
|
| 348 | - $sth->execute(array(':ident' => $ident)); |
|
| 349 | - } catch(PDOException $e) { |
|
| 350 | - echo $e->getMessage(); |
|
| 351 | - die; |
|
| 352 | - } |
|
| 353 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 354 | - |
|
| 355 | - return $spotter_array; |
|
| 356 | - } |
|
| 357 | - |
|
| 358 | - |
|
| 359 | - /** |
|
| 360 | - * Gets all the archive spotter information |
|
| 361 | - * |
|
| 362 | - * @param $ident |
|
| 363 | - * @param $fammarine_id |
|
| 364 | - * @param $date |
|
| 365 | - * @return array the spotter information |
|
| 366 | - */ |
|
| 367 | - public function getMarineArchiveData($ident,$fammarine_id,$date) |
|
| 368 | - { |
|
| 369 | - $Marine = new Marine($this->db); |
|
| 370 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 371 | - $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.fammarine_id = :fammarine_id AND l.date LIKE :date GROUP BY l.fammarine_id) s on spotter_live.fammarine_id = s.fammarine_id AND spotter_live.date = s.maxdate"; |
|
| 372 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':fammarine_id' => $fammarine_id,':date' => $date.'%')); |
|
| 373 | - return $spotter_array; |
|
| 374 | - } |
|
| 375 | - |
|
| 376 | - /** |
|
| 377 | - * Delete all tracking data |
|
| 378 | - * |
|
| 379 | - */ |
|
| 380 | - public function deleteMarineArchiveTrackData() |
|
| 381 | - { |
|
| 382 | - global $globalArchiveKeepTrackMonths, $globalDBdriver; |
|
| 383 | - if ($globalDBdriver == 'mysql') { |
|
| 384 | - $query = 'DELETE FROM marine_archive WHERE marine_archive.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepTrackMonths.' MONTH)'; |
|
| 385 | - } else { |
|
| 386 | - $query = "DELETE FROM marine_archive WHERE marine_archive_id IN (SELECT marine_archive_id FROM marine_archive WHERE marine_archive.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepTrackMonths." MONTH' LIMIT 10000)"; |
|
| 346 | + try { |
|
| 347 | + $sth = $this->db->prepare($query); |
|
| 348 | + $sth->execute(array(':ident' => $ident)); |
|
| 349 | + } catch(PDOException $e) { |
|
| 350 | + echo $e->getMessage(); |
|
| 351 | + die; |
|
| 352 | + } |
|
| 353 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 354 | + |
|
| 355 | + return $spotter_array; |
|
| 356 | + } |
|
| 357 | + |
|
| 358 | + |
|
| 359 | + /** |
|
| 360 | + * Gets all the archive spotter information |
|
| 361 | + * |
|
| 362 | + * @param $ident |
|
| 363 | + * @param $fammarine_id |
|
| 364 | + * @param $date |
|
| 365 | + * @return array the spotter information |
|
| 366 | + */ |
|
| 367 | + public function getMarineArchiveData($ident,$fammarine_id,$date) |
|
| 368 | + { |
|
| 369 | + $Marine = new Marine($this->db); |
|
| 370 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 371 | + $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.fammarine_id = :fammarine_id AND l.date LIKE :date GROUP BY l.fammarine_id) s on spotter_live.fammarine_id = s.fammarine_id AND spotter_live.date = s.maxdate"; |
|
| 372 | + $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':fammarine_id' => $fammarine_id,':date' => $date.'%')); |
|
| 373 | + return $spotter_array; |
|
| 374 | + } |
|
| 375 | + |
|
| 376 | + /** |
|
| 377 | + * Delete all tracking data |
|
| 378 | + * |
|
| 379 | + */ |
|
| 380 | + public function deleteMarineArchiveTrackData() |
|
| 381 | + { |
|
| 382 | + global $globalArchiveKeepTrackMonths, $globalDBdriver; |
|
| 383 | + if ($globalDBdriver == 'mysql') { |
|
| 384 | + $query = 'DELETE FROM marine_archive WHERE marine_archive.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepTrackMonths.' MONTH)'; |
|
| 385 | + } else { |
|
| 386 | + $query = "DELETE FROM marine_archive WHERE marine_archive_id IN (SELECT marine_archive_id FROM marine_archive WHERE marine_archive.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepTrackMonths." MONTH' LIMIT 10000)"; |
|
| 387 | 387 | } |
| 388 | 388 | try { |
| 389 | 389 | $sth = $this->db->prepare($query); |
@@ -394,42 +394,42 @@ discard block |
||
| 394 | 394 | } |
| 395 | 395 | } |
| 396 | 396 | |
| 397 | - /** |
|
| 398 | - * Gets Minimal Live Marine data |
|
| 399 | - * |
|
| 400 | - * @param $begindate |
|
| 401 | - * @param $enddate |
|
| 402 | - * @param array $filter |
|
| 403 | - * @return array the spotter information |
|
| 404 | - */ |
|
| 405 | - public function getMinLiveMarineData($begindate,$enddate,$filter = array()) |
|
| 406 | - { |
|
| 407 | - global $globalDBdriver, $globalLiveInterval; |
|
| 408 | - date_default_timezone_set('UTC'); |
|
| 409 | - |
|
| 410 | - $filter_query = ''; |
|
| 411 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 412 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 413 | - } |
|
| 414 | - // Use spotter_output also ? |
|
| 415 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 416 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
| 417 | - } |
|
| 418 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 419 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
|
| 420 | - } |
|
| 421 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 422 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 423 | - } |
|
| 424 | - |
|
| 425 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 426 | - if ($globalDBdriver == 'mysql') { |
|
| 427 | - /* |
|
| 397 | + /** |
|
| 398 | + * Gets Minimal Live Marine data |
|
| 399 | + * |
|
| 400 | + * @param $begindate |
|
| 401 | + * @param $enddate |
|
| 402 | + * @param array $filter |
|
| 403 | + * @return array the spotter information |
|
| 404 | + */ |
|
| 405 | + public function getMinLiveMarineData($begindate,$enddate,$filter = array()) |
|
| 406 | + { |
|
| 407 | + global $globalDBdriver, $globalLiveInterval; |
|
| 408 | + date_default_timezone_set('UTC'); |
|
| 409 | + |
|
| 410 | + $filter_query = ''; |
|
| 411 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 412 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 413 | + } |
|
| 414 | + // Use spotter_output also ? |
|
| 415 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 416 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
| 417 | + } |
|
| 418 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 419 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
|
| 420 | + } |
|
| 421 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 422 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 423 | + } |
|
| 424 | + |
|
| 425 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 426 | + if ($globalDBdriver == 'mysql') { |
|
| 427 | + /* |
|
| 428 | 428 | $query = 'SELECT a.aircraft_shadow, marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk |
| 429 | 429 | FROM marine_archive |
| 430 | 430 | INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive.aircraft_icao = a.icao'; |
| 431 | 431 | */ |
| 432 | - /* |
|
| 432 | + /* |
|
| 433 | 433 | $query = 'SELECT a.aircraft_shadow, marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk |
| 434 | 434 | FROM marine_archive |
| 435 | 435 | INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate |
@@ -438,540 +438,540 @@ discard block |
||
| 438 | 438 | GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id |
| 439 | 439 | AND marine_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive.aircraft_icao = a.icao'; |
| 440 | 440 | */ |
| 441 | - $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 441 | + $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 442 | 442 | FROM marine_archive |
| 443 | 443 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao |
| 444 | 444 | WHERE marine_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' |
| 445 | 445 | '.$filter_query.' ORDER BY fammarine_id'; |
| 446 | - } else { |
|
| 447 | - //$query = 'SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao'; |
|
| 448 | - $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 446 | + } else { |
|
| 447 | + //$query = 'SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao'; |
|
| 448 | + $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 449 | 449 | FROM marine_archive |
| 450 | 450 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao |
| 451 | 451 | WHERE marine_archive.date >= '."'".$begindate."'".' AND marine_archive.date <= '."'".$enddate."'".' |
| 452 | 452 | '.$filter_query.' ORDER BY fammarine_id'; |
| 453 | - } |
|
| 454 | - //echo $query; |
|
| 455 | - try { |
|
| 456 | - $sth = $this->db->prepare($query); |
|
| 457 | - $sth->execute(); |
|
| 458 | - } catch(PDOException $e) { |
|
| 459 | - echo $e->getMessage(); |
|
| 460 | - die; |
|
| 461 | - } |
|
| 462 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 463 | - |
|
| 464 | - return $spotter_array; |
|
| 465 | - } |
|
| 466 | - |
|
| 467 | - /** |
|
| 468 | - * Gets Minimal Live Marine data |
|
| 469 | - * |
|
| 470 | - * @param $begindate |
|
| 471 | - * @param $enddate |
|
| 472 | - * @param array $filter |
|
| 473 | - * @return array the spotter information |
|
| 474 | - */ |
|
| 475 | - public function getMinLiveMarineDataPlayback($begindate,$enddate,$filter = array()) |
|
| 476 | - { |
|
| 477 | - global $globalDBdriver, $globalLiveInterval; |
|
| 478 | - date_default_timezone_set('UTC'); |
|
| 479 | - |
|
| 480 | - $filter_query = ''; |
|
| 481 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 482 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 483 | - } |
|
| 484 | - // Should use spotter_output also ? |
|
| 485 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 486 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
| 487 | - } |
|
| 488 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 489 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
|
| 490 | - } |
|
| 491 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 492 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 493 | - } |
|
| 494 | - |
|
| 495 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 496 | - if ($globalDBdriver == 'mysql') { |
|
| 497 | - /* |
|
| 453 | + } |
|
| 454 | + //echo $query; |
|
| 455 | + try { |
|
| 456 | + $sth = $this->db->prepare($query); |
|
| 457 | + $sth->execute(); |
|
| 458 | + } catch(PDOException $e) { |
|
| 459 | + echo $e->getMessage(); |
|
| 460 | + die; |
|
| 461 | + } |
|
| 462 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 463 | + |
|
| 464 | + return $spotter_array; |
|
| 465 | + } |
|
| 466 | + |
|
| 467 | + /** |
|
| 468 | + * Gets Minimal Live Marine data |
|
| 469 | + * |
|
| 470 | + * @param $begindate |
|
| 471 | + * @param $enddate |
|
| 472 | + * @param array $filter |
|
| 473 | + * @return array the spotter information |
|
| 474 | + */ |
|
| 475 | + public function getMinLiveMarineDataPlayback($begindate,$enddate,$filter = array()) |
|
| 476 | + { |
|
| 477 | + global $globalDBdriver, $globalLiveInterval; |
|
| 478 | + date_default_timezone_set('UTC'); |
|
| 479 | + |
|
| 480 | + $filter_query = ''; |
|
| 481 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 482 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 483 | + } |
|
| 484 | + // Should use spotter_output also ? |
|
| 485 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 486 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
| 487 | + } |
|
| 488 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 489 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
|
| 490 | + } |
|
| 491 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 492 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 493 | + } |
|
| 494 | + |
|
| 495 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 496 | + if ($globalDBdriver == 'mysql') { |
|
| 497 | + /* |
|
| 498 | 498 | $query = 'SELECT a.aircraft_shadow, marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk |
| 499 | 499 | FROM marine_archive |
| 500 | 500 | INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive.aircraft_icao = a.icao'; |
| 501 | 501 | */ |
| 502 | - $query = 'SELECT a.aircraft_shadow, marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk |
|
| 502 | + $query = 'SELECT a.aircraft_shadow, marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk |
|
| 503 | 503 | FROM marine_archive_output |
| 504 | 504 | LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive_output.aircraft_icao = a.icao |
| 505 | 505 | WHERE (marine_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
| 506 | 506 | '.$filter_query.' GROUP BY marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao, marine_archive_output.arrival_airport_icao, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow'; |
| 507 | 507 | |
| 508 | - } else { |
|
| 509 | - //$query = 'SELECT marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow FROM marine_archive_output INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive_output.fammarine_id = s.fammarine_id AND marine_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao'; |
|
| 510 | - /* |
|
| 508 | + } else { |
|
| 509 | + //$query = 'SELECT marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow FROM marine_archive_output INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive_output.fammarine_id = s.fammarine_id AND marine_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao'; |
|
| 510 | + /* |
|
| 511 | 511 | $query = 'SELECT marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow |
| 512 | 512 | FROM marine_archive_output |
| 513 | 513 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao |
| 514 | 514 | WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".' |
| 515 | 515 | '.$filter_query.' GROUP BY marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao, marine_archive_output.arrival_airport_icao, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow'; |
| 516 | 516 | */ |
| 517 | - $query = 'SELECT DISTINCT marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow |
|
| 517 | + $query = 'SELECT DISTINCT marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow |
|
| 518 | 518 | FROM marine_archive_output |
| 519 | 519 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao |
| 520 | 520 | WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".' |
| 521 | 521 | '.$filter_query.' LIMIT 200 OFFSET 0'; |
| 522 | 522 | // .' GROUP BY spotter_output.fammarine_id, spotter_output.ident, spotter_output.aircraft_icao, spotter_output.departure_airport_icao, spotter_output.arrival_airport_icao, spotter_output.latitude, spotter_output.longitude, spotter_output.altitude, spotter_output.heading, spotter_output.ground_speed, spotter_output.squawk, a.aircraft_shadow'; |
| 523 | 523 | |
| 524 | - } |
|
| 525 | - //echo $query; |
|
| 526 | - try { |
|
| 527 | - $sth = $this->db->prepare($query); |
|
| 528 | - $sth->execute(); |
|
| 529 | - } catch(PDOException $e) { |
|
| 530 | - echo $e->getMessage(); |
|
| 531 | - die; |
|
| 532 | - } |
|
| 533 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 534 | - |
|
| 535 | - return $spotter_array; |
|
| 536 | - } |
|
| 537 | - |
|
| 538 | - /** |
|
| 539 | - * Gets count Live Marine data |
|
| 540 | - * |
|
| 541 | - * @param $begindate |
|
| 542 | - * @param $enddate |
|
| 543 | - * @param array $filter |
|
| 544 | - * @return array the spotter information |
|
| 545 | - */ |
|
| 546 | - public function getLiveMarineCount($begindate,$enddate,$filter = array()) |
|
| 547 | - { |
|
| 548 | - global $globalDBdriver, $globalLiveInterval; |
|
| 549 | - date_default_timezone_set('UTC'); |
|
| 550 | - |
|
| 551 | - $filter_query = ''; |
|
| 552 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 553 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 554 | - } |
|
| 555 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 556 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
| 557 | - } |
|
| 558 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 559 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
|
| 560 | - } |
|
| 561 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 562 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 563 | - } |
|
| 564 | - |
|
| 565 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 566 | - if ($globalDBdriver == 'mysql') { |
|
| 567 | - $query = 'SELECT COUNT(DISTINCT fammarine_id) as nb |
|
| 524 | + } |
|
| 525 | + //echo $query; |
|
| 526 | + try { |
|
| 527 | + $sth = $this->db->prepare($query); |
|
| 528 | + $sth->execute(); |
|
| 529 | + } catch(PDOException $e) { |
|
| 530 | + echo $e->getMessage(); |
|
| 531 | + die; |
|
| 532 | + } |
|
| 533 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 534 | + |
|
| 535 | + return $spotter_array; |
|
| 536 | + } |
|
| 537 | + |
|
| 538 | + /** |
|
| 539 | + * Gets count Live Marine data |
|
| 540 | + * |
|
| 541 | + * @param $begindate |
|
| 542 | + * @param $enddate |
|
| 543 | + * @param array $filter |
|
| 544 | + * @return array the spotter information |
|
| 545 | + */ |
|
| 546 | + public function getLiveMarineCount($begindate,$enddate,$filter = array()) |
|
| 547 | + { |
|
| 548 | + global $globalDBdriver, $globalLiveInterval; |
|
| 549 | + date_default_timezone_set('UTC'); |
|
| 550 | + |
|
| 551 | + $filter_query = ''; |
|
| 552 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 553 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 554 | + } |
|
| 555 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 556 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
| 557 | + } |
|
| 558 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 559 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
|
| 560 | + } |
|
| 561 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 562 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 563 | + } |
|
| 564 | + |
|
| 565 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 566 | + if ($globalDBdriver == 'mysql') { |
|
| 567 | + $query = 'SELECT COUNT(DISTINCT fammarine_id) as nb |
|
| 568 | 568 | FROM marine_archive l |
| 569 | 569 | WHERE (l.date BETWEEN DATE_SUB('."'".$begindate."'".',INTERVAL '.$globalLiveInterval.' SECOND) AND '."'".$begindate."'".')'.$filter_query; |
| 570 | - } else { |
|
| 571 | - $query = 'SELECT COUNT(DISTINCT fammarine_id) as nb FROM marine_archive l WHERE (l.date BETWEEN '."'".$begindate."' - INTERVAL '".$globalLiveInterval." SECONDS' AND "."'".$enddate."'".')'.$filter_query; |
|
| 572 | - } |
|
| 573 | - //echo $query; |
|
| 574 | - try { |
|
| 575 | - $sth = $this->db->prepare($query); |
|
| 576 | - $sth->execute(); |
|
| 577 | - } catch(PDOException $e) { |
|
| 578 | - echo $e->getMessage(); |
|
| 579 | - die; |
|
| 580 | - } |
|
| 581 | - $result = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 582 | - $sth->closeCursor(); |
|
| 583 | - return $result['nb']; |
|
| 584 | - } |
|
| 570 | + } else { |
|
| 571 | + $query = 'SELECT COUNT(DISTINCT fammarine_id) as nb FROM marine_archive l WHERE (l.date BETWEEN '."'".$begindate."' - INTERVAL '".$globalLiveInterval." SECONDS' AND "."'".$enddate."'".')'.$filter_query; |
|
| 572 | + } |
|
| 573 | + //echo $query; |
|
| 574 | + try { |
|
| 575 | + $sth = $this->db->prepare($query); |
|
| 576 | + $sth->execute(); |
|
| 577 | + } catch(PDOException $e) { |
|
| 578 | + echo $e->getMessage(); |
|
| 579 | + die; |
|
| 580 | + } |
|
| 581 | + $result = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 582 | + $sth->closeCursor(); |
|
| 583 | + return $result['nb']; |
|
| 584 | + } |
|
| 585 | 585 | |
| 586 | 586 | |
| 587 | 587 | |
| 588 | 588 | // marine_archive_output |
| 589 | 589 | |
| 590 | - /** |
|
| 591 | - * Gets all the spotter information |
|
| 592 | - * |
|
| 593 | - * @param string $q |
|
| 594 | - * @param string $registration |
|
| 595 | - * @param string $aircraft_icao |
|
| 596 | - * @param string $aircraft_manufacturer |
|
| 597 | - * @param string $highlights |
|
| 598 | - * @param string $airline_icao |
|
| 599 | - * @param string $airline_country |
|
| 600 | - * @param string $airline_type |
|
| 601 | - * @param string $airport |
|
| 602 | - * @param string $airport_country |
|
| 603 | - * @param string $callsign |
|
| 604 | - * @param string $departure_airport_route |
|
| 605 | - * @param string $arrival_airport_route |
|
| 606 | - * @param string $owner |
|
| 607 | - * @param string $pilot_id |
|
| 608 | - * @param string $pilot_name |
|
| 609 | - * @param string $altitude |
|
| 610 | - * @param string $date_posted |
|
| 611 | - * @param string $limit |
|
| 612 | - * @param string $sort |
|
| 613 | - * @param string $includegeodata |
|
| 614 | - * @param string $origLat |
|
| 615 | - * @param string $origLon |
|
| 616 | - * @param string $dist |
|
| 617 | - * @param array $filters |
|
| 618 | - * @return array the spotter information |
|
| 619 | - */ |
|
| 620 | - public function searchMarineData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array()) |
|
| 621 | - { |
|
| 622 | - global $globalTimezone, $globalDBdriver; |
|
| 623 | - require_once(dirname(__FILE__).'/class.Translation.php'); |
|
| 624 | - $Translation = new Translation($this->db); |
|
| 625 | - $Marine = new Marine($this->db); |
|
| 626 | - |
|
| 627 | - date_default_timezone_set('UTC'); |
|
| 590 | + /** |
|
| 591 | + * Gets all the spotter information |
|
| 592 | + * |
|
| 593 | + * @param string $q |
|
| 594 | + * @param string $registration |
|
| 595 | + * @param string $aircraft_icao |
|
| 596 | + * @param string $aircraft_manufacturer |
|
| 597 | + * @param string $highlights |
|
| 598 | + * @param string $airline_icao |
|
| 599 | + * @param string $airline_country |
|
| 600 | + * @param string $airline_type |
|
| 601 | + * @param string $airport |
|
| 602 | + * @param string $airport_country |
|
| 603 | + * @param string $callsign |
|
| 604 | + * @param string $departure_airport_route |
|
| 605 | + * @param string $arrival_airport_route |
|
| 606 | + * @param string $owner |
|
| 607 | + * @param string $pilot_id |
|
| 608 | + * @param string $pilot_name |
|
| 609 | + * @param string $altitude |
|
| 610 | + * @param string $date_posted |
|
| 611 | + * @param string $limit |
|
| 612 | + * @param string $sort |
|
| 613 | + * @param string $includegeodata |
|
| 614 | + * @param string $origLat |
|
| 615 | + * @param string $origLon |
|
| 616 | + * @param string $dist |
|
| 617 | + * @param array $filters |
|
| 618 | + * @return array the spotter information |
|
| 619 | + */ |
|
| 620 | + public function searchMarineData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array()) |
|
| 621 | + { |
|
| 622 | + global $globalTimezone, $globalDBdriver; |
|
| 623 | + require_once(dirname(__FILE__).'/class.Translation.php'); |
|
| 624 | + $Translation = new Translation($this->db); |
|
| 625 | + $Marine = new Marine($this->db); |
|
| 626 | + |
|
| 627 | + date_default_timezone_set('UTC'); |
|
| 628 | 628 | |
| 629 | - $query_values = array(); |
|
| 630 | - $additional_query = ''; |
|
| 631 | - $limit_query = ''; |
|
| 632 | - $filter_query = $this->getFilter($filters); |
|
| 633 | - if ($q != "") |
|
| 634 | - { |
|
| 635 | - if (!is_string($q)) |
|
| 636 | - { |
|
| 637 | - return array(); |
|
| 638 | - } else { |
|
| 639 | - $q_array = explode(" ", $q); |
|
| 629 | + $query_values = array(); |
|
| 630 | + $additional_query = ''; |
|
| 631 | + $limit_query = ''; |
|
| 632 | + $filter_query = $this->getFilter($filters); |
|
| 633 | + if ($q != "") |
|
| 634 | + { |
|
| 635 | + if (!is_string($q)) |
|
| 636 | + { |
|
| 637 | + return array(); |
|
| 638 | + } else { |
|
| 639 | + $q_array = explode(" ", $q); |
|
| 640 | 640 | |
| 641 | - foreach ($q_array as $q_item){ |
|
| 642 | - $additional_query .= " AND ("; |
|
| 643 | - $additional_query .= "(marine_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
| 644 | - $additional_query .= "(marine_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
| 645 | - $additional_query .= "(marine_archive_output.aircraft_name like '%".$q_item."%') OR "; |
|
| 646 | - $additional_query .= "(marine_archive_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
|
| 647 | - $additional_query .= "(marine_archive_output.airline_icao like '%".$q_item."%') OR "; |
|
| 648 | - $additional_query .= "(marine_archive_output.airline_name like '%".$q_item."%') OR "; |
|
| 649 | - $additional_query .= "(marine_archive_output.airline_country like '%".$q_item."%') OR "; |
|
| 650 | - $additional_query .= "(marine_archive_output.departure_airport_icao like '%".$q_item."%') OR "; |
|
| 651 | - $additional_query .= "(marine_archive_output.departure_airport_name like '%".$q_item."%') OR "; |
|
| 652 | - $additional_query .= "(marine_archive_output.departure_airport_city like '%".$q_item."%') OR "; |
|
| 653 | - $additional_query .= "(marine_archive_output.departure_airport_country like '%".$q_item."%') OR "; |
|
| 654 | - $additional_query .= "(marine_archive_output.arrival_airport_icao like '%".$q_item."%') OR "; |
|
| 655 | - $additional_query .= "(marine_archive_output.arrival_airport_name like '%".$q_item."%') OR "; |
|
| 656 | - $additional_query .= "(marine_archive_output.arrival_airport_city like '%".$q_item."%') OR "; |
|
| 657 | - $additional_query .= "(marine_archive_output.arrival_airport_country like '%".$q_item."%') OR "; |
|
| 658 | - $additional_query .= "(marine_archive_output.registration like '%".$q_item."%') OR "; |
|
| 659 | - $additional_query .= "(marine_archive_output.owner_name like '%".$q_item."%') OR "; |
|
| 660 | - $additional_query .= "(marine_archive_output.pilot_id like '%".$q_item."%') OR "; |
|
| 661 | - $additional_query .= "(marine_archive_output.pilot_name like '%".$q_item."%') OR "; |
|
| 662 | - $additional_query .= "(marine_archive_output.ident like '%".$q_item."%') OR "; |
|
| 663 | - $translate = $Translation->ident2icao($q_item); |
|
| 664 | - if ($translate != $q_item) $additional_query .= "(marine_archive_output.ident like '%".$translate."%') OR "; |
|
| 665 | - $additional_query .= "(marine_archive_output.highlight like '%".$q_item."%')"; |
|
| 666 | - $additional_query .= ")"; |
|
| 667 | - } |
|
| 668 | - } |
|
| 669 | - } |
|
| 641 | + foreach ($q_array as $q_item){ |
|
| 642 | + $additional_query .= " AND ("; |
|
| 643 | + $additional_query .= "(marine_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
| 644 | + $additional_query .= "(marine_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
| 645 | + $additional_query .= "(marine_archive_output.aircraft_name like '%".$q_item."%') OR "; |
|
| 646 | + $additional_query .= "(marine_archive_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
|
| 647 | + $additional_query .= "(marine_archive_output.airline_icao like '%".$q_item."%') OR "; |
|
| 648 | + $additional_query .= "(marine_archive_output.airline_name like '%".$q_item."%') OR "; |
|
| 649 | + $additional_query .= "(marine_archive_output.airline_country like '%".$q_item."%') OR "; |
|
| 650 | + $additional_query .= "(marine_archive_output.departure_airport_icao like '%".$q_item."%') OR "; |
|
| 651 | + $additional_query .= "(marine_archive_output.departure_airport_name like '%".$q_item."%') OR "; |
|
| 652 | + $additional_query .= "(marine_archive_output.departure_airport_city like '%".$q_item."%') OR "; |
|
| 653 | + $additional_query .= "(marine_archive_output.departure_airport_country like '%".$q_item."%') OR "; |
|
| 654 | + $additional_query .= "(marine_archive_output.arrival_airport_icao like '%".$q_item."%') OR "; |
|
| 655 | + $additional_query .= "(marine_archive_output.arrival_airport_name like '%".$q_item."%') OR "; |
|
| 656 | + $additional_query .= "(marine_archive_output.arrival_airport_city like '%".$q_item."%') OR "; |
|
| 657 | + $additional_query .= "(marine_archive_output.arrival_airport_country like '%".$q_item."%') OR "; |
|
| 658 | + $additional_query .= "(marine_archive_output.registration like '%".$q_item."%') OR "; |
|
| 659 | + $additional_query .= "(marine_archive_output.owner_name like '%".$q_item."%') OR "; |
|
| 660 | + $additional_query .= "(marine_archive_output.pilot_id like '%".$q_item."%') OR "; |
|
| 661 | + $additional_query .= "(marine_archive_output.pilot_name like '%".$q_item."%') OR "; |
|
| 662 | + $additional_query .= "(marine_archive_output.ident like '%".$q_item."%') OR "; |
|
| 663 | + $translate = $Translation->ident2icao($q_item); |
|
| 664 | + if ($translate != $q_item) $additional_query .= "(marine_archive_output.ident like '%".$translate."%') OR "; |
|
| 665 | + $additional_query .= "(marine_archive_output.highlight like '%".$q_item."%')"; |
|
| 666 | + $additional_query .= ")"; |
|
| 667 | + } |
|
| 668 | + } |
|
| 669 | + } |
|
| 670 | 670 | |
| 671 | - if ($registration != "") |
|
| 672 | - { |
|
| 673 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 674 | - if (!is_string($registration)) |
|
| 675 | - { |
|
| 676 | - return array(); |
|
| 677 | - } else { |
|
| 678 | - $additional_query .= " AND (marine_archive_output.registration = '".$registration."')"; |
|
| 679 | - } |
|
| 680 | - } |
|
| 671 | + if ($registration != "") |
|
| 672 | + { |
|
| 673 | + $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 674 | + if (!is_string($registration)) |
|
| 675 | + { |
|
| 676 | + return array(); |
|
| 677 | + } else { |
|
| 678 | + $additional_query .= " AND (marine_archive_output.registration = '".$registration."')"; |
|
| 679 | + } |
|
| 680 | + } |
|
| 681 | 681 | |
| 682 | - if ($aircraft_icao != "") |
|
| 683 | - { |
|
| 684 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 685 | - if (!is_string($aircraft_icao)) |
|
| 686 | - { |
|
| 687 | - return array(); |
|
| 688 | - } else { |
|
| 689 | - $additional_query .= " AND (marine_archive_output.aircraft_icao = '".$aircraft_icao."')"; |
|
| 690 | - } |
|
| 691 | - } |
|
| 682 | + if ($aircraft_icao != "") |
|
| 683 | + { |
|
| 684 | + $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 685 | + if (!is_string($aircraft_icao)) |
|
| 686 | + { |
|
| 687 | + return array(); |
|
| 688 | + } else { |
|
| 689 | + $additional_query .= " AND (marine_archive_output.aircraft_icao = '".$aircraft_icao."')"; |
|
| 690 | + } |
|
| 691 | + } |
|
| 692 | 692 | |
| 693 | - if ($aircraft_manufacturer != "") |
|
| 694 | - { |
|
| 695 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
| 696 | - if (!is_string($aircraft_manufacturer)) |
|
| 697 | - { |
|
| 698 | - return array(); |
|
| 699 | - } else { |
|
| 700 | - $additional_query .= " AND (marine_archive_output.aircraft_manufacturer = '".$aircraft_manufacturer."')"; |
|
| 701 | - } |
|
| 702 | - } |
|
| 693 | + if ($aircraft_manufacturer != "") |
|
| 694 | + { |
|
| 695 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
| 696 | + if (!is_string($aircraft_manufacturer)) |
|
| 697 | + { |
|
| 698 | + return array(); |
|
| 699 | + } else { |
|
| 700 | + $additional_query .= " AND (marine_archive_output.aircraft_manufacturer = '".$aircraft_manufacturer."')"; |
|
| 701 | + } |
|
| 702 | + } |
|
| 703 | 703 | |
| 704 | - if ($highlights == "true") |
|
| 705 | - { |
|
| 706 | - if (!is_string($highlights)) |
|
| 707 | - { |
|
| 708 | - return array(); |
|
| 709 | - } else { |
|
| 710 | - $additional_query .= " AND (marine_archive_output.highlight <> '')"; |
|
| 711 | - } |
|
| 712 | - } |
|
| 704 | + if ($highlights == "true") |
|
| 705 | + { |
|
| 706 | + if (!is_string($highlights)) |
|
| 707 | + { |
|
| 708 | + return array(); |
|
| 709 | + } else { |
|
| 710 | + $additional_query .= " AND (marine_archive_output.highlight <> '')"; |
|
| 711 | + } |
|
| 712 | + } |
|
| 713 | 713 | |
| 714 | - if ($airline_icao != "") |
|
| 715 | - { |
|
| 716 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
| 717 | - if (!is_string($airline_icao)) |
|
| 718 | - { |
|
| 719 | - return array(); |
|
| 720 | - } else { |
|
| 721 | - $additional_query .= " AND (marine_archive_output.airline_icao = '".$airline_icao."')"; |
|
| 722 | - } |
|
| 723 | - } |
|
| 714 | + if ($airline_icao != "") |
|
| 715 | + { |
|
| 716 | + $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
| 717 | + if (!is_string($airline_icao)) |
|
| 718 | + { |
|
| 719 | + return array(); |
|
| 720 | + } else { |
|
| 721 | + $additional_query .= " AND (marine_archive_output.airline_icao = '".$airline_icao."')"; |
|
| 722 | + } |
|
| 723 | + } |
|
| 724 | 724 | |
| 725 | - if ($airline_country != "") |
|
| 726 | - { |
|
| 727 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
| 728 | - if (!is_string($airline_country)) |
|
| 729 | - { |
|
| 730 | - return array(); |
|
| 731 | - } else { |
|
| 732 | - $additional_query .= " AND (marine_archive_output.airline_country = '".$airline_country."')"; |
|
| 733 | - } |
|
| 734 | - } |
|
| 725 | + if ($airline_country != "") |
|
| 726 | + { |
|
| 727 | + $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
| 728 | + if (!is_string($airline_country)) |
|
| 729 | + { |
|
| 730 | + return array(); |
|
| 731 | + } else { |
|
| 732 | + $additional_query .= " AND (marine_archive_output.airline_country = '".$airline_country."')"; |
|
| 733 | + } |
|
| 734 | + } |
|
| 735 | 735 | |
| 736 | - if ($airline_type != "") |
|
| 737 | - { |
|
| 738 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
| 739 | - if (!is_string($airline_type)) |
|
| 740 | - { |
|
| 741 | - return array(); |
|
| 742 | - } else { |
|
| 743 | - if ($airline_type == "passenger") |
|
| 744 | - { |
|
| 745 | - $additional_query .= " AND (marine_archive_output.airline_type = 'passenger')"; |
|
| 746 | - } |
|
| 747 | - if ($airline_type == "cargo") |
|
| 748 | - { |
|
| 749 | - $additional_query .= " AND (marine_archive_output.airline_type = 'cargo')"; |
|
| 750 | - } |
|
| 751 | - if ($airline_type == "military") |
|
| 752 | - { |
|
| 753 | - $additional_query .= " AND (marine_archive_output.airline_type = 'military')"; |
|
| 754 | - } |
|
| 755 | - } |
|
| 756 | - } |
|
| 736 | + if ($airline_type != "") |
|
| 737 | + { |
|
| 738 | + $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
| 739 | + if (!is_string($airline_type)) |
|
| 740 | + { |
|
| 741 | + return array(); |
|
| 742 | + } else { |
|
| 743 | + if ($airline_type == "passenger") |
|
| 744 | + { |
|
| 745 | + $additional_query .= " AND (marine_archive_output.airline_type = 'passenger')"; |
|
| 746 | + } |
|
| 747 | + if ($airline_type == "cargo") |
|
| 748 | + { |
|
| 749 | + $additional_query .= " AND (marine_archive_output.airline_type = 'cargo')"; |
|
| 750 | + } |
|
| 751 | + if ($airline_type == "military") |
|
| 752 | + { |
|
| 753 | + $additional_query .= " AND (marine_archive_output.airline_type = 'military')"; |
|
| 754 | + } |
|
| 755 | + } |
|
| 756 | + } |
|
| 757 | 757 | |
| 758 | - if ($airport != "") |
|
| 759 | - { |
|
| 760 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
| 761 | - if (!is_string($airport)) |
|
| 762 | - { |
|
| 763 | - return array(); |
|
| 764 | - } else { |
|
| 765 | - $additional_query .= " AND ((marine_archive_output.departure_airport_icao = '".$airport."') OR (marine_archive_output.arrival_airport_icao = '".$airport."'))"; |
|
| 766 | - } |
|
| 767 | - } |
|
| 758 | + if ($airport != "") |
|
| 759 | + { |
|
| 760 | + $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
| 761 | + if (!is_string($airport)) |
|
| 762 | + { |
|
| 763 | + return array(); |
|
| 764 | + } else { |
|
| 765 | + $additional_query .= " AND ((marine_archive_output.departure_airport_icao = '".$airport."') OR (marine_archive_output.arrival_airport_icao = '".$airport."'))"; |
|
| 766 | + } |
|
| 767 | + } |
|
| 768 | 768 | |
| 769 | - if ($airport_country != "") |
|
| 770 | - { |
|
| 771 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
| 772 | - if (!is_string($airport_country)) |
|
| 773 | - { |
|
| 774 | - return array(); |
|
| 775 | - } else { |
|
| 776 | - $additional_query .= " AND ((marine_archive_output.departure_airport_country = '".$airport_country."') OR (marine_archive_output.arrival_airport_country = '".$airport_country."'))"; |
|
| 777 | - } |
|
| 778 | - } |
|
| 769 | + if ($airport_country != "") |
|
| 770 | + { |
|
| 771 | + $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
| 772 | + if (!is_string($airport_country)) |
|
| 773 | + { |
|
| 774 | + return array(); |
|
| 775 | + } else { |
|
| 776 | + $additional_query .= " AND ((marine_archive_output.departure_airport_country = '".$airport_country."') OR (marine_archive_output.arrival_airport_country = '".$airport_country."'))"; |
|
| 777 | + } |
|
| 778 | + } |
|
| 779 | 779 | |
| 780 | - if ($callsign != "") |
|
| 781 | - { |
|
| 782 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 783 | - if (!is_string($callsign)) |
|
| 784 | - { |
|
| 785 | - return array(); |
|
| 786 | - } else { |
|
| 787 | - $translate = $Translation->ident2icao($callsign); |
|
| 788 | - if ($translate != $callsign) { |
|
| 789 | - $additional_query .= " AND (marine_archive_output.ident = :callsign OR marine_archive_output.ident = :translate)"; |
|
| 790 | - $query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate)); |
|
| 791 | - } else { |
|
| 792 | - $additional_query .= " AND (marine_archive_output.ident = '".$callsign."')"; |
|
| 793 | - } |
|
| 794 | - } |
|
| 795 | - } |
|
| 796 | - |
|
| 797 | - if ($owner != "") |
|
| 798 | - { |
|
| 799 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 800 | - if (!is_string($owner)) |
|
| 801 | - { |
|
| 802 | - return array(); |
|
| 803 | - } else { |
|
| 804 | - $additional_query .= " AND (marine_archive_output.owner_name = '".$owner."')"; |
|
| 805 | - } |
|
| 806 | - } |
|
| 807 | - |
|
| 808 | - if ($pilot_name != "") |
|
| 809 | - { |
|
| 810 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
| 811 | - if (!is_string($pilot_name)) |
|
| 812 | - { |
|
| 813 | - return array(); |
|
| 814 | - } else { |
|
| 815 | - $additional_query .= " AND (marine_archive_output.pilot_name = '".$pilot_name."')"; |
|
| 816 | - } |
|
| 817 | - } |
|
| 780 | + if ($callsign != "") |
|
| 781 | + { |
|
| 782 | + $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 783 | + if (!is_string($callsign)) |
|
| 784 | + { |
|
| 785 | + return array(); |
|
| 786 | + } else { |
|
| 787 | + $translate = $Translation->ident2icao($callsign); |
|
| 788 | + if ($translate != $callsign) { |
|
| 789 | + $additional_query .= " AND (marine_archive_output.ident = :callsign OR marine_archive_output.ident = :translate)"; |
|
| 790 | + $query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate)); |
|
| 791 | + } else { |
|
| 792 | + $additional_query .= " AND (marine_archive_output.ident = '".$callsign."')"; |
|
| 793 | + } |
|
| 794 | + } |
|
| 795 | + } |
|
| 796 | + |
|
| 797 | + if ($owner != "") |
|
| 798 | + { |
|
| 799 | + $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 800 | + if (!is_string($owner)) |
|
| 801 | + { |
|
| 802 | + return array(); |
|
| 803 | + } else { |
|
| 804 | + $additional_query .= " AND (marine_archive_output.owner_name = '".$owner."')"; |
|
| 805 | + } |
|
| 806 | + } |
|
| 807 | + |
|
| 808 | + if ($pilot_name != "") |
|
| 809 | + { |
|
| 810 | + $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
| 811 | + if (!is_string($pilot_name)) |
|
| 812 | + { |
|
| 813 | + return array(); |
|
| 814 | + } else { |
|
| 815 | + $additional_query .= " AND (marine_archive_output.pilot_name = '".$pilot_name."')"; |
|
| 816 | + } |
|
| 817 | + } |
|
| 818 | 818 | |
| 819 | - if ($pilot_id != "") |
|
| 820 | - { |
|
| 821 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
| 822 | - if (!is_string($pilot_id)) |
|
| 823 | - { |
|
| 824 | - return array(); |
|
| 825 | - } else { |
|
| 826 | - $additional_query .= " AND (marine_archive_output.pilot_id = '".$pilot_id."')"; |
|
| 827 | - } |
|
| 828 | - } |
|
| 819 | + if ($pilot_id != "") |
|
| 820 | + { |
|
| 821 | + $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
| 822 | + if (!is_string($pilot_id)) |
|
| 823 | + { |
|
| 824 | + return array(); |
|
| 825 | + } else { |
|
| 826 | + $additional_query .= " AND (marine_archive_output.pilot_id = '".$pilot_id."')"; |
|
| 827 | + } |
|
| 828 | + } |
|
| 829 | 829 | |
| 830 | - if ($departure_airport_route != "") |
|
| 831 | - { |
|
| 832 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
| 833 | - if (!is_string($departure_airport_route)) |
|
| 834 | - { |
|
| 835 | - return array(); |
|
| 836 | - } else { |
|
| 837 | - $additional_query .= " AND (marine_archive_output.departure_airport_icao = '".$departure_airport_route."')"; |
|
| 838 | - } |
|
| 839 | - } |
|
| 830 | + if ($departure_airport_route != "") |
|
| 831 | + { |
|
| 832 | + $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
| 833 | + if (!is_string($departure_airport_route)) |
|
| 834 | + { |
|
| 835 | + return array(); |
|
| 836 | + } else { |
|
| 837 | + $additional_query .= " AND (marine_archive_output.departure_airport_icao = '".$departure_airport_route."')"; |
|
| 838 | + } |
|
| 839 | + } |
|
| 840 | 840 | |
| 841 | - if ($arrival_airport_route != "") |
|
| 842 | - { |
|
| 843 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
| 844 | - if (!is_string($arrival_airport_route)) |
|
| 845 | - { |
|
| 846 | - return array(); |
|
| 847 | - } else { |
|
| 848 | - $additional_query .= " AND (marine_archive_output.arrival_airport_icao = '".$arrival_airport_route."')"; |
|
| 849 | - } |
|
| 850 | - } |
|
| 841 | + if ($arrival_airport_route != "") |
|
| 842 | + { |
|
| 843 | + $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
| 844 | + if (!is_string($arrival_airport_route)) |
|
| 845 | + { |
|
| 846 | + return array(); |
|
| 847 | + } else { |
|
| 848 | + $additional_query .= " AND (marine_archive_output.arrival_airport_icao = '".$arrival_airport_route."')"; |
|
| 849 | + } |
|
| 850 | + } |
|
| 851 | 851 | |
| 852 | - if ($altitude != "") |
|
| 853 | - { |
|
| 854 | - $altitude_array = explode(",", $altitude); |
|
| 852 | + if ($altitude != "") |
|
| 853 | + { |
|
| 854 | + $altitude_array = explode(",", $altitude); |
|
| 855 | 855 | |
| 856 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 857 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 856 | + $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 857 | + $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 858 | 858 | |
| 859 | 859 | |
| 860 | - if ($altitude_array[1] != "") |
|
| 861 | - { |
|
| 862 | - $altitude_array[0] = substr($altitude_array[0], 0, -2); |
|
| 863 | - $altitude_array[1] = substr($altitude_array[1], 0, -2); |
|
| 864 | - $additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' "; |
|
| 865 | - } else { |
|
| 866 | - $altitude_array[0] = substr($altitude_array[0], 0, -2); |
|
| 867 | - $additional_query .= " AND altitude <= '".$altitude_array[0]."' "; |
|
| 868 | - } |
|
| 869 | - } |
|
| 860 | + if ($altitude_array[1] != "") |
|
| 861 | + { |
|
| 862 | + $altitude_array[0] = substr($altitude_array[0], 0, -2); |
|
| 863 | + $altitude_array[1] = substr($altitude_array[1], 0, -2); |
|
| 864 | + $additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' "; |
|
| 865 | + } else { |
|
| 866 | + $altitude_array[0] = substr($altitude_array[0], 0, -2); |
|
| 867 | + $additional_query .= " AND altitude <= '".$altitude_array[0]."' "; |
|
| 868 | + } |
|
| 869 | + } |
|
| 870 | 870 | |
| 871 | - if ($date_posted != "") |
|
| 872 | - { |
|
| 873 | - $date_array = explode(",", $date_posted); |
|
| 871 | + if ($date_posted != "") |
|
| 872 | + { |
|
| 873 | + $date_array = explode(",", $date_posted); |
|
| 874 | 874 | |
| 875 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
| 876 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
| 875 | + $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
| 876 | + $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
| 877 | 877 | |
| 878 | - if ($globalTimezone != '') { |
|
| 879 | - date_default_timezone_set($globalTimezone); |
|
| 880 | - $datetime = new DateTime(); |
|
| 881 | - $offset = $datetime->format('P'); |
|
| 882 | - } else $offset = '+00:00'; |
|
| 883 | - |
|
| 884 | - |
|
| 885 | - if ($date_array[1] != "") |
|
| 886 | - { |
|
| 887 | - $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
|
| 888 | - $date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1])); |
|
| 889 | - if ($globalDBdriver == 'mysql') { |
|
| 890 | - $additional_query .= " AND TIMESTAMP(CONVERT_TZ(marine_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' AND TIMESTAMP(CONVERT_TZ(marine_archive_output.date,'+00:00', '".$offset."')) <= '".$date_array[1]."' "; |
|
| 891 | - } else { |
|
| 892 | - $additional_query .= " AND marine_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) AND marine_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." <= CAST('".$date_array[1]."' AS TIMESTAMP) "; |
|
| 893 | - } |
|
| 894 | - } else { |
|
| 895 | - $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
|
| 896 | - if ($globalDBdriver == 'mysql') { |
|
| 897 | - $additional_query .= " AND TIMESTAMP(CONVERT_TZ(marine_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' "; |
|
| 898 | - } else { |
|
| 899 | - $additional_query .= " AND marine_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) "; |
|
| 900 | - } |
|
| 901 | - } |
|
| 902 | - } |
|
| 878 | + if ($globalTimezone != '') { |
|
| 879 | + date_default_timezone_set($globalTimezone); |
|
| 880 | + $datetime = new DateTime(); |
|
| 881 | + $offset = $datetime->format('P'); |
|
| 882 | + } else $offset = '+00:00'; |
|
| 883 | + |
|
| 884 | + |
|
| 885 | + if ($date_array[1] != "") |
|
| 886 | + { |
|
| 887 | + $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
|
| 888 | + $date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1])); |
|
| 889 | + if ($globalDBdriver == 'mysql') { |
|
| 890 | + $additional_query .= " AND TIMESTAMP(CONVERT_TZ(marine_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' AND TIMESTAMP(CONVERT_TZ(marine_archive_output.date,'+00:00', '".$offset."')) <= '".$date_array[1]."' "; |
|
| 891 | + } else { |
|
| 892 | + $additional_query .= " AND marine_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) AND marine_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." <= CAST('".$date_array[1]."' AS TIMESTAMP) "; |
|
| 893 | + } |
|
| 894 | + } else { |
|
| 895 | + $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
|
| 896 | + if ($globalDBdriver == 'mysql') { |
|
| 897 | + $additional_query .= " AND TIMESTAMP(CONVERT_TZ(marine_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' "; |
|
| 898 | + } else { |
|
| 899 | + $additional_query .= " AND marine_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) "; |
|
| 900 | + } |
|
| 901 | + } |
|
| 902 | + } |
|
| 903 | 903 | |
| 904 | - if ($limit != "") |
|
| 905 | - { |
|
| 906 | - $limit_array = explode(",", $limit); |
|
| 904 | + if ($limit != "") |
|
| 905 | + { |
|
| 906 | + $limit_array = explode(",", $limit); |
|
| 907 | 907 | |
| 908 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 909 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 908 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 909 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 910 | 910 | |
| 911 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 912 | - { |
|
| 913 | - //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
|
| 914 | - $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
|
| 915 | - } |
|
| 916 | - } |
|
| 911 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 912 | + { |
|
| 913 | + //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
|
| 914 | + $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
|
| 915 | + } |
|
| 916 | + } |
|
| 917 | 917 | |
| 918 | 918 | |
| 919 | - if ($origLat != "" && $origLon != "" && $dist != "") { |
|
| 920 | - $dist = number_format($dist*0.621371,2,'.',''); |
|
| 921 | - $query="SELECT marine_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(marine_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(marine_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
| 919 | + if ($origLat != "" && $origLon != "" && $dist != "") { |
|
| 920 | + $dist = number_format($dist*0.621371,2,'.',''); |
|
| 921 | + $query="SELECT marine_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(marine_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(marine_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
| 922 | 922 | FROM marine_archive_output, marine_archive WHERE spotter_output_archive.fammarine_id = marine_archive.fammarine_id AND spotter_output.ident <> '' ".$additional_query."AND CAST(marine_archive.longitude as double precision) between ($origLon-$dist/ABS(cos(radians($origLat))*69)) and ($origLon+$dist/ABS(cos(radians($origLat))*69)) and CAST(marine_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) |
| 923 | 923 | AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(marine_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(marine_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query." ORDER BY distance"; |
| 924 | - } else { |
|
| 925 | - if ($sort != "") |
|
| 926 | - { |
|
| 927 | - $search_orderby_array = $Marine->getOrderBy(); |
|
| 928 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 929 | - } else { |
|
| 930 | - $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
| 931 | - } |
|
| 924 | + } else { |
|
| 925 | + if ($sort != "") |
|
| 926 | + { |
|
| 927 | + $search_orderby_array = $Marine->getOrderBy(); |
|
| 928 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 929 | + } else { |
|
| 930 | + $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
| 931 | + } |
|
| 932 | 932 | |
| 933 | - if ($includegeodata == "true") |
|
| 934 | - { |
|
| 935 | - $additional_query .= " AND (marine_archive_output.waypoints <> '')"; |
|
| 936 | - } |
|
| 933 | + if ($includegeodata == "true") |
|
| 934 | + { |
|
| 935 | + $additional_query .= " AND (marine_archive_output.waypoints <> '')"; |
|
| 936 | + } |
|
| 937 | 937 | |
| 938 | - $query = "SELECT marine_archive_output.* FROM marine_archive_output |
|
| 938 | + $query = "SELECT marine_archive_output.* FROM marine_archive_output |
|
| 939 | 939 | WHERE marine_archive_output.ident <> '' |
| 940 | 940 | ".$additional_query." |
| 941 | 941 | ".$filter_query.$orderby_query; |
| 942 | - } |
|
| 943 | - $spotter_array = $Marine->getDataFromDB($query, $query_values,$limit_query); |
|
| 944 | - |
|
| 945 | - return $spotter_array; |
|
| 946 | - } |
|
| 947 | - |
|
| 948 | - public function deleteMarineArchiveData() |
|
| 949 | - { |
|
| 950 | - global $globalArchiveKeepMonths, $globalDBdriver; |
|
| 951 | - date_default_timezone_set('UTC'); |
|
| 952 | - if ($globalDBdriver == 'mysql') { |
|
| 953 | - $query = 'DELETE FROM marine_archive_output WHERE marine_archive_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepMonths.' MONTH)'; |
|
| 954 | - } else { |
|
| 955 | - $query = "DELETE FROM marine_archive_output WHERE marine_archive_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepMonths." MONTH'"; |
|
| 956 | - } |
|
| 957 | - try { |
|
| 958 | - $sth = $this->db->prepare($query); |
|
| 959 | - $sth->execute(); |
|
| 960 | - } catch(PDOException $e) { |
|
| 961 | - return "error"; |
|
| 962 | - } |
|
| 963 | - } |
|
| 964 | - |
|
| 965 | - /** |
|
| 966 | - * Gets all the spotter information based on the callsign |
|
| 967 | - * |
|
| 968 | - * @param string $ident |
|
| 969 | - * @param string $limit |
|
| 970 | - * @param string $sort |
|
| 971 | - * @return array the spotter information |
|
| 972 | - */ |
|
| 973 | - public function getMarineDataByIdent($ident = '', $limit = '', $sort = '') |
|
| 974 | - { |
|
| 942 | + } |
|
| 943 | + $spotter_array = $Marine->getDataFromDB($query, $query_values,$limit_query); |
|
| 944 | + |
|
| 945 | + return $spotter_array; |
|
| 946 | + } |
|
| 947 | + |
|
| 948 | + public function deleteMarineArchiveData() |
|
| 949 | + { |
|
| 950 | + global $globalArchiveKeepMonths, $globalDBdriver; |
|
| 951 | + date_default_timezone_set('UTC'); |
|
| 952 | + if ($globalDBdriver == 'mysql') { |
|
| 953 | + $query = 'DELETE FROM marine_archive_output WHERE marine_archive_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepMonths.' MONTH)'; |
|
| 954 | + } else { |
|
| 955 | + $query = "DELETE FROM marine_archive_output WHERE marine_archive_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepMonths." MONTH'"; |
|
| 956 | + } |
|
| 957 | + try { |
|
| 958 | + $sth = $this->db->prepare($query); |
|
| 959 | + $sth->execute(); |
|
| 960 | + } catch(PDOException $e) { |
|
| 961 | + return "error"; |
|
| 962 | + } |
|
| 963 | + } |
|
| 964 | + |
|
| 965 | + /** |
|
| 966 | + * Gets all the spotter information based on the callsign |
|
| 967 | + * |
|
| 968 | + * @param string $ident |
|
| 969 | + * @param string $limit |
|
| 970 | + * @param string $sort |
|
| 971 | + * @return array the spotter information |
|
| 972 | + */ |
|
| 973 | + public function getMarineDataByIdent($ident = '', $limit = '', $sort = '') |
|
| 974 | + { |
|
| 975 | 975 | $global_query = "SELECT marine_archive_output.* FROM marine_archive_output"; |
| 976 | 976 | |
| 977 | 977 | date_default_timezone_set('UTC'); |
@@ -983,35 +983,35 @@ discard block |
||
| 983 | 983 | |
| 984 | 984 | if ($ident != "") |
| 985 | 985 | { |
| 986 | - if (!is_string($ident)) |
|
| 987 | - { |
|
| 986 | + if (!is_string($ident)) |
|
| 987 | + { |
|
| 988 | 988 | return false; |
| 989 | - } else { |
|
| 989 | + } else { |
|
| 990 | 990 | $additional_query = " AND (marine_archive_output.ident = :ident)"; |
| 991 | 991 | $query_values = array(':ident' => $ident); |
| 992 | - } |
|
| 992 | + } |
|
| 993 | 993 | } |
| 994 | 994 | |
| 995 | 995 | if ($limit != "") |
| 996 | 996 | { |
| 997 | - $limit_array = explode(",", $limit); |
|
| 997 | + $limit_array = explode(",", $limit); |
|
| 998 | 998 | |
| 999 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1000 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 999 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1000 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1001 | 1001 | |
| 1002 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1003 | - { |
|
| 1002 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1003 | + { |
|
| 1004 | 1004 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 1005 | 1005 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 1006 | - } |
|
| 1006 | + } |
|
| 1007 | 1007 | } |
| 1008 | 1008 | |
| 1009 | 1009 | if ($sort != "") |
| 1010 | 1010 | { |
| 1011 | - $search_orderby_array = $Marine->getOrderBy(); |
|
| 1012 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1011 | + $search_orderby_array = $Marine->getOrderBy(); |
|
| 1012 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1013 | 1013 | } else { |
| 1014 | - $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
| 1014 | + $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
| 1015 | 1015 | } |
| 1016 | 1016 | |
| 1017 | 1017 | $query = $global_query." WHERE marine_archive_output.ident <> '' ".$additional_query." ".$orderby_query; |
@@ -1019,20 +1019,20 @@ discard block |
||
| 1019 | 1019 | $spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query); |
| 1020 | 1020 | |
| 1021 | 1021 | return $spotter_array; |
| 1022 | - } |
|
| 1023 | - |
|
| 1024 | - |
|
| 1025 | - /** |
|
| 1026 | - * Gets all the spotter information based on the owner |
|
| 1027 | - * |
|
| 1028 | - * @param string $owner |
|
| 1029 | - * @param string $limit |
|
| 1030 | - * @param string $sort |
|
| 1031 | - * @param array $filter |
|
| 1032 | - * @return array the spotter information |
|
| 1033 | - */ |
|
| 1034 | - public function getMarineDataByOwner($owner = '', $limit = '', $sort = '', $filter = array()) |
|
| 1035 | - { |
|
| 1022 | + } |
|
| 1023 | + |
|
| 1024 | + |
|
| 1025 | + /** |
|
| 1026 | + * Gets all the spotter information based on the owner |
|
| 1027 | + * |
|
| 1028 | + * @param string $owner |
|
| 1029 | + * @param string $limit |
|
| 1030 | + * @param string $sort |
|
| 1031 | + * @param array $filter |
|
| 1032 | + * @return array the spotter information |
|
| 1033 | + */ |
|
| 1034 | + public function getMarineDataByOwner($owner = '', $limit = '', $sort = '', $filter = array()) |
|
| 1035 | + { |
|
| 1036 | 1036 | $global_query = "SELECT marine_archive_output.* FROM marine_archive_output"; |
| 1037 | 1037 | |
| 1038 | 1038 | date_default_timezone_set('UTC'); |
@@ -1045,35 +1045,35 @@ discard block |
||
| 1045 | 1045 | |
| 1046 | 1046 | if ($owner != "") |
| 1047 | 1047 | { |
| 1048 | - if (!is_string($owner)) |
|
| 1049 | - { |
|
| 1048 | + if (!is_string($owner)) |
|
| 1049 | + { |
|
| 1050 | 1050 | return array(); |
| 1051 | - } else { |
|
| 1051 | + } else { |
|
| 1052 | 1052 | $additional_query = " AND (marine_archive_output.owner_name = :owner)"; |
| 1053 | 1053 | $query_values = array(':owner' => $owner); |
| 1054 | - } |
|
| 1054 | + } |
|
| 1055 | 1055 | } |
| 1056 | 1056 | |
| 1057 | 1057 | if ($limit != "") |
| 1058 | 1058 | { |
| 1059 | - $limit_array = explode(",", $limit); |
|
| 1059 | + $limit_array = explode(",", $limit); |
|
| 1060 | 1060 | |
| 1061 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1062 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1061 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1062 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1063 | 1063 | |
| 1064 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1065 | - { |
|
| 1064 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1065 | + { |
|
| 1066 | 1066 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 1067 | 1067 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 1068 | - } |
|
| 1068 | + } |
|
| 1069 | 1069 | } |
| 1070 | 1070 | |
| 1071 | 1071 | if ($sort != "") |
| 1072 | 1072 | { |
| 1073 | - $search_orderby_array = $Marine->getOrderBy(); |
|
| 1074 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1073 | + $search_orderby_array = $Marine->getOrderBy(); |
|
| 1074 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1075 | 1075 | } else { |
| 1076 | - $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
| 1076 | + $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
| 1077 | 1077 | } |
| 1078 | 1078 | |
| 1079 | 1079 | $query = $global_query.$filter_query." marine_archive_output.owner_name <> '' ".$additional_query." ".$orderby_query; |
@@ -1081,19 +1081,19 @@ discard block |
||
| 1081 | 1081 | $spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query); |
| 1082 | 1082 | |
| 1083 | 1083 | return $spotter_array; |
| 1084 | - } |
|
| 1085 | - |
|
| 1086 | - /** |
|
| 1087 | - * Gets all the spotter information based on the pilot |
|
| 1088 | - * |
|
| 1089 | - * @param string $pilot |
|
| 1090 | - * @param string $limit |
|
| 1091 | - * @param string $sort |
|
| 1092 | - * @param array $filter |
|
| 1093 | - * @return array the spotter information |
|
| 1094 | - */ |
|
| 1095 | - public function getMarineDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array()) |
|
| 1096 | - { |
|
| 1084 | + } |
|
| 1085 | + |
|
| 1086 | + /** |
|
| 1087 | + * Gets all the spotter information based on the pilot |
|
| 1088 | + * |
|
| 1089 | + * @param string $pilot |
|
| 1090 | + * @param string $limit |
|
| 1091 | + * @param string $sort |
|
| 1092 | + * @param array $filter |
|
| 1093 | + * @return array the spotter information |
|
| 1094 | + */ |
|
| 1095 | + public function getMarineDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array()) |
|
| 1096 | + { |
|
| 1097 | 1097 | $global_query = "SELECT marine_archive_output.* FROM marine_archive_output"; |
| 1098 | 1098 | |
| 1099 | 1099 | date_default_timezone_set('UTC'); |
@@ -1112,24 +1112,24 @@ discard block |
||
| 1112 | 1112 | |
| 1113 | 1113 | if ($limit != "") |
| 1114 | 1114 | { |
| 1115 | - $limit_array = explode(",", $limit); |
|
| 1115 | + $limit_array = explode(",", $limit); |
|
| 1116 | 1116 | |
| 1117 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1118 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1117 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1118 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1119 | 1119 | |
| 1120 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1121 | - { |
|
| 1120 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1121 | + { |
|
| 1122 | 1122 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 1123 | 1123 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 1124 | - } |
|
| 1124 | + } |
|
| 1125 | 1125 | } |
| 1126 | 1126 | |
| 1127 | 1127 | if ($sort != "") |
| 1128 | 1128 | { |
| 1129 | - $search_orderby_array = $Marine->getOrderBy(); |
|
| 1130 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1129 | + $search_orderby_array = $Marine->getOrderBy(); |
|
| 1130 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1131 | 1131 | } else { |
| 1132 | - $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
| 1132 | + $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
| 1133 | 1133 | } |
| 1134 | 1134 | |
| 1135 | 1135 | $query = $global_query.$filter_query." marine_archive_output.pilot_name <> '' ".$additional_query." ".$orderby_query; |
@@ -1137,18 +1137,18 @@ discard block |
||
| 1137 | 1137 | $spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query); |
| 1138 | 1138 | |
| 1139 | 1139 | return $spotter_array; |
| 1140 | - } |
|
| 1141 | - |
|
| 1142 | - /** |
|
| 1143 | - * Gets all number of flight over countries |
|
| 1144 | - * |
|
| 1145 | - * @param bool $limit |
|
| 1146 | - * @param int $olderthanmonths |
|
| 1147 | - * @param string $sincedate |
|
| 1148 | - * @return array the airline country list |
|
| 1149 | - */ |
|
| 1150 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1151 | - { |
|
| 1140 | + } |
|
| 1141 | + |
|
| 1142 | + /** |
|
| 1143 | + * Gets all number of flight over countries |
|
| 1144 | + * |
|
| 1145 | + * @param bool $limit |
|
| 1146 | + * @param int $olderthanmonths |
|
| 1147 | + * @param string $sincedate |
|
| 1148 | + * @return array the airline country list |
|
| 1149 | + */ |
|
| 1150 | + public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1151 | + { |
|
| 1152 | 1152 | global $globalDBdriver; |
| 1153 | 1153 | /* |
| 1154 | 1154 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
@@ -1158,14 +1158,14 @@ discard block |
||
| 1158 | 1158 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
| 1159 | 1159 | FROM countries c, marine_archive s |
| 1160 | 1160 | WHERE c.iso2 = s.over_country "; |
| 1161 | - if ($olderthanmonths > 0) { |
|
| 1162 | - if ($globalDBdriver == 'mysql') { |
|
| 1161 | + if ($olderthanmonths > 0) { |
|
| 1162 | + if ($globalDBdriver == 'mysql') { |
|
| 1163 | 1163 | $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
| 1164 | 1164 | } else { |
| 1165 | 1165 | $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
| 1166 | 1166 | } |
| 1167 | 1167 | } |
| 1168 | - if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
| 1168 | + if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
| 1169 | 1169 | $query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
| 1170 | 1170 | if ($limit) $query .= " LIMIT 0,10"; |
| 1171 | 1171 | |
@@ -1178,25 +1178,25 @@ discard block |
||
| 1178 | 1178 | |
| 1179 | 1179 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
| 1180 | 1180 | { |
| 1181 | - $temp_array['flight_count'] = $row['nb']; |
|
| 1182 | - $temp_array['flight_country'] = $row['name']; |
|
| 1183 | - $temp_array['flight_country_iso3'] = $row['iso3']; |
|
| 1184 | - $temp_array['flight_country_iso2'] = $row['iso2']; |
|
| 1185 | - $flight_array[] = $temp_array; |
|
| 1181 | + $temp_array['flight_count'] = $row['nb']; |
|
| 1182 | + $temp_array['flight_country'] = $row['name']; |
|
| 1183 | + $temp_array['flight_country_iso3'] = $row['iso3']; |
|
| 1184 | + $temp_array['flight_country_iso2'] = $row['iso2']; |
|
| 1185 | + $flight_array[] = $temp_array; |
|
| 1186 | 1186 | } |
| 1187 | 1187 | return $flight_array; |
| 1188 | - } |
|
| 1189 | - |
|
| 1190 | - /** |
|
| 1191 | - * Gets all number of flight over countries |
|
| 1192 | - * |
|
| 1193 | - * @param bool $limit |
|
| 1194 | - * @param int $olderthanmonths |
|
| 1195 | - * @param string $sincedate |
|
| 1196 | - * @return array the airline country list |
|
| 1197 | - */ |
|
| 1198 | - public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1199 | - { |
|
| 1188 | + } |
|
| 1189 | + |
|
| 1190 | + /** |
|
| 1191 | + * Gets all number of flight over countries |
|
| 1192 | + * |
|
| 1193 | + * @param bool $limit |
|
| 1194 | + * @param int $olderthanmonths |
|
| 1195 | + * @param string $sincedate |
|
| 1196 | + * @return array the airline country list |
|
| 1197 | + */ |
|
| 1198 | + public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1199 | + { |
|
| 1200 | 1200 | global $globalDBdriver; |
| 1201 | 1201 | /* |
| 1202 | 1202 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
@@ -1206,14 +1206,14 @@ discard block |
||
| 1206 | 1206 | $query = "SELECT o.airline_icao,c.name, c.iso3, c.iso2, count(c.name) as nb |
| 1207 | 1207 | FROM countries c, marine_archive s, spotter_output o |
| 1208 | 1208 | WHERE c.iso2 = s.over_country AND o.airline_icao <> '' AND o.fammarine_id = s.fammarine_id "; |
| 1209 | - if ($olderthanmonths > 0) { |
|
| 1210 | - if ($globalDBdriver == 'mysql') { |
|
| 1209 | + if ($olderthanmonths > 0) { |
|
| 1210 | + if ($globalDBdriver == 'mysql') { |
|
| 1211 | 1211 | $query .= 'AND s.date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
| 1212 | 1212 | } else { |
| 1213 | 1213 | $query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
| 1214 | 1214 | } |
| 1215 | 1215 | } |
| 1216 | - if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
| 1216 | + if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
| 1217 | 1217 | $query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
| 1218 | 1218 | if ($limit) $query .= " LIMIT 0,10"; |
| 1219 | 1219 | |
@@ -1226,25 +1226,25 @@ discard block |
||
| 1226 | 1226 | |
| 1227 | 1227 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
| 1228 | 1228 | { |
| 1229 | - $temp_array['airline_icao'] = $row['airline_icao']; |
|
| 1230 | - $temp_array['flight_count'] = $row['nb']; |
|
| 1231 | - $temp_array['flight_country'] = $row['name']; |
|
| 1232 | - $temp_array['flight_country_iso3'] = $row['iso3']; |
|
| 1233 | - $temp_array['flight_country_iso2'] = $row['iso2']; |
|
| 1234 | - $flight_array[] = $temp_array; |
|
| 1229 | + $temp_array['airline_icao'] = $row['airline_icao']; |
|
| 1230 | + $temp_array['flight_count'] = $row['nb']; |
|
| 1231 | + $temp_array['flight_country'] = $row['name']; |
|
| 1232 | + $temp_array['flight_country_iso3'] = $row['iso3']; |
|
| 1233 | + $temp_array['flight_country_iso2'] = $row['iso2']; |
|
| 1234 | + $flight_array[] = $temp_array; |
|
| 1235 | 1235 | } |
| 1236 | 1236 | return $flight_array; |
| 1237 | - } |
|
| 1238 | - |
|
| 1239 | - /** |
|
| 1240 | - * Gets last spotter information based on a particular callsign |
|
| 1241 | - * |
|
| 1242 | - * @param $id |
|
| 1243 | - * @param $date |
|
| 1244 | - * @return array the spotter information |
|
| 1245 | - */ |
|
| 1246 | - public function getDateArchiveMarineDataById($id,$date) |
|
| 1247 | - { |
|
| 1237 | + } |
|
| 1238 | + |
|
| 1239 | + /** |
|
| 1240 | + * Gets last spotter information based on a particular callsign |
|
| 1241 | + * |
|
| 1242 | + * @param $id |
|
| 1243 | + * @param $date |
|
| 1244 | + * @return array the spotter information |
|
| 1245 | + */ |
|
| 1246 | + public function getDateArchiveMarineDataById($id,$date) |
|
| 1247 | + { |
|
| 1248 | 1248 | $Marine = new Marine($this->db); |
| 1249 | 1249 | date_default_timezone_set('UTC'); |
| 1250 | 1250 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
@@ -1252,17 +1252,17 @@ discard block |
||
| 1252 | 1252 | $date = date('c',$date); |
| 1253 | 1253 | $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
| 1254 | 1254 | return $spotter_array; |
| 1255 | - } |
|
| 1256 | - |
|
| 1257 | - /** |
|
| 1258 | - * Gets all the spotter information based on a particular callsign |
|
| 1259 | - * |
|
| 1260 | - * @param $ident |
|
| 1261 | - * @param $date |
|
| 1262 | - * @return array the spotter information |
|
| 1263 | - */ |
|
| 1264 | - public function getDateArchiveMarineDataByIdent($ident,$date) |
|
| 1265 | - { |
|
| 1255 | + } |
|
| 1256 | + |
|
| 1257 | + /** |
|
| 1258 | + * Gets all the spotter information based on a particular callsign |
|
| 1259 | + * |
|
| 1260 | + * @param $ident |
|
| 1261 | + * @param $date |
|
| 1262 | + * @return array the spotter information |
|
| 1263 | + */ |
|
| 1264 | + public function getDateArchiveMarineDataByIdent($ident,$date) |
|
| 1265 | + { |
|
| 1266 | 1266 | $Marine = new Marine($this->db); |
| 1267 | 1267 | date_default_timezone_set('UTC'); |
| 1268 | 1268 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
@@ -1270,65 +1270,65 @@ discard block |
||
| 1270 | 1270 | $date = date('c',$date); |
| 1271 | 1271 | $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
| 1272 | 1272 | return $spotter_array; |
| 1273 | - } |
|
| 1274 | - |
|
| 1275 | - /** |
|
| 1276 | - * Gets all the spotter information based on the airport |
|
| 1277 | - * |
|
| 1278 | - * @param string $airport |
|
| 1279 | - * @param string $limit |
|
| 1280 | - * @param string $sort |
|
| 1281 | - * @param array $filters |
|
| 1282 | - * @return array the spotter information |
|
| 1283 | - */ |
|
| 1284 | - public function getMarineDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
| 1285 | - { |
|
| 1286 | - global $global_query; |
|
| 1287 | - $Marine = new Marine($this->db); |
|
| 1288 | - date_default_timezone_set('UTC'); |
|
| 1289 | - $query_values = array(); |
|
| 1290 | - $limit_query = ''; |
|
| 1291 | - $additional_query = ''; |
|
| 1292 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1273 | + } |
|
| 1274 | + |
|
| 1275 | + /** |
|
| 1276 | + * Gets all the spotter information based on the airport |
|
| 1277 | + * |
|
| 1278 | + * @param string $airport |
|
| 1279 | + * @param string $limit |
|
| 1280 | + * @param string $sort |
|
| 1281 | + * @param array $filters |
|
| 1282 | + * @return array the spotter information |
|
| 1283 | + */ |
|
| 1284 | + public function getMarineDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
| 1285 | + { |
|
| 1286 | + global $global_query; |
|
| 1287 | + $Marine = new Marine($this->db); |
|
| 1288 | + date_default_timezone_set('UTC'); |
|
| 1289 | + $query_values = array(); |
|
| 1290 | + $limit_query = ''; |
|
| 1291 | + $additional_query = ''; |
|
| 1292 | + $filter_query = $this->getFilter($filters,true,true); |
|
| 1293 | 1293 | |
| 1294 | - if ($airport != "") |
|
| 1295 | - { |
|
| 1296 | - if (!is_string($airport)) |
|
| 1297 | - { |
|
| 1298 | - return array(); |
|
| 1299 | - } else { |
|
| 1300 | - $additional_query .= " AND ((marine_archive_output.departure_airport_icao = :airport) OR (marine_archive_output.arrival_airport_icao = :airport))"; |
|
| 1301 | - $query_values = array(':airport' => $airport); |
|
| 1302 | - } |
|
| 1303 | - } |
|
| 1294 | + if ($airport != "") |
|
| 1295 | + { |
|
| 1296 | + if (!is_string($airport)) |
|
| 1297 | + { |
|
| 1298 | + return array(); |
|
| 1299 | + } else { |
|
| 1300 | + $additional_query .= " AND ((marine_archive_output.departure_airport_icao = :airport) OR (marine_archive_output.arrival_airport_icao = :airport))"; |
|
| 1301 | + $query_values = array(':airport' => $airport); |
|
| 1302 | + } |
|
| 1303 | + } |
|
| 1304 | 1304 | |
| 1305 | - if ($limit != "") |
|
| 1306 | - { |
|
| 1307 | - $limit_array = explode(",", $limit); |
|
| 1305 | + if ($limit != "") |
|
| 1306 | + { |
|
| 1307 | + $limit_array = explode(",", $limit); |
|
| 1308 | 1308 | |
| 1309 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1310 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1309 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1310 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1311 | 1311 | |
| 1312 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1313 | - { |
|
| 1314 | - //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
|
| 1315 | - $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
|
| 1316 | - } |
|
| 1317 | - } |
|
| 1312 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1313 | + { |
|
| 1314 | + //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
|
| 1315 | + $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
|
| 1316 | + } |
|
| 1317 | + } |
|
| 1318 | 1318 | |
| 1319 | - if ($sort != "") |
|
| 1320 | - { |
|
| 1321 | - $search_orderby_array = $Marine->getOrderBy(); |
|
| 1322 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1323 | - } else { |
|
| 1324 | - $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
| 1325 | - } |
|
| 1319 | + if ($sort != "") |
|
| 1320 | + { |
|
| 1321 | + $search_orderby_array = $Marine->getOrderBy(); |
|
| 1322 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1323 | + } else { |
|
| 1324 | + $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
| 1325 | + } |
|
| 1326 | 1326 | |
| 1327 | - $query = $global_query.$filter_query." marine_archive_output.ident <> '' ".$additional_query." AND ((marine_archive_output.departure_airport_icao <> 'NA') AND (marine_archive_output.arrival_airport_icao <> 'NA')) ".$orderby_query; |
|
| 1327 | + $query = $global_query.$filter_query." marine_archive_output.ident <> '' ".$additional_query." AND ((marine_archive_output.departure_airport_icao <> 'NA') AND (marine_archive_output.arrival_airport_icao <> 'NA')) ".$orderby_query; |
|
| 1328 | 1328 | |
| 1329 | - $spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query); |
|
| 1329 | + $spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query); |
|
| 1330 | 1330 | |
| 1331 | - return $spotter_array; |
|
| 1332 | - } |
|
| 1331 | + return $spotter_array; |
|
| 1332 | + } |
|
| 1333 | 1333 | } |
| 1334 | 1334 | ?> |
| 1335 | 1335 | \ No newline at end of file |
@@ -23,33 +23,33 @@ discard block |
||
| 23 | 23 | * @param bool $and |
| 24 | 24 | * @return string the SQL part |
| 25 | 25 | */ |
| 26 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
| 26 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
| 27 | 27 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
| 28 | 28 | $filters = array(); |
| 29 | 29 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
| 30 | 30 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
| 31 | 31 | $filters = $globalStatsFilters[$globalFilterName]; |
| 32 | 32 | } else { |
| 33 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
| 33 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
| 34 | 34 | } |
| 35 | 35 | } |
| 36 | 36 | if (isset($filter[0]['source'])) { |
| 37 | - $filters = array_merge($filters,$filter); |
|
| 37 | + $filters = array_merge($filters, $filter); |
|
| 38 | 38 | } |
| 39 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 39 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
| 40 | 40 | $filter_query_join = ''; |
| 41 | 41 | $filter_query_where = ''; |
| 42 | - foreach($filters as $flt) { |
|
| 42 | + foreach ($filters as $flt) { |
|
| 43 | 43 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
| 44 | 44 | if (isset($flt['source'])) { |
| 45 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.ident IN ('".implode("','",$flt['idents'])."') AND marine_archive_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.fammarine_id = marine_archive.fammarine_id"; |
|
| 45 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.ident IN ('".implode("','", $flt['idents'])."') AND marine_archive_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.fammarine_id = marine_archive.fammarine_id"; |
|
| 46 | 46 | } else { |
| 47 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.fammarine_id = marine_archive.fammarine_id"; |
|
| 47 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.fammarine_id = marine_archive.fammarine_id"; |
|
| 48 | 48 | } |
| 49 | 49 | } |
| 50 | 50 | } |
| 51 | 51 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 52 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
| 52 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
| 53 | 53 | } |
| 54 | 54 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
| 55 | 55 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -77,15 +77,15 @@ discard block |
||
| 77 | 77 | $filter_query_date .= " AND EXTRACT(DAY FROM marine_archive_output.date) = '".$filter['day']."'"; |
| 78 | 78 | } |
| 79 | 79 | } |
| 80 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.fammarine_id = marine_archive.fammarine_id"; |
|
| 80 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.fammarine_id = marine_archive.fammarine_id"; |
|
| 81 | 81 | } |
| 82 | 82 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 83 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 83 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 84 | 84 | } |
| 85 | 85 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
| 86 | 86 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
| 87 | 87 | if ($filter_query_where != '') { |
| 88 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
| 88 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
| 89 | 89 | } |
| 90 | 90 | $filter_query = $filter_query_join.$filter_query_where; |
| 91 | 91 | return $filter_query; |
@@ -128,21 +128,21 @@ discard block |
||
| 128 | 128 | require_once(dirname(__FILE__).'/class.Marine.php'); |
| 129 | 129 | if ($over_country == '') { |
| 130 | 130 | $Marine = new Marine($this->db); |
| 131 | - $data_country = $Marine->getCountryFromLatitudeLongitude($latitude,$longitude); |
|
| 131 | + $data_country = $Marine->getCountryFromLatitudeLongitude($latitude, $longitude); |
|
| 132 | 132 | if (!empty($data_country)) $country = $data_country['iso2']; |
| 133 | 133 | else $country = ''; |
| 134 | 134 | } else $country = $over_country; |
| 135 | 135 | |
| 136 | 136 | //$country = $over_country; |
| 137 | 137 | // Route is not added in marine_archive |
| 138 | - $query = 'INSERT INTO marine_archive (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,type_id,status,status_id,imo,arrival_port_name,arrival_port_date,captain_id,captain_name,race_id,race_name,distance,race_rank,race_time) |
|
| 138 | + $query = 'INSERT INTO marine_archive (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,type_id,status,status_id,imo,arrival_port_name,arrival_port_date,captain_id,captain_name,race_id,race_name,distance,race_rank,race_time) |
|
| 139 | 139 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:mmsi,:type,:type_id,:status,:status_id,:imo,:arrival_port_name,:arrival_port_date,:captain_id,:captain_name,:race_id,:race_name,:distance,:race_rank,:race_time)'; |
| 140 | - $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $country,':mmsi' => $mmsi,':type' => $type,':type_id' => $typeid,':status' => $status,':status_id' => $statusid,':imo' => $imo,':arrival_port_name' => $arrival_code,':arrival_port_date' => $arrival_date,':captain_id' => $captain_id,':captain_name' => $captain_name,':race_id' => $race_id,':race_name' => $race_name,':distance' => $distance,':race_rank' => $race_rank,':race_time' => $race_time); |
|
| 140 | + $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $country, ':mmsi' => $mmsi, ':type' => $type, ':type_id' => $typeid, ':status' => $status, ':status_id' => $statusid, ':imo' => $imo, ':arrival_port_name' => $arrival_code, ':arrival_port_date' => $arrival_date, ':captain_id' => $captain_id, ':captain_name' => $captain_name, ':race_id' => $race_id, ':race_name' => $race_name, ':distance' => $distance, ':race_rank' => $race_rank, ':race_time' => $race_time); |
|
| 141 | 141 | try { |
| 142 | 142 | $sth = $this->db->prepare($query); |
| 143 | 143 | $sth->execute($query_values); |
| 144 | 144 | $sth->closeCursor(); |
| 145 | - } catch(PDOException $e) { |
|
| 145 | + } catch (PDOException $e) { |
|
| 146 | 146 | return "error : ".$e->getMessage(); |
| 147 | 147 | } |
| 148 | 148 | return "success"; |
@@ -162,8 +162,8 @@ discard block |
||
| 162 | 162 | |
| 163 | 163 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 164 | 164 | //$query = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
| 165 | - $query = "SELECT marine_archive.* FROM marine_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
| 166 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident)); |
|
| 165 | + $query = "SELECT marine_archive.* FROM marine_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
| 166 | + $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident)); |
|
| 167 | 167 | return $spotter_array; |
| 168 | 168 | } |
| 169 | 169 | |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 182 | 182 | //$query = MarineArchive->$global_query." WHERE marine_archive.fammarine_id = :id"; |
| 183 | 183 | //$query = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
| 184 | - $query = "SELECT * FROM marine_archive WHERE fammarine_id = :id ORDER BY date DESC LIMIT 1"; |
|
| 184 | + $query = "SELECT * FROM marine_archive WHERE fammarine_id = :id ORDER BY date DESC LIMIT 1"; |
|
| 185 | 185 | |
| 186 | 186 | // $spotter_array = Marine->getDataFromDB($query,array(':id' => $id)); |
| 187 | 187 | /* |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | } |
| 195 | 195 | $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC); |
| 196 | 196 | */ |
| 197 | - $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id)); |
|
| 197 | + $spotter_array = $Marine->getDataFromDB($query, array(':id' => $id)); |
|
| 198 | 198 | return $spotter_array; |
| 199 | 199 | } |
| 200 | 200 | |
@@ -208,14 +208,14 @@ discard block |
||
| 208 | 208 | { |
| 209 | 209 | date_default_timezone_set('UTC'); |
| 210 | 210 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 211 | - $query = $this->global_query." WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
| 211 | + $query = $this->global_query." WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
| 212 | 212 | |
| 213 | 213 | // $spotter_array = Marine->getDataFromDB($query,array(':id' => $id)); |
| 214 | 214 | |
| 215 | 215 | try { |
| 216 | 216 | $sth = $this->db->prepare($query); |
| 217 | 217 | $sth->execute(array(':id' => $id)); |
| 218 | - } catch(PDOException $e) { |
|
| 218 | + } catch (PDOException $e) { |
|
| 219 | 219 | echo $e->getMessage(); |
| 220 | 220 | die; |
| 221 | 221 | } |
@@ -233,14 +233,14 @@ discard block |
||
| 233 | 233 | { |
| 234 | 234 | date_default_timezone_set('UTC'); |
| 235 | 235 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 236 | - $query = "SELECT marine_archive.latitude, marine_archive.longitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id"; |
|
| 236 | + $query = "SELECT marine_archive.latitude, marine_archive.longitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id"; |
|
| 237 | 237 | |
| 238 | 238 | // $spotter_array = Marine->getDataFromDB($query,array(':id' => $id)); |
| 239 | 239 | |
| 240 | 240 | try { |
| 241 | 241 | $sth = $this->db->prepare($query); |
| 242 | 242 | $sth->execute(array(':id' => $id)); |
| 243 | - } catch(PDOException $e) { |
|
| 243 | + } catch (PDOException $e) { |
|
| 244 | 244 | echo $e->getMessage(); |
| 245 | 245 | die; |
| 246 | 246 | } |
@@ -262,12 +262,12 @@ discard block |
||
| 262 | 262 | date_default_timezone_set('UTC'); |
| 263 | 263 | |
| 264 | 264 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 265 | - $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date"; |
|
| 265 | + $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date"; |
|
| 266 | 266 | |
| 267 | 267 | try { |
| 268 | 268 | $sth = $this->db->prepare($query); |
| 269 | 269 | $sth->execute(array(':ident' => $ident)); |
| 270 | - } catch(PDOException $e) { |
|
| 270 | + } catch (PDOException $e) { |
|
| 271 | 271 | echo $e->getMessage(); |
| 272 | 272 | die; |
| 273 | 273 | } |
@@ -288,12 +288,12 @@ discard block |
||
| 288 | 288 | date_default_timezone_set('UTC'); |
| 289 | 289 | |
| 290 | 290 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 291 | - $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date"; |
|
| 291 | + $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date"; |
|
| 292 | 292 | |
| 293 | 293 | try { |
| 294 | 294 | $sth = $this->db->prepare($query); |
| 295 | 295 | $sth->execute(array(':id' => $id)); |
| 296 | - } catch(PDOException $e) { |
|
| 296 | + } catch (PDOException $e) { |
|
| 297 | 297 | echo $e->getMessage(); |
| 298 | 298 | die; |
| 299 | 299 | } |
@@ -313,12 +313,12 @@ discard block |
||
| 313 | 313 | date_default_timezone_set('UTC'); |
| 314 | 314 | |
| 315 | 315 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 316 | - $query = "SELECT marine_archive.altitude, marine_archive.ground_speed, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
| 316 | + $query = "SELECT marine_archive.altitude, marine_archive.ground_speed, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
| 317 | 317 | |
| 318 | 318 | try { |
| 319 | 319 | $sth = $this->db->prepare($query); |
| 320 | 320 | $sth->execute(array(':id' => $id)); |
| 321 | - } catch(PDOException $e) { |
|
| 321 | + } catch (PDOException $e) { |
|
| 322 | 322 | echo $e->getMessage(); |
| 323 | 323 | die; |
| 324 | 324 | } |
@@ -340,13 +340,13 @@ discard block |
||
| 340 | 340 | date_default_timezone_set('UTC'); |
| 341 | 341 | |
| 342 | 342 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 343 | - $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
|
| 343 | + $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
|
| 344 | 344 | // $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident"; |
| 345 | 345 | |
| 346 | 346 | try { |
| 347 | 347 | $sth = $this->db->prepare($query); |
| 348 | 348 | $sth->execute(array(':ident' => $ident)); |
| 349 | - } catch(PDOException $e) { |
|
| 349 | + } catch (PDOException $e) { |
|
| 350 | 350 | echo $e->getMessage(); |
| 351 | 351 | die; |
| 352 | 352 | } |
@@ -364,12 +364,12 @@ discard block |
||
| 364 | 364 | * @param $date |
| 365 | 365 | * @return array the spotter information |
| 366 | 366 | */ |
| 367 | - public function getMarineArchiveData($ident,$fammarine_id,$date) |
|
| 367 | + public function getMarineArchiveData($ident, $fammarine_id, $date) |
|
| 368 | 368 | { |
| 369 | 369 | $Marine = new Marine($this->db); |
| 370 | 370 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 371 | 371 | $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.fammarine_id = :fammarine_id AND l.date LIKE :date GROUP BY l.fammarine_id) s on spotter_live.fammarine_id = s.fammarine_id AND spotter_live.date = s.maxdate"; |
| 372 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':fammarine_id' => $fammarine_id,':date' => $date.'%')); |
|
| 372 | + $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident, ':fammarine_id' => $fammarine_id, ':date' => $date.'%')); |
|
| 373 | 373 | return $spotter_array; |
| 374 | 374 | } |
| 375 | 375 | |
@@ -388,7 +388,7 @@ discard block |
||
| 388 | 388 | try { |
| 389 | 389 | $sth = $this->db->prepare($query); |
| 390 | 390 | $sth->execute(); |
| 391 | - } catch(PDOException $e) { |
|
| 391 | + } catch (PDOException $e) { |
|
| 392 | 392 | echo $e->getMessage(); |
| 393 | 393 | die; |
| 394 | 394 | } |
@@ -402,24 +402,24 @@ discard block |
||
| 402 | 402 | * @param array $filter |
| 403 | 403 | * @return array the spotter information |
| 404 | 404 | */ |
| 405 | - public function getMinLiveMarineData($begindate,$enddate,$filter = array()) |
|
| 405 | + public function getMinLiveMarineData($begindate, $enddate, $filter = array()) |
|
| 406 | 406 | { |
| 407 | 407 | global $globalDBdriver, $globalLiveInterval; |
| 408 | 408 | date_default_timezone_set('UTC'); |
| 409 | 409 | |
| 410 | 410 | $filter_query = ''; |
| 411 | 411 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 412 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 412 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
| 413 | 413 | } |
| 414 | 414 | // Use spotter_output also ? |
| 415 | 415 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 416 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
| 416 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
| 417 | 417 | } |
| 418 | 418 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
| 419 | 419 | $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
| 420 | 420 | } |
| 421 | 421 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 422 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 422 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 423 | 423 | } |
| 424 | 424 | |
| 425 | 425 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -438,14 +438,14 @@ discard block |
||
| 438 | 438 | GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id |
| 439 | 439 | AND marine_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive.aircraft_icao = a.icao'; |
| 440 | 440 | */ |
| 441 | - $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 441 | + $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 442 | 442 | FROM marine_archive |
| 443 | 443 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao |
| 444 | 444 | WHERE marine_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' |
| 445 | 445 | '.$filter_query.' ORDER BY fammarine_id'; |
| 446 | 446 | } else { |
| 447 | 447 | //$query = 'SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao'; |
| 448 | - $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 448 | + $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 449 | 449 | FROM marine_archive |
| 450 | 450 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao |
| 451 | 451 | WHERE marine_archive.date >= '."'".$begindate."'".' AND marine_archive.date <= '."'".$enddate."'".' |
@@ -455,7 +455,7 @@ discard block |
||
| 455 | 455 | try { |
| 456 | 456 | $sth = $this->db->prepare($query); |
| 457 | 457 | $sth->execute(); |
| 458 | - } catch(PDOException $e) { |
|
| 458 | + } catch (PDOException $e) { |
|
| 459 | 459 | echo $e->getMessage(); |
| 460 | 460 | die; |
| 461 | 461 | } |
@@ -472,24 +472,24 @@ discard block |
||
| 472 | 472 | * @param array $filter |
| 473 | 473 | * @return array the spotter information |
| 474 | 474 | */ |
| 475 | - public function getMinLiveMarineDataPlayback($begindate,$enddate,$filter = array()) |
|
| 475 | + public function getMinLiveMarineDataPlayback($begindate, $enddate, $filter = array()) |
|
| 476 | 476 | { |
| 477 | 477 | global $globalDBdriver, $globalLiveInterval; |
| 478 | 478 | date_default_timezone_set('UTC'); |
| 479 | 479 | |
| 480 | 480 | $filter_query = ''; |
| 481 | 481 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 482 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 482 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
| 483 | 483 | } |
| 484 | 484 | // Should use spotter_output also ? |
| 485 | 485 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 486 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
| 486 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
| 487 | 487 | } |
| 488 | 488 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
| 489 | 489 | $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
| 490 | 490 | } |
| 491 | 491 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 492 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 492 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 493 | 493 | } |
| 494 | 494 | |
| 495 | 495 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -499,7 +499,7 @@ discard block |
||
| 499 | 499 | FROM marine_archive |
| 500 | 500 | INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive.aircraft_icao = a.icao'; |
| 501 | 501 | */ |
| 502 | - $query = 'SELECT a.aircraft_shadow, marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk |
|
| 502 | + $query = 'SELECT a.aircraft_shadow, marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk |
|
| 503 | 503 | FROM marine_archive_output |
| 504 | 504 | LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive_output.aircraft_icao = a.icao |
| 505 | 505 | WHERE (marine_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
@@ -514,7 +514,7 @@ discard block |
||
| 514 | 514 | WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".' |
| 515 | 515 | '.$filter_query.' GROUP BY marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao, marine_archive_output.arrival_airport_icao, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow'; |
| 516 | 516 | */ |
| 517 | - $query = 'SELECT DISTINCT marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow |
|
| 517 | + $query = 'SELECT DISTINCT marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow |
|
| 518 | 518 | FROM marine_archive_output |
| 519 | 519 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao |
| 520 | 520 | WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".' |
@@ -526,7 +526,7 @@ discard block |
||
| 526 | 526 | try { |
| 527 | 527 | $sth = $this->db->prepare($query); |
| 528 | 528 | $sth->execute(); |
| 529 | - } catch(PDOException $e) { |
|
| 529 | + } catch (PDOException $e) { |
|
| 530 | 530 | echo $e->getMessage(); |
| 531 | 531 | die; |
| 532 | 532 | } |
@@ -543,23 +543,23 @@ discard block |
||
| 543 | 543 | * @param array $filter |
| 544 | 544 | * @return array the spotter information |
| 545 | 545 | */ |
| 546 | - public function getLiveMarineCount($begindate,$enddate,$filter = array()) |
|
| 546 | + public function getLiveMarineCount($begindate, $enddate, $filter = array()) |
|
| 547 | 547 | { |
| 548 | 548 | global $globalDBdriver, $globalLiveInterval; |
| 549 | 549 | date_default_timezone_set('UTC'); |
| 550 | 550 | |
| 551 | 551 | $filter_query = ''; |
| 552 | 552 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 553 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 553 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
| 554 | 554 | } |
| 555 | 555 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 556 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
| 556 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
| 557 | 557 | } |
| 558 | 558 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
| 559 | 559 | $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
| 560 | 560 | } |
| 561 | 561 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 562 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 562 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 563 | 563 | } |
| 564 | 564 | |
| 565 | 565 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -574,7 +574,7 @@ discard block |
||
| 574 | 574 | try { |
| 575 | 575 | $sth = $this->db->prepare($query); |
| 576 | 576 | $sth->execute(); |
| 577 | - } catch(PDOException $e) { |
|
| 577 | + } catch (PDOException $e) { |
|
| 578 | 578 | echo $e->getMessage(); |
| 579 | 579 | die; |
| 580 | 580 | } |
@@ -617,7 +617,7 @@ discard block |
||
| 617 | 617 | * @param array $filters |
| 618 | 618 | * @return array the spotter information |
| 619 | 619 | */ |
| 620 | - public function searchMarineData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array()) |
|
| 620 | + public function searchMarineData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '', $pilot_id = '', $pilot_name = '', $altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $filters = array()) |
|
| 621 | 621 | { |
| 622 | 622 | global $globalTimezone, $globalDBdriver; |
| 623 | 623 | require_once(dirname(__FILE__).'/class.Translation.php'); |
@@ -638,7 +638,7 @@ discard block |
||
| 638 | 638 | } else { |
| 639 | 639 | $q_array = explode(" ", $q); |
| 640 | 640 | |
| 641 | - foreach ($q_array as $q_item){ |
|
| 641 | + foreach ($q_array as $q_item) { |
|
| 642 | 642 | $additional_query .= " AND ("; |
| 643 | 643 | $additional_query .= "(marine_archive_output.spotter_id like '%".$q_item."%') OR "; |
| 644 | 644 | $additional_query .= "(marine_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
@@ -670,7 +670,7 @@ discard block |
||
| 670 | 670 | |
| 671 | 671 | if ($registration != "") |
| 672 | 672 | { |
| 673 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 673 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
| 674 | 674 | if (!is_string($registration)) |
| 675 | 675 | { |
| 676 | 676 | return array(); |
@@ -681,7 +681,7 @@ discard block |
||
| 681 | 681 | |
| 682 | 682 | if ($aircraft_icao != "") |
| 683 | 683 | { |
| 684 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 684 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
| 685 | 685 | if (!is_string($aircraft_icao)) |
| 686 | 686 | { |
| 687 | 687 | return array(); |
@@ -692,7 +692,7 @@ discard block |
||
| 692 | 692 | |
| 693 | 693 | if ($aircraft_manufacturer != "") |
| 694 | 694 | { |
| 695 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
| 695 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING); |
|
| 696 | 696 | if (!is_string($aircraft_manufacturer)) |
| 697 | 697 | { |
| 698 | 698 | return array(); |
@@ -713,7 +713,7 @@ discard block |
||
| 713 | 713 | |
| 714 | 714 | if ($airline_icao != "") |
| 715 | 715 | { |
| 716 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
| 716 | + $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING); |
|
| 717 | 717 | if (!is_string($airline_icao)) |
| 718 | 718 | { |
| 719 | 719 | return array(); |
@@ -724,7 +724,7 @@ discard block |
||
| 724 | 724 | |
| 725 | 725 | if ($airline_country != "") |
| 726 | 726 | { |
| 727 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
| 727 | + $airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING); |
|
| 728 | 728 | if (!is_string($airline_country)) |
| 729 | 729 | { |
| 730 | 730 | return array(); |
@@ -735,7 +735,7 @@ discard block |
||
| 735 | 735 | |
| 736 | 736 | if ($airline_type != "") |
| 737 | 737 | { |
| 738 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
| 738 | + $airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING); |
|
| 739 | 739 | if (!is_string($airline_type)) |
| 740 | 740 | { |
| 741 | 741 | return array(); |
@@ -757,7 +757,7 @@ discard block |
||
| 757 | 757 | |
| 758 | 758 | if ($airport != "") |
| 759 | 759 | { |
| 760 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
| 760 | + $airport = filter_var($airport, FILTER_SANITIZE_STRING); |
|
| 761 | 761 | if (!is_string($airport)) |
| 762 | 762 | { |
| 763 | 763 | return array(); |
@@ -768,7 +768,7 @@ discard block |
||
| 768 | 768 | |
| 769 | 769 | if ($airport_country != "") |
| 770 | 770 | { |
| 771 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
| 771 | + $airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING); |
|
| 772 | 772 | if (!is_string($airport_country)) |
| 773 | 773 | { |
| 774 | 774 | return array(); |
@@ -779,7 +779,7 @@ discard block |
||
| 779 | 779 | |
| 780 | 780 | if ($callsign != "") |
| 781 | 781 | { |
| 782 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 782 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
| 783 | 783 | if (!is_string($callsign)) |
| 784 | 784 | { |
| 785 | 785 | return array(); |
@@ -787,7 +787,7 @@ discard block |
||
| 787 | 787 | $translate = $Translation->ident2icao($callsign); |
| 788 | 788 | if ($translate != $callsign) { |
| 789 | 789 | $additional_query .= " AND (marine_archive_output.ident = :callsign OR marine_archive_output.ident = :translate)"; |
| 790 | - $query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate)); |
|
| 790 | + $query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate)); |
|
| 791 | 791 | } else { |
| 792 | 792 | $additional_query .= " AND (marine_archive_output.ident = '".$callsign."')"; |
| 793 | 793 | } |
@@ -796,7 +796,7 @@ discard block |
||
| 796 | 796 | |
| 797 | 797 | if ($owner != "") |
| 798 | 798 | { |
| 799 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 799 | + $owner = filter_var($owner, FILTER_SANITIZE_STRING); |
|
| 800 | 800 | if (!is_string($owner)) |
| 801 | 801 | { |
| 802 | 802 | return array(); |
@@ -807,7 +807,7 @@ discard block |
||
| 807 | 807 | |
| 808 | 808 | if ($pilot_name != "") |
| 809 | 809 | { |
| 810 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
| 810 | + $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING); |
|
| 811 | 811 | if (!is_string($pilot_name)) |
| 812 | 812 | { |
| 813 | 813 | return array(); |
@@ -818,7 +818,7 @@ discard block |
||
| 818 | 818 | |
| 819 | 819 | if ($pilot_id != "") |
| 820 | 820 | { |
| 821 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
| 821 | + $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT); |
|
| 822 | 822 | if (!is_string($pilot_id)) |
| 823 | 823 | { |
| 824 | 824 | return array(); |
@@ -829,7 +829,7 @@ discard block |
||
| 829 | 829 | |
| 830 | 830 | if ($departure_airport_route != "") |
| 831 | 831 | { |
| 832 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
| 832 | + $departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING); |
|
| 833 | 833 | if (!is_string($departure_airport_route)) |
| 834 | 834 | { |
| 835 | 835 | return array(); |
@@ -840,7 +840,7 @@ discard block |
||
| 840 | 840 | |
| 841 | 841 | if ($arrival_airport_route != "") |
| 842 | 842 | { |
| 843 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
| 843 | + $arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING); |
|
| 844 | 844 | if (!is_string($arrival_airport_route)) |
| 845 | 845 | { |
| 846 | 846 | return array(); |
@@ -853,8 +853,8 @@ discard block |
||
| 853 | 853 | { |
| 854 | 854 | $altitude_array = explode(",", $altitude); |
| 855 | 855 | |
| 856 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 857 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 856 | + $altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 857 | + $altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 858 | 858 | |
| 859 | 859 | |
| 860 | 860 | if ($altitude_array[1] != "") |
@@ -872,8 +872,8 @@ discard block |
||
| 872 | 872 | { |
| 873 | 873 | $date_array = explode(",", $date_posted); |
| 874 | 874 | |
| 875 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
| 876 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
| 875 | + $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING); |
|
| 876 | + $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING); |
|
| 877 | 877 | |
| 878 | 878 | if ($globalTimezone != '') { |
| 879 | 879 | date_default_timezone_set($globalTimezone); |
@@ -905,8 +905,8 @@ discard block |
||
| 905 | 905 | { |
| 906 | 906 | $limit_array = explode(",", $limit); |
| 907 | 907 | |
| 908 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 909 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 908 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 909 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 910 | 910 | |
| 911 | 911 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 912 | 912 | { |
@@ -917,8 +917,8 @@ discard block |
||
| 917 | 917 | |
| 918 | 918 | |
| 919 | 919 | if ($origLat != "" && $origLon != "" && $dist != "") { |
| 920 | - $dist = number_format($dist*0.621371,2,'.',''); |
|
| 921 | - $query="SELECT marine_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(marine_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(marine_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
| 920 | + $dist = number_format($dist*0.621371, 2, '.', ''); |
|
| 921 | + $query = "SELECT marine_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(marine_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(marine_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
| 922 | 922 | FROM marine_archive_output, marine_archive WHERE spotter_output_archive.fammarine_id = marine_archive.fammarine_id AND spotter_output.ident <> '' ".$additional_query."AND CAST(marine_archive.longitude as double precision) between ($origLon-$dist/ABS(cos(radians($origLat))*69)) and ($origLon+$dist/ABS(cos(radians($origLat))*69)) and CAST(marine_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) |
| 923 | 923 | AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(marine_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(marine_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query." ORDER BY distance"; |
| 924 | 924 | } else { |
@@ -935,12 +935,12 @@ discard block |
||
| 935 | 935 | $additional_query .= " AND (marine_archive_output.waypoints <> '')"; |
| 936 | 936 | } |
| 937 | 937 | |
| 938 | - $query = "SELECT marine_archive_output.* FROM marine_archive_output |
|
| 938 | + $query = "SELECT marine_archive_output.* FROM marine_archive_output |
|
| 939 | 939 | WHERE marine_archive_output.ident <> '' |
| 940 | 940 | ".$additional_query." |
| 941 | 941 | ".$filter_query.$orderby_query; |
| 942 | 942 | } |
| 943 | - $spotter_array = $Marine->getDataFromDB($query, $query_values,$limit_query); |
|
| 943 | + $spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query); |
|
| 944 | 944 | |
| 945 | 945 | return $spotter_array; |
| 946 | 946 | } |
@@ -957,7 +957,7 @@ discard block |
||
| 957 | 957 | try { |
| 958 | 958 | $sth = $this->db->prepare($query); |
| 959 | 959 | $sth->execute(); |
| 960 | - } catch(PDOException $e) { |
|
| 960 | + } catch (PDOException $e) { |
|
| 961 | 961 | return "error"; |
| 962 | 962 | } |
| 963 | 963 | } |
@@ -996,8 +996,8 @@ discard block |
||
| 996 | 996 | { |
| 997 | 997 | $limit_array = explode(",", $limit); |
| 998 | 998 | |
| 999 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1000 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 999 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1000 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1001 | 1001 | |
| 1002 | 1002 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1003 | 1003 | { |
@@ -1041,7 +1041,7 @@ discard block |
||
| 1041 | 1041 | $query_values = array(); |
| 1042 | 1042 | $limit_query = ''; |
| 1043 | 1043 | $additional_query = ''; |
| 1044 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 1044 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 1045 | 1045 | |
| 1046 | 1046 | if ($owner != "") |
| 1047 | 1047 | { |
@@ -1058,8 +1058,8 @@ discard block |
||
| 1058 | 1058 | { |
| 1059 | 1059 | $limit_array = explode(",", $limit); |
| 1060 | 1060 | |
| 1061 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1062 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1061 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1062 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1063 | 1063 | |
| 1064 | 1064 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1065 | 1065 | { |
@@ -1102,7 +1102,7 @@ discard block |
||
| 1102 | 1102 | $query_values = array(); |
| 1103 | 1103 | $limit_query = ''; |
| 1104 | 1104 | $additional_query = ''; |
| 1105 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 1105 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 1106 | 1106 | |
| 1107 | 1107 | if ($pilot != "") |
| 1108 | 1108 | { |
@@ -1114,8 +1114,8 @@ discard block |
||
| 1114 | 1114 | { |
| 1115 | 1115 | $limit_array = explode(",", $limit); |
| 1116 | 1116 | |
| 1117 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1118 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1117 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1118 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1119 | 1119 | |
| 1120 | 1120 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1121 | 1121 | { |
@@ -1147,7 +1147,7 @@ discard block |
||
| 1147 | 1147 | * @param string $sincedate |
| 1148 | 1148 | * @return array the airline country list |
| 1149 | 1149 | */ |
| 1150 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1150 | + public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
| 1151 | 1151 | { |
| 1152 | 1152 | global $globalDBdriver; |
| 1153 | 1153 | /* |
@@ -1176,7 +1176,7 @@ discard block |
||
| 1176 | 1176 | $flight_array = array(); |
| 1177 | 1177 | $temp_array = array(); |
| 1178 | 1178 | |
| 1179 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1179 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1180 | 1180 | { |
| 1181 | 1181 | $temp_array['flight_count'] = $row['nb']; |
| 1182 | 1182 | $temp_array['flight_country'] = $row['name']; |
@@ -1195,7 +1195,7 @@ discard block |
||
| 1195 | 1195 | * @param string $sincedate |
| 1196 | 1196 | * @return array the airline country list |
| 1197 | 1197 | */ |
| 1198 | - public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1198 | + public function countAllFlightOverCountriesByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
| 1199 | 1199 | { |
| 1200 | 1200 | global $globalDBdriver; |
| 1201 | 1201 | /* |
@@ -1224,7 +1224,7 @@ discard block |
||
| 1224 | 1224 | $flight_array = array(); |
| 1225 | 1225 | $temp_array = array(); |
| 1226 | 1226 | |
| 1227 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1227 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1228 | 1228 | { |
| 1229 | 1229 | $temp_array['airline_icao'] = $row['airline_icao']; |
| 1230 | 1230 | $temp_array['flight_count'] = $row['nb']; |
@@ -1243,14 +1243,14 @@ discard block |
||
| 1243 | 1243 | * @param $date |
| 1244 | 1244 | * @return array the spotter information |
| 1245 | 1245 | */ |
| 1246 | - public function getDateArchiveMarineDataById($id,$date) |
|
| 1246 | + public function getDateArchiveMarineDataById($id, $date) |
|
| 1247 | 1247 | { |
| 1248 | 1248 | $Marine = new Marine($this->db); |
| 1249 | 1249 | date_default_timezone_set('UTC'); |
| 1250 | 1250 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 1251 | 1251 | $query = 'SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate ORDER BY marine_archive.date DESC'; |
| 1252 | - $date = date('c',$date); |
|
| 1253 | - $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
|
| 1252 | + $date = date('c', $date); |
|
| 1253 | + $spotter_array = $Marine->getDataFromDB($query, array(':id' => $id, ':date' => $date)); |
|
| 1254 | 1254 | return $spotter_array; |
| 1255 | 1255 | } |
| 1256 | 1256 | |
@@ -1261,14 +1261,14 @@ discard block |
||
| 1261 | 1261 | * @param $date |
| 1262 | 1262 | * @return array the spotter information |
| 1263 | 1263 | */ |
| 1264 | - public function getDateArchiveMarineDataByIdent($ident,$date) |
|
| 1264 | + public function getDateArchiveMarineDataByIdent($ident, $date) |
|
| 1265 | 1265 | { |
| 1266 | 1266 | $Marine = new Marine($this->db); |
| 1267 | 1267 | date_default_timezone_set('UTC'); |
| 1268 | 1268 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 1269 | 1269 | $query = 'SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate ORDER BY marine_archive.date DESC'; |
| 1270 | - $date = date('c',$date); |
|
| 1271 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
| 1270 | + $date = date('c', $date); |
|
| 1271 | + $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
| 1272 | 1272 | return $spotter_array; |
| 1273 | 1273 | } |
| 1274 | 1274 | |
@@ -1281,7 +1281,7 @@ discard block |
||
| 1281 | 1281 | * @param array $filters |
| 1282 | 1282 | * @return array the spotter information |
| 1283 | 1283 | */ |
| 1284 | - public function getMarineDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
| 1284 | + public function getMarineDataByAirport($airport = '', $limit = '', $sort = '', $filters = array()) |
|
| 1285 | 1285 | { |
| 1286 | 1286 | global $global_query; |
| 1287 | 1287 | $Marine = new Marine($this->db); |
@@ -1289,7 +1289,7 @@ discard block |
||
| 1289 | 1289 | $query_values = array(); |
| 1290 | 1290 | $limit_query = ''; |
| 1291 | 1291 | $additional_query = ''; |
| 1292 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1292 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1293 | 1293 | |
| 1294 | 1294 | if ($airport != "") |
| 1295 | 1295 | { |
@@ -1306,8 +1306,8 @@ discard block |
||
| 1306 | 1306 | { |
| 1307 | 1307 | $limit_array = explode(",", $limit); |
| 1308 | 1308 | |
| 1309 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1310 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1309 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1310 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1311 | 1311 | |
| 1312 | 1312 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1313 | 1313 | { |
@@ -13,7 +13,9 @@ discard block |
||
| 13 | 13 | public function __construct($dbc = null) { |
| 14 | 14 | $Connection = new Connection($dbc); |
| 15 | 15 | $this->db = $Connection->db; |
| 16 | - if ($this->db === null) die('Error: No DB connection. (MarineArchive)'); |
|
| 16 | + if ($this->db === null) { |
|
| 17 | + die('Error: No DB connection. (MarineArchive)'); |
|
| 18 | + } |
|
| 17 | 19 | } |
| 18 | 20 | |
| 19 | 21 | /** |
@@ -36,7 +38,9 @@ discard block |
||
| 36 | 38 | if (isset($filter[0]['source'])) { |
| 37 | 39 | $filters = array_merge($filters,$filter); |
| 38 | 40 | } |
| 39 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 41 | + if (is_array($globalFilter)) { |
|
| 42 | + $filter = array_merge($filter,$globalFilter); |
|
| 43 | + } |
|
| 40 | 44 | $filter_query_join = ''; |
| 41 | 45 | $filter_query_where = ''; |
| 42 | 46 | foreach($filters as $flt) { |
@@ -82,8 +86,11 @@ discard block |
||
| 82 | 86 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 83 | 87 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
| 84 | 88 | } |
| 85 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
| 86 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
| 89 | + if ($filter_query_where == '' && $where) { |
|
| 90 | + $filter_query_where = ' WHERE'; |
|
| 91 | + } elseif ($filter_query_where != '' && $and) { |
|
| 92 | + $filter_query_where .= ' AND'; |
|
| 93 | + } |
|
| 87 | 94 | if ($filter_query_where != '') { |
| 88 | 95 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
| 89 | 96 | } |
@@ -129,9 +136,14 @@ discard block |
||
| 129 | 136 | if ($over_country == '') { |
| 130 | 137 | $Marine = new Marine($this->db); |
| 131 | 138 | $data_country = $Marine->getCountryFromLatitudeLongitude($latitude,$longitude); |
| 132 | - if (!empty($data_country)) $country = $data_country['iso2']; |
|
| 133 | - else $country = ''; |
|
| 134 | - } else $country = $over_country; |
|
| 139 | + if (!empty($data_country)) { |
|
| 140 | + $country = $data_country['iso2']; |
|
| 141 | + } else { |
|
| 142 | + $country = ''; |
|
| 143 | + } |
|
| 144 | + } else { |
|
| 145 | + $country = $over_country; |
|
| 146 | + } |
|
| 135 | 147 | |
| 136 | 148 | //$country = $over_country; |
| 137 | 149 | // Route is not added in marine_archive |
@@ -661,7 +673,9 @@ discard block |
||
| 661 | 673 | $additional_query .= "(marine_archive_output.pilot_name like '%".$q_item."%') OR "; |
| 662 | 674 | $additional_query .= "(marine_archive_output.ident like '%".$q_item."%') OR "; |
| 663 | 675 | $translate = $Translation->ident2icao($q_item); |
| 664 | - if ($translate != $q_item) $additional_query .= "(marine_archive_output.ident like '%".$translate."%') OR "; |
|
| 676 | + if ($translate != $q_item) { |
|
| 677 | + $additional_query .= "(marine_archive_output.ident like '%".$translate."%') OR "; |
|
| 678 | + } |
|
| 665 | 679 | $additional_query .= "(marine_archive_output.highlight like '%".$q_item."%')"; |
| 666 | 680 | $additional_query .= ")"; |
| 667 | 681 | } |
@@ -879,7 +893,9 @@ discard block |
||
| 879 | 893 | date_default_timezone_set($globalTimezone); |
| 880 | 894 | $datetime = new DateTime(); |
| 881 | 895 | $offset = $datetime->format('P'); |
| 882 | - } else $offset = '+00:00'; |
|
| 896 | + } else { |
|
| 897 | + $offset = '+00:00'; |
|
| 898 | + } |
|
| 883 | 899 | |
| 884 | 900 | |
| 885 | 901 | if ($date_array[1] != "") |
@@ -1165,9 +1181,13 @@ discard block |
||
| 1165 | 1181 | $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
| 1166 | 1182 | } |
| 1167 | 1183 | } |
| 1168 | - if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
| 1184 | + if ($sincedate != '') { |
|
| 1185 | + $query .= "AND date > '".$sincedate."' "; |
|
| 1186 | + } |
|
| 1169 | 1187 | $query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
| 1170 | - if ($limit) $query .= " LIMIT 0,10"; |
|
| 1188 | + if ($limit) { |
|
| 1189 | + $query .= " LIMIT 0,10"; |
|
| 1190 | + } |
|
| 1171 | 1191 | |
| 1172 | 1192 | |
| 1173 | 1193 | $sth = $this->db->prepare($query); |
@@ -1213,9 +1233,13 @@ discard block |
||
| 1213 | 1233 | $query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
| 1214 | 1234 | } |
| 1215 | 1235 | } |
| 1216 | - if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
| 1236 | + if ($sincedate != '') { |
|
| 1237 | + $query .= "AND s.date > '".$sincedate."' "; |
|
| 1238 | + } |
|
| 1217 | 1239 | $query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
| 1218 | - if ($limit) $query .= " LIMIT 0,10"; |
|
| 1240 | + if ($limit) { |
|
| 1241 | + $query .= " LIMIT 0,10"; |
|
| 1242 | + } |
|
| 1219 | 1243 | |
| 1220 | 1244 | |
| 1221 | 1245 | $sth = $this->db->prepare($query); |
@@ -60,11 +60,11 @@ |
||
| 60 | 60 | return $all; |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | - /** |
|
| 64 | - * @param $name |
|
| 65 | - * @return array |
|
| 66 | - */ |
|
| 67 | - public function getLocationInfobySourceName($name) { |
|
| 63 | + /** |
|
| 64 | + * @param $name |
|
| 65 | + * @return array |
|
| 66 | + */ |
|
| 67 | + public function getLocationInfobySourceName($name) { |
|
| 68 | 68 | $query = "SELECT * FROM source_location WHERE source = :name"; |
| 69 | 69 | $query_values = array(':name' => $name); |
| 70 | 70 | try { |
@@ -16,20 +16,20 @@ discard block |
||
| 16 | 16 | require_once(dirname(__FILE__).'/class.Source.php'); |
| 17 | 17 | require_once(dirname(__FILE__).'/class.GeoidHeight.php'); |
| 18 | 18 | if (isset($globalServerAPRS) && $globalServerAPRS) { |
| 19 | - require_once(dirname(__FILE__).'/class.APRS.php'); |
|
| 19 | + require_once(dirname(__FILE__).'/class.APRS.php'); |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | class SpotterImport { |
| 23 | - private $all_flights = array(); |
|
| 24 | - private $last_delete_hourly = 0; |
|
| 25 | - private $last_delete = 0; |
|
| 26 | - private $stats = array(); |
|
| 27 | - private $tmd = 0; |
|
| 28 | - private $source_location = array(); |
|
| 29 | - public $db = null; |
|
| 30 | - public $nb = 0; |
|
| 23 | + private $all_flights = array(); |
|
| 24 | + private $last_delete_hourly = 0; |
|
| 25 | + private $last_delete = 0; |
|
| 26 | + private $stats = array(); |
|
| 27 | + private $tmd = 0; |
|
| 28 | + private $source_location = array(); |
|
| 29 | + public $db = null; |
|
| 30 | + public $nb = 0; |
|
| 31 | 31 | |
| 32 | - public function __construct($dbc = null) { |
|
| 32 | + public function __construct($dbc = null) { |
|
| 33 | 33 | global $globalBeta, $globalServerAPRS, $APRSSpotter, $globalNoDB, $GeoidClass, $globalDebug, $globalGeoid; |
| 34 | 34 | if (!(isset($globalNoDB) && $globalNoDB)) { |
| 35 | 35 | $Connection = new Connection($dbc); |
@@ -41,14 +41,14 @@ discard block |
||
| 41 | 41 | $currentdate = date('Y-m-d'); |
| 42 | 42 | $sourcestat = $Stats->getStatsSource($currentdate); |
| 43 | 43 | if (!empty($sourcestat)) { |
| 44 | - foreach($sourcestat as $srcst) { |
|
| 45 | - $type = $srcst['stats_type']; |
|
| 44 | + foreach($sourcestat as $srcst) { |
|
| 45 | + $type = $srcst['stats_type']; |
|
| 46 | 46 | if ($type == 'polar' || $type == 'hist') { |
| 47 | - $source = $srcst['source_name']; |
|
| 48 | - $data = $srcst['source_data']; |
|
| 49 | - $this->stats[$currentdate][$source][$type] = json_decode($data,true); |
|
| 50 | - } |
|
| 51 | - } |
|
| 47 | + $source = $srcst['source_name']; |
|
| 48 | + $data = $srcst['source_data']; |
|
| 49 | + $this->stats[$currentdate][$source][$type] = json_decode($data,true); |
|
| 50 | + } |
|
| 51 | + } |
|
| 52 | 52 | } |
| 53 | 53 | } |
| 54 | 54 | if (isset($globalServerAPRS) && $globalServerAPRS) { |
@@ -63,9 +63,9 @@ discard block |
||
| 63 | 63 | $GeoidClass = FALSE; |
| 64 | 64 | } |
| 65 | 65 | } |
| 66 | - } |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - public function get_Schedule($id,$ident) { |
|
| 68 | + public function get_Schedule($id,$ident) { |
|
| 69 | 69 | global $globalDebug, $globalFork, $globalSchedulesFetch; |
| 70 | 70 | // Get schedule here, so it's done only one time |
| 71 | 71 | |
@@ -85,43 +85,43 @@ discard block |
||
| 85 | 85 | $operator = $Spotter->getOperator($ident); |
| 86 | 86 | $scheduleexist = false; |
| 87 | 87 | if ($Schedule->checkSchedule($operator) == 0) { |
| 88 | - $operator = $Translation->checkTranslation($ident); |
|
| 89 | - if ($Schedule->checkSchedule($operator) == 0) { |
|
| 88 | + $operator = $Translation->checkTranslation($ident); |
|
| 89 | + if ($Schedule->checkSchedule($operator) == 0) { |
|
| 90 | 90 | $schedule = $Schedule->fetchSchedule($operator); |
| 91 | 91 | if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) { |
| 92 | - if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
| 93 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
|
| 94 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
| 95 | - // Should also check if route schedule = route from DB |
|
| 96 | - if ($schedule['DepartureAirportIATA'] != '') { |
|
| 92 | + if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
| 93 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
|
| 94 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
| 95 | + // Should also check if route schedule = route from DB |
|
| 96 | + if ($schedule['DepartureAirportIATA'] != '') { |
|
| 97 | 97 | if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) { |
| 98 | - $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']); |
|
| 99 | - if (trim($airport_icao) != '') { |
|
| 98 | + $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']); |
|
| 99 | + if (trim($airport_icao) != '') { |
|
| 100 | 100 | $this->all_flights[$id]['departure_airport'] = $airport_icao; |
| 101 | 101 | if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n"; |
| 102 | - } |
|
| 102 | + } |
|
| 103 | + } |
|
| 103 | 104 | } |
| 104 | - } |
|
| 105 | - if ($schedule['ArrivalAirportIATA'] != '') { |
|
| 105 | + if ($schedule['ArrivalAirportIATA'] != '') { |
|
| 106 | 106 | if ($this->all_flights[$id]['arrival_airport'] != $Spotter->getAirportIcao($schedule['ArrivalAirportIATA'])) { |
| 107 | - $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']); |
|
| 108 | - if (trim($airport_icao) != '') { |
|
| 107 | + $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']); |
|
| 108 | + if (trim($airport_icao) != '') { |
|
| 109 | 109 | $this->all_flights[$id]['arrival_airport'] = $airport_icao; |
| 110 | 110 | if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n"; |
| 111 | - } |
|
| 111 | + } |
|
| 112 | 112 | } |
| 113 | - } |
|
| 114 | - $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']); |
|
| 113 | + } |
|
| 114 | + $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']); |
|
| 115 | 115 | } |
| 116 | - } else $scheduleexist = true; |
|
| 116 | + } else $scheduleexist = true; |
|
| 117 | 117 | } else $scheduleexist = true; |
| 118 | 118 | // close connection, at least one way will work ? |
| 119 | - if ($scheduleexist) { |
|
| 119 | + if ($scheduleexist) { |
|
| 120 | 120 | if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n"; |
| 121 | - $sch = $Schedule->getSchedule($operator); |
|
| 121 | + $sch = $Schedule->getSchedule($operator); |
|
| 122 | 122 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time'])); |
| 123 | 123 | if ($this->all_flights[$id]['addedSpotter'] == 1) $Spotter->updateLatestScheduleSpotterData($this->all_flights[$id]['id'],$sch['departure_airport_icao'],$sch['departure_airport_time'],$sch['arrival_airport_icao'],$sch['arrival_airport_time']); |
| 124 | - } |
|
| 124 | + } |
|
| 125 | 125 | $Spotter->db = null; |
| 126 | 126 | $Schedule->db = null; |
| 127 | 127 | $Translation->db = null; |
@@ -136,65 +136,65 @@ discard block |
||
| 136 | 136 | } |
| 137 | 137 | */ |
| 138 | 138 | } |
| 139 | - } |
|
| 139 | + } |
|
| 140 | 140 | |
| 141 | - public function checkAll() { |
|
| 141 | + public function checkAll() { |
|
| 142 | 142 | global $globalDebug, $globalNoImport; |
| 143 | 143 | if ($globalDebug) echo "Update last seen flights data...\n"; |
| 144 | 144 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
| 145 | - foreach ($this->all_flights as $key => $flight) { |
|
| 145 | + foreach ($this->all_flights as $key => $flight) { |
|
| 146 | 146 | if (isset($this->all_flights[$key]['id'])) { |
| 147 | - //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
|
| 148 | - $Spotter = new Spotter($this->db); |
|
| 149 | - $real_arrival = $this->arrival($key); |
|
| 150 | - if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
| 151 | - } |
|
| 152 | - } |
|
| 147 | + //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
|
| 148 | + $Spotter = new Spotter($this->db); |
|
| 149 | + $real_arrival = $this->arrival($key); |
|
| 150 | + if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
| 151 | + } |
|
| 152 | + } |
|
| 153 | + } |
|
| 153 | 154 | } |
| 154 | - } |
|
| 155 | 155 | |
| 156 | - public function arrival($key) { |
|
| 156 | + public function arrival($key) { |
|
| 157 | 157 | global $globalClosestMinDist, $globalDebug; |
| 158 | 158 | if ($globalDebug) echo 'Update arrival...'."\n"; |
| 159 | 159 | $Spotter = new Spotter($this->db); |
| 160 | - $airport_icao = ''; |
|
| 161 | - $airport_time = ''; |
|
| 162 | - if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
|
| 160 | + $airport_icao = ''; |
|
| 161 | + $airport_time = ''; |
|
| 162 | + if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
|
| 163 | 163 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
| 164 | - $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
|
| 165 | - if (isset($closestAirports[0])) { |
|
| 166 | - if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
|
| 167 | - $airport_icao = $closestAirports[0]['icao']; |
|
| 168 | - $airport_time = $this->all_flights[$key]['datetime']; |
|
| 169 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
| 170 | - } elseif (count($closestAirports) > 1 && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') { |
|
| 171 | - foreach ($closestAirports as $airport) { |
|
| 172 | - if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) { |
|
| 173 | - $airport_icao = $airport['icao']; |
|
| 174 | - $airport_time = $this->all_flights[$key]['datetime']; |
|
| 175 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
| 176 | - break; |
|
| 177 | - } |
|
| 178 | - } |
|
| 179 | - } elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) { |
|
| 180 | - $airport_icao = $closestAirports[0]['icao']; |
|
| 181 | - $airport_time = $this->all_flights[$key]['datetime']; |
|
| 182 | - } else { |
|
| 183 | - if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
| 184 | - } |
|
| 185 | - } else { |
|
| 186 | - if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
| 187 | - } |
|
| 164 | + $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
|
| 165 | + if (isset($closestAirports[0])) { |
|
| 166 | + if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
|
| 167 | + $airport_icao = $closestAirports[0]['icao']; |
|
| 168 | + $airport_time = $this->all_flights[$key]['datetime']; |
|
| 169 | + if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
| 170 | + } elseif (count($closestAirports) > 1 && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') { |
|
| 171 | + foreach ($closestAirports as $airport) { |
|
| 172 | + if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) { |
|
| 173 | + $airport_icao = $airport['icao']; |
|
| 174 | + $airport_time = $this->all_flights[$key]['datetime']; |
|
| 175 | + if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
| 176 | + break; |
|
| 177 | + } |
|
| 178 | + } |
|
| 179 | + } elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) { |
|
| 180 | + $airport_icao = $closestAirports[0]['icao']; |
|
| 181 | + $airport_time = $this->all_flights[$key]['datetime']; |
|
| 182 | + } else { |
|
| 183 | + if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
| 184 | + } |
|
| 185 | + } else { |
|
| 186 | + if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
| 187 | + } |
|
| 188 | 188 | |
| 189 | - } else { |
|
| 190 | - if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
| 191 | - } |
|
| 192 | - return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
|
| 193 | - } |
|
| 189 | + } else { |
|
| 190 | + if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
| 191 | + } |
|
| 192 | + return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
|
| 193 | + } |
|
| 194 | 194 | |
| 195 | 195 | |
| 196 | 196 | |
| 197 | - public function del() { |
|
| 197 | + public function del() { |
|
| 198 | 198 | global $globalDebug, $globalNoImport, $globalNoDB; |
| 199 | 199 | // Delete old infos |
| 200 | 200 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
@@ -206,9 +206,9 @@ discard block |
||
| 206 | 206 | } |
| 207 | 207 | } |
| 208 | 208 | } |
| 209 | - } |
|
| 209 | + } |
|
| 210 | 210 | |
| 211 | - public function delKey($key) { |
|
| 211 | + public function delKey($key) { |
|
| 212 | 212 | global $globalDebug, $globalNoImport, $globalNoDB; |
| 213 | 213 | // Delete old infos |
| 214 | 214 | if (isset($this->all_flights[$key]['id'])) { |
@@ -230,9 +230,9 @@ discard block |
||
| 230 | 230 | if ($globalDebug) echo "\n"; |
| 231 | 231 | } |
| 232 | 232 | unset($this->all_flights[$key]); |
| 233 | - } |
|
| 233 | + } |
|
| 234 | 234 | |
| 235 | - public function add($line) { |
|
| 235 | + public function add($line) { |
|
| 236 | 236 | global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBS1update, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAirlinesSource, $globalVAM, $globalAllFlights, $globalServerAPRS, $APRSSpotter, $globalNoImport, $globalNoDB, $globalVA, $globalAircraftMaxUpdate, $globalAircraftMinUpdate, $globalLiveInterval, $GeoidClass, $globalArchive; |
| 237 | 237 | //if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE; |
| 238 | 238 | if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.01'; |
@@ -258,20 +258,20 @@ discard block |
||
| 258 | 258 | |
| 259 | 259 | // SBS format is CSV format |
| 260 | 260 | if(is_array($line) && (isset($line['hex']) || isset($line['id']))) { |
| 261 | - //print_r($line); |
|
| 262 | - if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']); |
|
| 263 | - if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && substr($line['hex'],0,1) != '~' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) { |
|
| 261 | + //print_r($line); |
|
| 262 | + if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']); |
|
| 263 | + if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && substr($line['hex'],0,1) != '~' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) { |
|
| 264 | 264 | |
| 265 | 265 | // Increment message number |
| 266 | 266 | if (isset($line['sourcestats']) && $line['sourcestats'] === TRUE) { |
| 267 | - $current_date = date('Y-m-d'); |
|
| 268 | - if (isset($line['source_name'])) $source = $line['source_name']; |
|
| 269 | - else $source = ''; |
|
| 270 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
| 271 | - if (!isset($this->stats[$current_date][$source]['msg'])) { |
|
| 272 | - $this->stats[$current_date][$source]['msg']['date'] = time(); |
|
| 273 | - $this->stats[$current_date][$source]['msg']['nb'] = 1; |
|
| 274 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
| 267 | + $current_date = date('Y-m-d'); |
|
| 268 | + if (isset($line['source_name'])) $source = $line['source_name']; |
|
| 269 | + else $source = ''; |
|
| 270 | + if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
| 271 | + if (!isset($this->stats[$current_date][$source]['msg'])) { |
|
| 272 | + $this->stats[$current_date][$source]['msg']['date'] = time(); |
|
| 273 | + $this->stats[$current_date][$source]['msg']['nb'] = 1; |
|
| 274 | + } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | /* |
@@ -287,54 +287,54 @@ discard block |
||
| 287 | 287 | //$this->db = $dbc; |
| 288 | 288 | |
| 289 | 289 | //$hex = trim($line['hex']); |
| 290 | - if (!isset($line['id'])) $id = trim($line['hex']); |
|
| 291 | - else $id = trim($line['id']); |
|
| 290 | + if (!isset($line['id'])) $id = trim($line['hex']); |
|
| 291 | + else $id = trim($line['id']); |
|
| 292 | 292 | |
| 293 | 293 | if (!isset($this->all_flights[$id])) { |
| 294 | - if ($globalDebug) echo 'New flight...'."\n"; |
|
| 295 | - $this->all_flights[$id] = array(); |
|
| 296 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
| 297 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => '','coordinates' => 0)); |
|
| 298 | - if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
| 299 | - if (!isset($line['id'])) { |
|
| 294 | + if ($globalDebug) echo 'New flight...'."\n"; |
|
| 295 | + $this->all_flights[$id] = array(); |
|
| 296 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
| 297 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => '','coordinates' => 0)); |
|
| 298 | + if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
| 299 | + if (!isset($line['id'])) { |
|
| 300 | 300 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
| 301 | 301 | // if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi'))); |
| 302 | 302 | // if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
| 303 | 303 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
| 304 | - //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 305 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 306 | - if ($globalAllFlights !== FALSE) $dataFound = true; |
|
| 304 | + //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 305 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 306 | + if ($globalAllFlights !== FALSE) $dataFound = true; |
|
| 307 | 307 | } |
| 308 | 308 | if (isset($line['source_type']) && $line['source_type'] != '') { |
| 309 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type'])); |
|
| 309 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type'])); |
|
| 310 | 310 | } |
| 311 | 311 | |
| 312 | 312 | //print_r($this->all_flights); |
| 313 | 313 | if (isset($line['hex']) && !isset($this->all_flights[$id]['hex']) && ctype_xdigit($line['hex'])) { |
| 314 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex']))); |
|
| 315 | - //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
|
| 314 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex']))); |
|
| 315 | + //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
|
| 316 | 316 | //$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
| 317 | - //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
| 318 | - if (!isset($line['aircraft_name']) && (!isset($line['aircraft_icao']) || $line['aircraft_icao'] == '????') && $line['format_source'] != 'whazzup' && $line['format_source'] != 'vatsimtxt' && $line['format_source'] != 'pireps' && $line['format_source'] != 'phpvmacars' && $line['format_source'] != 'vam' && $line['format_source'] != 'flightgearsp' && $line['format_source'] != 'flightgearmp') { |
|
| 317 | + //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
| 318 | + if (!isset($line['aircraft_name']) && (!isset($line['aircraft_icao']) || $line['aircraft_icao'] == '????') && $line['format_source'] != 'whazzup' && $line['format_source'] != 'vatsimtxt' && $line['format_source'] != 'pireps' && $line['format_source'] != 'phpvmacars' && $line['format_source'] != 'vam' && $line['format_source'] != 'flightgearsp' && $line['format_source'] != 'flightgearmp') { |
|
| 319 | 319 | $timeelapsed = microtime(true); |
| 320 | 320 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 321 | - $Spotter = new Spotter($this->db); |
|
| 322 | - if (isset($this->all_flights[$id]['source_type'])) { |
|
| 321 | + $Spotter = new Spotter($this->db); |
|
| 322 | + if (isset($this->all_flights[$id]['source_type'])) { |
|
| 323 | 323 | $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']),$this->all_flights[$id]['source_type']); |
| 324 | - } else { |
|
| 324 | + } else { |
|
| 325 | 325 | $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex'])); |
| 326 | - } |
|
| 327 | - $Spotter->db = null; |
|
| 328 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 329 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
| 326 | + } |
|
| 327 | + $Spotter->db = null; |
|
| 328 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 329 | + if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
| 330 | 330 | } |
| 331 | - } |
|
| 332 | - if ($globalAllFlights !== FALSE) $dataFound = true; |
|
| 333 | - if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
|
| 331 | + } |
|
| 332 | + if ($globalAllFlights !== FALSE) $dataFound = true; |
|
| 333 | + if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
|
| 334 | 334 | } |
| 335 | - if (isset($line['id']) && !isset($line['hex'])) { |
|
| 336 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => '')); |
|
| 337 | - } |
|
| 335 | + if (isset($line['id']) && !isset($line['hex'])) { |
|
| 336 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => '')); |
|
| 337 | + } |
|
| 338 | 338 | if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') { |
| 339 | 339 | $icao = $line['aircraft_icao']; |
| 340 | 340 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
@@ -364,9 +364,9 @@ discard block |
||
| 364 | 364 | } |
| 365 | 365 | //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
| 366 | 366 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) { |
| 367 | - if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
|
| 367 | + if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
|
| 368 | 368 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
| 369 | - } else { |
|
| 369 | + } else { |
|
| 370 | 370 | if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
| 371 | 371 | elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
| 372 | 372 | /* |
@@ -375,7 +375,7 @@ discard block |
||
| 375 | 375 | print_r($line); |
| 376 | 376 | */ |
| 377 | 377 | return ''; |
| 378 | - } |
|
| 378 | + } |
|
| 379 | 379 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
| 380 | 380 | if ($globalDebug) echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n"; |
| 381 | 381 | return ''; |
@@ -391,21 +391,21 @@ discard block |
||
| 391 | 391 | } |
| 392 | 392 | |
| 393 | 393 | if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG' && $line['registration'] != 'NA') { |
| 394 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration'])); |
|
| 394 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration'])); |
|
| 395 | 395 | } |
| 396 | 396 | if (isset($line['waypoints']) && $line['waypoints'] != '') { |
| 397 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints'])); |
|
| 397 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints'])); |
|
| 398 | 398 | } |
| 399 | 399 | if (isset($line['pilot_id']) && $line['pilot_id'] != '') { |
| 400 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id']))); |
|
| 400 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id']))); |
|
| 401 | 401 | } |
| 402 | 402 | if (isset($line['pilot_name']) && $line['pilot_name'] != '') { |
| 403 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name']))); |
|
| 403 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name']))); |
|
| 404 | 404 | } |
| 405 | 405 | |
| 406 | 406 | if (isset($line['ident']) && trim($line['ident']) != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_flights[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) { |
| 407 | 407 | |
| 408 | - if ($this->all_flights[$id]['addedSpotter'] == 1) { |
|
| 408 | + if ($this->all_flights[$id]['addedSpotter'] == 1) { |
|
| 409 | 409 | if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 1600) { |
| 410 | 410 | if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n"; |
| 411 | 411 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
@@ -414,23 +414,23 @@ discard block |
||
| 414 | 414 | elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
| 415 | 415 | elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
| 416 | 416 | } else { |
| 417 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
| 418 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 417 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
| 418 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 419 | 419 | $timeelapsed = microtime(true); |
| 420 | - $Spotter = new Spotter($this->db); |
|
| 421 | - $fromsource = NULL; |
|
| 422 | - if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
|
| 423 | - elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
|
| 420 | + $Spotter = new Spotter($this->db); |
|
| 421 | + $fromsource = NULL; |
|
| 422 | + if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
|
| 423 | + elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
|
| 424 | 424 | elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao'; |
| 425 | 425 | elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
| 426 | 426 | elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
| 427 | - $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource,$this->all_flights[$id]['source_type']); |
|
| 427 | + $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource,$this->all_flights[$id]['source_type']); |
|
| 428 | 428 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
| 429 | 429 | $Spotter->db = null; |
| 430 | 430 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 431 | - } |
|
| 431 | + } |
|
| 432 | 432 | } |
| 433 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
| 433 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
| 434 | 434 | |
| 435 | 435 | /* |
| 436 | 436 | if (!isset($line['id'])) { |
@@ -440,63 +440,63 @@ discard block |
||
| 440 | 440 | else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
| 441 | 441 | } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
| 442 | 442 | */ |
| 443 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 443 | + if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 444 | 444 | |
| 445 | - //$putinarchive = true; |
|
| 446 | - if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
|
| 445 | + //$putinarchive = true; |
|
| 446 | + if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
|
| 447 | 447 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time'])); |
| 448 | - } |
|
| 449 | - if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) { |
|
| 448 | + } |
|
| 449 | + if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) { |
|
| 450 | 450 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time'])); |
| 451 | - } |
|
| 452 | - if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) { |
|
| 453 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
| 454 | - } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) { |
|
| 451 | + } |
|
| 452 | + if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) { |
|
| 453 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
| 454 | + } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) { |
|
| 455 | 455 | $timeelapsed = microtime(true); |
| 456 | 456 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 457 | 457 | $Spotter = new Spotter($this->db); |
| 458 | 458 | $line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']); |
| 459 | 459 | $line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']); |
| 460 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
| 460 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
| 461 | 461 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 462 | - } |
|
| 463 | - } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
|
| 462 | + } |
|
| 463 | + } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
|
| 464 | 464 | $timeelapsed = microtime(true); |
| 465 | 465 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 466 | - $Spotter = new Spotter($this->db); |
|
| 467 | - $route = $Spotter->getRouteInfo(trim($line['ident'])); |
|
| 468 | - if (!isset($route['fromairport_icao']) && !isset($route['toairport_icao'])) { |
|
| 466 | + $Spotter = new Spotter($this->db); |
|
| 467 | + $route = $Spotter->getRouteInfo(trim($line['ident'])); |
|
| 468 | + if (!isset($route['fromairport_icao']) && !isset($route['toairport_icao'])) { |
|
| 469 | 469 | $Translation = new Translation($this->db); |
| 470 | 470 | $ident = $Translation->checkTranslation(trim($line['ident'])); |
| 471 | 471 | $route = $Spotter->getRouteInfo($ident); |
| 472 | 472 | $Translation->db = null; |
| 473 | - } |
|
| 474 | - $Spotter->db = null; |
|
| 475 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 476 | - } |
|
| 473 | + } |
|
| 474 | + $Spotter->db = null; |
|
| 475 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 476 | + } |
|
| 477 | 477 | if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) { |
| 478 | - //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
|
| 479 | - if ($route['fromairport_icao'] != $route['toairport_icao']) { |
|
| 478 | + //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
|
| 479 | + if ($route['fromairport_icao'] != $route['toairport_icao']) { |
|
| 480 | 480 | // $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['FromAirport_ICAO'],'arrival_airport' => $route['ToAirport_ICAO'],'route_stop' => $route['RouteStop'])); |
| 481 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop'])); |
|
| 482 | - } |
|
| 481 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop'])); |
|
| 482 | + } |
|
| 483 | 483 | } |
| 484 | 484 | if (!isset($globalFork)) $globalFork = TRUE; |
| 485 | 485 | if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) { |
| 486 | 486 | if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident'])); |
| 487 | 487 | } |
| 488 | - } |
|
| 488 | + } |
|
| 489 | 489 | } |
| 490 | 490 | |
| 491 | 491 | if (isset($line['speed']) && $line['speed'] != '' && $line['speed'] != 0) { |
| 492 | 492 | // $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12])); |
| 493 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed']))); |
|
| 494 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true)); |
|
| 495 | - //$dataFound = true; |
|
| 493 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed']))); |
|
| 494 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true)); |
|
| 495 | + //$dataFound = true; |
|
| 496 | 496 | } else if (!isset($this->all_flights[$id]['speed_fromsrc']) && isset($this->all_flights[$id]['time_last_coord']) && $this->all_flights[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) { |
| 497 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'); |
|
| 498 | - if ($distance > 1000 && $distance < 10000) { |
|
| 499 | - // use datetime |
|
| 497 | + $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'); |
|
| 498 | + if ($distance > 1000 && $distance < 10000) { |
|
| 499 | + // use datetime |
|
| 500 | 500 | $speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']); |
| 501 | 501 | $speed = $speed*3.6; |
| 502 | 502 | if ($speed < 1000) { |
@@ -505,49 +505,49 @@ discard block |
||
| 505 | 505 | } else { |
| 506 | 506 | if ($globalDebug) echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
| 507 | 507 | } |
| 508 | - } |
|
| 508 | + } |
|
| 509 | 509 | } |
| 510 | 510 | |
| 511 | 511 | |
| 512 | 512 | |
| 513 | - if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
| 514 | - if (ctype_digit(strval($line['latitude'])) || ctype_digit(strval($line['longitude']))) { |
|
| 515 | - if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n"; |
|
| 516 | - return false; |
|
| 517 | - } |
|
| 518 | - if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
| 519 | - else unset($timediff); |
|
| 520 | - if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']); |
|
| 521 | - else unset($timediff_archive); |
|
| 522 | - if ($this->tmd > 5 |
|
| 523 | - || (isset($line['format_source']) |
|
| 524 | - && $line['format_source'] == 'airwhere' |
|
| 525 | - && ((!isset($this->all_flights[$id]['latitude']) |
|
| 526 | - || !isset($this->all_flights[$id]['longitude'])) |
|
| 527 | - || (isset($this->all_flights[$id]['latitude']) |
|
| 528 | - && isset($this->all_flights[$id]['longitude']) |
|
| 529 | - && $this->all_flights[$id]['latitude'] != $line['latitude'] |
|
| 530 | - && $this->all_flights[$id]['longitude'] != $line['longitude'] |
|
| 531 | - ) |
|
| 532 | - ) |
|
| 533 | - ) |
|
| 534 | - || (isset($globalVA) && $globalVA) |
|
| 535 | - || (isset($globalIVAO) && $globalIVAO) |
|
| 536 | - || (isset($globalVATSIM) && $globalVATSIM) |
|
| 537 | - || (isset($globalphpVMS) && $globalphpVMS) |
|
| 538 | - || (isset($globalVAM) && $globalVAM) |
|
| 539 | - || !isset($timediff) |
|
| 540 | - || (isset($timediff) && $timediff > $globalLiveInterval) |
|
| 541 | - || $globalArchive |
|
| 542 | - || (isset($timediff) && $timediff > 30 |
|
| 543 | - && isset($this->all_flights[$id]['latitude']) |
|
| 544 | - && isset($this->all_flights[$id]['longitude']) |
|
| 545 | - && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')) |
|
| 546 | - ) |
|
| 547 | - ) { |
|
| 513 | + if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
| 514 | + if (ctype_digit(strval($line['latitude'])) || ctype_digit(strval($line['longitude']))) { |
|
| 515 | + if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n"; |
|
| 516 | + return false; |
|
| 517 | + } |
|
| 518 | + if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
| 519 | + else unset($timediff); |
|
| 520 | + if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']); |
|
| 521 | + else unset($timediff_archive); |
|
| 522 | + if ($this->tmd > 5 |
|
| 523 | + || (isset($line['format_source']) |
|
| 524 | + && $line['format_source'] == 'airwhere' |
|
| 525 | + && ((!isset($this->all_flights[$id]['latitude']) |
|
| 526 | + || !isset($this->all_flights[$id]['longitude'])) |
|
| 527 | + || (isset($this->all_flights[$id]['latitude']) |
|
| 528 | + && isset($this->all_flights[$id]['longitude']) |
|
| 529 | + && $this->all_flights[$id]['latitude'] != $line['latitude'] |
|
| 530 | + && $this->all_flights[$id]['longitude'] != $line['longitude'] |
|
| 531 | + ) |
|
| 532 | + ) |
|
| 533 | + ) |
|
| 534 | + || (isset($globalVA) && $globalVA) |
|
| 535 | + || (isset($globalIVAO) && $globalIVAO) |
|
| 536 | + || (isset($globalVATSIM) && $globalVATSIM) |
|
| 537 | + || (isset($globalphpVMS) && $globalphpVMS) |
|
| 538 | + || (isset($globalVAM) && $globalVAM) |
|
| 539 | + || !isset($timediff) |
|
| 540 | + || (isset($timediff) && $timediff > $globalLiveInterval) |
|
| 541 | + || $globalArchive |
|
| 542 | + || (isset($timediff) && $timediff > 30 |
|
| 543 | + && isset($this->all_flights[$id]['latitude']) |
|
| 544 | + && isset($this->all_flights[$id]['longitude']) |
|
| 545 | + && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')) |
|
| 546 | + ) |
|
| 547 | + ) { |
|
| 548 | 548 | |
| 549 | 549 | if ((isset($timediff) && !isset($timediff_archive)) || (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude']))) { |
| 550 | - if ((isset($timediff_archive) && $timediff_archive > $globalAircraftMaxUpdate) |
|
| 550 | + if ((isset($timediff_archive) && $timediff_archive > $globalAircraftMaxUpdate) |
|
| 551 | 551 | || (isset($line['format_source']) && $line['format_source'] == 'airwhere') |
| 552 | 552 | || !$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
| 553 | 553 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
@@ -559,9 +559,9 @@ discard block |
||
| 559 | 559 | } |
| 560 | 560 | $this->tmd = 0; |
| 561 | 561 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
| 562 | - if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
| 563 | - $timeelapsed = microtime(true); |
|
| 564 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 562 | + if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
| 563 | + $timeelapsed = microtime(true); |
|
| 564 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 565 | 565 | $Spotter = new Spotter($this->db); |
| 566 | 566 | $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
| 567 | 567 | if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
@@ -569,11 +569,11 @@ discard block |
||
| 569 | 569 | $Spotter->db = null; |
| 570 | 570 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 571 | 571 | if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
| 572 | - } |
|
| 572 | + } |
|
| 573 | 573 | } |
| 574 | 574 | $this->all_flights[$id]['time_last_archive_coord'] = time(); |
| 575 | - } |
|
| 576 | - /* |
|
| 575 | + } |
|
| 576 | + /* |
|
| 577 | 577 | else { |
| 578 | 578 | if (!isset($timediff)) echo 'NO TIMEDIFF'; |
| 579 | 579 | else { |
@@ -587,16 +587,16 @@ discard block |
||
| 587 | 587 | } |
| 588 | 588 | |
| 589 | 589 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
| 590 | - //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
|
| 590 | + //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
|
| 591 | 591 | if (!isset($this->all_flights[$id]['archive_latitude'])) { |
| 592 | 592 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
| 593 | 593 | $this->all_flights[$id]['time_last_coord'] = time(); |
| 594 | 594 | } |
| 595 | 595 | //if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) { |
| 596 | 596 | if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) { |
| 597 | - $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
|
| 598 | - $dataFound = true; |
|
| 599 | - $this->all_flights[$id]['time_last_coord'] = time(); |
|
| 597 | + $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
|
| 598 | + $dataFound = true; |
|
| 599 | + $this->all_flights[$id]['time_last_coord'] = time(); |
|
| 600 | 600 | } |
| 601 | 601 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
| 602 | 602 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude'])); |
@@ -607,25 +607,25 @@ discard block |
||
| 607 | 607 | //$putinarchive = true; |
| 608 | 608 | } |
| 609 | 609 | */ |
| 610 | - /* |
|
| 610 | + /* |
|
| 611 | 611 | } elseif (isset($this->all_flights[$id]['latitude'])) { |
| 612 | 612 | if ($globalDebug) echo '!!! Strange latitude value - diff : '.abs($this->all_flights[$id]['latitude']-$line['latitude']).'- previous lat : '.$this->all_flights[$id]['latitude'].'- new lat : '.$line['latitude']."\n"; |
| 613 | 613 | } |
| 614 | 614 | */ |
| 615 | 615 | } |
| 616 | 616 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
| 617 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
| 618 | - //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == '' || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
|
| 617 | + if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
| 618 | + //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == '' || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
|
| 619 | 619 | if (!isset($this->all_flights[$id]['archive_longitude'])) { |
| 620 | 620 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
| 621 | 621 | $this->all_flights[$id]['time_last_coord'] = time(); |
| 622 | 622 | } |
| 623 | 623 | //if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) { |
| 624 | 624 | if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) { |
| 625 | - $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
|
| 626 | - $dataFound = true; |
|
| 627 | - $this->all_flights[$id]['coordinates'] += 1; |
|
| 628 | - $this->all_flights[$id]['time_last_coord'] = time(); |
|
| 625 | + $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
|
| 626 | + $dataFound = true; |
|
| 627 | + $this->all_flights[$id]['coordinates'] += 1; |
|
| 628 | + $this->all_flights[$id]['time_last_coord'] = time(); |
|
| 629 | 629 | } |
| 630 | 630 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
| 631 | 631 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude'])); |
@@ -643,76 +643,76 @@ discard block |
||
| 643 | 643 | */ |
| 644 | 644 | } |
| 645 | 645 | if ($globalDaemon === TRUE && isset($updateinitial) && $updateinitial && $this->all_flights[$id]['addedSpotter'] == 1) { |
| 646 | - if ($globalDebug) echo "\n".'>>> Update initial data !'."\n"; |
|
| 647 | - unset($updateinitial); |
|
| 648 | - $SpotterArchive = new SpotterArchive(); |
|
| 649 | - $SpotterArchive->deleteSpotterArchiveTrackDataByID($this->all_flights[$id]['id']); |
|
| 650 | - $SpotterArchive->db = null; |
|
| 651 | - $Spotter = new Spotter(); |
|
| 652 | - $Spotter->updateInitialSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime']); |
|
| 653 | - $Spotter->db = null; |
|
| 646 | + if ($globalDebug) echo "\n".'>>> Update initial data !'."\n"; |
|
| 647 | + unset($updateinitial); |
|
| 648 | + $SpotterArchive = new SpotterArchive(); |
|
| 649 | + $SpotterArchive->deleteSpotterArchiveTrackDataByID($this->all_flights[$id]['id']); |
|
| 650 | + $SpotterArchive->db = null; |
|
| 651 | + $Spotter = new Spotter(); |
|
| 652 | + $Spotter->updateInitialSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime']); |
|
| 653 | + $Spotter->db = null; |
|
| 654 | 654 | } |
| 655 | - } else if ($globalDebug && $timediff > 30) { |
|
| 655 | + } else if ($globalDebug && $timediff > 30) { |
|
| 656 | 656 | $this->tmd = $this->tmd + 1; |
| 657 | 657 | echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n"; |
| 658 | 658 | echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -"; |
| 659 | 659 | echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
| 660 | 660 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n"; |
| 661 | - } |
|
| 661 | + } |
|
| 662 | 662 | } |
| 663 | 663 | if (isset($line['last_update']) && $line['last_update'] != '') { |
| 664 | - if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
| 665 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
|
| 664 | + if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
| 665 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
|
| 666 | 666 | } |
| 667 | 667 | if (isset($line['verticalrate']) && $line['verticalrate'] != '') { |
| 668 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate'])); |
|
| 669 | - //$dataFound = true; |
|
| 668 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate'])); |
|
| 669 | + //$dataFound = true; |
|
| 670 | 670 | } |
| 671 | 671 | if (isset($line['format_source']) && $line['format_source'] != '') { |
| 672 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source'])); |
|
| 672 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source'])); |
|
| 673 | 673 | } |
| 674 | 674 | if (isset($line['source_name']) && $line['source_name'] != '') { |
| 675 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name'])); |
|
| 675 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name'])); |
|
| 676 | 676 | } |
| 677 | 677 | if (isset($line['emergency']) && $line['emergency'] != '') { |
| 678 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency'])); |
|
| 679 | - //$dataFound = true; |
|
| 678 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency'])); |
|
| 679 | + //$dataFound = true; |
|
| 680 | 680 | } |
| 681 | 681 | if (isset($line['ground']) && $line['ground'] != '') { |
| 682 | - if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) { |
|
| 682 | + if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) { |
|
| 683 | 683 | // Here we force archive of flight because after ground it's a new one (or should be) |
| 684 | 684 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
| 685 | 685 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
| 686 | 686 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
| 687 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 687 | + elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 688 | 688 | elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
| 689 | - } |
|
| 690 | - if ($line['ground'] != 1) $line['ground'] = 0; |
|
| 691 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
|
| 692 | - //$dataFound = true; |
|
| 689 | + } |
|
| 690 | + if ($line['ground'] != 1) $line['ground'] = 0; |
|
| 691 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
|
| 692 | + //$dataFound = true; |
|
| 693 | 693 | } |
| 694 | 694 | if (isset($line['squawk']) && $line['squawk'] != '') { |
| 695 | - if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) { |
|
| 696 | - if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
|
| 697 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
| 698 | - $highlight = ''; |
|
| 699 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
| 700 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
| 701 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
| 702 | - if ($highlight != '') { |
|
| 695 | + if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) { |
|
| 696 | + if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
|
| 697 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
| 698 | + $highlight = ''; |
|
| 699 | + if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
| 700 | + if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
| 701 | + if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
| 702 | + if ($highlight != '') { |
|
| 703 | 703 | $timeelapsed = microtime(true); |
| 704 | 704 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 705 | - $Spotter = new Spotter($this->db); |
|
| 706 | - $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
|
| 707 | - $Spotter->db = null; |
|
| 708 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 705 | + $Spotter = new Spotter($this->db); |
|
| 706 | + $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
|
| 707 | + $Spotter->db = null; |
|
| 708 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 709 | 709 | } |
| 710 | 710 | //$putinarchive = true; |
| 711 | 711 | //$highlight = ''; |
| 712 | - } |
|
| 712 | + } |
|
| 713 | 713 | |
| 714 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
| 715 | - //$dataFound = true; |
|
| 714 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
| 715 | + //$dataFound = true; |
|
| 716 | 716 | } |
| 717 | 717 | |
| 718 | 718 | if (isset($line['altitude']) && $line['altitude'] != '') { |
@@ -723,13 +723,13 @@ discard block |
||
| 723 | 723 | $line['altitude'] = $line['altitude'] - $geoid; |
| 724 | 724 | } |
| 725 | 725 | } |
| 726 | - //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
|
| 726 | + //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
|
| 727 | 727 | if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true; |
| 728 | 728 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100))); |
| 729 | 729 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude'])); |
| 730 | 730 | //$dataFound = true; |
| 731 | - //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
|
| 732 | - if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) { |
|
| 731 | + //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
|
| 732 | + if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) { |
|
| 733 | 733 | if (isset($this->all_flights[$id]['over_country']) && $this->all_flights[$id]['over_country'] != '' && isset($this->all_flights[$id]['altitude_previous']) && $this->all_flights[$id]['altitude_previous'] != '' && $this->all_flights[$id]['altitude_previous'] < $this->all_flights[$id]['altitude_real'] && isset($this->all_flights[$id]['lastupdate']) && $this->all_flights[$id]['lastupdate'] < time() - 1600) { |
| 734 | 734 | if ($globalDebug) echo '--- Reset because of altitude'."\n"; |
| 735 | 735 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
@@ -738,27 +738,27 @@ discard block |
||
| 738 | 738 | elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
| 739 | 739 | elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
| 740 | 740 | } |
| 741 | - } |
|
| 742 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude'])); |
|
| 741 | + } |
|
| 742 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude'])); |
|
| 743 | 743 | } |
| 744 | 744 | |
| 745 | 745 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
| 746 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true)); |
|
| 746 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true)); |
|
| 747 | 747 | } |
| 748 | 748 | |
| 749 | 749 | if (isset($line['heading']) && $line['heading'] != '') { |
| 750 | - if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
| 751 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
|
| 752 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
|
| 753 | - //$dataFound = true; |
|
| 750 | + if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
| 751 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
|
| 752 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
|
| 753 | + //$dataFound = true; |
|
| 754 | 754 | } elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) { |
| 755 | - $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
| 756 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
|
| 757 | - if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
| 758 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
|
| 755 | + $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
| 756 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
|
| 757 | + if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
| 758 | + if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
|
| 759 | 759 | } elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') { |
| 760 | - // If not enough messages and ACARS set heading to 0 |
|
| 761 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
|
| 760 | + // If not enough messages and ACARS set heading to 0 |
|
| 761 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
|
| 762 | 762 | } |
| 763 | 763 | if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
| 764 | 764 | elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
@@ -771,133 +771,133 @@ discard block |
||
| 771 | 771 | //if ($dataFound === true && isset($this->all_flights[$id]['hex']) && $this->all_flights[$id]['heading'] != '' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
| 772 | 772 | //if ($dataFound === true && isset($this->all_flights[$id]['hex'])) { |
| 773 | 773 | if ($dataFound === true && isset($this->all_flights[$id]['id'])) { |
| 774 | - $this->all_flights[$id]['lastupdate'] = time(); |
|
| 775 | - if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) { |
|
| 776 | - if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
| 777 | - //print_r($this->all_flights); |
|
| 778 | - //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n"; |
|
| 779 | - //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
|
| 780 | - if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) { |
|
| 774 | + $this->all_flights[$id]['lastupdate'] = time(); |
|
| 775 | + if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) { |
|
| 776 | + if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
| 777 | + //print_r($this->all_flights); |
|
| 778 | + //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n"; |
|
| 779 | + //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
|
| 780 | + if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) { |
|
| 781 | 781 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 782 | - if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
| 783 | - $timeelapsed = microtime(true); |
|
| 784 | - $SpotterLive = new SpotterLive($this->db); |
|
| 785 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
|
| 782 | + if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
| 783 | + $timeelapsed = microtime(true); |
|
| 784 | + $SpotterLive = new SpotterLive($this->db); |
|
| 785 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
|
| 786 | 786 | $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']); |
| 787 | 787 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 788 | - } elseif (isset($line['id'])) { |
|
| 788 | + } elseif (isset($line['id'])) { |
|
| 789 | 789 | $recent_ident = $SpotterLive->checkIdRecent($line['id']); |
| 790 | 790 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 791 | - } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
|
| 791 | + } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
|
| 792 | 792 | $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']); |
| 793 | 793 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 794 | - } else $recent_ident = ''; |
|
| 795 | - $SpotterLive->db=null; |
|
| 796 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
| 797 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
| 794 | + } else $recent_ident = ''; |
|
| 795 | + $SpotterLive->db=null; |
|
| 796 | + if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
| 797 | + elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
| 798 | 798 | } else $recent_ident = ''; |
| 799 | - } else { |
|
| 799 | + } else { |
|
| 800 | 800 | $recent_ident = ''; |
| 801 | 801 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0)); |
| 802 | - } |
|
| 803 | - //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
| 804 | - if($recent_ident == "") |
|
| 805 | - { |
|
| 802 | + } |
|
| 803 | + //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
| 804 | + if($recent_ident == "") |
|
| 805 | + { |
|
| 806 | 806 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
| 807 | 807 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
| 808 | 808 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
| 809 | 809 | //adds the spotter data for the archive |
| 810 | 810 | $ignoreImport = false; |
| 811 | 811 | foreach($globalAirportIgnore as $airportIgnore) { |
| 812 | - if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
| 812 | + if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
| 813 | 813 | $ignoreImport = true; |
| 814 | - } |
|
| 814 | + } |
|
| 815 | 815 | } |
| 816 | 816 | if (count($globalAirportAccept) > 0) { |
| 817 | - $ignoreImport = true; |
|
| 818 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
| 817 | + $ignoreImport = true; |
|
| 818 | + foreach($globalAirportIgnore as $airportIgnore) { |
|
| 819 | 819 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
| 820 | - $ignoreImport = false; |
|
| 820 | + $ignoreImport = false; |
|
| 821 | + } |
|
| 821 | 822 | } |
| 822 | - } |
|
| 823 | 823 | } |
| 824 | 824 | if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
| 825 | - foreach($globalAirlineIgnore as $airlineIgnore) { |
|
| 825 | + foreach($globalAirlineIgnore as $airlineIgnore) { |
|
| 826 | 826 | if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
| 827 | - $ignoreImport = true; |
|
| 827 | + $ignoreImport = true; |
|
| 828 | + } |
|
| 828 | 829 | } |
| 829 | - } |
|
| 830 | 830 | } |
| 831 | 831 | if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
| 832 | - $ignoreImport = true; |
|
| 833 | - foreach($globalAirlineAccept as $airlineAccept) { |
|
| 832 | + $ignoreImport = true; |
|
| 833 | + foreach($globalAirlineAccept as $airlineAccept) { |
|
| 834 | 834 | if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
| 835 | - $ignoreImport = false; |
|
| 835 | + $ignoreImport = false; |
|
| 836 | + } |
|
| 836 | 837 | } |
| 837 | - } |
|
| 838 | 838 | } |
| 839 | 839 | if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
| 840 | - $ignoreImport = true; |
|
| 841 | - foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
| 840 | + $ignoreImport = true; |
|
| 841 | + foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
| 842 | 842 | if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
| 843 | - $ignoreImport = false; |
|
| 843 | + $ignoreImport = false; |
|
| 844 | + } |
|
| 844 | 845 | } |
| 845 | - } |
|
| 846 | 846 | } |
| 847 | 847 | |
| 848 | 848 | if (!$ignoreImport) { |
| 849 | - $highlight = ''; |
|
| 850 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
|
| 851 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
| 852 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
|
| 853 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
| 854 | - $timeelapsed = microtime(true); |
|
| 855 | - if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
| 849 | + $highlight = ''; |
|
| 850 | + if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
|
| 851 | + if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
| 852 | + if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
|
| 853 | + if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
| 854 | + $timeelapsed = microtime(true); |
|
| 855 | + if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
| 856 | 856 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 857 | - $Spotter = new Spotter($this->db); |
|
| 858 | - $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']); |
|
| 859 | - $Spotter->db = null; |
|
| 860 | - if ($globalDebug) { |
|
| 857 | + $Spotter = new Spotter($this->db); |
|
| 858 | + $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']); |
|
| 859 | + $Spotter->db = null; |
|
| 860 | + if ($globalDebug) { |
|
| 861 | 861 | if (isset($result['error'])) echo 'Error: '.$result['error']."\n"; |
| 862 | 862 | else echo 'Success'; |
| 863 | - } |
|
| 864 | - if (count($result) > 1) { |
|
| 865 | - // ':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type, |
|
| 863 | + } |
|
| 864 | + if (count($result) > 1) { |
|
| 865 | + // ':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type, |
|
| 866 | 866 | if ($this->all_flights[$id]['aircraft_icao'] == '') $this->all_flights[$id]['aircraft_icao'] = $result[':aircraft_icao']; |
| 867 | 867 | if ($this->all_flights[$id]['registration'] == '') $this->all_flights[$id]['registration'] = $result[':registration']; |
| 868 | - } |
|
| 868 | + } |
|
| 869 | 869 | } |
| 870 | - } |
|
| 871 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 872 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 870 | + } |
|
| 871 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 872 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 873 | 873 | |
| 874 | - // Add source stat in DB |
|
| 875 | - $Stats = new Stats($this->db); |
|
| 876 | - if (!empty($this->stats)) { |
|
| 874 | + // Add source stat in DB |
|
| 875 | + $Stats = new Stats($this->db); |
|
| 876 | + if (!empty($this->stats)) { |
|
| 877 | 877 | if ($globalDebug) echo 'Add source stats : '; |
| 878 | - foreach($this->stats as $date => $data) { |
|
| 879 | - foreach($data as $source => $sourced) { |
|
| 880 | - //print_r($sourced); |
|
| 881 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
| 882 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
| 883 | - if (isset($sourced['msg'])) { |
|
| 884 | - if (time() - $sourced['msg']['date'] > 10) { |
|
| 885 | - $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
| 886 | - echo $Stats->addStatSource($nbmsg,$source,'msg',$date); |
|
| 887 | - unset($this->stats[$date][$source]['msg']); |
|
| 888 | - } |
|
| 889 | - } |
|
| 890 | - } |
|
| 891 | - if ($date != date('Y-m-d')) { |
|
| 892 | - unset($this->stats[$date]); |
|
| 893 | - } |
|
| 894 | - } |
|
| 895 | - if ($globalDebug) echo 'Done'."\n"; |
|
| 878 | + foreach($this->stats as $date => $data) { |
|
| 879 | + foreach($data as $source => $sourced) { |
|
| 880 | + //print_r($sourced); |
|
| 881 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
| 882 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
| 883 | + if (isset($sourced['msg'])) { |
|
| 884 | + if (time() - $sourced['msg']['date'] > 10) { |
|
| 885 | + $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
| 886 | + echo $Stats->addStatSource($nbmsg,$source,'msg',$date); |
|
| 887 | + unset($this->stats[$date][$source]['msg']); |
|
| 888 | + } |
|
| 889 | + } |
|
| 890 | + } |
|
| 891 | + if ($date != date('Y-m-d')) { |
|
| 892 | + unset($this->stats[$date]); |
|
| 893 | + } |
|
| 894 | + } |
|
| 895 | + if ($globalDebug) echo 'Done'."\n"; |
|
| 896 | 896 | |
| 897 | - } |
|
| 898 | - $Stats->db = null; |
|
| 899 | - } |
|
| 900 | - $this->del(); |
|
| 897 | + } |
|
| 898 | + $Stats->db = null; |
|
| 899 | + } |
|
| 900 | + $this->del(); |
|
| 901 | 901 | } elseif ($globalDebug) echo 'Ignore data'."\n"; |
| 902 | 902 | //$ignoreImport = false; |
| 903 | 903 | $this->all_flights[$id]['addedSpotter'] = 1; |
@@ -915,41 +915,41 @@ discard block |
||
| 915 | 915 | */ |
| 916 | 916 | //SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']); |
| 917 | 917 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
| 918 | - if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
| 919 | - //SpotterLive->deleteLiveSpotterDataNotUpdated(); |
|
| 920 | - if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
| 918 | + if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
| 919 | + //SpotterLive->deleteLiveSpotterDataNotUpdated(); |
|
| 920 | + if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
| 921 | 921 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 922 | - $SpotterLive = new SpotterLive($this->db); |
|
| 923 | - $SpotterLive->deleteLiveSpotterData(); |
|
| 924 | - $SpotterLive->db=null; |
|
| 922 | + $SpotterLive = new SpotterLive($this->db); |
|
| 923 | + $SpotterLive->deleteLiveSpotterData(); |
|
| 924 | + $SpotterLive->db=null; |
|
| 925 | 925 | } |
| 926 | - } |
|
| 927 | - if ($globalDebug) echo " Done\n"; |
|
| 928 | - $this->last_delete = time(); |
|
| 926 | + } |
|
| 927 | + if ($globalDebug) echo " Done\n"; |
|
| 928 | + $this->last_delete = time(); |
|
| 929 | 929 | } |
| 930 | - } else { |
|
| 930 | + } else { |
|
| 931 | 931 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt'|| $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'famaprs' || $line['format_source'] === 'airwhere')) { |
| 932 | - $this->all_flights[$id]['id'] = $recent_ident; |
|
| 933 | - $this->all_flights[$id]['addedSpotter'] = 1; |
|
| 932 | + $this->all_flights[$id]['id'] = $recent_ident; |
|
| 933 | + $this->all_flights[$id]['addedSpotter'] = 1; |
|
| 934 | 934 | } |
| 935 | 935 | if (isset($globalDaemon) && !$globalDaemon) { |
| 936 | - if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
| 936 | + if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
| 937 | 937 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 938 | - $Spotter = new Spotter($this->db); |
|
| 939 | - $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time']); |
|
| 940 | - $Spotter->db = null; |
|
| 938 | + $Spotter = new Spotter($this->db); |
|
| 939 | + $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time']); |
|
| 940 | + $Spotter->db = null; |
|
| 941 | + } |
|
| 941 | 942 | } |
| 942 | - } |
|
| 943 | 943 | } |
| 944 | 944 | |
| 945 | - } |
|
| 945 | + } |
|
| 946 | 946 | } |
| 947 | - } |
|
| 948 | - //adds the spotter LIVE data |
|
| 949 | - //SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed); |
|
| 950 | - //echo "\nAdd in Live !! \n"; |
|
| 951 | - //echo "{$line[8]} {$line[7]} - MODES:{$line[4]} CALLSIGN:{$line[10]} ALT:{$line[11]} VEL:{$line[12]} HDG:{$line[13]} LAT:{$line[14]} LON:{$line[15]} VR:{$line[16]} SQUAWK:{$line[17]}\n"; |
|
| 952 | - if ($globalDebug) { |
|
| 947 | + } |
|
| 948 | + //adds the spotter LIVE data |
|
| 949 | + //SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed); |
|
| 950 | + //echo "\nAdd in Live !! \n"; |
|
| 951 | + //echo "{$line[8]} {$line[7]} - MODES:{$line[4]} CALLSIGN:{$line[10]} ALT:{$line[11]} VEL:{$line[12]} HDG:{$line[13]} LAT:{$line[14]} LON:{$line[15]} VR:{$line[16]} SQUAWK:{$line[17]}\n"; |
|
| 952 | + if ($globalDebug) { |
|
| 953 | 953 | if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) { |
| 954 | 954 | if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n"; |
| 955 | 955 | else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n"; |
@@ -957,61 +957,61 @@ discard block |
||
| 957 | 957 | if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n"; |
| 958 | 958 | else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n"; |
| 959 | 959 | } |
| 960 | - } |
|
| 961 | - $ignoreImport = false; |
|
| 962 | - if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
|
| 963 | - if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
|
| 960 | + } |
|
| 961 | + $ignoreImport = false; |
|
| 962 | + if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
|
| 963 | + if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
|
| 964 | 964 | |
| 965 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
| 966 | - if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
| 967 | - $ignoreImport = true; |
|
| 965 | + foreach($globalAirportIgnore as $airportIgnore) { |
|
| 966 | + if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
| 967 | + $ignoreImport = true; |
|
| 968 | + } |
|
| 968 | 969 | } |
| 969 | - } |
|
| 970 | - if (count($globalAirportAccept) > 0) { |
|
| 971 | - $ignoreImport = true; |
|
| 972 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
| 973 | - if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
| 970 | + if (count($globalAirportAccept) > 0) { |
|
| 971 | + $ignoreImport = true; |
|
| 972 | + foreach($globalAirportIgnore as $airportIgnore) { |
|
| 973 | + if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
| 974 | 974 | $ignoreImport = false; |
| 975 | - } |
|
| 975 | + } |
|
| 976 | 976 | } |
| 977 | - } |
|
| 978 | - if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
|
| 977 | + } |
|
| 978 | + if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
|
| 979 | 979 | foreach($globalAirlineIgnore as $airlineIgnore) { |
| 980 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
|
| 980 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
|
| 981 | 981 | $ignoreImport = true; |
| 982 | - } |
|
| 982 | + } |
|
| 983 | 983 | } |
| 984 | - } |
|
| 985 | - if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
|
| 984 | + } |
|
| 985 | + if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
|
| 986 | 986 | $ignoreImport = true; |
| 987 | 987 | foreach($globalAirlineAccept as $airlineAccept) { |
| 988 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
|
| 988 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
|
| 989 | 989 | $ignoreImport = false; |
| 990 | - } |
|
| 990 | + } |
|
| 991 | + } |
|
| 991 | 992 | } |
| 992 | - } |
|
| 993 | - if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
|
| 993 | + if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
|
| 994 | 994 | $ignoreImport = true; |
| 995 | 995 | foreach($globalPilotIdAccept as $pilotIdAccept) { |
| 996 | - if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
|
| 997 | - $ignoreImport = false; |
|
| 998 | - } |
|
| 996 | + if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
|
| 997 | + $ignoreImport = false; |
|
| 998 | + } |
|
| 999 | + } |
|
| 999 | 1000 | } |
| 1000 | - } |
|
| 1001 | 1001 | |
| 1002 | - if (!$ignoreImport) { |
|
| 1002 | + if (!$ignoreImport) { |
|
| 1003 | 1003 | if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
| 1004 | 1004 | if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
| 1005 | 1005 | $timeelapsed = microtime(true); |
| 1006 | 1006 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
| 1007 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 1007 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 1008 | 1008 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
| 1009 | 1009 | $SpotterLive = new SpotterLive($this->db); |
| 1010 | 1010 | //var_dump($this->all_flights[$id]); |
| 1011 | 1011 | $result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
| 1012 | 1012 | $SpotterLive->db = null; |
| 1013 | 1013 | if ($globalDebug) echo $result."\n"; |
| 1014 | - } |
|
| 1014 | + } |
|
| 1015 | 1015 | } |
| 1016 | 1016 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) { |
| 1017 | 1017 | $APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
@@ -1023,7 +1023,7 @@ discard block |
||
| 1023 | 1023 | //if ($line['format_source'] != 'aprs') { |
| 1024 | 1024 | //if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt')) { |
| 1025 | 1025 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 1026 | - if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
|
| 1026 | + if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
|
| 1027 | 1027 | $source = $this->all_flights[$id]['source_name']; |
| 1028 | 1028 | if ($source == '') $source = $this->all_flights[$id]['format_source']; |
| 1029 | 1029 | if (!isset($this->source_location[$source])) { |
@@ -1049,7 +1049,7 @@ discard block |
||
| 1049 | 1049 | if ($stats_heading == 16) $stats_heading = 0; |
| 1050 | 1050 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
| 1051 | 1051 | for ($i=0;$i<=15;$i++) { |
| 1052 | - $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
| 1052 | + $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
| 1053 | 1053 | } |
| 1054 | 1054 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
| 1055 | 1055 | } else { |
@@ -1062,17 +1062,17 @@ discard block |
||
| 1062 | 1062 | //var_dump($this->stats); |
| 1063 | 1063 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
| 1064 | 1064 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
| 1065 | - end($this->stats[$current_date][$source]['hist']); |
|
| 1066 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
| 1065 | + end($this->stats[$current_date][$source]['hist']); |
|
| 1066 | + $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
| 1067 | 1067 | } else $mini = 0; |
| 1068 | 1068 | for ($i=$mini;$i<=$distance;$i+=10) { |
| 1069 | - $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
| 1069 | + $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
| 1070 | 1070 | } |
| 1071 | 1071 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
| 1072 | 1072 | } else { |
| 1073 | 1073 | $this->stats[$current_date][$source]['hist'][$distance] += 1; |
| 1074 | 1074 | } |
| 1075 | - } |
|
| 1075 | + } |
|
| 1076 | 1076 | } |
| 1077 | 1077 | |
| 1078 | 1078 | $this->all_flights[$id]['lastupdate'] = time(); |
@@ -1082,7 +1082,7 @@ discard block |
||
| 1082 | 1082 | //$this->del(); |
| 1083 | 1083 | |
| 1084 | 1084 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
| 1085 | - if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
|
| 1085 | + if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
|
| 1086 | 1086 | if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour..."; |
| 1087 | 1087 | $SpotterLive = new SpotterLive($this->db); |
| 1088 | 1088 | $SpotterLive->deleteLiveSpotterDataNotUpdated(); |
@@ -1090,19 +1090,19 @@ discard block |
||
| 1090 | 1090 | //SpotterLive->deleteLiveSpotterData(); |
| 1091 | 1091 | if ($globalDebug) echo " Done\n"; |
| 1092 | 1092 | $this->last_delete_hourly = time(); |
| 1093 | - } else { |
|
| 1093 | + } else { |
|
| 1094 | 1094 | $this->del(); |
| 1095 | 1095 | $this->last_delete_hourly = time(); |
| 1096 | - } |
|
| 1096 | + } |
|
| 1097 | 1097 | } |
| 1098 | 1098 | |
| 1099 | - } |
|
| 1100 | - //$ignoreImport = false; |
|
| 1099 | + } |
|
| 1100 | + //$ignoreImport = false; |
|
| 1101 | 1101 | } |
| 1102 | 1102 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
| 1103 | 1103 | if ($send) return $this->all_flights[$id]; |
| 1104 | - } |
|
| 1104 | + } |
|
| 1105 | + } |
|
| 1105 | 1106 | } |
| 1106 | - } |
|
| 1107 | 1107 | } |
| 1108 | 1108 | ?> |
@@ -41,12 +41,12 @@ discard block |
||
| 41 | 41 | $currentdate = date('Y-m-d'); |
| 42 | 42 | $sourcestat = $Stats->getStatsSource($currentdate); |
| 43 | 43 | if (!empty($sourcestat)) { |
| 44 | - foreach($sourcestat as $srcst) { |
|
| 44 | + foreach ($sourcestat as $srcst) { |
|
| 45 | 45 | $type = $srcst['stats_type']; |
| 46 | 46 | if ($type == 'polar' || $type == 'hist') { |
| 47 | 47 | $source = $srcst['source_name']; |
| 48 | 48 | $data = $srcst['source_data']; |
| 49 | - $this->stats[$currentdate][$source][$type] = json_decode($data,true); |
|
| 49 | + $this->stats[$currentdate][$source][$type] = json_decode($data, true); |
|
| 50 | 50 | } |
| 51 | 51 | } |
| 52 | 52 | } |
@@ -58,14 +58,14 @@ discard block |
||
| 58 | 58 | if (isset($globalGeoid) && $globalGeoid) { |
| 59 | 59 | try { |
| 60 | 60 | $GeoidClass = new GeoidHeight(); |
| 61 | - } catch(Exception $e) { |
|
| 61 | + } catch (Exception $e) { |
|
| 62 | 62 | if ($globalDebug) echo "Can't calculate geoid, check that you downloaded it via update_db.php (".$e.")\n"; |
| 63 | 63 | $GeoidClass = FALSE; |
| 64 | 64 | } |
| 65 | 65 | } |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | - public function get_Schedule($id,$ident) { |
|
| 68 | + public function get_Schedule($id, $ident) { |
|
| 69 | 69 | global $globalDebug, $globalFork, $globalSchedulesFetch; |
| 70 | 70 | // Get schedule here, so it's done only one time |
| 71 | 71 | |
@@ -90,8 +90,8 @@ discard block |
||
| 90 | 90 | $schedule = $Schedule->fetchSchedule($operator); |
| 91 | 91 | if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) { |
| 92 | 92 | if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
| 93 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
|
| 94 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
| 93 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $schedule['DepartureTime'])); |
|
| 94 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
| 95 | 95 | // Should also check if route schedule = route from DB |
| 96 | 96 | if ($schedule['DepartureAirportIATA'] != '') { |
| 97 | 97 | if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) { |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | } |
| 112 | 112 | } |
| 113 | 113 | } |
| 114 | - $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']); |
|
| 114 | + $Schedule->addSchedule($operator, $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['arrival_airport_time'], $schedule['Source']); |
|
| 115 | 115 | } |
| 116 | 116 | } else $scheduleexist = true; |
| 117 | 117 | } else $scheduleexist = true; |
@@ -119,8 +119,8 @@ discard block |
||
| 119 | 119 | if ($scheduleexist) { |
| 120 | 120 | if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n"; |
| 121 | 121 | $sch = $Schedule->getSchedule($operator); |
| 122 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time'])); |
|
| 123 | - if ($this->all_flights[$id]['addedSpotter'] == 1) $Spotter->updateLatestScheduleSpotterData($this->all_flights[$id]['id'],$sch['departure_airport_icao'],$sch['departure_airport_time'],$sch['arrival_airport_icao'],$sch['arrival_airport_time']); |
|
| 122 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport' => $sch['arrival_airport_icao'], 'departure_airport' => $sch['departure_airport_icao'], 'departure_airport_time' => $sch['departure_airport_time'], 'arrival_airport_time' => $sch['arrival_airport_time'])); |
|
| 123 | + if ($this->all_flights[$id]['addedSpotter'] == 1) $Spotter->updateLatestScheduleSpotterData($this->all_flights[$id]['id'], $sch['departure_airport_icao'], $sch['departure_airport_time'], $sch['arrival_airport_icao'], $sch['arrival_airport_time']); |
|
| 124 | 124 | } |
| 125 | 125 | $Spotter->db = null; |
| 126 | 126 | $Schedule->db = null; |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
| 148 | 148 | $Spotter = new Spotter($this->db); |
| 149 | 149 | $real_arrival = $this->arrival($key); |
| 150 | - if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
| 150 | + if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['altitude'], $this->all_flights[$key]['ground'], $this->all_flights[$key]['speed'], $this->all_flights[$key]['datetime'], $real_arrival['airport_icao'], $real_arrival['airport_time']); |
|
| 151 | 151 | } |
| 152 | 152 | } |
| 153 | 153 | } |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | $airport_time = ''; |
| 162 | 162 | if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
| 163 | 163 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
| 164 | - $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
|
| 164 | + $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $globalClosestMinDist); |
|
| 165 | 165 | if (isset($closestAirports[0])) { |
| 166 | 166 | if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
| 167 | 167 | $airport_icao = $closestAirports[0]['icao']; |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | break; |
| 177 | 177 | } |
| 178 | 178 | } |
| 179 | - } elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) { |
|
| 179 | + } elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude'] + 5000))) { |
|
| 180 | 180 | $airport_icao = $closestAirports[0]['icao']; |
| 181 | 181 | $airport_time = $this->all_flights[$key]['datetime']; |
| 182 | 182 | } else { |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | } else { |
| 190 | 190 | if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
| 191 | 191 | } |
| 192 | - return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
|
| 192 | + return array('airport_icao' => $airport_icao, 'airport_time' => $airport_time); |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | |
| 202 | 202 | foreach ($this->all_flights as $key => $flight) { |
| 203 | 203 | if (isset($flight['lastupdate'])) { |
| 204 | - if ($flight['lastupdate'] < (time()-1800)) { |
|
| 204 | + if ($flight['lastupdate'] < (time() - 1800)) { |
|
| 205 | 205 | $this->delKey($key); |
| 206 | 206 | } |
| 207 | 207 | } |
@@ -218,10 +218,10 @@ discard block |
||
| 218 | 218 | $Spotter = new Spotter($this->db); |
| 219 | 219 | $SpotterLive = new SpotterLive($this->db); |
| 220 | 220 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
| 221 | - $result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
| 221 | + $result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['altitude'], $this->all_flights[$key]['ground'], $this->all_flights[$key]['speed'], $this->all_flights[$key]['datetime'], $real_arrival['airport_icao'], $real_arrival['airport_time']); |
|
| 222 | 222 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
| 223 | 223 | $this->all_flights[$key]['putinarchive'] = true; |
| 224 | - $result = $SpotterLive->addLiveSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['aircraft_icao'], $this->all_flights[$key]['departure_airport'], $this->all_flights[$key]['arrival_airport'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['waypoints'], $this->all_flights[$key]['altitude'],$this->all_flights[$key]['altitude_real'], $this->all_flights[$key]['heading'], $this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'], $this->all_flights[$key]['departure_airport_time'], $this->all_flights[$key]['arrival_airport_time'], $this->all_flights[$key]['squawk'],$this->all_flights[$key]['route_stop'],$this->all_flights[$key]['hex'],$this->all_flights[$key]['putinarchive'],$this->all_flights[$key]['registration'],$this->all_flights[$key]['pilot_id'],$this->all_flights[$key]['pilot_name'], $this->all_flights[$key]['verticalrate'], $this->all_flights[$key]['noarchive'], $this->all_flights[$key]['ground'],$this->all_flights[$key]['format_source'],$this->all_flights[$key]['source_name'],$this->all_flights[$key]['over_country']); |
|
| 224 | + $result = $SpotterLive->addLiveSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['aircraft_icao'], $this->all_flights[$key]['departure_airport'], $this->all_flights[$key]['arrival_airport'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['waypoints'], $this->all_flights[$key]['altitude'], $this->all_flights[$key]['altitude_real'], $this->all_flights[$key]['heading'], $this->all_flights[$key]['speed'], $this->all_flights[$key]['datetime'], $this->all_flights[$key]['departure_airport_time'], $this->all_flights[$key]['arrival_airport_time'], $this->all_flights[$key]['squawk'], $this->all_flights[$key]['route_stop'], $this->all_flights[$key]['hex'], $this->all_flights[$key]['putinarchive'], $this->all_flights[$key]['registration'], $this->all_flights[$key]['pilot_id'], $this->all_flights[$key]['pilot_name'], $this->all_flights[$key]['verticalrate'], $this->all_flights[$key]['noarchive'], $this->all_flights[$key]['ground'], $this->all_flights[$key]['format_source'], $this->all_flights[$key]['source_name'], $this->all_flights[$key]['over_country']); |
|
| 225 | 225 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
| 226 | 226 | } |
| 227 | 227 | $Spotter->db = null; |
@@ -257,10 +257,10 @@ discard block |
||
| 257 | 257 | $send = false; |
| 258 | 258 | |
| 259 | 259 | // SBS format is CSV format |
| 260 | - if(is_array($line) && (isset($line['hex']) || isset($line['id']))) { |
|
| 260 | + if (is_array($line) && (isset($line['hex']) || isset($line['id']))) { |
|
| 261 | 261 | //print_r($line); |
| 262 | 262 | if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']); |
| 263 | - if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && substr($line['hex'],0,1) != '~' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) { |
|
| 263 | + if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && substr($line['hex'], 0, 1) != '~' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) { |
|
| 264 | 264 | |
| 265 | 265 | // Increment message number |
| 266 | 266 | if (isset($line['sourcestats']) && $line['sourcestats'] === TRUE) { |
@@ -293,25 +293,25 @@ discard block |
||
| 293 | 293 | if (!isset($this->all_flights[$id])) { |
| 294 | 294 | if ($globalDebug) echo 'New flight...'."\n"; |
| 295 | 295 | $this->all_flights[$id] = array(); |
| 296 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
| 297 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => '','coordinates' => 0)); |
|
| 298 | - if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
| 296 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
| 297 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => '', 'departure_airport' => '', 'arrival_airport' => '', 'latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'altitude_real' => '', 'altitude_previous' => '', 'heading' => '', 'departure_airport_time' => '', 'arrival_airport_time' => '', 'squawk' => '', 'route_stop' => '', 'registration' => '', 'pilot_id' => '', 'pilot_name' => '', 'waypoints' => '', 'ground' => '0', 'format_source' => '', 'source_name' => '', 'over_country' => '', 'verticalrate' => '', 'noarchive' => false, 'putinarchive' => true, 'source_type' => '', 'coordinates' => 0)); |
|
| 298 | + if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('lastupdate' => time())); |
|
| 299 | 299 | if (!isset($line['id'])) { |
| 300 | 300 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
| 301 | 301 | // if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi'))); |
| 302 | 302 | // if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
| 303 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
| 303 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
| 304 | 304 | //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
| 305 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 305 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
| 306 | 306 | if ($globalAllFlights !== FALSE) $dataFound = true; |
| 307 | 307 | } |
| 308 | 308 | if (isset($line['source_type']) && $line['source_type'] != '') { |
| 309 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type'])); |
|
| 309 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_type' => $line['source_type'])); |
|
| 310 | 310 | } |
| 311 | 311 | |
| 312 | 312 | //print_r($this->all_flights); |
| 313 | 313 | if (isset($line['hex']) && !isset($this->all_flights[$id]['hex']) && ctype_xdigit($line['hex'])) { |
| 314 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex']))); |
|
| 314 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('hex' => trim($line['hex']))); |
|
| 315 | 315 | //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
| 316 | 316 | //$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
| 317 | 317 | //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
@@ -320,20 +320,20 @@ discard block |
||
| 320 | 320 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 321 | 321 | $Spotter = new Spotter($this->db); |
| 322 | 322 | if (isset($this->all_flights[$id]['source_type'])) { |
| 323 | - $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']),$this->all_flights[$id]['source_type']); |
|
| 323 | + $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']), $this->all_flights[$id]['source_type']); |
|
| 324 | 324 | } else { |
| 325 | 325 | $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex'])); |
| 326 | 326 | } |
| 327 | 327 | $Spotter->db = null; |
| 328 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 329 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
| 328 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 329 | + if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao)); |
|
| 330 | 330 | } |
| 331 | 331 | } |
| 332 | 332 | if ($globalAllFlights !== FALSE) $dataFound = true; |
| 333 | 333 | if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
| 334 | 334 | } |
| 335 | 335 | if (isset($line['id']) && !isset($line['hex'])) { |
| 336 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => '')); |
|
| 336 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('hex' => '')); |
|
| 337 | 337 | } |
| 338 | 338 | if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') { |
| 339 | 339 | $icao = $line['aircraft_icao']; |
@@ -342,14 +342,14 @@ discard block |
||
| 342 | 342 | if (isset($Spotter->aircraft_correct_icaotype[$icao])) $icao = $Spotter->aircraft_correct_icaotype[$icao]; |
| 343 | 343 | $Spotter->db = null; |
| 344 | 344 | } |
| 345 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $icao)); |
|
| 345 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $icao)); |
|
| 346 | 346 | } elseif (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_name'])) { |
| 347 | 347 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 348 | 348 | // Get aircraft ICAO from aircraft name |
| 349 | 349 | $Spotter = new Spotter($this->db); |
| 350 | 350 | $aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']); |
| 351 | 351 | $Spotter->db = null; |
| 352 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
| 352 | + if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao)); |
|
| 353 | 353 | } |
| 354 | 354 | } |
| 355 | 355 | if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) { |
@@ -357,15 +357,15 @@ discard block |
||
| 357 | 357 | elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL'; |
| 358 | 358 | elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE'; |
| 359 | 359 | elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC'; |
| 360 | - if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
| 360 | + if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao)); |
|
| 361 | 361 | } |
| 362 | 362 | if (!isset($this->all_flights[$id]['aircraft_icao'])) { |
| 363 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA')); |
|
| 363 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => 'NA')); |
|
| 364 | 364 | } |
| 365 | 365 | //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
| 366 | - if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) { |
|
| 366 | + if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 20*60 && strtotime($line['datetime']) < time() + 20*60) { |
|
| 367 | 367 | if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
| 368 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
|
| 368 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => $line['datetime'])); |
|
| 369 | 369 | } else { |
| 370 | 370 | if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
| 371 | 371 | elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
@@ -376,31 +376,31 @@ discard block |
||
| 376 | 376 | */ |
| 377 | 377 | return ''; |
| 378 | 378 | } |
| 379 | - } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
|
| 379 | + } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time() - 20*60) { |
|
| 380 | 380 | if ($globalDebug) echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n"; |
| 381 | 381 | return ''; |
| 382 | - } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) { |
|
| 382 | + } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time() + 20*60) { |
|
| 383 | 383 | if ($globalDebug) echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n"; |
| 384 | 384 | return ''; |
| 385 | 385 | } elseif (!isset($line['datetime'])) { |
| 386 | 386 | date_default_timezone_set('UTC'); |
| 387 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
| 387 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => date('Y-m-d H:i:s'))); |
|
| 388 | 388 | } else { |
| 389 | 389 | if ($globalDebug) echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!"; |
| 390 | 390 | return ''; |
| 391 | 391 | } |
| 392 | 392 | |
| 393 | 393 | if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG' && $line['registration'] != 'NA') { |
| 394 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration'])); |
|
| 394 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('registration' => $line['registration'])); |
|
| 395 | 395 | } |
| 396 | 396 | if (isset($line['waypoints']) && $line['waypoints'] != '') { |
| 397 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints'])); |
|
| 397 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('waypoints' => $line['waypoints'])); |
|
| 398 | 398 | } |
| 399 | 399 | if (isset($line['pilot_id']) && $line['pilot_id'] != '') { |
| 400 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id']))); |
|
| 400 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_id' => trim($line['pilot_id']))); |
|
| 401 | 401 | } |
| 402 | 402 | if (isset($line['pilot_name']) && $line['pilot_name'] != '') { |
| 403 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name']))); |
|
| 403 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_name' => trim($line['pilot_name']))); |
|
| 404 | 404 | } |
| 405 | 405 | |
| 406 | 406 | if (isset($line['ident']) && trim($line['ident']) != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_flights[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) { |
@@ -408,13 +408,13 @@ discard block |
||
| 408 | 408 | if ($this->all_flights[$id]['addedSpotter'] == 1) { |
| 409 | 409 | if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 1600) { |
| 410 | 410 | if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n"; |
| 411 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
| 412 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
|
| 413 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
| 414 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 415 | - elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 411 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
| 412 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1)); |
|
| 413 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
| 414 | + elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
| 415 | + elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 416 | 416 | } else { |
| 417 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
| 417 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident']))); |
|
| 418 | 418 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 419 | 419 | $timeelapsed = microtime(true); |
| 420 | 420 | $Spotter = new Spotter($this->db); |
@@ -424,13 +424,13 @@ discard block |
||
| 424 | 424 | elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao'; |
| 425 | 425 | elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
| 426 | 426 | elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
| 427 | - $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource,$this->all_flights[$id]['source_type']); |
|
| 427 | + $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $fromsource, $this->all_flights[$id]['source_type']); |
|
| 428 | 428 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
| 429 | 429 | $Spotter->db = null; |
| 430 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 430 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 431 | 431 | } |
| 432 | 432 | } |
| 433 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
| 433 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident']))); |
|
| 434 | 434 | |
| 435 | 435 | /* |
| 436 | 436 | if (!isset($line['id'])) { |
@@ -440,25 +440,25 @@ discard block |
||
| 440 | 440 | else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
| 441 | 441 | } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
| 442 | 442 | */ |
| 443 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 443 | + if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 444 | 444 | |
| 445 | 445 | //$putinarchive = true; |
| 446 | 446 | if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
| 447 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time'])); |
|
| 447 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $line['departure_airport_time'])); |
|
| 448 | 448 | } |
| 449 | 449 | if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) { |
| 450 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time'])); |
|
| 450 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $line['arrival_airport_time'])); |
|
| 451 | 451 | } |
| 452 | 452 | if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) { |
| 453 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
| 453 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $line['departure_airport_icao'], 'arrival_airport' => $line['arrival_airport_icao'], 'route_stop' => '')); |
|
| 454 | 454 | } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) { |
| 455 | 455 | $timeelapsed = microtime(true); |
| 456 | 456 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 457 | 457 | $Spotter = new Spotter($this->db); |
| 458 | 458 | $line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']); |
| 459 | 459 | $line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']); |
| 460 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
| 461 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 460 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $line['departure_airport_icao'], 'arrival_airport' => $line['arrival_airport_icao'], 'route_stop' => '')); |
|
| 461 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 462 | 462 | } |
| 463 | 463 | } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
| 464 | 464 | $timeelapsed = microtime(true); |
@@ -472,35 +472,35 @@ discard block |
||
| 472 | 472 | $Translation->db = null; |
| 473 | 473 | } |
| 474 | 474 | $Spotter->db = null; |
| 475 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 475 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 476 | 476 | } |
| 477 | 477 | if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) { |
| 478 | 478 | //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
| 479 | 479 | if ($route['fromairport_icao'] != $route['toairport_icao']) { |
| 480 | 480 | // $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['FromAirport_ICAO'],'arrival_airport' => $route['ToAirport_ICAO'],'route_stop' => $route['RouteStop'])); |
| 481 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop'])); |
|
| 481 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $route['fromairport_icao'], 'arrival_airport' => $route['toairport_icao'], 'route_stop' => $route['routestop'])); |
|
| 482 | 482 | } |
| 483 | 483 | } |
| 484 | 484 | if (!isset($globalFork)) $globalFork = TRUE; |
| 485 | 485 | if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) { |
| 486 | - if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident'])); |
|
| 486 | + if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id, trim($line['ident'])); |
|
| 487 | 487 | } |
| 488 | 488 | } |
| 489 | 489 | } |
| 490 | 490 | |
| 491 | 491 | if (isset($line['speed']) && $line['speed'] != '' && $line['speed'] != 0) { |
| 492 | 492 | // $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12])); |
| 493 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed']))); |
|
| 494 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true)); |
|
| 493 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($line['speed']))); |
|
| 494 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed_fromsrc' => true)); |
|
| 495 | 495 | //$dataFound = true; |
| 496 | 496 | } else if (!isset($this->all_flights[$id]['speed_fromsrc']) && isset($this->all_flights[$id]['time_last_coord']) && $this->all_flights[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) { |
| 497 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'); |
|
| 497 | + $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm'); |
|
| 498 | 498 | if ($distance > 1000 && $distance < 10000) { |
| 499 | 499 | // use datetime |
| 500 | 500 | $speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']); |
| 501 | 501 | $speed = $speed*3.6; |
| 502 | 502 | if ($speed < 1000) { |
| 503 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed))); |
|
| 503 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($speed))); |
|
| 504 | 504 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
| 505 | 505 | } else { |
| 506 | 506 | if ($globalDebug) echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
@@ -515,9 +515,9 @@ discard block |
||
| 515 | 515 | if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n"; |
| 516 | 516 | return false; |
| 517 | 517 | } |
| 518 | - if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
| 518 | + if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time() - $this->all_flights[$id]['time_last_coord']); |
|
| 519 | 519 | else unset($timediff); |
| 520 | - if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']); |
|
| 520 | + if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time() - $this->all_flights[$id]['time_last_archive_coord']); |
|
| 521 | 521 | else unset($timediff_archive); |
| 522 | 522 | if ($this->tmd > 5 |
| 523 | 523 | || (isset($line['format_source']) |
@@ -542,14 +542,14 @@ discard block |
||
| 542 | 542 | || (isset($timediff) && $timediff > 30 |
| 543 | 543 | && isset($this->all_flights[$id]['latitude']) |
| 544 | 544 | && isset($this->all_flights[$id]['longitude']) |
| 545 | - && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')) |
|
| 545 | + && $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')) |
|
| 546 | 546 | ) |
| 547 | 547 | ) { |
| 548 | 548 | |
| 549 | 549 | if ((isset($timediff) && !isset($timediff_archive)) || (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude']))) { |
| 550 | 550 | if ((isset($timediff_archive) && $timediff_archive > $globalAircraftMaxUpdate) |
| 551 | 551 | || (isset($line['format_source']) && $line['format_source'] == 'airwhere') |
| 552 | - || !$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
|
| 552 | + || !$Common->checkLine($this->all_flights[$id]['archive_latitude'], $this->all_flights[$id]['archive_longitude'], $this->all_flights[$id]['livedb_latitude'], $this->all_flights[$id]['livedb_longitude'], $line['latitude'], $line['longitude'])) { |
|
| 553 | 553 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
| 554 | 554 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
| 555 | 555 | $this->all_flights[$id]['putinarchive'] = true; |
@@ -563,11 +563,11 @@ discard block |
||
| 563 | 563 | $timeelapsed = microtime(true); |
| 564 | 564 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 565 | 565 | $Spotter = new Spotter($this->db); |
| 566 | - $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
| 566 | + $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']); |
|
| 567 | 567 | if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
| 568 | 568 | else $this->all_flights[$id]['over_country'] = ''; |
| 569 | 569 | $Spotter->db = null; |
| 570 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 570 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 571 | 571 | if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
| 572 | 572 | } |
| 573 | 573 | } |
@@ -593,13 +593,13 @@ discard block |
||
| 593 | 593 | $this->all_flights[$id]['time_last_coord'] = time(); |
| 594 | 594 | } |
| 595 | 595 | //if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) { |
| 596 | - if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) { |
|
| 596 | + if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude'] - $line['latitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude'] - $line['latitude']) > 0.0001)) { |
|
| 597 | 597 | $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
| 598 | 598 | $dataFound = true; |
| 599 | 599 | $this->all_flights[$id]['time_last_coord'] = time(); |
| 600 | 600 | } |
| 601 | 601 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
| 602 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude'])); |
|
| 602 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('latitude' => $line['latitude'])); |
|
| 603 | 603 | /* |
| 604 | 604 | if (abs($this->all_flights[$id]['archive_latitude']-$this->all_flights[$id]['latitude']) > 0.3) { |
| 605 | 605 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
@@ -621,14 +621,14 @@ discard block |
||
| 621 | 621 | $this->all_flights[$id]['time_last_coord'] = time(); |
| 622 | 622 | } |
| 623 | 623 | //if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) { |
| 624 | - if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) { |
|
| 624 | + if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude'] - $line['longitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude'] - $line['longitude']) > 0.0001)) { |
|
| 625 | 625 | $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
| 626 | 626 | $dataFound = true; |
| 627 | 627 | $this->all_flights[$id]['coordinates'] += 1; |
| 628 | 628 | $this->all_flights[$id]['time_last_coord'] = time(); |
| 629 | 629 | } |
| 630 | 630 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
| 631 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude'])); |
|
| 631 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('longitude' => $line['longitude'])); |
|
| 632 | 632 | /* |
| 633 | 633 | if (abs($this->all_flights[$id]['archive_longitude']-$this->all_flights[$id]['longitude']) > 0.3) { |
| 634 | 634 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
@@ -649,52 +649,52 @@ discard block |
||
| 649 | 649 | $SpotterArchive->deleteSpotterArchiveTrackDataByID($this->all_flights[$id]['id']); |
| 650 | 650 | $SpotterArchive->db = null; |
| 651 | 651 | $Spotter = new Spotter(); |
| 652 | - $Spotter->updateInitialSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime']); |
|
| 652 | + $Spotter->updateInitialSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime']); |
|
| 653 | 653 | $Spotter->db = null; |
| 654 | 654 | } |
| 655 | 655 | } else if ($globalDebug && $timediff > 30) { |
| 656 | 656 | $this->tmd = $this->tmd + 1; |
| 657 | 657 | echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n"; |
| 658 | - echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -"; |
|
| 659 | - echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
|
| 658 | + echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')."m -"; |
|
| 659 | + echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - "; |
|
| 660 | 660 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n"; |
| 661 | 661 | } |
| 662 | 662 | } |
| 663 | 663 | if (isset($line['last_update']) && $line['last_update'] != '') { |
| 664 | 664 | if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
| 665 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
|
| 665 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('last_update' => $line['last_update'])); |
|
| 666 | 666 | } |
| 667 | 667 | if (isset($line['verticalrate']) && $line['verticalrate'] != '') { |
| 668 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate'])); |
|
| 668 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('verticalrate' => $line['verticalrate'])); |
|
| 669 | 669 | //$dataFound = true; |
| 670 | 670 | } |
| 671 | 671 | if (isset($line['format_source']) && $line['format_source'] != '') { |
| 672 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source'])); |
|
| 672 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('format_source' => $line['format_source'])); |
|
| 673 | 673 | } |
| 674 | 674 | if (isset($line['source_name']) && $line['source_name'] != '') { |
| 675 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name'])); |
|
| 675 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_name' => $line['source_name'])); |
|
| 676 | 676 | } |
| 677 | 677 | if (isset($line['emergency']) && $line['emergency'] != '') { |
| 678 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency'])); |
|
| 678 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('emergency' => $line['emergency'])); |
|
| 679 | 679 | //$dataFound = true; |
| 680 | 680 | } |
| 681 | 681 | if (isset($line['ground']) && $line['ground'] != '') { |
| 682 | 682 | if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) { |
| 683 | 683 | // Here we force archive of flight because after ground it's a new one (or should be) |
| 684 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
| 685 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
|
| 686 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
| 687 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 688 | - elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 684 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
| 685 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1)); |
|
| 686 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
| 687 | + elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
| 688 | + elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 689 | 689 | } |
| 690 | 690 | if ($line['ground'] != 1) $line['ground'] = 0; |
| 691 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
|
| 691 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ground' => $line['ground'])); |
|
| 692 | 692 | //$dataFound = true; |
| 693 | 693 | } |
| 694 | 694 | if (isset($line['squawk']) && $line['squawk'] != '') { |
| 695 | 695 | if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) { |
| 696 | 696 | if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
| 697 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
| 697 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk'])); |
|
| 698 | 698 | $highlight = ''; |
| 699 | 699 | if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
| 700 | 700 | if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
@@ -703,66 +703,66 @@ discard block |
||
| 703 | 703 | $timeelapsed = microtime(true); |
| 704 | 704 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 705 | 705 | $Spotter = new Spotter($this->db); |
| 706 | - $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
|
| 706 | + $Spotter->setHighlightFlight($this->all_flights[$id]['id'], $highlight); |
|
| 707 | 707 | $Spotter->db = null; |
| 708 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 708 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 709 | 709 | } |
| 710 | 710 | //$putinarchive = true; |
| 711 | 711 | //$highlight = ''; |
| 712 | 712 | } |
| 713 | 713 | |
| 714 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
| 714 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk'])); |
|
| 715 | 715 | //$dataFound = true; |
| 716 | 716 | } |
| 717 | 717 | |
| 718 | 718 | if (isset($line['altitude']) && $line['altitude'] != '') { |
| 719 | 719 | if (isset($line['altitude_relative']) && isset($GeoidClass) && is_object($GeoidClass)) { |
| 720 | 720 | if ($line['altitude_relative'] == 'AMSL' || $line['altitude_relative'] == 'MSL') { |
| 721 | - $geoid = round($GeoidClass->get($this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'])*3.28084,2); |
|
| 721 | + $geoid = round($GeoidClass->get($this->all_flights[$id]['livedb_latitude'], $this->all_flights[$id]['livedb_longitude'])*3.28084, 2); |
|
| 722 | 722 | //if ($globalDebug) echo '=> Set altitude to WGS84 Ellipsoid, add '.$geoid.' to '.$line['altitude']."\n"; |
| 723 | 723 | $line['altitude'] = $line['altitude'] - $geoid; |
| 724 | 724 | } |
| 725 | 725 | } |
| 726 | 726 | //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
| 727 | - if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true; |
|
| 728 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100))); |
|
| 729 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude'])); |
|
| 727 | + if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100) - $this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true; |
|
| 728 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude' => round($line['altitude']/100))); |
|
| 729 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_real' => $line['altitude'])); |
|
| 730 | 730 | //$dataFound = true; |
| 731 | 731 | //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
| 732 | 732 | if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) { |
| 733 | 733 | if (isset($this->all_flights[$id]['over_country']) && $this->all_flights[$id]['over_country'] != '' && isset($this->all_flights[$id]['altitude_previous']) && $this->all_flights[$id]['altitude_previous'] != '' && $this->all_flights[$id]['altitude_previous'] < $this->all_flights[$id]['altitude_real'] && isset($this->all_flights[$id]['lastupdate']) && $this->all_flights[$id]['lastupdate'] < time() - 1600) { |
| 734 | 734 | if ($globalDebug) echo '--- Reset because of altitude'."\n"; |
| 735 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
| 736 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
|
| 737 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
| 738 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 739 | - elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 735 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
| 736 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1)); |
|
| 737 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
| 738 | + elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
| 739 | + elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 740 | 740 | } |
| 741 | 741 | } |
| 742 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude'])); |
|
| 742 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_previous' => $line['altitude'])); |
|
| 743 | 743 | } |
| 744 | 744 | |
| 745 | 745 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
| 746 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true)); |
|
| 746 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('noarchive' => true)); |
|
| 747 | 747 | } |
| 748 | 748 | |
| 749 | 749 | if (isset($line['heading']) && $line['heading'] != '') { |
| 750 | - if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
| 751 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
|
| 752 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
|
| 750 | + if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading'] - round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
| 751 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($line['heading']))); |
|
| 752 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading_fromsrc' => true)); |
|
| 753 | 753 | //$dataFound = true; |
| 754 | 754 | } elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) { |
| 755 | - $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
| 756 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
|
| 757 | - if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
| 755 | + $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'], $this->all_flights[$id]['archive_longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']); |
|
| 756 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($heading))); |
|
| 757 | + if (abs($this->all_flights[$id]['heading'] - round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
| 758 | 758 | if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
| 759 | 759 | } elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') { |
| 760 | 760 | // If not enough messages and ACARS set heading to 0 |
| 761 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
|
| 761 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => 0)); |
|
| 762 | 762 | } |
| 763 | - if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
|
| 764 | - elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
|
| 765 | - elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalAircraftMinUpdate) $dataFound = false; |
|
| 763 | + if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
|
| 764 | + elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
|
| 765 | + elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalAircraftMinUpdate) $dataFound = false; |
|
| 766 | 766 | |
| 767 | 767 | // print_r($this->all_flights[$id]); |
| 768 | 768 | //gets the callsign from the last hour |
@@ -773,7 +773,7 @@ discard block |
||
| 773 | 773 | if ($dataFound === true && isset($this->all_flights[$id]['id'])) { |
| 774 | 774 | $this->all_flights[$id]['lastupdate'] = time(); |
| 775 | 775 | if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) { |
| 776 | - if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
| 776 | + if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
| 777 | 777 | //print_r($this->all_flights); |
| 778 | 778 | //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n"; |
| 779 | 779 | //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
@@ -784,61 +784,61 @@ discard block |
||
| 784 | 784 | $SpotterLive = new SpotterLive($this->db); |
| 785 | 785 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
| 786 | 786 | $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']); |
| 787 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 787 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 788 | 788 | } elseif (isset($line['id'])) { |
| 789 | 789 | $recent_ident = $SpotterLive->checkIdRecent($line['id']); |
| 790 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 790 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 791 | 791 | } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
| 792 | 792 | $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']); |
| 793 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 793 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 794 | 794 | } else $recent_ident = ''; |
| 795 | - $SpotterLive->db=null; |
|
| 795 | + $SpotterLive->db = null; |
|
| 796 | 796 | if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
| 797 | 797 | elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
| 798 | 798 | } else $recent_ident = ''; |
| 799 | 799 | } else { |
| 800 | 800 | $recent_ident = ''; |
| 801 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0)); |
|
| 801 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 0)); |
|
| 802 | 802 | } |
| 803 | 803 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
| 804 | - if($recent_ident == "") |
|
| 804 | + if ($recent_ident == "") |
|
| 805 | 805 | { |
| 806 | 806 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
| 807 | 807 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
| 808 | 808 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
| 809 | 809 | //adds the spotter data for the archive |
| 810 | 810 | $ignoreImport = false; |
| 811 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
| 811 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
| 812 | 812 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
| 813 | 813 | $ignoreImport = true; |
| 814 | 814 | } |
| 815 | 815 | } |
| 816 | 816 | if (count($globalAirportAccept) > 0) { |
| 817 | 817 | $ignoreImport = true; |
| 818 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
| 818 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
| 819 | 819 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
| 820 | 820 | $ignoreImport = false; |
| 821 | 821 | } |
| 822 | 822 | } |
| 823 | 823 | } |
| 824 | 824 | if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
| 825 | - foreach($globalAirlineIgnore as $airlineIgnore) { |
|
| 826 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
|
| 825 | + foreach ($globalAirlineIgnore as $airlineIgnore) { |
|
| 826 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineIgnore)) { |
|
| 827 | 827 | $ignoreImport = true; |
| 828 | 828 | } |
| 829 | 829 | } |
| 830 | 830 | } |
| 831 | 831 | if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
| 832 | 832 | $ignoreImport = true; |
| 833 | - foreach($globalAirlineAccept as $airlineAccept) { |
|
| 834 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
|
| 833 | + foreach ($globalAirlineAccept as $airlineAccept) { |
|
| 834 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineAccept)) { |
|
| 835 | 835 | $ignoreImport = false; |
| 836 | 836 | } |
| 837 | 837 | } |
| 838 | 838 | } |
| 839 | 839 | if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
| 840 | 840 | $ignoreImport = true; |
| 841 | - foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
| 841 | + foreach ($globalPilotIdAccept as $pilotIdAccept) { |
|
| 842 | 842 | if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
| 843 | 843 | $ignoreImport = false; |
| 844 | 844 | } |
@@ -850,12 +850,12 @@ discard block |
||
| 850 | 850 | if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
| 851 | 851 | if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
| 852 | 852 | if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
| 853 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
| 853 | + if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
| 854 | 854 | $timeelapsed = microtime(true); |
| 855 | 855 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
| 856 | 856 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 857 | 857 | $Spotter = new Spotter($this->db); |
| 858 | - $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']); |
|
| 858 | + $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $highlight, $this->all_flights[$id]['hex'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['source_type']); |
|
| 859 | 859 | $Spotter->db = null; |
| 860 | 860 | if ($globalDebug) { |
| 861 | 861 | if (isset($result['error'])) echo 'Error: '.$result['error']."\n"; |
@@ -868,22 +868,22 @@ discard block |
||
| 868 | 868 | } |
| 869 | 869 | } |
| 870 | 870 | } |
| 871 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 871 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 872 | 872 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 873 | 873 | |
| 874 | 874 | // Add source stat in DB |
| 875 | 875 | $Stats = new Stats($this->db); |
| 876 | 876 | if (!empty($this->stats)) { |
| 877 | 877 | if ($globalDebug) echo 'Add source stats : '; |
| 878 | - foreach($this->stats as $date => $data) { |
|
| 879 | - foreach($data as $source => $sourced) { |
|
| 878 | + foreach ($this->stats as $date => $data) { |
|
| 879 | + foreach ($data as $source => $sourced) { |
|
| 880 | 880 | //print_r($sourced); |
| 881 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
| 882 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
| 881 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar', $date); |
|
| 882 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist', $date); |
|
| 883 | 883 | if (isset($sourced['msg'])) { |
| 884 | 884 | if (time() - $sourced['msg']['date'] > 10) { |
| 885 | 885 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
| 886 | - echo $Stats->addStatSource($nbmsg,$source,'msg',$date); |
|
| 886 | + echo $Stats->addStatSource($nbmsg, $source, 'msg', $date); |
|
| 887 | 887 | unset($this->stats[$date][$source]['msg']); |
| 888 | 888 | } |
| 889 | 889 | } |
@@ -921,14 +921,14 @@ discard block |
||
| 921 | 921 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 922 | 922 | $SpotterLive = new SpotterLive($this->db); |
| 923 | 923 | $SpotterLive->deleteLiveSpotterData(); |
| 924 | - $SpotterLive->db=null; |
|
| 924 | + $SpotterLive->db = null; |
|
| 925 | 925 | } |
| 926 | 926 | } |
| 927 | 927 | if ($globalDebug) echo " Done\n"; |
| 928 | 928 | $this->last_delete = time(); |
| 929 | 929 | } |
| 930 | 930 | } else { |
| 931 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt'|| $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'famaprs' || $line['format_source'] === 'airwhere')) { |
|
| 931 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'famaprs' || $line['format_source'] === 'airwhere')) { |
|
| 932 | 932 | $this->all_flights[$id]['id'] = $recent_ident; |
| 933 | 933 | $this->all_flights[$id]['addedSpotter'] = 1; |
| 934 | 934 | } |
@@ -936,7 +936,7 @@ discard block |
||
| 936 | 936 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
| 937 | 937 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 938 | 938 | $Spotter = new Spotter($this->db); |
| 939 | - $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time']); |
|
| 939 | + $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['arrival_airport_time']); |
|
| 940 | 940 | $Spotter->db = null; |
| 941 | 941 | } |
| 942 | 942 | } |
@@ -962,37 +962,37 @@ discard block |
||
| 962 | 962 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
| 963 | 963 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
| 964 | 964 | |
| 965 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
| 965 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
| 966 | 966 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
| 967 | 967 | $ignoreImport = true; |
| 968 | 968 | } |
| 969 | 969 | } |
| 970 | 970 | if (count($globalAirportAccept) > 0) { |
| 971 | 971 | $ignoreImport = true; |
| 972 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
| 972 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
| 973 | 973 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
| 974 | 974 | $ignoreImport = false; |
| 975 | 975 | } |
| 976 | 976 | } |
| 977 | 977 | } |
| 978 | 978 | if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
| 979 | - foreach($globalAirlineIgnore as $airlineIgnore) { |
|
| 980 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
|
| 979 | + foreach ($globalAirlineIgnore as $airlineIgnore) { |
|
| 980 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineIgnore)) { |
|
| 981 | 981 | $ignoreImport = true; |
| 982 | 982 | } |
| 983 | 983 | } |
| 984 | 984 | } |
| 985 | 985 | if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
| 986 | 986 | $ignoreImport = true; |
| 987 | - foreach($globalAirlineAccept as $airlineAccept) { |
|
| 988 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
|
| 987 | + foreach ($globalAirlineAccept as $airlineAccept) { |
|
| 988 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineAccept)) { |
|
| 989 | 989 | $ignoreImport = false; |
| 990 | 990 | } |
| 991 | 991 | } |
| 992 | 992 | } |
| 993 | 993 | if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
| 994 | 994 | $ignoreImport = true; |
| 995 | - foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
| 995 | + foreach ($globalPilotIdAccept as $pilotIdAccept) { |
|
| 996 | 996 | if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
| 997 | 997 | $ignoreImport = false; |
| 998 | 998 | } |
@@ -1000,24 +1000,24 @@ discard block |
||
| 1000 | 1000 | } |
| 1001 | 1001 | |
| 1002 | 1002 | if (!$ignoreImport) { |
| 1003 | - if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
| 1004 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
| 1003 | + if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
| 1004 | + if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
| 1005 | 1005 | $timeelapsed = microtime(true); |
| 1006 | 1006 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
| 1007 | 1007 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 1008 | 1008 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
| 1009 | 1009 | $SpotterLive = new SpotterLive($this->db); |
| 1010 | 1010 | //var_dump($this->all_flights[$id]); |
| 1011 | - $result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
|
| 1011 | + $result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $this->all_flights[$id]['hex'], $this->all_flights[$id]['putinarchive'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['over_country']); |
|
| 1012 | 1012 | $SpotterLive->db = null; |
| 1013 | 1013 | if ($globalDebug) echo $result."\n"; |
| 1014 | 1014 | } |
| 1015 | 1015 | } |
| 1016 | 1016 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) { |
| 1017 | - $APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
|
| 1017 | + $APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $this->all_flights[$id]['hex'], $this->all_flights[$id]['putinarchive'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['over_country']); |
|
| 1018 | 1018 | } |
| 1019 | 1019 | $this->all_flights[$id]['putinarchive'] = false; |
| 1020 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 1020 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 1021 | 1021 | |
| 1022 | 1022 | // Put statistics in $this->stats variable |
| 1023 | 1023 | //if ($line['format_source'] != 'aprs') { |
@@ -1036,19 +1036,19 @@ discard block |
||
| 1036 | 1036 | $latitude = $globalCenterLatitude; |
| 1037 | 1037 | $longitude = $globalCenterLongitude; |
| 1038 | 1038 | } |
| 1039 | - $this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude); |
|
| 1039 | + $this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude); |
|
| 1040 | 1040 | } else { |
| 1041 | 1041 | $latitude = $this->source_location[$source]['latitude']; |
| 1042 | 1042 | $longitude = $this->source_location[$source]['longitude']; |
| 1043 | 1043 | } |
| 1044 | - $stats_heading = $Common->getHeading($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
| 1044 | + $stats_heading = $Common->getHeading($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']); |
|
| 1045 | 1045 | //$stats_heading = $stats_heading%22.5; |
| 1046 | 1046 | $stats_heading = round($stats_heading/22.5); |
| 1047 | - $stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
| 1047 | + $stats_distance = $Common->distance($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']); |
|
| 1048 | 1048 | $current_date = date('Y-m-d'); |
| 1049 | 1049 | if ($stats_heading == 16) $stats_heading = 0; |
| 1050 | 1050 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
| 1051 | - for ($i=0;$i<=15;$i++) { |
|
| 1051 | + for ($i = 0; $i <= 15; $i++) { |
|
| 1052 | 1052 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
| 1053 | 1053 | } |
| 1054 | 1054 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
@@ -1063,9 +1063,9 @@ discard block |
||
| 1063 | 1063 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
| 1064 | 1064 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
| 1065 | 1065 | end($this->stats[$current_date][$source]['hist']); |
| 1066 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
| 1066 | + $mini = key($this->stats[$current_date][$source]['hist']) + 10; |
|
| 1067 | 1067 | } else $mini = 0; |
| 1068 | - for ($i=$mini;$i<=$distance;$i+=10) { |
|
| 1068 | + for ($i = $mini; $i <= $distance; $i += 10) { |
|
| 1069 | 1069 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
| 1070 | 1070 | } |
| 1071 | 1071 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
@@ -1078,7 +1078,7 @@ discard block |
||
| 1078 | 1078 | $this->all_flights[$id]['lastupdate'] = time(); |
| 1079 | 1079 | if ($this->all_flights[$id]['putinarchive']) $send = true; |
| 1080 | 1080 | //if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
| 1081 | - } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
| 1081 | + } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude'])."\n"; |
|
| 1082 | 1082 | //$this->del(); |
| 1083 | 1083 | |
| 1084 | 1084 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
@@ -59,7 +59,9 @@ discard block |
||
| 59 | 59 | try { |
| 60 | 60 | $GeoidClass = new GeoidHeight(); |
| 61 | 61 | } catch(Exception $e) { |
| 62 | - if ($globalDebug) echo "Can't calculate geoid, check that you downloaded it via update_db.php (".$e.")\n"; |
|
| 62 | + if ($globalDebug) { |
|
| 63 | + echo "Can't calculate geoid, check that you downloaded it via update_db.php (".$e.")\n"; |
|
| 64 | + } |
|
| 63 | 65 | $GeoidClass = FALSE; |
| 64 | 66 | } |
| 65 | 67 | } |
@@ -78,7 +80,9 @@ discard block |
||
| 78 | 80 | $dbc = $this->db; |
| 79 | 81 | $this->all_flights[$id]['schedule_check'] = true; |
| 80 | 82 | if ($globalSchedulesFetch) { |
| 81 | - if ($globalDebug) echo 'Getting schedule info...'."\n"; |
|
| 83 | + if ($globalDebug) { |
|
| 84 | + echo 'Getting schedule info...'."\n"; |
|
| 85 | + } |
|
| 82 | 86 | $Spotter = new Spotter($dbc); |
| 83 | 87 | $Schedule = new Schedule($dbc); |
| 84 | 88 | $Translation = new Translation($dbc); |
@@ -89,7 +93,9 @@ discard block |
||
| 89 | 93 | if ($Schedule->checkSchedule($operator) == 0) { |
| 90 | 94 | $schedule = $Schedule->fetchSchedule($operator); |
| 91 | 95 | if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) { |
| 92 | - if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
| 96 | + if ($globalDebug) { |
|
| 97 | + echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
| 98 | + } |
|
| 93 | 99 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
| 94 | 100 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
| 95 | 101 | // Should also check if route schedule = route from DB |
@@ -98,7 +104,9 @@ discard block |
||
| 98 | 104 | $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']); |
| 99 | 105 | if (trim($airport_icao) != '') { |
| 100 | 106 | $this->all_flights[$id]['departure_airport'] = $airport_icao; |
| 101 | - if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n"; |
|
| 107 | + if ($globalDebug) { |
|
| 108 | + echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n"; |
|
| 109 | + } |
|
| 102 | 110 | } |
| 103 | 111 | } |
| 104 | 112 | } |
@@ -107,20 +115,30 @@ discard block |
||
| 107 | 115 | $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']); |
| 108 | 116 | if (trim($airport_icao) != '') { |
| 109 | 117 | $this->all_flights[$id]['arrival_airport'] = $airport_icao; |
| 110 | - if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n"; |
|
| 118 | + if ($globalDebug) { |
|
| 119 | + echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n"; |
|
| 120 | + } |
|
| 111 | 121 | } |
| 112 | 122 | } |
| 113 | 123 | } |
| 114 | 124 | $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']); |
| 115 | 125 | } |
| 116 | - } else $scheduleexist = true; |
|
| 117 | - } else $scheduleexist = true; |
|
| 126 | + } else { |
|
| 127 | + $scheduleexist = true; |
|
| 128 | + } |
|
| 129 | + } else { |
|
| 130 | + $scheduleexist = true; |
|
| 131 | + } |
|
| 118 | 132 | // close connection, at least one way will work ? |
| 119 | 133 | if ($scheduleexist) { |
| 120 | - if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n"; |
|
| 134 | + if ($globalDebug) { |
|
| 135 | + echo "-> get arrival/departure airport info for ".$ident."\n"; |
|
| 136 | + } |
|
| 121 | 137 | $sch = $Schedule->getSchedule($operator); |
| 122 | 138 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time'])); |
| 123 | - if ($this->all_flights[$id]['addedSpotter'] == 1) $Spotter->updateLatestScheduleSpotterData($this->all_flights[$id]['id'],$sch['departure_airport_icao'],$sch['departure_airport_time'],$sch['arrival_airport_icao'],$sch['arrival_airport_time']); |
|
| 139 | + if ($this->all_flights[$id]['addedSpotter'] == 1) { |
|
| 140 | + $Spotter->updateLatestScheduleSpotterData($this->all_flights[$id]['id'],$sch['departure_airport_icao'],$sch['departure_airport_time'],$sch['arrival_airport_icao'],$sch['arrival_airport_time']); |
|
| 141 | + } |
|
| 124 | 142 | } |
| 125 | 143 | $Spotter->db = null; |
| 126 | 144 | $Schedule->db = null; |
@@ -140,14 +158,18 @@ discard block |
||
| 140 | 158 | |
| 141 | 159 | public function checkAll() { |
| 142 | 160 | global $globalDebug, $globalNoImport; |
| 143 | - if ($globalDebug) echo "Update last seen flights data...\n"; |
|
| 161 | + if ($globalDebug) { |
|
| 162 | + echo "Update last seen flights data...\n"; |
|
| 163 | + } |
|
| 144 | 164 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
| 145 | 165 | foreach ($this->all_flights as $key => $flight) { |
| 146 | 166 | if (isset($this->all_flights[$key]['id'])) { |
| 147 | 167 | //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
| 148 | 168 | $Spotter = new Spotter($this->db); |
| 149 | 169 | $real_arrival = $this->arrival($key); |
| 150 | - if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
| 170 | + if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) { |
|
| 171 | + $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
| 172 | + } |
|
| 151 | 173 | } |
| 152 | 174 | } |
| 153 | 175 | } |
@@ -155,24 +177,32 @@ discard block |
||
| 155 | 177 | |
| 156 | 178 | public function arrival($key) { |
| 157 | 179 | global $globalClosestMinDist, $globalDebug; |
| 158 | - if ($globalDebug) echo 'Update arrival...'."\n"; |
|
| 180 | + if ($globalDebug) { |
|
| 181 | + echo 'Update arrival...'."\n"; |
|
| 182 | + } |
|
| 159 | 183 | $Spotter = new Spotter($this->db); |
| 160 | 184 | $airport_icao = ''; |
| 161 | 185 | $airport_time = ''; |
| 162 | - if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
|
| 186 | + if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') { |
|
| 187 | + $globalClosestMinDist = 50; |
|
| 188 | + } |
|
| 163 | 189 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
| 164 | 190 | $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
| 165 | 191 | if (isset($closestAirports[0])) { |
| 166 | 192 | if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
| 167 | 193 | $airport_icao = $closestAirports[0]['icao']; |
| 168 | 194 | $airport_time = $this->all_flights[$key]['datetime']; |
| 169 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
| 195 | + if ($globalDebug) { |
|
| 196 | + echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
| 197 | + } |
|
| 170 | 198 | } elseif (count($closestAirports) > 1 && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') { |
| 171 | 199 | foreach ($closestAirports as $airport) { |
| 172 | 200 | if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) { |
| 173 | 201 | $airport_icao = $airport['icao']; |
| 174 | 202 | $airport_time = $this->all_flights[$key]['datetime']; |
| 175 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
| 203 | + if ($globalDebug) { |
|
| 204 | + echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
| 205 | + } |
|
| 176 | 206 | break; |
| 177 | 207 | } |
| 178 | 208 | } |
@@ -180,14 +210,20 @@ discard block |
||
| 180 | 210 | $airport_icao = $closestAirports[0]['icao']; |
| 181 | 211 | $airport_time = $this->all_flights[$key]['datetime']; |
| 182 | 212 | } else { |
| 183 | - if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
| 213 | + if ($globalDebug) { |
|
| 214 | + echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
| 215 | + } |
|
| 184 | 216 | } |
| 185 | 217 | } else { |
| 186 | - if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
| 218 | + if ($globalDebug) { |
|
| 219 | + echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
| 220 | + } |
|
| 187 | 221 | } |
| 188 | 222 | |
| 189 | 223 | } else { |
| 190 | - if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
| 224 | + if ($globalDebug) { |
|
| 225 | + echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
| 226 | + } |
|
| 191 | 227 | } |
| 192 | 228 | return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
| 193 | 229 | } |
@@ -197,7 +233,9 @@ discard block |
||
| 197 | 233 | public function del() { |
| 198 | 234 | global $globalDebug, $globalNoImport, $globalNoDB; |
| 199 | 235 | // Delete old infos |
| 200 | - if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
|
| 236 | + if ($globalDebug) { |
|
| 237 | + echo 'Delete old values and update latest data...'."\n"; |
|
| 238 | + } |
|
| 201 | 239 | |
| 202 | 240 | foreach ($this->all_flights as $key => $flight) { |
| 203 | 241 | if (isset($flight['lastupdate'])) { |
@@ -212,22 +250,30 @@ discard block |
||
| 212 | 250 | global $globalDebug, $globalNoImport, $globalNoDB; |
| 213 | 251 | // Delete old infos |
| 214 | 252 | if (isset($this->all_flights[$key]['id'])) { |
| 215 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n"; |
|
| 253 | + if ($globalDebug) { |
|
| 254 | + echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n"; |
|
| 255 | + } |
|
| 216 | 256 | if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
| 217 | 257 | $real_arrival = $this->arrival($key); |
| 218 | 258 | $Spotter = new Spotter($this->db); |
| 219 | 259 | $SpotterLive = new SpotterLive($this->db); |
| 220 | 260 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
| 221 | 261 | $result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
| 222 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
| 262 | + if ($globalDebug && $result != 'success') { |
|
| 263 | + echo '!!! ERROR : '.$result."\n"; |
|
| 264 | + } |
|
| 223 | 265 | $this->all_flights[$key]['putinarchive'] = true; |
| 224 | 266 | $result = $SpotterLive->addLiveSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['aircraft_icao'], $this->all_flights[$key]['departure_airport'], $this->all_flights[$key]['arrival_airport'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['waypoints'], $this->all_flights[$key]['altitude'],$this->all_flights[$key]['altitude_real'], $this->all_flights[$key]['heading'], $this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'], $this->all_flights[$key]['departure_airport_time'], $this->all_flights[$key]['arrival_airport_time'], $this->all_flights[$key]['squawk'],$this->all_flights[$key]['route_stop'],$this->all_flights[$key]['hex'],$this->all_flights[$key]['putinarchive'],$this->all_flights[$key]['registration'],$this->all_flights[$key]['pilot_id'],$this->all_flights[$key]['pilot_name'], $this->all_flights[$key]['verticalrate'], $this->all_flights[$key]['noarchive'], $this->all_flights[$key]['ground'],$this->all_flights[$key]['format_source'],$this->all_flights[$key]['source_name'],$this->all_flights[$key]['over_country']); |
| 225 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
| 267 | + if ($globalDebug && $result != 'success') { |
|
| 268 | + echo '!!! ERROR : '.$result."\n"; |
|
| 269 | + } |
|
| 226 | 270 | } |
| 227 | 271 | $Spotter->db = null; |
| 228 | 272 | $SpotterLive->db = null; |
| 229 | 273 | } |
| 230 | - if ($globalDebug) echo "\n"; |
|
| 274 | + if ($globalDebug) { |
|
| 275 | + echo "\n"; |
|
| 276 | + } |
|
| 231 | 277 | } |
| 232 | 278 | unset($this->all_flights[$key]); |
| 233 | 279 | } |
@@ -235,9 +281,13 @@ discard block |
||
| 235 | 281 | public function add($line) { |
| 236 | 282 | global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBS1update, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAirlinesSource, $globalVAM, $globalAllFlights, $globalServerAPRS, $APRSSpotter, $globalNoImport, $globalNoDB, $globalVA, $globalAircraftMaxUpdate, $globalAircraftMinUpdate, $globalLiveInterval, $GeoidClass, $globalArchive; |
| 237 | 283 | //if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE; |
| 238 | - if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.01'; |
|
| 239 | - if (!isset($globalAircraftMaxUpdate) || $globalAircraftMaxUpdate == '') $globalAircraftMaxUpdate = 3000; |
|
| 240 | -/* |
|
| 284 | + if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') { |
|
| 285 | + $globalCoordMinChange = '0.01'; |
|
| 286 | + } |
|
| 287 | + if (!isset($globalAircraftMaxUpdate) || $globalAircraftMaxUpdate == '') { |
|
| 288 | + $globalAircraftMaxUpdate = 3000; |
|
| 289 | + } |
|
| 290 | + /* |
|
| 241 | 291 | $Spotter = new Spotter(); |
| 242 | 292 | $dbc = $Spotter->db; |
| 243 | 293 | $SpotterLive = new SpotterLive($dbc); |
@@ -259,19 +309,28 @@ discard block |
||
| 259 | 309 | // SBS format is CSV format |
| 260 | 310 | if(is_array($line) && (isset($line['hex']) || isset($line['id']))) { |
| 261 | 311 | //print_r($line); |
| 262 | - if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']); |
|
| 312 | + if (isset($line['hex'])) { |
|
| 313 | + $line['hex'] = strtoupper($line['hex']); |
|
| 314 | + } |
|
| 263 | 315 | if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && substr($line['hex'],0,1) != '~' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) { |
| 264 | 316 | |
| 265 | 317 | // Increment message number |
| 266 | 318 | if (isset($line['sourcestats']) && $line['sourcestats'] === TRUE) { |
| 267 | 319 | $current_date = date('Y-m-d'); |
| 268 | - if (isset($line['source_name'])) $source = $line['source_name']; |
|
| 269 | - else $source = ''; |
|
| 270 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
| 320 | + if (isset($line['source_name'])) { |
|
| 321 | + $source = $line['source_name']; |
|
| 322 | + } else { |
|
| 323 | + $source = ''; |
|
| 324 | + } |
|
| 325 | + if ($source == '' || $line['format_source'] == 'aprs') { |
|
| 326 | + $source = $line['format_source']; |
|
| 327 | + } |
|
| 271 | 328 | if (!isset($this->stats[$current_date][$source]['msg'])) { |
| 272 | 329 | $this->stats[$current_date][$source]['msg']['date'] = time(); |
| 273 | 330 | $this->stats[$current_date][$source]['msg']['nb'] = 1; |
| 274 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
| 331 | + } else { |
|
| 332 | + $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
| 333 | + } |
|
| 275 | 334 | } |
| 276 | 335 | |
| 277 | 336 | /* |
@@ -287,23 +346,38 @@ discard block |
||
| 287 | 346 | //$this->db = $dbc; |
| 288 | 347 | |
| 289 | 348 | //$hex = trim($line['hex']); |
| 290 | - if (!isset($line['id'])) $id = trim($line['hex']); |
|
| 291 | - else $id = trim($line['id']); |
|
| 349 | + if (!isset($line['id'])) { |
|
| 350 | + $id = trim($line['hex']); |
|
| 351 | + } else { |
|
| 352 | + $id = trim($line['id']); |
|
| 353 | + } |
|
| 292 | 354 | |
| 293 | 355 | if (!isset($this->all_flights[$id])) { |
| 294 | - if ($globalDebug) echo 'New flight...'."\n"; |
|
| 356 | + if ($globalDebug) { |
|
| 357 | + echo 'New flight...'."\n"; |
|
| 358 | + } |
|
| 295 | 359 | $this->all_flights[$id] = array(); |
| 296 | 360 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
| 297 | 361 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => '','coordinates' => 0)); |
| 298 | - if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
| 362 | + if (isset($globalDaemon) && $globalDaemon === FALSE) { |
|
| 363 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
| 364 | + } |
|
| 299 | 365 | if (!isset($line['id'])) { |
| 300 | - if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
| 301 | -// if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi'))); |
|
| 366 | + if (!isset($globalDaemon)) { |
|
| 367 | + $globalDaemon = TRUE; |
|
| 368 | + } |
|
| 369 | + // if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi'))); |
|
| 302 | 370 | // if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
| 303 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
| 371 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
|
| 372 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
| 373 | + } |
|
| 304 | 374 | //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
| 305 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 306 | - if ($globalAllFlights !== FALSE) $dataFound = true; |
|
| 375 | + } else { |
|
| 376 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 377 | + } |
|
| 378 | + if ($globalAllFlights !== FALSE) { |
|
| 379 | + $dataFound = true; |
|
| 380 | + } |
|
| 307 | 381 | } |
| 308 | 382 | if (isset($line['source_type']) && $line['source_type'] != '') { |
| 309 | 383 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type'])); |
@@ -325,12 +399,20 @@ discard block |
||
| 325 | 399 | $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex'])); |
| 326 | 400 | } |
| 327 | 401 | $Spotter->db = null; |
| 328 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 329 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
| 402 | + if ($globalDebugTimeElapsed) { |
|
| 403 | + echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 404 | + } |
|
| 405 | + if ($aircraft_icao != '') { |
|
| 406 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
| 407 | + } |
|
| 330 | 408 | } |
| 331 | 409 | } |
| 332 | - if ($globalAllFlights !== FALSE) $dataFound = true; |
|
| 333 | - if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
|
| 410 | + if ($globalAllFlights !== FALSE) { |
|
| 411 | + $dataFound = true; |
|
| 412 | + } |
|
| 413 | + if ($globalDebug) { |
|
| 414 | + echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
|
| 415 | + } |
|
| 334 | 416 | } |
| 335 | 417 | if (isset($line['id']) && !isset($line['hex'])) { |
| 336 | 418 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => '')); |
@@ -339,7 +421,9 @@ discard block |
||
| 339 | 421 | $icao = $line['aircraft_icao']; |
| 340 | 422 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 341 | 423 | $Spotter = new Spotter($this->db); |
| 342 | - if (isset($Spotter->aircraft_correct_icaotype[$icao])) $icao = $Spotter->aircraft_correct_icaotype[$icao]; |
|
| 424 | + if (isset($Spotter->aircraft_correct_icaotype[$icao])) { |
|
| 425 | + $icao = $Spotter->aircraft_correct_icaotype[$icao]; |
|
| 426 | + } |
|
| 343 | 427 | $Spotter->db = null; |
| 344 | 428 | } |
| 345 | 429 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $icao)); |
@@ -349,15 +433,24 @@ discard block |
||
| 349 | 433 | $Spotter = new Spotter($this->db); |
| 350 | 434 | $aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']); |
| 351 | 435 | $Spotter->db = null; |
| 352 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
| 436 | + if ($aircraft_icao != '') { |
|
| 437 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
| 438 | + } |
|
| 353 | 439 | } |
| 354 | 440 | } |
| 355 | 441 | if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) { |
| 356 | - if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID'; |
|
| 357 | - elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL'; |
|
| 358 | - elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE'; |
|
| 359 | - elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC'; |
|
| 360 | - if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
| 442 | + if ($line['aircraft_type'] == 'PARA_GLIDER') { |
|
| 443 | + $aircraft_icao = 'GLID'; |
|
| 444 | + } elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') { |
|
| 445 | + $aircraft_icao = 'UHEL'; |
|
| 446 | + } elseif ($line['aircraft_type'] == 'TOW_PLANE') { |
|
| 447 | + $aircraft_icao = 'TOWPLANE'; |
|
| 448 | + } elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') { |
|
| 449 | + $aircraft_icao = 'POWAIRC'; |
|
| 450 | + } |
|
| 451 | + if (isset($aircraft_icao)) { |
|
| 452 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
| 453 | + } |
|
| 361 | 454 | } |
| 362 | 455 | if (!isset($this->all_flights[$id]['aircraft_icao'])) { |
| 363 | 456 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA')); |
@@ -367,8 +460,11 @@ discard block |
||
| 367 | 460 | if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
| 368 | 461 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
| 369 | 462 | } else { |
| 370 | - if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
| 371 | - elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
| 463 | + if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) { |
|
| 464 | + echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
| 465 | + } elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) { |
|
| 466 | + echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
| 467 | + } |
|
| 372 | 468 | /* |
| 373 | 469 | echo strtotime($line['datetime']).' > '.strtotime($this->all_flights[$id]['datetime']); |
| 374 | 470 | print_r($this->all_flights[$id]); |
@@ -377,16 +473,22 @@ discard block |
||
| 377 | 473 | return ''; |
| 378 | 474 | } |
| 379 | 475 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
| 380 | - if ($globalDebug) echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n"; |
|
| 476 | + if ($globalDebug) { |
|
| 477 | + echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n"; |
|
| 478 | + } |
|
| 381 | 479 | return ''; |
| 382 | 480 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) { |
| 383 | - if ($globalDebug) echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n"; |
|
| 481 | + if ($globalDebug) { |
|
| 482 | + echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n"; |
|
| 483 | + } |
|
| 384 | 484 | return ''; |
| 385 | 485 | } elseif (!isset($line['datetime'])) { |
| 386 | 486 | date_default_timezone_set('UTC'); |
| 387 | 487 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
| 388 | 488 | } else { |
| 389 | - if ($globalDebug) echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!"; |
|
| 489 | + if ($globalDebug) { |
|
| 490 | + echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!"; |
|
| 491 | + } |
|
| 390 | 492 | return ''; |
| 391 | 493 | } |
| 392 | 494 | |
@@ -407,30 +509,48 @@ discard block |
||
| 407 | 509 | |
| 408 | 510 | if ($this->all_flights[$id]['addedSpotter'] == 1) { |
| 409 | 511 | if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 1600) { |
| 410 | - if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n"; |
|
| 512 | + if ($globalDebug) { |
|
| 513 | + echo '---!!!! New ident, reset aircraft data...'."\n"; |
|
| 514 | + } |
|
| 411 | 515 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
| 412 | 516 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
| 413 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
| 414 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 415 | - elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 517 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
|
| 518 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
| 519 | + } elseif (isset($line['id'])) { |
|
| 520 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 521 | + } elseif (isset($this->all_flights[$id]['ident'])) { |
|
| 522 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 523 | + } |
|
| 416 | 524 | } else { |
| 417 | 525 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
| 418 | 526 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 419 | 527 | $timeelapsed = microtime(true); |
| 420 | 528 | $Spotter = new Spotter($this->db); |
| 421 | 529 | $fromsource = NULL; |
| 422 | - if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
|
| 423 | - elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
|
| 424 | - elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao'; |
|
| 425 | - elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
|
| 426 | - elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
|
| 530 | + if (isset($globalAirlinesSource) && $globalAirlinesSource != '') { |
|
| 531 | + $fromsource = $globalAirlinesSource; |
|
| 532 | + } elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') { |
|
| 533 | + $fromsource = 'vatsim'; |
|
| 534 | + } elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') { |
|
| 535 | + $fromsource = 'ivao'; |
|
| 536 | + } elseif (isset($globalVATSIM) && $globalVATSIM) { |
|
| 537 | + $fromsource = 'vatsim'; |
|
| 538 | + } elseif (isset($globalIVAO) && $globalIVAO) { |
|
| 539 | + $fromsource = 'ivao'; |
|
| 540 | + } |
|
| 427 | 541 | $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource,$this->all_flights[$id]['source_type']); |
| 428 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
| 542 | + if ($globalDebug && $result != 'success') { |
|
| 543 | + echo '!!! ERROR : '.$result."\n"; |
|
| 544 | + } |
|
| 429 | 545 | $Spotter->db = null; |
| 430 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 546 | + if ($globalDebugTimeElapsed) { |
|
| 547 | + echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 548 | + } |
|
| 431 | 549 | } |
| 432 | 550 | } |
| 433 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
| 551 | + } else { |
|
| 552 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
| 553 | + } |
|
| 434 | 554 | |
| 435 | 555 | /* |
| 436 | 556 | if (!isset($line['id'])) { |
@@ -440,7 +560,9 @@ discard block |
||
| 440 | 560 | else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
| 441 | 561 | } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
| 442 | 562 | */ |
| 443 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 563 | + if (!isset($this->all_flights[$id]['id'])) { |
|
| 564 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 565 | + } |
|
| 444 | 566 | |
| 445 | 567 | //$putinarchive = true; |
| 446 | 568 | if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
@@ -458,7 +580,9 @@ discard block |
||
| 458 | 580 | $line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']); |
| 459 | 581 | $line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']); |
| 460 | 582 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
| 461 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 583 | + if ($globalDebugTimeElapsed) { |
|
| 584 | + echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 585 | + } |
|
| 462 | 586 | } |
| 463 | 587 | } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
| 464 | 588 | $timeelapsed = microtime(true); |
@@ -472,7 +596,9 @@ discard block |
||
| 472 | 596 | $Translation->db = null; |
| 473 | 597 | } |
| 474 | 598 | $Spotter->db = null; |
| 475 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 599 | + if ($globalDebugTimeElapsed) { |
|
| 600 | + echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 601 | + } |
|
| 476 | 602 | } |
| 477 | 603 | if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) { |
| 478 | 604 | //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
@@ -481,9 +607,13 @@ discard block |
||
| 481 | 607 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop'])); |
| 482 | 608 | } |
| 483 | 609 | } |
| 484 | - if (!isset($globalFork)) $globalFork = TRUE; |
|
| 610 | + if (!isset($globalFork)) { |
|
| 611 | + $globalFork = TRUE; |
|
| 612 | + } |
|
| 485 | 613 | if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) { |
| 486 | - if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident'])); |
|
| 614 | + if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) { |
|
| 615 | + $this->get_Schedule($id,trim($line['ident'])); |
|
| 616 | + } |
|
| 487 | 617 | } |
| 488 | 618 | } |
| 489 | 619 | } |
@@ -501,9 +631,13 @@ discard block |
||
| 501 | 631 | $speed = $speed*3.6; |
| 502 | 632 | if ($speed < 1000) { |
| 503 | 633 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed))); |
| 504 | - if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
|
| 634 | + if ($globalDebug) { |
|
| 635 | + echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
|
| 636 | + } |
|
| 505 | 637 | } else { |
| 506 | - if ($globalDebug) echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
|
| 638 | + if ($globalDebug) { |
|
| 639 | + echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
|
| 640 | + } |
|
| 507 | 641 | } |
| 508 | 642 | } |
| 509 | 643 | } |
@@ -512,13 +646,21 @@ discard block |
||
| 512 | 646 | |
| 513 | 647 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
| 514 | 648 | if (ctype_digit(strval($line['latitude'])) || ctype_digit(strval($line['longitude']))) { |
| 515 | - if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n"; |
|
| 649 | + if ($globalDebug) { |
|
| 650 | + echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n"; |
|
| 651 | + } |
|
| 516 | 652 | return false; |
| 517 | 653 | } |
| 518 | - if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
| 519 | - else unset($timediff); |
|
| 520 | - if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']); |
|
| 521 | - else unset($timediff_archive); |
|
| 654 | + if (isset($this->all_flights[$id]['time_last_coord'])) { |
|
| 655 | + $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
| 656 | + } else { |
|
| 657 | + unset($timediff); |
|
| 658 | + } |
|
| 659 | + if (isset($this->all_flights[$id]['time_last_archive_coord'])) { |
|
| 660 | + $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']); |
|
| 661 | + } else { |
|
| 662 | + unset($timediff_archive); |
|
| 663 | + } |
|
| 522 | 664 | if ($this->tmd > 5 |
| 523 | 665 | || (isset($line['format_source']) |
| 524 | 666 | && $line['format_source'] == 'airwhere' |
@@ -554,21 +696,32 @@ discard block |
||
| 554 | 696 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
| 555 | 697 | $this->all_flights[$id]['putinarchive'] = true; |
| 556 | 698 | if ($this->tmd > 5 && $this->all_flights[$id]['putinarchive'] == true) { |
| 557 | - if ($globalDebug) echo "\n".' Update Initial data ! '."\n"; |
|
| 699 | + if ($globalDebug) { |
|
| 700 | + echo "\n".' Update Initial data ! '."\n"; |
|
| 701 | + } |
|
| 558 | 702 | $updateinitial = true; |
| 559 | 703 | } |
| 560 | 704 | $this->tmd = 0; |
| 561 | 705 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
| 562 | - if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
| 706 | + if ($globalDebug) { |
|
| 707 | + echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
| 708 | + } |
|
| 563 | 709 | $timeelapsed = microtime(true); |
| 564 | 710 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 565 | 711 | $Spotter = new Spotter($this->db); |
| 566 | 712 | $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
| 567 | - if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
|
| 568 | - else $this->all_flights[$id]['over_country'] = ''; |
|
| 713 | + if (!empty($all_country)) { |
|
| 714 | + $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
|
| 715 | + } else { |
|
| 716 | + $this->all_flights[$id]['over_country'] = ''; |
|
| 717 | + } |
|
| 569 | 718 | $Spotter->db = null; |
| 570 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 571 | - if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
|
| 719 | + if ($globalDebugTimeElapsed) { |
|
| 720 | + echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 721 | + } |
|
| 722 | + if ($globalDebug) { |
|
| 723 | + echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
|
| 724 | + } |
|
| 572 | 725 | } |
| 573 | 726 | } |
| 574 | 727 | $this->all_flights[$id]['time_last_archive_coord'] = time(); |
@@ -614,7 +767,9 @@ discard block |
||
| 614 | 767 | */ |
| 615 | 768 | } |
| 616 | 769 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
| 617 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
| 770 | + if ($line['longitude'] > 180) { |
|
| 771 | + $line['longitude'] = $line['longitude'] - 360; |
|
| 772 | + } |
|
| 618 | 773 | //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == '' || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
| 619 | 774 | if (!isset($this->all_flights[$id]['archive_longitude'])) { |
| 620 | 775 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
@@ -643,7 +798,9 @@ discard block |
||
| 643 | 798 | */ |
| 644 | 799 | } |
| 645 | 800 | if ($globalDaemon === TRUE && isset($updateinitial) && $updateinitial && $this->all_flights[$id]['addedSpotter'] == 1) { |
| 646 | - if ($globalDebug) echo "\n".'>>> Update initial data !'."\n"; |
|
| 801 | + if ($globalDebug) { |
|
| 802 | + echo "\n".'>>> Update initial data !'."\n"; |
|
| 803 | + } |
|
| 647 | 804 | unset($updateinitial); |
| 648 | 805 | $SpotterArchive = new SpotterArchive(); |
| 649 | 806 | $SpotterArchive->deleteSpotterArchiveTrackDataByID($this->all_flights[$id]['id']); |
@@ -661,7 +818,9 @@ discard block |
||
| 661 | 818 | } |
| 662 | 819 | } |
| 663 | 820 | if (isset($line['last_update']) && $line['last_update'] != '') { |
| 664 | - if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
| 821 | + if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) { |
|
| 822 | + $dataFound = true; |
|
| 823 | + } |
|
| 665 | 824 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
| 666 | 825 | } |
| 667 | 826 | if (isset($line['verticalrate']) && $line['verticalrate'] != '') { |
@@ -683,35 +842,53 @@ discard block |
||
| 683 | 842 | // Here we force archive of flight because after ground it's a new one (or should be) |
| 684 | 843 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
| 685 | 844 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
| 686 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
| 687 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 688 | - elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 845 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
|
| 846 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
| 847 | + } elseif (isset($line['id'])) { |
|
| 848 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 849 | + } elseif (isset($this->all_flights[$id]['ident'])) { |
|
| 850 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 851 | + } |
|
| 852 | + } |
|
| 853 | + if ($line['ground'] != 1) { |
|
| 854 | + $line['ground'] = 0; |
|
| 689 | 855 | } |
| 690 | - if ($line['ground'] != 1) $line['ground'] = 0; |
|
| 691 | 856 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
| 692 | 857 | //$dataFound = true; |
| 693 | 858 | } |
| 694 | 859 | if (isset($line['squawk']) && $line['squawk'] != '') { |
| 695 | 860 | if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) { |
| 696 | - if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
|
| 861 | + if ($this->all_flights[$id]['squawk'] != $line['squawk']) { |
|
| 862 | + $this->all_flights[$id]['putinarchive'] = true; |
|
| 863 | + } |
|
| 697 | 864 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
| 698 | 865 | $highlight = ''; |
| 699 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
| 700 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
| 701 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
| 866 | + if ($this->all_flights[$id]['squawk'] == '7500') { |
|
| 867 | + $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
| 868 | + } |
|
| 869 | + if ($this->all_flights[$id]['squawk'] == '7600') { |
|
| 870 | + $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
| 871 | + } |
|
| 872 | + if ($this->all_flights[$id]['squawk'] == '7700') { |
|
| 873 | + $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
| 874 | + } |
|
| 702 | 875 | if ($highlight != '') { |
| 703 | 876 | $timeelapsed = microtime(true); |
| 704 | 877 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 705 | 878 | $Spotter = new Spotter($this->db); |
| 706 | 879 | $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
| 707 | 880 | $Spotter->db = null; |
| 708 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 881 | + if ($globalDebugTimeElapsed) { |
|
| 882 | + echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 883 | + } |
|
| 709 | 884 | } |
| 710 | 885 | //$putinarchive = true; |
| 711 | 886 | //$highlight = ''; |
| 712 | 887 | } |
| 713 | 888 | |
| 714 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
| 889 | + } else { |
|
| 890 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
| 891 | + } |
|
| 715 | 892 | //$dataFound = true; |
| 716 | 893 | } |
| 717 | 894 | |
@@ -724,19 +901,27 @@ discard block |
||
| 724 | 901 | } |
| 725 | 902 | } |
| 726 | 903 | //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
| 727 | - if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true; |
|
| 904 | + if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) { |
|
| 905 | + $this->all_flights[$id]['putinarchive'] = true; |
|
| 906 | + } |
|
| 728 | 907 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100))); |
| 729 | 908 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude'])); |
| 730 | 909 | //$dataFound = true; |
| 731 | 910 | //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
| 732 | 911 | if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) { |
| 733 | 912 | if (isset($this->all_flights[$id]['over_country']) && $this->all_flights[$id]['over_country'] != '' && isset($this->all_flights[$id]['altitude_previous']) && $this->all_flights[$id]['altitude_previous'] != '' && $this->all_flights[$id]['altitude_previous'] < $this->all_flights[$id]['altitude_real'] && isset($this->all_flights[$id]['lastupdate']) && $this->all_flights[$id]['lastupdate'] < time() - 1600) { |
| 734 | - if ($globalDebug) echo '--- Reset because of altitude'."\n"; |
|
| 913 | + if ($globalDebug) { |
|
| 914 | + echo '--- Reset because of altitude'."\n"; |
|
| 915 | + } |
|
| 735 | 916 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
| 736 | 917 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
| 737 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
| 738 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 739 | - elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 918 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
|
| 919 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
| 920 | + } elseif (isset($line['id'])) { |
|
| 921 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 922 | + } elseif (isset($this->all_flights[$id]['ident'])) { |
|
| 923 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 924 | + } |
|
| 740 | 925 | } |
| 741 | 926 | } |
| 742 | 927 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude'])); |
@@ -747,22 +932,32 @@ discard block |
||
| 747 | 932 | } |
| 748 | 933 | |
| 749 | 934 | if (isset($line['heading']) && $line['heading'] != '') { |
| 750 | - if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
| 935 | + if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) { |
|
| 936 | + $this->all_flights[$id]['putinarchive'] = true; |
|
| 937 | + } |
|
| 751 | 938 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
| 752 | 939 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
| 753 | 940 | //$dataFound = true; |
| 754 | 941 | } elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) { |
| 755 | 942 | $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
| 756 | 943 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
| 757 | - if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
| 758 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
|
| 944 | + if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) { |
|
| 945 | + $this->all_flights[$id]['putinarchive'] = true; |
|
| 946 | + } |
|
| 947 | + if ($globalDebug) { |
|
| 948 | + echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
|
| 949 | + } |
|
| 759 | 950 | } elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') { |
| 760 | 951 | // If not enough messages and ACARS set heading to 0 |
| 761 | 952 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
| 762 | 953 | } |
| 763 | - if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
|
| 764 | - elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
|
| 765 | - elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalAircraftMinUpdate) $dataFound = false; |
|
| 954 | + if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) { |
|
| 955 | + $dataFound = false; |
|
| 956 | + } elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) { |
|
| 957 | + $dataFound = false; |
|
| 958 | + } elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalAircraftMinUpdate) { |
|
| 959 | + $dataFound = false; |
|
| 960 | + } |
|
| 766 | 961 | |
| 767 | 962 | // print_r($this->all_flights[$id]); |
| 768 | 963 | //gets the callsign from the last hour |
@@ -779,23 +974,38 @@ discard block |
||
| 779 | 974 | //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
| 780 | 975 | if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) { |
| 781 | 976 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 782 | - if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
| 977 | + if ($globalDebug) { |
|
| 978 | + echo "Check if aircraft is already in DB..."; |
|
| 979 | + } |
|
| 783 | 980 | $timeelapsed = microtime(true); |
| 784 | 981 | $SpotterLive = new SpotterLive($this->db); |
| 785 | 982 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
| 786 | 983 | $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']); |
| 787 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 984 | + if ($globalDebugTimeElapsed) { |
|
| 985 | + echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 986 | + } |
|
| 788 | 987 | } elseif (isset($line['id'])) { |
| 789 | 988 | $recent_ident = $SpotterLive->checkIdRecent($line['id']); |
| 790 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 989 | + if ($globalDebugTimeElapsed) { |
|
| 990 | + echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 991 | + } |
|
| 791 | 992 | } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
| 792 | 993 | $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']); |
| 793 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 794 | - } else $recent_ident = ''; |
|
| 994 | + if ($globalDebugTimeElapsed) { |
|
| 995 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 996 | + } |
|
| 997 | + } else { |
|
| 998 | + $recent_ident = ''; |
|
| 999 | + } |
|
| 795 | 1000 | $SpotterLive->db=null; |
| 796 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
| 797 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
| 798 | - } else $recent_ident = ''; |
|
| 1001 | + if ($globalDebug && $recent_ident == '') { |
|
| 1002 | + echo " Not in DB.\n"; |
|
| 1003 | + } elseif ($globalDebug && $recent_ident != '') { |
|
| 1004 | + echo " Already in DB.\n"; |
|
| 1005 | + } |
|
| 1006 | + } else { |
|
| 1007 | + $recent_ident = ''; |
|
| 1008 | + } |
|
| 799 | 1009 | } else { |
| 800 | 1010 | $recent_ident = ''; |
| 801 | 1011 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0)); |
@@ -803,7 +1013,9 @@ discard block |
||
| 803 | 1013 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
| 804 | 1014 | if($recent_ident == "") |
| 805 | 1015 | { |
| 806 | - if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
|
| 1016 | + if ($globalDebug) { |
|
| 1017 | + echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
|
| 1018 | + } |
|
| 807 | 1019 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
| 808 | 1020 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
| 809 | 1021 | //adds the spotter data for the archive |
@@ -847,10 +1059,18 @@ discard block |
||
| 847 | 1059 | |
| 848 | 1060 | if (!$ignoreImport) { |
| 849 | 1061 | $highlight = ''; |
| 850 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
|
| 851 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
| 852 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
|
| 853 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
| 1062 | + if ($this->all_flights[$id]['squawk'] == '7500') { |
|
| 1063 | + $highlight = 'Squawk 7500 : Hijack'; |
|
| 1064 | + } |
|
| 1065 | + if ($this->all_flights[$id]['squawk'] == '7600') { |
|
| 1066 | + $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
| 1067 | + } |
|
| 1068 | + if ($this->all_flights[$id]['squawk'] == '7700') { |
|
| 1069 | + $highlight = 'Squawk 7700 : Emergency'; |
|
| 1070 | + } |
|
| 1071 | + if (!isset($this->all_flights[$id]['id'])) { |
|
| 1072 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
| 1073 | + } |
|
| 854 | 1074 | $timeelapsed = microtime(true); |
| 855 | 1075 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
| 856 | 1076 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
@@ -858,28 +1078,43 @@ discard block |
||
| 858 | 1078 | $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']); |
| 859 | 1079 | $Spotter->db = null; |
| 860 | 1080 | if ($globalDebug) { |
| 861 | - if (isset($result['error'])) echo 'Error: '.$result['error']."\n"; |
|
| 862 | - else echo 'Success'; |
|
| 1081 | + if (isset($result['error'])) { |
|
| 1082 | + echo 'Error: '.$result['error']."\n"; |
|
| 1083 | + } else { |
|
| 1084 | + echo 'Success'; |
|
| 1085 | + } |
|
| 863 | 1086 | } |
| 864 | 1087 | if (count($result) > 1) { |
| 865 | 1088 | // ':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type, |
| 866 | - if ($this->all_flights[$id]['aircraft_icao'] == '') $this->all_flights[$id]['aircraft_icao'] = $result[':aircraft_icao']; |
|
| 867 | - if ($this->all_flights[$id]['registration'] == '') $this->all_flights[$id]['registration'] = $result[':registration']; |
|
| 1089 | + if ($this->all_flights[$id]['aircraft_icao'] == '') { |
|
| 1090 | + $this->all_flights[$id]['aircraft_icao'] = $result[':aircraft_icao']; |
|
| 1091 | + } |
|
| 1092 | + if ($this->all_flights[$id]['registration'] == '') { |
|
| 1093 | + $this->all_flights[$id]['registration'] = $result[':registration']; |
|
| 1094 | + } |
|
| 868 | 1095 | } |
| 869 | 1096 | } |
| 870 | 1097 | } |
| 871 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 1098 | + if ($globalDebugTimeElapsed) { |
|
| 1099 | + echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 1100 | + } |
|
| 872 | 1101 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 873 | 1102 | |
| 874 | 1103 | // Add source stat in DB |
| 875 | 1104 | $Stats = new Stats($this->db); |
| 876 | 1105 | if (!empty($this->stats)) { |
| 877 | - if ($globalDebug) echo 'Add source stats : '; |
|
| 1106 | + if ($globalDebug) { |
|
| 1107 | + echo 'Add source stats : '; |
|
| 1108 | + } |
|
| 878 | 1109 | foreach($this->stats as $date => $data) { |
| 879 | 1110 | foreach($data as $source => $sourced) { |
| 880 | 1111 | //print_r($sourced); |
| 881 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
| 882 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
| 1112 | + if (isset($sourced['polar'])) { |
|
| 1113 | + echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
| 1114 | + } |
|
| 1115 | + if (isset($sourced['hist'])) { |
|
| 1116 | + echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
| 1117 | + } |
|
| 883 | 1118 | if (isset($sourced['msg'])) { |
| 884 | 1119 | if (time() - $sourced['msg']['date'] > 10) { |
| 885 | 1120 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
@@ -892,13 +1127,17 @@ discard block |
||
| 892 | 1127 | unset($this->stats[$date]); |
| 893 | 1128 | } |
| 894 | 1129 | } |
| 895 | - if ($globalDebug) echo 'Done'."\n"; |
|
| 1130 | + if ($globalDebug) { |
|
| 1131 | + echo 'Done'."\n"; |
|
| 1132 | + } |
|
| 896 | 1133 | |
| 897 | 1134 | } |
| 898 | 1135 | $Stats->db = null; |
| 899 | 1136 | } |
| 900 | 1137 | $this->del(); |
| 901 | - } elseif ($globalDebug) echo 'Ignore data'."\n"; |
|
| 1138 | + } elseif ($globalDebug) { |
|
| 1139 | + echo 'Ignore data'."\n"; |
|
| 1140 | + } |
|
| 902 | 1141 | //$ignoreImport = false; |
| 903 | 1142 | $this->all_flights[$id]['addedSpotter'] = 1; |
| 904 | 1143 | //print_r($this->all_flights[$id]); |
@@ -915,7 +1154,9 @@ discard block |
||
| 915 | 1154 | */ |
| 916 | 1155 | //SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']); |
| 917 | 1156 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
| 918 | - if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
| 1157 | + if ($globalDebug) { |
|
| 1158 | + echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
| 1159 | + } |
|
| 919 | 1160 | //SpotterLive->deleteLiveSpotterDataNotUpdated(); |
| 920 | 1161 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
| 921 | 1162 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
@@ -924,7 +1165,9 @@ discard block |
||
| 924 | 1165 | $SpotterLive->db=null; |
| 925 | 1166 | } |
| 926 | 1167 | } |
| 927 | - if ($globalDebug) echo " Done\n"; |
|
| 1168 | + if ($globalDebug) { |
|
| 1169 | + echo " Done\n"; |
|
| 1170 | + } |
|
| 928 | 1171 | $this->last_delete = time(); |
| 929 | 1172 | } |
| 930 | 1173 | } else { |
@@ -951,11 +1194,17 @@ discard block |
||
| 951 | 1194 | //echo "{$line[8]} {$line[7]} - MODES:{$line[4]} CALLSIGN:{$line[10]} ALT:{$line[11]} VEL:{$line[12]} HDG:{$line[13]} LAT:{$line[14]} LON:{$line[15]} VR:{$line[16]} SQUAWK:{$line[17]}\n"; |
| 952 | 1195 | if ($globalDebug) { |
| 953 | 1196 | if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) { |
| 954 | - if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n"; |
|
| 955 | - else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n"; |
|
| 1197 | + if (isset($this->all_flights[$id]['source_name'])) { |
|
| 1198 | + echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n"; |
|
| 1199 | + } else { |
|
| 1200 | + echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n"; |
|
| 1201 | + } |
|
| 956 | 1202 | } else { |
| 957 | - if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n"; |
|
| 958 | - else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n"; |
|
| 1203 | + if (isset($this->all_flights[$id]['source_name'])) { |
|
| 1204 | + echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n"; |
|
| 1205 | + } else { |
|
| 1206 | + echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n"; |
|
| 1207 | + } |
|
| 959 | 1208 | } |
| 960 | 1209 | } |
| 961 | 1210 | $ignoreImport = false; |
@@ -1001,23 +1250,31 @@ discard block |
||
| 1001 | 1250 | |
| 1002 | 1251 | if (!$ignoreImport) { |
| 1003 | 1252 | if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
| 1004 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
| 1253 | + if (!isset($this->all_flights[$id]['id'])) { |
|
| 1254 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
| 1255 | + } |
|
| 1005 | 1256 | $timeelapsed = microtime(true); |
| 1006 | 1257 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
| 1007 | 1258 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 1008 | - if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
|
| 1259 | + if ($globalDebug) { |
|
| 1260 | + echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
|
| 1261 | + } |
|
| 1009 | 1262 | $SpotterLive = new SpotterLive($this->db); |
| 1010 | 1263 | //var_dump($this->all_flights[$id]); |
| 1011 | 1264 | $result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
| 1012 | 1265 | $SpotterLive->db = null; |
| 1013 | - if ($globalDebug) echo $result."\n"; |
|
| 1266 | + if ($globalDebug) { |
|
| 1267 | + echo $result."\n"; |
|
| 1268 | + } |
|
| 1014 | 1269 | } |
| 1015 | 1270 | } |
| 1016 | 1271 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) { |
| 1017 | 1272 | $APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
| 1018 | 1273 | } |
| 1019 | 1274 | $this->all_flights[$id]['putinarchive'] = false; |
| 1020 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 1275 | + if ($globalDebugTimeElapsed) { |
|
| 1276 | + echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 1277 | + } |
|
| 1021 | 1278 | |
| 1022 | 1279 | // Put statistics in $this->stats variable |
| 1023 | 1280 | //if ($line['format_source'] != 'aprs') { |
@@ -1025,7 +1282,9 @@ discard block |
||
| 1025 | 1282 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 1026 | 1283 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
| 1027 | 1284 | $source = $this->all_flights[$id]['source_name']; |
| 1028 | - if ($source == '') $source = $this->all_flights[$id]['format_source']; |
|
| 1285 | + if ($source == '') { |
|
| 1286 | + $source = $this->all_flights[$id]['format_source']; |
|
| 1287 | + } |
|
| 1029 | 1288 | if (!isset($this->source_location[$source])) { |
| 1030 | 1289 | $Location = new Source($this->db); |
| 1031 | 1290 | $coord = $Location->getLocationInfobySourceName($source); |
@@ -1046,7 +1305,9 @@ discard block |
||
| 1046 | 1305 | $stats_heading = round($stats_heading/22.5); |
| 1047 | 1306 | $stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
| 1048 | 1307 | $current_date = date('Y-m-d'); |
| 1049 | - if ($stats_heading == 16) $stats_heading = 0; |
|
| 1308 | + if ($stats_heading == 16) { |
|
| 1309 | + $stats_heading = 0; |
|
| 1310 | + } |
|
| 1050 | 1311 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
| 1051 | 1312 | for ($i=0;$i<=15;$i++) { |
| 1052 | 1313 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
@@ -1064,7 +1325,9 @@ discard block |
||
| 1064 | 1325 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
| 1065 | 1326 | end($this->stats[$current_date][$source]['hist']); |
| 1066 | 1327 | $mini = key($this->stats[$current_date][$source]['hist'])+10; |
| 1067 | - } else $mini = 0; |
|
| 1328 | + } else { |
|
| 1329 | + $mini = 0; |
|
| 1330 | + } |
|
| 1068 | 1331 | for ($i=$mini;$i<=$distance;$i+=10) { |
| 1069 | 1332 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
| 1070 | 1333 | } |
@@ -1076,19 +1339,27 @@ discard block |
||
| 1076 | 1339 | } |
| 1077 | 1340 | |
| 1078 | 1341 | $this->all_flights[$id]['lastupdate'] = time(); |
| 1079 | - if ($this->all_flights[$id]['putinarchive']) $send = true; |
|
| 1342 | + if ($this->all_flights[$id]['putinarchive']) { |
|
| 1343 | + $send = true; |
|
| 1344 | + } |
|
| 1080 | 1345 | //if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
| 1081 | - } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
| 1346 | + } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) { |
|
| 1347 | + echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
| 1348 | + } |
|
| 1082 | 1349 | //$this->del(); |
| 1083 | 1350 | |
| 1084 | 1351 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
| 1085 | 1352 | if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
| 1086 | - if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour..."; |
|
| 1353 | + if ($globalDebug) { |
|
| 1354 | + echo "---- Deleting Live Spotter data Not updated since 2 hour..."; |
|
| 1355 | + } |
|
| 1087 | 1356 | $SpotterLive = new SpotterLive($this->db); |
| 1088 | 1357 | $SpotterLive->deleteLiveSpotterDataNotUpdated(); |
| 1089 | 1358 | $SpotterLive->db = null; |
| 1090 | 1359 | //SpotterLive->deleteLiveSpotterData(); |
| 1091 | - if ($globalDebug) echo " Done\n"; |
|
| 1360 | + if ($globalDebug) { |
|
| 1361 | + echo " Done\n"; |
|
| 1362 | + } |
|
| 1092 | 1363 | $this->last_delete_hourly = time(); |
| 1093 | 1364 | } else { |
| 1094 | 1365 | $this->del(); |
@@ -1100,7 +1371,9 @@ discard block |
||
| 1100 | 1371 | //$ignoreImport = false; |
| 1101 | 1372 | } |
| 1102 | 1373 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
| 1103 | - if ($send) return $this->all_flights[$id]; |
|
| 1374 | + if ($send) { |
|
| 1375 | + return $this->all_flights[$id]; |
|
| 1376 | + } |
|
| 1104 | 1377 | } |
| 1105 | 1378 | } |
| 1106 | 1379 | } |