@@ -68,6 +68,10 @@ discard block |
||
| 68 | 68 | 't', 'u', 'v', 'w' // 119 |
| 69 | 69 | ); // char 64 |
| 70 | 70 | */ |
| 71 | + |
|
| 72 | + /** |
|
| 73 | + * @param integer $ascii |
|
| 74 | + */ |
|
| 71 | 75 | private function asciidec_2_8bit($ascii) { |
| 72 | 76 | //only process in the following range: 48-87, 96-119 |
| 73 | 77 | if ($ascii < 48) { } |
@@ -93,6 +97,10 @@ discard block |
||
| 93 | 97 | return(substr($bin, -6)); |
| 94 | 98 | } |
| 95 | 99 | |
| 100 | + /** |
|
| 101 | + * @param integer $_start |
|
| 102 | + * @param integer $_size |
|
| 103 | + */ |
|
| 96 | 104 | private function binchar($_str, $_start, $_size) { |
| 97 | 105 | // ' ' --- '?', // 0x20 - 0x3F |
| 98 | 106 | // '@' --- '_', // 0x40 - 0x5F |
@@ -117,6 +125,10 @@ discard block |
||
| 117 | 125 | } |
| 118 | 126 | |
| 119 | 127 | // function for decoding the AIS Message ITU Payload |
| 128 | + |
|
| 129 | + /** |
|
| 130 | + * @param string $_aisdata |
|
| 131 | + */ |
|
| 120 | 132 | private function decode_ais($_aisdata) { |
| 121 | 133 | $ro = new stdClass(); // return object |
| 122 | 134 | $ro->cls = 0; // AIS class undefined, also indicate unparsed msg |
@@ -202,6 +214,12 @@ discard block |
||
| 202 | 214 | } |
| 203 | 215 | } |
| 204 | 216 | |
| 217 | + /** |
|
| 218 | + * @param string $_itu |
|
| 219 | + * @param integer $_len |
|
| 220 | + * @param integer $_filler |
|
| 221 | + * @param string $aux |
|
| 222 | + */ |
|
| 205 | 223 | public function process_ais_itu($_itu, $_len, $_filler, $aux /*, $ais_ch*/) { |
| 206 | 224 | global $port; // tcpip port... |
| 207 | 225 | |
@@ -221,6 +239,10 @@ discard block |
||
| 221 | 239 | |
| 222 | 240 | // char* - AIS \r terminated string |
| 223 | 241 | // TCP based streams which send messages in full can use this instead of calling process_ais_buf |
| 242 | + |
|
| 243 | + /** |
|
| 244 | + * @param string $rawdata |
|
| 245 | + */ |
|
| 224 | 246 | public function process_ais_raw($rawdata, $aux = '') { // return int |
| 225 | 247 | static $num_seq; // 1 to 9 |
| 226 | 248 | static $seq; // 1 to 9 |
@@ -35,7 +35,9 @@ discard block |
||
| 35 | 35 | $temp += 1; |
| 36 | 36 | $flat = (float)($temp / (60.0 * 10000.0)); |
| 37 | 37 | $flat *= -1.0; |
| 38 | - } else $flat = (float)($temp / (60.0 * 10000.0)); |
|
| 38 | + } else { |
|
| 39 | + $flat = (float)($temp / (60.0 * 10000.0)); |
|
| 40 | + } |
|
| 39 | 41 | return $flat; // float |
| 40 | 42 | } |
| 41 | 43 | |
@@ -47,7 +49,9 @@ discard block |
||
| 47 | 49 | $temp += 1; |
| 48 | 50 | $flon = (float)($temp / (60.0 * 10000.0)); |
| 49 | 51 | $flon *= -1.0; |
| 50 | - } else $flon = (float)($temp / (60.0 * 10000.0)); |
|
| 52 | + } else { |
|
| 53 | + $flon = (float)($temp / (60.0 * 10000.0)); |
|
| 54 | + } |
|
| 51 | 55 | return $flon; |
| 52 | 56 | } |
| 53 | 57 | |
@@ -70,10 +74,8 @@ discard block |
||
| 70 | 74 | */ |
| 71 | 75 | private function asciidec_2_8bit($ascii) { |
| 72 | 76 | //only process in the following range: 48-87, 96-119 |
| 73 | - if ($ascii < 48) { } |
|
| 74 | - else { |
|
| 75 | - if($ascii>119) { } |
|
| 76 | - else { |
|
| 77 | + if ($ascii < 48) { } else { |
|
| 78 | + if($ascii>119) { } else { |
|
| 77 | 79 | if ($ascii>87 && $ascii<96) ; |
| 78 | 80 | else { |
| 79 | 81 | $ascii=$ascii+40; |
@@ -236,19 +238,34 @@ discard block |
||
| 236 | 238 | // assume 1st ! is valid |
| 237 | 239 | // find * ensure that it is at correct position |
| 238 | 240 | $end = strrpos ( $rawdata , '*' ); |
| 239 | - if ($end === FALSE) return -1; // check for NULLS!!! |
|
| 241 | + if ($end === FALSE) { |
|
| 242 | + return -1; |
|
| 243 | + } |
|
| 244 | + // check for NULLS!!! |
|
| 240 | 245 | $cs = substr( $rawdata, $end + 1 ); |
| 241 | - if ( strlen($cs) != 2 ) return -1; // correct cs length |
|
| 246 | + if ( strlen($cs) != 2 ) { |
|
| 247 | + return -1; |
|
| 248 | + } |
|
| 249 | + // correct cs length |
|
| 242 | 250 | $dcs = (int)hexdec( $cs ); |
| 243 | - for ( $alias=1; $alias<$end; $alias++) $chksum ^= ord( $rawdata[$alias] ); // perform XOR for NMEA checksum |
|
| 251 | + for ( $alias=1; $alias<$end; $alias++) { |
|
| 252 | + $chksum ^= ord( $rawdata[$alias] ); |
|
| 253 | + } |
|
| 254 | + // perform XOR for NMEA checksum |
|
| 244 | 255 | if ( $chksum == $dcs ) { // NMEA checksum pass |
| 245 | 256 | $pcs = explode(',', $rawdata); |
| 246 | 257 | // !AI??? identifier |
| 247 | 258 | $num_seq = (int)$pcs[1]; // number of sequences |
| 248 | 259 | $seq = (int)$pcs[2]; // get sequence |
| 249 | 260 | // get msg sequence id |
| 250 | - if ($pcs[3] == '') $msg_sid = -1; // non-multipart message, set to -1 |
|
| 251 | - else $msg_sid = (int)$pcs[3]; // multipart message |
|
| 261 | + if ($pcs[3] == '') { |
|
| 262 | + $msg_sid = -1; |
|
| 263 | + } |
|
| 264 | + // non-multipart message, set to -1 |
|
| 265 | + else { |
|
| 266 | + $msg_sid = (int)$pcs[3]; |
|
| 267 | + } |
|
| 268 | + // multipart message |
|
| 252 | 269 | $ais_ch = $pcs[4]; // get AIS channel |
| 253 | 270 | // message sequence checking |
| 254 | 271 | if ($num_seq < 1 || $num_seq > 9) { |
@@ -309,10 +326,18 @@ discard block |
||
| 309 | 326 | //DEBUG echo "[$start $end $tst]\n"; |
| 310 | 327 | $result = $this->process_ais_raw( $tst, "" ); |
| 311 | 328 | $last_pos = $end + 1; |
| 312 | - } else break; |
|
| 329 | + } else { |
|
| 330 | + break; |
|
| 331 | + } |
|
| 332 | + } |
|
| 333 | + if ($last_pos > 0) { |
|
| 334 | + $cbuf = substr($cbuf, $last_pos); |
|
| 313 | 335 | } |
| 314 | - if ($last_pos > 0) $cbuf = substr($cbuf, $last_pos); // move... |
|
| 315 | - if (strlen($cbuf) > 1024) $cbuf = ""; // prevent overflow simple mode... |
|
| 336 | + // move... |
|
| 337 | + if (strlen($cbuf) > 1024) { |
|
| 338 | + $cbuf = ""; |
|
| 339 | + } |
|
| 340 | + // prevent overflow simple mode... |
|
| 316 | 341 | return $result; |
| 317 | 342 | } |
| 318 | 343 | |
@@ -332,7 +357,9 @@ discard block |
||
| 332 | 357 | if ($lat<0.0) { |
| 333 | 358 | $lat = -$lat; |
| 334 | 359 | $neg=true; |
| 335 | - } else $neg=false; |
|
| 360 | + } else { |
|
| 361 | + $neg=false; |
|
| 362 | + } |
|
| 336 | 363 | $latd = 0x00000000; |
| 337 | 364 | $latd = intval ($lat * 600000.0); |
| 338 | 365 | if ($neg==true) { |
@@ -348,7 +375,9 @@ discard block |
||
| 348 | 375 | if ($lon<0.0) { |
| 349 | 376 | $lon = -$lon; |
| 350 | 377 | $neg=true; |
| 351 | - } else $neg=false; |
|
| 378 | + } else { |
|
| 379 | + $neg=false; |
|
| 380 | + } |
|
| 352 | 381 | $lond = 0x00000000; |
| 353 | 382 | $lond = intval ($lon * 600000.0); |
| 354 | 383 | if ($neg==true) { |
@@ -361,9 +390,14 @@ discard block |
||
| 361 | 390 | |
| 362 | 391 | private function char2bin($name, $max_len) { |
| 363 | 392 | $len = strlen($name); |
| 364 | - if ($len > $max_len) $name = substr($name,0,$max_len); |
|
| 365 | - if ($len < $max_len) $pad = str_repeat('0', ($max_len - $len) * 6); |
|
| 366 | - else $pad = ''; |
|
| 393 | + if ($len > $max_len) { |
|
| 394 | + $name = substr($name,0,$max_len); |
|
| 395 | + } |
|
| 396 | + if ($len < $max_len) { |
|
| 397 | + $pad = str_repeat('0', ($max_len - $len) * 6); |
|
| 398 | + } else { |
|
| 399 | + $pad = ''; |
|
| 400 | + } |
|
| 367 | 401 | $rv = ''; |
| 368 | 402 | $ais_chars = array( |
| 369 | 403 | '@'=>0, 'A'=>1, 'B'=>2, 'C'=>3, 'D'=>4, 'E'=>5, 'F'=>6, 'G'=>7, 'H'=>8, 'I'=>9, |
@@ -375,9 +409,12 @@ discard block |
||
| 375 | 409 | '<'=>60, '='=>61, '>'=>62, '?'=>63 |
| 376 | 410 | ); |
| 377 | 411 | $_a = str_split($name); |
| 378 | - if ($_a) foreach ($_a as $_1) { |
|
| 412 | + if ($_a) { |
|
| 413 | + foreach ($_a as $_1) { |
|
| 379 | 414 | if (isset($ais_chars[$_1])) $dec = $ais_chars[$_1]; |
| 380 | - else $dec = 0; |
|
| 415 | + } else { |
|
| 416 | + $dec = 0; |
|
| 417 | + } |
|
| 381 | 418 | $bin = str_pad(decbin( $dec ), 6, '0', STR_PAD_LEFT); |
| 382 | 419 | $rv .= $bin; |
| 383 | 420 | //echo "$_1 $dec ($bin)<br/>"; |
@@ -389,7 +426,9 @@ discard block |
||
| 389 | 426 | $len_bit = strlen($_enc); |
| 390 | 427 | $rem6 = $len_bit % 6; |
| 391 | 428 | $pad6_len = 0; |
| 392 | - if ($rem6) $pad6_len = 6 - $rem6; |
|
| 429 | + if ($rem6) { |
|
| 430 | + $pad6_len = 6 - $rem6; |
|
| 431 | + } |
|
| 393 | 432 | //echo $pad6_len.'<br>'; |
| 394 | 433 | $_enc .= str_repeat("0", $pad6_len); // pad the text... |
| 395 | 434 | $len_enc = strlen($_enc) / 6; |
@@ -398,8 +437,11 @@ discard block |
||
| 398 | 437 | for ($i=0; $i<$len_enc; $i++) { |
| 399 | 438 | $offset = $i * 6; |
| 400 | 439 | $dec = bindec(substr($_enc,$offset,6)); |
| 401 | - if ($dec < 40) $dec += 48; |
|
| 402 | - else $dec += 56; |
|
| 440 | + if ($dec < 40) { |
|
| 441 | + $dec += 48; |
|
| 442 | + } else { |
|
| 443 | + $dec += 56; |
|
| 444 | + } |
|
| 403 | 445 | //echo chr($dec)." $dec<br/>"; |
| 404 | 446 | $itu .= chr($dec); |
| 405 | 447 | } |
@@ -412,25 +454,41 @@ discard block |
||
| 412 | 454 | } |
| 413 | 455 | $hex_arr = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'); |
| 414 | 456 | $lsb = $chksum & 0x0F; |
| 415 | - if ($lsb >=0 && $lsb <= 15 ) $lsbc = $hex_arr[$lsb]; |
|
| 416 | - else $lsbc = '0'; |
|
| 457 | + if ($lsb >=0 && $lsb <= 15 ) { |
|
| 458 | + $lsbc = $hex_arr[$lsb]; |
|
| 459 | + } else { |
|
| 460 | + $lsbc = '0'; |
|
| 461 | + } |
|
| 417 | 462 | $msb = (($chksum & 0xF0) >> 4) & 0x0F; |
| 418 | - if ($msb >=0 && $msb <= 15 ) $msbc = $hex_arr[$msb]; |
|
| 419 | - else $msbc = '0'; |
|
| 463 | + if ($msb >=0 && $msb <= 15 ) { |
|
| 464 | + $msbc = $hex_arr[$msb]; |
|
| 465 | + } else { |
|
| 466 | + $msbc = '0'; |
|
| 467 | + } |
|
| 420 | 468 | $itu = '!'.$itu."*{$msbc}{$lsbc}\r\n"; |
| 421 | 469 | return $itu; |
| 422 | 470 | } |
| 423 | 471 | |
| 424 | 472 | public function parse($buffer) { |
| 425 | 473 | $data = $this->process_ais_buf($buffer); |
| 426 | - if (!is_object($data)) return array(); |
|
| 427 | - if ($data->lon != 0) $result['longitude'] = $data->lon; |
|
| 428 | - if ($data->lat != 0) $result['latitude'] = $data->lat; |
|
| 474 | + if (!is_object($data)) { |
|
| 475 | + return array(); |
|
| 476 | + } |
|
| 477 | + if ($data->lon != 0) { |
|
| 478 | + $result['longitude'] = $data->lon; |
|
| 479 | + } |
|
| 480 | + if ($data->lat != 0) { |
|
| 481 | + $result['latitude'] = $data->lat; |
|
| 482 | + } |
|
| 429 | 483 | $result['ident'] = trim($data->name); |
| 430 | 484 | $result['timestamp'] = $data->ts; |
| 431 | 485 | $result['mmsi'] = $data->mmsi; |
| 432 | - if ($data->sog != -1.0) $result['speed'] = $data->sog; |
|
| 433 | - if ($data->cog != 0) $result['heading'] = $data->cog; |
|
| 486 | + if ($data->sog != -1.0) { |
|
| 487 | + $result['speed'] = $data->sog; |
|
| 488 | + } |
|
| 489 | + if ($data->cog != 0) { |
|
| 490 | + $result['heading'] = $data->cog; |
|
| 491 | + } |
|
| 434 | 492 | /* |
| 435 | 493 | $ro->cls = 0; // AIS class undefined, also indicate unparsed msg |
| 436 | 494 | $ro->id = bindec(substr($_aisdata,0,6)); |
@@ -444,15 +502,27 @@ discard block |
||
| 444 | 502 | $start = strpos($buffer,"VDM"); |
| 445 | 503 | $tst = substr($buffer, $start - 3); |
| 446 | 504 | $data = $this->process_ais_raw( $tst, "" ); |
| 447 | - if (!is_object($data)) return array(); |
|
| 448 | - if ($data->lon != 0) $result['longitude'] = $data->lon; |
|
| 449 | - if ($data->lat != 0) $result['latitude'] = $data->lat; |
|
| 505 | + if (!is_object($data)) { |
|
| 506 | + return array(); |
|
| 507 | + } |
|
| 508 | + if ($data->lon != 0) { |
|
| 509 | + $result['longitude'] = $data->lon; |
|
| 510 | + } |
|
| 511 | + if ($data->lat != 0) { |
|
| 512 | + $result['latitude'] = $data->lat; |
|
| 513 | + } |
|
| 450 | 514 | $result['ident'] = trim(str_replace('@','',$data->name)); |
| 451 | 515 | $result['timestamp'] = $data->ts; |
| 452 | 516 | $result['mmsi'] = $data->mmsi; |
| 453 | - if ($data->sog != -1.0) $result['speed'] = $data->sog; |
|
| 454 | - if ($data->cog != 0) $result['heading'] = $data->cog; |
|
| 455 | - if ($data->status != '') $result['status'] = $data->status; |
|
| 517 | + if ($data->sog != -1.0) { |
|
| 518 | + $result['speed'] = $data->sog; |
|
| 519 | + } |
|
| 520 | + if ($data->cog != 0) { |
|
| 521 | + $result['heading'] = $data->cog; |
|
| 522 | + } |
|
| 523 | + if ($data->status != '') { |
|
| 524 | + $result['status'] = $data->status; |
|
| 525 | + } |
|
| 456 | 526 | $result['all'] = (array) $data; |
| 457 | 527 | /* |
| 458 | 528 | $ro->cls = 0; // AIS class undefined, also indicate unparsed msg |
@@ -6,6 +6,9 @@ discard block |
||
| 6 | 6 | public $dbs = array(); |
| 7 | 7 | public $latest_schema = 37; |
| 8 | 8 | |
| 9 | + /** |
|
| 10 | + * @param string $dbname |
|
| 11 | + */ |
|
| 9 | 12 | public function __construct($dbc = null,$dbname = null,$user = null,$pass = null) { |
| 10 | 13 | global $globalDBdriver; |
| 11 | 14 | if ($dbc === null) { |
@@ -132,6 +135,9 @@ discard block |
||
| 132 | 135 | return true; |
| 133 | 136 | } |
| 134 | 137 | |
| 138 | + /** |
|
| 139 | + * @param string $table |
|
| 140 | + */ |
|
| 135 | 141 | public function tableExists($table) |
| 136 | 142 | { |
| 137 | 143 | global $globalDBdriver, $globalDBname; |
@@ -181,6 +187,11 @@ discard block |
||
| 181 | 187 | /* |
| 182 | 188 | * Check if index exist |
| 183 | 189 | */ |
| 190 | + |
|
| 191 | + /** |
|
| 192 | + * @param string $table |
|
| 193 | + * @param string $index |
|
| 194 | + */ |
|
| 184 | 195 | public function indexExists($table,$index) |
| 185 | 196 | { |
| 186 | 197 | global $globalDBdriver, $globalDBname; |
@@ -223,6 +234,10 @@ discard block |
||
| 223 | 234 | return $columns; |
| 224 | 235 | } |
| 225 | 236 | |
| 237 | + /** |
|
| 238 | + * @param string $table |
|
| 239 | + * @param string $column |
|
| 240 | + */ |
|
| 226 | 241 | public function getColumnType($table,$column) { |
| 227 | 242 | $select = $this->db->query('SELECT '.$column.' FROM '.$table); |
| 228 | 243 | $tomet = $select->getColumnMeta(0); |
@@ -233,6 +248,11 @@ discard block |
||
| 233 | 248 | * Check if a column name exist in a table |
| 234 | 249 | * @return Boolean column exist or not |
| 235 | 250 | */ |
| 251 | + |
|
| 252 | + /** |
|
| 253 | + * @param string $table |
|
| 254 | + * @param string $name |
|
| 255 | + */ |
|
| 236 | 256 | public function checkColumnName($table,$name) |
| 237 | 257 | { |
| 238 | 258 | global $globalDBdriver, $globalDBname; |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | /** |
| 16 | 16 | * Get SQL query part for filter used |
| 17 | 17 | * @param Array $filter the filter |
| 18 | - * @return Array the SQL part |
|
| 18 | + * @return string the SQL part |
|
| 19 | 19 | */ |
| 20 | 20 | |
| 21 | 21 | public function getFilter($filter = array(),$where = false,$and = false) { |
@@ -502,9 +502,6 @@ discard block |
||
| 502 | 502 | /** |
| 503 | 503 | * Update ident spotter data |
| 504 | 504 | * |
| 505 | - * @param String $flightaware_id the ID from flightaware |
|
| 506 | - * @param String $ident the flight ident |
|
| 507 | - * @return String success or false |
|
| 508 | 505 | * |
| 509 | 506 | */ |
| 510 | 507 | public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL) |
@@ -526,10 +523,6 @@ discard block |
||
| 526 | 523 | /** |
| 527 | 524 | * Update latest spotter data |
| 528 | 525 | * |
| 529 | - * @param String $flightaware_id the ID from flightaware |
|
| 530 | - * @param String $ident the flight ident |
|
| 531 | - * @param String $arrival_airport_icao the arrival airport |
|
| 532 | - * @return String success or false |
|
| 533 | 526 | * |
| 534 | 527 | */ |
| 535 | 528 | public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '') |
@@ -551,28 +544,6 @@ discard block |
||
| 551 | 544 | /** |
| 552 | 545 | * Adds a new spotter data |
| 553 | 546 | * |
| 554 | - * @param String $flightaware_id the ID from flightaware |
|
| 555 | - * @param String $ident the flight ident |
|
| 556 | - * @param String $aircraft_icao the aircraft type |
|
| 557 | - * @param String $departure_airport_icao the departure airport |
|
| 558 | - * @param String $arrival_airport_icao the arrival airport |
|
| 559 | - * @param String $latitude latitude of flight |
|
| 560 | - * @param String $longitude latitude of flight |
|
| 561 | - * @param String $waypoints waypoints of flight |
|
| 562 | - * @param String $heading heading of flight |
|
| 563 | - * @param String $groundspeed speed of flight |
|
| 564 | - * @param String $date date of flight |
|
| 565 | - * @param String $departure_airport_time departure time of flight |
|
| 566 | - * @param String $arrival_airport_time arrival time of flight |
|
| 567 | - * @param String $squawk squawk code of flight |
|
| 568 | - * @param String $route_stop route stop of flight |
|
| 569 | - * @param String $highlight highlight or not |
|
| 570 | - * @param String $ModeS ModesS code of flight |
|
| 571 | - * @param String $registration registration code of flight |
|
| 572 | - * @param String $pilot_id pilot id of flight (for virtual airlines) |
|
| 573 | - * @param String $pilot_name pilot name of flight (for virtual airlines) |
|
| 574 | - * @param String $verticalrate vertival rate of flight |
|
| 575 | - * @return String success or false |
|
| 576 | 547 | */ |
| 577 | 548 | public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '',$type = '',$status = '',$format_source = '', $source_name = '') |
| 578 | 549 | { |
@@ -1442,7 +1413,7 @@ discard block |
||
| 1442 | 1413 | /** |
| 1443 | 1414 | * Parses the direction degrees to working |
| 1444 | 1415 | * |
| 1445 | - * @param Float $direction the direction in degrees |
|
| 1416 | + * @param integer $direction the direction in degrees |
|
| 1446 | 1417 | * @return Array the direction information |
| 1447 | 1418 | * |
| 1448 | 1419 | */ |
@@ -31,7 +31,9 @@ discard block |
||
| 31 | 31 | if (isset($filter[0]['source'])) { |
| 32 | 32 | $filters = array_merge($filters,$filter); |
| 33 | 33 | } |
| 34 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 34 | + if (is_array($globalFilter)) { |
|
| 35 | + $filter = array_merge($filter,$globalFilter); |
|
| 36 | + } |
|
| 35 | 37 | $filter_query_join = ''; |
| 36 | 38 | $filter_query_where = ''; |
| 37 | 39 | foreach($filters as $flt) { |
@@ -70,8 +72,11 @@ discard block |
||
| 70 | 72 | $filter_query_where .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'"; |
| 71 | 73 | } |
| 72 | 74 | } |
| 73 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
| 74 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
| 75 | + if ($filter_query_where == '' && $where) { |
|
| 76 | + $filter_query_where = ' WHERE'; |
|
| 77 | + } elseif ($filter_query_where != '' && $and) { |
|
| 78 | + $filter_query_where .= ' AND'; |
|
| 79 | + } |
|
| 75 | 80 | if ($filter_query_where != '') { |
| 76 | 81 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
| 77 | 82 | } |
@@ -125,25 +130,40 @@ discard block |
||
| 125 | 130 | $temp_array['spotter_id'] = $row['spotter_archive_id']; |
| 126 | 131 | } elseif (isset($row['spotter_archive_output_id'])) { |
| 127 | 132 | $temp_array['spotter_id'] = $row['spotter_archive_output_id']; |
| 128 | - */} |
|
| 129 | - elseif (isset($row['marineid'])) { |
|
| 133 | + */} elseif (isset($row['marineid'])) { |
|
| 130 | 134 | $temp_array['marineid'] = $row['marineid']; |
| 131 | 135 | } else { |
| 132 | 136 | $temp_array['marineid'] = ''; |
| 133 | 137 | } |
| 134 | - if (isset($row['fammarine_id'])) $temp_array['fammarine_id'] = $row['fammarine_id']; |
|
| 135 | - if (isset($row['mmsi'])) $temp_array['mmsi'] = $row['mmsi']; |
|
| 136 | - if (isset($row['type'])) $temp_array['type'] = $row['type']; |
|
| 138 | + if (isset($row['fammarine_id'])) { |
|
| 139 | + $temp_array['fammarine_id'] = $row['fammarine_id']; |
|
| 140 | + } |
|
| 141 | + if (isset($row['mmsi'])) { |
|
| 142 | + $temp_array['mmsi'] = $row['mmsi']; |
|
| 143 | + } |
|
| 144 | + if (isset($row['type'])) { |
|
| 145 | + $temp_array['type'] = $row['type']; |
|
| 146 | + } |
|
| 137 | 147 | $temp_array['ident'] = $row['ident']; |
| 138 | - if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude']; |
|
| 139 | - if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude']; |
|
| 140 | - if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source']; |
|
| 148 | + if (isset($row['latitude'])) { |
|
| 149 | + $temp_array['latitude'] = $row['latitude']; |
|
| 150 | + } |
|
| 151 | + if (isset($row['longitude'])) { |
|
| 152 | + $temp_array['longitude'] = $row['longitude']; |
|
| 153 | + } |
|
| 154 | + if (isset($row['format_source'])) { |
|
| 155 | + $temp_array['format_source'] = $row['format_source']; |
|
| 156 | + } |
|
| 141 | 157 | if (isset($row['heading'])) { |
| 142 | 158 | $temp_array['heading'] = $row['heading']; |
| 143 | 159 | $heading_direction = $this->parseDirection($row['heading']); |
| 144 | - if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
| 160 | + if (isset($heading_direction[0]['direction_fullname'])) { |
|
| 161 | + $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
| 162 | + } |
|
| 163 | + } |
|
| 164 | + if (isset($row['ground_speed'])) { |
|
| 165 | + $temp_array['ground_speed'] = $row['ground_speed']; |
|
| 145 | 166 | } |
| 146 | - if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed']; |
|
| 147 | 167 | |
| 148 | 168 | if (isset($row['date'])) { |
| 149 | 169 | $dateArray = $this->parseDateString($row['date']); |
@@ -186,13 +206,21 @@ discard block |
||
| 186 | 206 | } |
| 187 | 207 | |
| 188 | 208 | $fromsource = NULL; |
| 189 | - if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name']; |
|
| 190 | - if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country']; |
|
| 191 | - if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance']; |
|
| 209 | + if (isset($row['source_name']) && $row['source_name'] != '') { |
|
| 210 | + $temp_array['source_name'] = $row['source_name']; |
|
| 211 | + } |
|
| 212 | + if (isset($row['over_country']) && $row['over_country'] != '') { |
|
| 213 | + $temp_array['over_country'] = $row['over_country']; |
|
| 214 | + } |
|
| 215 | + if (isset($row['distance']) && $row['distance'] != '') { |
|
| 216 | + $temp_array['distance'] = $row['distance']; |
|
| 217 | + } |
|
| 192 | 218 | $temp_array['query_number_rows'] = $num_rows; |
| 193 | 219 | $spotter_array[] = $temp_array; |
| 194 | 220 | } |
| 195 | - if ($num_rows == 0) return array(); |
|
| 221 | + if ($num_rows == 0) { |
|
| 222 | + return array(); |
|
| 223 | + } |
|
| 196 | 224 | $spotter_array[0]['query_number_rows'] = $num_rows; |
| 197 | 225 | return $spotter_array; |
| 198 | 226 | } |
@@ -223,8 +251,12 @@ discard block |
||
| 223 | 251 | { |
| 224 | 252 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 225 | 253 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 226 | - } else $limit_query = ""; |
|
| 227 | - } else $limit_query = ""; |
|
| 254 | + } else { |
|
| 255 | + $limit_query = ""; |
|
| 256 | + } |
|
| 257 | + } else { |
|
| 258 | + $limit_query = ""; |
|
| 259 | + } |
|
| 228 | 260 | |
| 229 | 261 | if ($sort != "") |
| 230 | 262 | { |
@@ -252,7 +284,9 @@ discard block |
||
| 252 | 284 | global $global_query; |
| 253 | 285 | |
| 254 | 286 | date_default_timezone_set('UTC'); |
| 255 | - if ($id == '') return array(); |
|
| 287 | + if ($id == '') { |
|
| 288 | + return array(); |
|
| 289 | + } |
|
| 256 | 290 | $additional_query = "marine_output.fammarine_id = :id"; |
| 257 | 291 | $query_values = array(':id' => $id); |
| 258 | 292 | $query = $global_query." WHERE ".$additional_query." "; |
@@ -395,8 +429,11 @@ discard block |
||
| 395 | 429 | $query .= " ORDER BY marine_output.source_name ASC"; |
| 396 | 430 | |
| 397 | 431 | $sth = $this->db->prepare($query); |
| 398 | - if (!empty($query_values)) $sth->execute($query_values); |
|
| 399 | - else $sth->execute(); |
|
| 432 | + if (!empty($query_values)) { |
|
| 433 | + $sth->execute($query_values); |
|
| 434 | + } else { |
|
| 435 | + $sth->execute(); |
|
| 436 | + } |
|
| 400 | 437 | |
| 401 | 438 | $source_array = array(); |
| 402 | 439 | $temp_array = array(); |
@@ -451,8 +488,11 @@ discard block |
||
| 451 | 488 | $sth = $this->db->prepare($query); |
| 452 | 489 | $sth->execute(array(':mmsi' => $mmsi)); |
| 453 | 490 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 454 | - if (isset($result[0])) return $result[0]; |
|
| 455 | - else return array(); |
|
| 491 | + if (isset($result[0])) { |
|
| 492 | + return $result[0]; |
|
| 493 | + } else { |
|
| 494 | + return array(); |
|
| 495 | + } |
|
| 456 | 496 | } |
| 457 | 497 | |
| 458 | 498 | /* |
@@ -468,7 +508,9 @@ discard block |
||
| 468 | 508 | date_default_timezone_set($globalTimezone); |
| 469 | 509 | $datetime = new DateTime(); |
| 470 | 510 | $offset = $datetime->format('P'); |
| 471 | - } else $offset = '+00:00'; |
|
| 511 | + } else { |
|
| 512 | + $offset = '+00:00'; |
|
| 513 | + } |
|
| 472 | 514 | |
| 473 | 515 | if ($globalDBdriver == 'mysql') { |
| 474 | 516 | $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
@@ -661,8 +703,12 @@ discard block |
||
| 661 | 703 | $latitude = 0; |
| 662 | 704 | $longitude = 0; |
| 663 | 705 | } |
| 664 | - if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
| 665 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
| 706 | + if ($heading == '' || $Common->isInteger($heading) === false) { |
|
| 707 | + $heading = 0; |
|
| 708 | + } |
|
| 709 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) { |
|
| 710 | + $groundspeed = 0; |
|
| 711 | + } |
|
| 666 | 712 | $query = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status) |
| 667 | 713 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status)"; |
| 668 | 714 | |
@@ -827,12 +873,18 @@ discard block |
||
| 827 | 873 | $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
| 828 | 874 | FROM marine_output".$filter_query." marine_output.ident <> ''"; |
| 829 | 875 | if ($olderthanmonths > 0) { |
| 830 | - if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
| 831 | - else $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
| 876 | + if ($globalDBdriver == 'mysql') { |
|
| 877 | + $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
| 878 | + } else { |
|
| 879 | + $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
| 880 | + } |
|
| 832 | 881 | } |
| 833 | 882 | if ($sincedate != '') { |
| 834 | - if ($globalDBdriver == 'mysql') $query .= " AND marine_output.date > '".$sincedate."'"; |
|
| 835 | - else $query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
| 883 | + if ($globalDBdriver == 'mysql') { |
|
| 884 | + $query .= " AND marine_output.date > '".$sincedate."'"; |
|
| 885 | + } else { |
|
| 886 | + $query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
| 887 | + } |
|
| 836 | 888 | } |
| 837 | 889 | $query_values = array(); |
| 838 | 890 | if ($year != '') { |
@@ -863,7 +915,9 @@ discard block |
||
| 863 | 915 | } |
| 864 | 916 | } |
| 865 | 917 | $query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC"; |
| 866 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
| 918 | + if ($limit) { |
|
| 919 | + $query .= " LIMIT 10 OFFSET 0"; |
|
| 920 | + } |
|
| 867 | 921 | |
| 868 | 922 | $sth = $this->db->prepare($query); |
| 869 | 923 | $sth->execute($query_values); |
@@ -898,7 +952,9 @@ discard block |
||
| 898 | 952 | date_default_timezone_set($globalTimezone); |
| 899 | 953 | $datetime = new DateTime(); |
| 900 | 954 | $offset = $datetime->format('P'); |
| 901 | - } else $offset = '+00:00'; |
|
| 955 | + } else { |
|
| 956 | + $offset = '+00:00'; |
|
| 957 | + } |
|
| 902 | 958 | |
| 903 | 959 | if ($globalDBdriver == 'mysql') { |
| 904 | 960 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -948,7 +1004,9 @@ discard block |
||
| 948 | 1004 | date_default_timezone_set($globalTimezone); |
| 949 | 1005 | $datetime = new DateTime(); |
| 950 | 1006 | $offset = $datetime->format('P'); |
| 951 | - } else $offset = '+00:00'; |
|
| 1007 | + } else { |
|
| 1008 | + $offset = '+00:00'; |
|
| 1009 | + } |
|
| 952 | 1010 | $filter_query = $this->getFilter($filters,true,true); |
| 953 | 1011 | if ($globalDBdriver == 'mysql') { |
| 954 | 1012 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -994,7 +1052,9 @@ discard block |
||
| 994 | 1052 | date_default_timezone_set($globalTimezone); |
| 995 | 1053 | $datetime = new DateTime(); |
| 996 | 1054 | $offset = $datetime->format('P'); |
| 997 | - } else $offset = '+00:00'; |
|
| 1055 | + } else { |
|
| 1056 | + $offset = '+00:00'; |
|
| 1057 | + } |
|
| 998 | 1058 | $filter_query = $this->getFilter($filters,true,true); |
| 999 | 1059 | if ($globalDBdriver == 'mysql') { |
| 1000 | 1060 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1042,7 +1102,9 @@ discard block |
||
| 1042 | 1102 | date_default_timezone_set($globalTimezone); |
| 1043 | 1103 | $datetime = new DateTime(); |
| 1044 | 1104 | $offset = $datetime->format('P'); |
| 1045 | - } else $offset = '+00:00'; |
|
| 1105 | + } else { |
|
| 1106 | + $offset = '+00:00'; |
|
| 1107 | + } |
|
| 1046 | 1108 | |
| 1047 | 1109 | if ($globalDBdriver == 'mysql') { |
| 1048 | 1110 | $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 |
@@ -1091,7 +1153,9 @@ discard block |
||
| 1091 | 1153 | date_default_timezone_set($globalTimezone); |
| 1092 | 1154 | $datetime = new DateTime(); |
| 1093 | 1155 | $offset = $datetime->format('P'); |
| 1094 | - } else $offset = '+00:00'; |
|
| 1156 | + } else { |
|
| 1157 | + $offset = '+00:00'; |
|
| 1158 | + } |
|
| 1095 | 1159 | $filter_query = $this->getFilter($filters,true,true); |
| 1096 | 1160 | if ($globalDBdriver == 'mysql') { |
| 1097 | 1161 | $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 |
@@ -1140,7 +1204,9 @@ discard block |
||
| 1140 | 1204 | date_default_timezone_set($globalTimezone); |
| 1141 | 1205 | $datetime = new DateTime(); |
| 1142 | 1206 | $offset = $datetime->format('P'); |
| 1143 | - } else $offset = '+00:00'; |
|
| 1207 | + } else { |
|
| 1208 | + $offset = '+00:00'; |
|
| 1209 | + } |
|
| 1144 | 1210 | |
| 1145 | 1211 | $orderby_sql = ''; |
| 1146 | 1212 | if ($orderby == "hour") |
@@ -1209,7 +1275,9 @@ discard block |
||
| 1209 | 1275 | date_default_timezone_set($globalTimezone); |
| 1210 | 1276 | $datetime = new DateTime($date); |
| 1211 | 1277 | $offset = $datetime->format('P'); |
| 1212 | - } else $offset = '+00:00'; |
|
| 1278 | + } else { |
|
| 1279 | + $offset = '+00:00'; |
|
| 1280 | + } |
|
| 1213 | 1281 | |
| 1214 | 1282 | if ($globalDBdriver == 'mysql') { |
| 1215 | 1283 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1257,7 +1325,9 @@ discard block |
||
| 1257 | 1325 | date_default_timezone_set($globalTimezone); |
| 1258 | 1326 | $datetime = new DateTime(); |
| 1259 | 1327 | $offset = $datetime->format('P'); |
| 1260 | - } else $offset = '+00:00'; |
|
| 1328 | + } else { |
|
| 1329 | + $offset = '+00:00'; |
|
| 1330 | + } |
|
| 1261 | 1331 | |
| 1262 | 1332 | if ($globalDBdriver == 'mysql') { |
| 1263 | 1333 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1321,8 +1391,11 @@ discard block |
||
| 1321 | 1391 | $query_values = array_merge($query_values,array(':month' => $month)); |
| 1322 | 1392 | } |
| 1323 | 1393 | } |
| 1324 | - if (empty($query_values)) $queryi .= $this->getFilter($filters); |
|
| 1325 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 1394 | + if (empty($query_values)) { |
|
| 1395 | + $queryi .= $this->getFilter($filters); |
|
| 1396 | + } else { |
|
| 1397 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 1398 | + } |
|
| 1326 | 1399 | |
| 1327 | 1400 | $sth = $this->db->prepare($queryi); |
| 1328 | 1401 | $sth->execute($query_values); |
@@ -1344,7 +1417,9 @@ discard block |
||
| 1344 | 1417 | date_default_timezone_set($globalTimezone); |
| 1345 | 1418 | $datetime = new DateTime(); |
| 1346 | 1419 | $offset = $datetime->format('P'); |
| 1347 | - } else $offset = '+00:00'; |
|
| 1420 | + } else { |
|
| 1421 | + $offset = '+00:00'; |
|
| 1422 | + } |
|
| 1348 | 1423 | |
| 1349 | 1424 | if ($globalDBdriver == 'mysql') { |
| 1350 | 1425 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1448,7 +1523,9 @@ discard block |
||
| 1448 | 1523 | */ |
| 1449 | 1524 | public function parseDirection($direction = 0) |
| 1450 | 1525 | { |
| 1451 | - if ($direction == '') $direction = 0; |
|
| 1526 | + if ($direction == '') { |
|
| 1527 | + $direction = 0; |
|
| 1528 | + } |
|
| 1452 | 1529 | $direction_array = array(); |
| 1453 | 1530 | $temp_array = array(); |
| 1454 | 1531 | |
@@ -1537,7 +1614,9 @@ discard block |
||
| 1537 | 1614 | $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 1538 | 1615 | |
| 1539 | 1616 | $Connection = new Connection($this->db); |
| 1540 | - if (!$Connection->tableExists('countries')) return ''; |
|
| 1617 | + if (!$Connection->tableExists('countries')) { |
|
| 1618 | + return ''; |
|
| 1619 | + } |
|
| 1541 | 1620 | |
| 1542 | 1621 | try { |
| 1543 | 1622 | /* |
@@ -1557,9 +1636,13 @@ discard block |
||
| 1557 | 1636 | $sth->closeCursor(); |
| 1558 | 1637 | if (count($row) > 0) { |
| 1559 | 1638 | return $row; |
| 1560 | - } else return ''; |
|
| 1639 | + } else { |
|
| 1640 | + return ''; |
|
| 1641 | + } |
|
| 1561 | 1642 | } catch (PDOException $e) { |
| 1562 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
| 1643 | + if (isset($globalDebug) && $globalDebug) { |
|
| 1644 | + echo 'Error : '.$e->getMessage()."\n"; |
|
| 1645 | + } |
|
| 1563 | 1646 | return ''; |
| 1564 | 1647 | } |
| 1565 | 1648 | |
@@ -1577,7 +1660,9 @@ discard block |
||
| 1577 | 1660 | $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); |
| 1578 | 1661 | |
| 1579 | 1662 | $Connection = new Connection($this->db); |
| 1580 | - if (!$Connection->tableExists('countries')) return ''; |
|
| 1663 | + if (!$Connection->tableExists('countries')) { |
|
| 1664 | + return ''; |
|
| 1665 | + } |
|
| 1581 | 1666 | |
| 1582 | 1667 | try { |
| 1583 | 1668 | $query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1"; |
@@ -1589,9 +1674,13 @@ discard block |
||
| 1589 | 1674 | $sth->closeCursor(); |
| 1590 | 1675 | if (count($row) > 0) { |
| 1591 | 1676 | return $row; |
| 1592 | - } else return ''; |
|
| 1677 | + } else { |
|
| 1678 | + return ''; |
|
| 1679 | + } |
|
| 1593 | 1680 | } catch (PDOException $e) { |
| 1594 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
| 1681 | + if (isset($globalDebug) && $globalDebug) { |
|
| 1682 | + echo 'Error : '.$e->getMessage()."\n"; |
|
| 1683 | + } |
|
| 1595 | 1684 | return ''; |
| 1596 | 1685 | } |
| 1597 | 1686 | |
@@ -1609,7 +1698,9 @@ discard block |
||
| 1609 | 1698 | { |
| 1610 | 1699 | global $globalBitlyAccessToken; |
| 1611 | 1700 | |
| 1612 | - if ($globalBitlyAccessToken == '') return $url; |
|
| 1701 | + if ($globalBitlyAccessToken == '') { |
|
| 1702 | + return $url; |
|
| 1703 | + } |
|
| 1613 | 1704 | |
| 1614 | 1705 | $google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url; |
| 1615 | 1706 | |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | /** |
| 15 | 15 | * Get SQL query part for filter used |
| 16 | 16 | * @param Array $filter the filter |
| 17 | - * @return Array the SQL part |
|
| 17 | + * @return string the SQL part |
|
| 18 | 18 | */ |
| 19 | 19 | public function getFilter($filter = array(),$where = false,$and = false) { |
| 20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
@@ -762,10 +762,6 @@ discard block |
||
| 762 | 762 | * |
| 763 | 763 | * @param String $fammarine_id the ID from flightaware |
| 764 | 764 | * @param String $ident the flight ident |
| 765 | - * @param String $aircraft_icao the aircraft type |
|
| 766 | - * @param String $departure_airport_icao the departure airport |
|
| 767 | - * @param String $arrival_airport_icao the arrival airport |
|
| 768 | - * @return String success or false |
|
| 769 | 765 | * |
| 770 | 766 | */ |
| 771 | 767 | public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '',$type = '',$status = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '') |
@@ -29,7 +29,9 @@ discard block |
||
| 29 | 29 | if (isset($filter[0]['source'])) { |
| 30 | 30 | $filters = array_merge($filters,$filter); |
| 31 | 31 | } |
| 32 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 32 | + if (is_array($globalFilter)) { |
|
| 33 | + $filter = array_merge($filter,$globalFilter); |
|
| 34 | + } |
|
| 33 | 35 | $filter_query_join = ''; |
| 34 | 36 | $filter_query_where = ''; |
| 35 | 37 | foreach($filters as $flt) { |
@@ -76,8 +78,11 @@ discard block |
||
| 76 | 78 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 77 | 79 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
| 78 | 80 | } |
| 79 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
| 80 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
| 81 | + if ($filter_query_where == '' && $where) { |
|
| 82 | + $filter_query_where = ' WHERE'; |
|
| 83 | + } elseif ($filter_query_where != '' && $and) { |
|
| 84 | + $filter_query_where .= ' AND'; |
|
| 85 | + } |
|
| 81 | 86 | if ($filter_query_where != '') { |
| 82 | 87 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
| 83 | 88 | } |
@@ -119,7 +124,9 @@ discard block |
||
| 119 | 124 | } |
| 120 | 125 | } |
| 121 | 126 | |
| 122 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 127 | + if (!isset($globalLiveInterval)) { |
|
| 128 | + $globalLiveInterval = '200'; |
|
| 129 | + } |
|
| 123 | 130 | if ($globalDBdriver == 'mysql') { |
| 124 | 131 | //$query = "SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate"; |
| 125 | 132 | $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate'.$filter_query.$orderby_query; |
@@ -144,7 +151,9 @@ discard block |
||
| 144 | 151 | |
| 145 | 152 | $filter_query = $this->getFilter($filter,true,true); |
| 146 | 153 | |
| 147 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 154 | + if (!isset($globalLiveInterval)) { |
|
| 155 | + $globalLiveInterval = '200'; |
|
| 156 | + } |
|
| 148 | 157 | if ($globalDBdriver == 'mysql') { |
| 149 | 158 | $query = 'SELECT marine_live.mmsi, marine_live.ident, marine_live.type,marine_live.fammarine_id, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
| 150 | 159 | FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate'.$filter_query." marine_live.latitude <> 0 AND marine_live.longitude <> 0"; |
@@ -178,7 +187,9 @@ discard block |
||
| 178 | 187 | |
| 179 | 188 | $filter_query = $this->getFilter($filter,true,true); |
| 180 | 189 | |
| 181 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 190 | + if (!isset($globalLiveInterval)) { |
|
| 191 | + $globalLiveInterval = '200'; |
|
| 192 | + } |
|
| 182 | 193 | if ($globalDBdriver == 'mysql') { |
| 183 | 194 | $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
| 184 | 195 | FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' |
@@ -211,7 +222,9 @@ discard block |
||
| 211 | 222 | global $globalDBdriver, $globalLiveInterval; |
| 212 | 223 | $filter_query = $this->getFilter($filter,true,true); |
| 213 | 224 | |
| 214 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 225 | + if (!isset($globalLiveInterval)) { |
|
| 226 | + $globalLiveInterval = '200'; |
|
| 227 | + } |
|
| 215 | 228 | if ($globalDBdriver == 'mysql') { |
| 216 | 229 | $query = 'SELECT COUNT(DISTINCT marine_live.fammarine_id) as nb FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
| 217 | 230 | } else { |
@@ -239,7 +252,9 @@ discard block |
||
| 239 | 252 | { |
| 240 | 253 | global $globalDBdriver, $globalLiveInterval; |
| 241 | 254 | $Spotter = new Spotter($this->db); |
| 242 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 255 | + if (!isset($globalLiveInterval)) { |
|
| 256 | + $globalLiveInterval = '200'; |
|
| 257 | + } |
|
| 243 | 258 | $filter_query = $this->getFilter($filter); |
| 244 | 259 | |
| 245 | 260 | if (is_array($coord)) { |
@@ -247,7 +262,9 @@ discard block |
||
| 247 | 262 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 248 | 263 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 249 | 264 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 250 | - } else return array(); |
|
| 265 | + } else { |
|
| 266 | + return array(); |
|
| 267 | + } |
|
| 251 | 268 | if ($globalDBdriver == 'mysql') { |
| 252 | 269 | $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND marine_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY marine_live.fammarine_id'.$filter_query; |
| 253 | 270 | } else { |
@@ -411,11 +428,15 @@ discard block |
||
| 411 | 428 | //$query = self::$global_query.' WHERE marine_live.fammarine_id = :id ORDER BY date'; |
| 412 | 429 | if ($globalDBdriver == 'mysql') { |
| 413 | 430 | $query = 'SELECT marine_live.* FROM marine_live WHERE marine_live.fammarine_id = :id'; |
| 414 | - if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
| 431 | + if ($liveinterval) { |
|
| 432 | + $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
| 433 | + } |
|
| 415 | 434 | $query .= ' ORDER BY date'; |
| 416 | 435 | } else { |
| 417 | 436 | $query = 'SELECT marine_live.* FROM marine_live WHERE marine_live.fammarine_id = :id'; |
| 418 | - if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
| 437 | + if ($liveinterval) { |
|
| 438 | + $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
| 439 | + } |
|
| 419 | 440 | $query .= ' ORDER BY date'; |
| 420 | 441 | } |
| 421 | 442 | |
@@ -510,7 +531,9 @@ discard block |
||
| 510 | 531 | $i++; |
| 511 | 532 | $j++; |
| 512 | 533 | if ($j == 30) { |
| 513 | - if ($globalDebug) echo "."; |
|
| 534 | + if ($globalDebug) { |
|
| 535 | + echo "."; |
|
| 536 | + } |
|
| 514 | 537 | try { |
| 515 | 538 | |
| 516 | 539 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
@@ -790,7 +813,9 @@ discard block |
||
| 790 | 813 | { |
| 791 | 814 | return false; |
| 792 | 815 | } |
| 793 | - } else return ''; |
|
| 816 | + } else { |
|
| 817 | + return ''; |
|
| 818 | + } |
|
| 794 | 819 | |
| 795 | 820 | if ($longitude != '') |
| 796 | 821 | { |
@@ -798,7 +823,9 @@ discard block |
||
| 798 | 823 | { |
| 799 | 824 | return false; |
| 800 | 825 | } |
| 801 | - } else return ''; |
|
| 826 | + } else { |
|
| 827 | + return ''; |
|
| 828 | + } |
|
| 802 | 829 | |
| 803 | 830 | |
| 804 | 831 | if ($heading != '') |
@@ -807,7 +834,9 @@ discard block |
||
| 807 | 834 | { |
| 808 | 835 | return false; |
| 809 | 836 | } |
| 810 | - } else $heading = 0; |
|
| 837 | + } else { |
|
| 838 | + $heading = 0; |
|
| 839 | + } |
|
| 811 | 840 | |
| 812 | 841 | if ($groundspeed != '') |
| 813 | 842 | { |
@@ -815,9 +844,13 @@ discard block |
||
| 815 | 844 | { |
| 816 | 845 | return false; |
| 817 | 846 | } |
| 818 | - } else $groundspeed = 0; |
|
| 847 | + } else { |
|
| 848 | + $groundspeed = 0; |
|
| 849 | + } |
|
| 819 | 850 | date_default_timezone_set('UTC'); |
| 820 | - if ($date == '') $date = date("Y-m-d H:i:s", time()); |
|
| 851 | + if ($date == '') { |
|
| 852 | + $date = date("Y-m-d H:i:s", time()); |
|
| 853 | + } |
|
| 821 | 854 | |
| 822 | 855 | |
| 823 | 856 | $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
@@ -833,8 +866,12 @@ discard block |
||
| 833 | 866 | $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
| 834 | 867 | $status = filter_var($status,FILTER_SANITIZE_STRING); |
| 835 | 868 | |
| 836 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 837 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 869 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) { |
|
| 870 | + $groundspeed = 0; |
|
| 871 | + } |
|
| 872 | + if ($heading == '' || $Common->isInteger($heading) === false ) { |
|
| 873 | + $heading = 0; |
|
| 874 | + } |
|
| 838 | 875 | |
| 839 | 876 | $query = 'INSERT INTO marine_live (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,status) |
| 840 | 877 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:mmsi,:type,:status)'; |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | /** |
| 16 | 16 | * Get SQL query part for filter used |
| 17 | 17 | * @param Array $filter the filter |
| 18 | - * @return Array the SQL part |
|
| 18 | + * @return string the SQL part |
|
| 19 | 19 | */ |
| 20 | 20 | |
| 21 | 21 | public function getFilter($filter = array(),$where = false,$and = false) { |
@@ -486,9 +486,6 @@ discard block |
||
| 486 | 486 | /** |
| 487 | 487 | * Update ident spotter data |
| 488 | 488 | * |
| 489 | - * @param String $flightaware_id the ID from flightaware |
|
| 490 | - * @param String $ident the flight ident |
|
| 491 | - * @return String success or false |
|
| 492 | 489 | * |
| 493 | 490 | */ |
| 494 | 491 | public function updateIdentTrackerData($famtrackid = '', $ident = '',$fromsource = NULL) |
@@ -510,10 +507,6 @@ discard block |
||
| 510 | 507 | /** |
| 511 | 508 | * Update latest spotter data |
| 512 | 509 | * |
| 513 | - * @param String $flightaware_id the ID from flightaware |
|
| 514 | - * @param String $ident the flight ident |
|
| 515 | - * @param String $arrival_airport_icao the arrival airport |
|
| 516 | - * @return String success or false |
|
| 517 | 510 | * |
| 518 | 511 | */ |
| 519 | 512 | public function updateLatestTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $groundspeed = NULL, $date = '') |
@@ -535,29 +528,6 @@ discard block |
||
| 535 | 528 | /** |
| 536 | 529 | * Adds a new spotter data |
| 537 | 530 | * |
| 538 | - * @param String $flightaware_id the ID from flightaware |
|
| 539 | - * @param String $ident the flight ident |
|
| 540 | - * @param String $aircraft_icao the aircraft type |
|
| 541 | - * @param String $departure_airport_icao the departure airport |
|
| 542 | - * @param String $arrival_airport_icao the arrival airport |
|
| 543 | - * @param String $latitude latitude of flight |
|
| 544 | - * @param String $longitude latitude of flight |
|
| 545 | - * @param String $waypoints waypoints of flight |
|
| 546 | - * @param String $altitude altitude of flight |
|
| 547 | - * @param String $heading heading of flight |
|
| 548 | - * @param String $groundspeed speed of flight |
|
| 549 | - * @param String $date date of flight |
|
| 550 | - * @param String $departure_airport_time departure time of flight |
|
| 551 | - * @param String $arrival_airport_time arrival time of flight |
|
| 552 | - * @param String $squawk squawk code of flight |
|
| 553 | - * @param String $route_stop route stop of flight |
|
| 554 | - * @param String $highlight highlight or not |
|
| 555 | - * @param String $ModeS ModesS code of flight |
|
| 556 | - * @param String $registration registration code of flight |
|
| 557 | - * @param String $pilot_id pilot id of flight (for virtual airlines) |
|
| 558 | - * @param String $pilot_name pilot name of flight (for virtual airlines) |
|
| 559 | - * @param String $verticalrate vertival rate of flight |
|
| 560 | - * @return String success or false |
|
| 561 | 531 | */ |
| 562 | 532 | public function addTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $comment = '', $type = '',$format_source = '', $source_name = '') |
| 563 | 533 | { |
@@ -1428,7 +1398,7 @@ discard block |
||
| 1428 | 1398 | /** |
| 1429 | 1399 | * Parses the direction degrees to working |
| 1430 | 1400 | * |
| 1431 | - * @param Float $direction the direction in degrees |
|
| 1401 | + * @param integer $direction the direction in degrees |
|
| 1432 | 1402 | * @return Array the direction information |
| 1433 | 1403 | * |
| 1434 | 1404 | */ |
@@ -31,7 +31,9 @@ discard block |
||
| 31 | 31 | if (isset($filter[0]['source'])) { |
| 32 | 32 | $filters = array_merge($filters,$filter); |
| 33 | 33 | } |
| 34 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 34 | + if (is_array($globalFilter)) { |
|
| 35 | + $filter = array_merge($filter,$globalFilter); |
|
| 36 | + } |
|
| 35 | 37 | $filter_query_join = ''; |
| 36 | 38 | $filter_query_where = ''; |
| 37 | 39 | foreach($filters as $flt) { |
@@ -70,8 +72,11 @@ discard block |
||
| 70 | 72 | $filter_query_where .= " AND EXTRACT(DAY FROM tracker_output.date) = '".$filter['day']."'"; |
| 71 | 73 | } |
| 72 | 74 | } |
| 73 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
| 74 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
| 75 | + if ($filter_query_where == '' && $where) { |
|
| 76 | + $filter_query_where = ' WHERE'; |
|
| 77 | + } elseif ($filter_query_where != '' && $and) { |
|
| 78 | + $filter_query_where .= ' AND'; |
|
| 79 | + } |
|
| 75 | 80 | if ($filter_query_where != '') { |
| 76 | 81 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
| 77 | 82 | } |
@@ -125,26 +130,43 @@ discard block |
||
| 125 | 130 | $temp_array['spotter_id'] = $row['spotter_archive_id']; |
| 126 | 131 | } elseif (isset($row['spotter_archive_output_id'])) { |
| 127 | 132 | $temp_array['spotter_id'] = $row['spotter_archive_output_id']; |
| 128 | - */} |
|
| 129 | - elseif (isset($row['trackerid'])) { |
|
| 133 | + */} elseif (isset($row['trackerid'])) { |
|
| 130 | 134 | $temp_array['trackerid'] = $row['trackerid']; |
| 131 | 135 | } else { |
| 132 | 136 | $temp_array['trackerid'] = ''; |
| 133 | 137 | } |
| 134 | - if (isset($row['famtrackid'])) $temp_array['famtrackid'] = $row['famtrackid']; |
|
| 135 | - if (isset($row['type'])) $temp_array['type'] = $row['type']; |
|
| 136 | - if (isset($row['comment'])) $temp_array['comment'] = $row['comment']; |
|
| 138 | + if (isset($row['famtrackid'])) { |
|
| 139 | + $temp_array['famtrackid'] = $row['famtrackid']; |
|
| 140 | + } |
|
| 141 | + if (isset($row['type'])) { |
|
| 142 | + $temp_array['type'] = $row['type']; |
|
| 143 | + } |
|
| 144 | + if (isset($row['comment'])) { |
|
| 145 | + $temp_array['comment'] = $row['comment']; |
|
| 146 | + } |
|
| 137 | 147 | $temp_array['ident'] = $row['ident']; |
| 138 | - if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude']; |
|
| 139 | - if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude']; |
|
| 140 | - if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source']; |
|
| 141 | - if (isset($row['altitude'])) $temp_array['altitude'] = $row['altitude']; |
|
| 148 | + if (isset($row['latitude'])) { |
|
| 149 | + $temp_array['latitude'] = $row['latitude']; |
|
| 150 | + } |
|
| 151 | + if (isset($row['longitude'])) { |
|
| 152 | + $temp_array['longitude'] = $row['longitude']; |
|
| 153 | + } |
|
| 154 | + if (isset($row['format_source'])) { |
|
| 155 | + $temp_array['format_source'] = $row['format_source']; |
|
| 156 | + } |
|
| 157 | + if (isset($row['altitude'])) { |
|
| 158 | + $temp_array['altitude'] = $row['altitude']; |
|
| 159 | + } |
|
| 142 | 160 | if (isset($row['heading'])) { |
| 143 | 161 | $temp_array['heading'] = $row['heading']; |
| 144 | 162 | $heading_direction = $this->parseDirection($row['heading']); |
| 145 | - if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
| 163 | + if (isset($heading_direction[0]['direction_fullname'])) { |
|
| 164 | + $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
| 165 | + } |
|
| 166 | + } |
|
| 167 | + if (isset($row['ground_speed'])) { |
|
| 168 | + $temp_array['ground_speed'] = $row['ground_speed']; |
|
| 146 | 169 | } |
| 147 | - if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed']; |
|
| 148 | 170 | |
| 149 | 171 | if (isset($row['date'])) { |
| 150 | 172 | $dateArray = $this->parseDateString($row['date']); |
@@ -187,13 +209,21 @@ discard block |
||
| 187 | 209 | } |
| 188 | 210 | |
| 189 | 211 | $fromsource = NULL; |
| 190 | - if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name']; |
|
| 191 | - if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country']; |
|
| 192 | - if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance']; |
|
| 212 | + if (isset($row['source_name']) && $row['source_name'] != '') { |
|
| 213 | + $temp_array['source_name'] = $row['source_name']; |
|
| 214 | + } |
|
| 215 | + if (isset($row['over_country']) && $row['over_country'] != '') { |
|
| 216 | + $temp_array['over_country'] = $row['over_country']; |
|
| 217 | + } |
|
| 218 | + if (isset($row['distance']) && $row['distance'] != '') { |
|
| 219 | + $temp_array['distance'] = $row['distance']; |
|
| 220 | + } |
|
| 193 | 221 | $temp_array['query_number_rows'] = $num_rows; |
| 194 | 222 | $spotter_array[] = $temp_array; |
| 195 | 223 | } |
| 196 | - if ($num_rows == 0) return array(); |
|
| 224 | + if ($num_rows == 0) { |
|
| 225 | + return array(); |
|
| 226 | + } |
|
| 197 | 227 | $spotter_array[0]['query_number_rows'] = $num_rows; |
| 198 | 228 | return $spotter_array; |
| 199 | 229 | } |
@@ -224,8 +254,12 @@ discard block |
||
| 224 | 254 | { |
| 225 | 255 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 226 | 256 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 227 | - } else $limit_query = ""; |
|
| 228 | - } else $limit_query = ""; |
|
| 257 | + } else { |
|
| 258 | + $limit_query = ""; |
|
| 259 | + } |
|
| 260 | + } else { |
|
| 261 | + $limit_query = ""; |
|
| 262 | + } |
|
| 229 | 263 | |
| 230 | 264 | if ($sort != "") |
| 231 | 265 | { |
@@ -253,7 +287,9 @@ discard block |
||
| 253 | 287 | global $global_query; |
| 254 | 288 | |
| 255 | 289 | date_default_timezone_set('UTC'); |
| 256 | - if ($id == '') return array(); |
|
| 290 | + if ($id == '') { |
|
| 291 | + return array(); |
|
| 292 | + } |
|
| 257 | 293 | $additional_query = "tracker_output.famtrackid = :id"; |
| 258 | 294 | $query_values = array(':id' => $id); |
| 259 | 295 | $query = $global_query." WHERE ".$additional_query." "; |
@@ -396,8 +432,11 @@ discard block |
||
| 396 | 432 | $query .= " ORDER BY tracker_output.source_name ASC"; |
| 397 | 433 | |
| 398 | 434 | $sth = $this->db->prepare($query); |
| 399 | - if (!empty($query_values)) $sth->execute($query_values); |
|
| 400 | - else $sth->execute(); |
|
| 435 | + if (!empty($query_values)) { |
|
| 436 | + $sth->execute($query_values); |
|
| 437 | + } else { |
|
| 438 | + $sth->execute(); |
|
| 439 | + } |
|
| 401 | 440 | |
| 402 | 441 | $source_array = array(); |
| 403 | 442 | $temp_array = array(); |
@@ -452,7 +491,9 @@ discard block |
||
| 452 | 491 | date_default_timezone_set($globalTimezone); |
| 453 | 492 | $datetime = new DateTime(); |
| 454 | 493 | $offset = $datetime->format('P'); |
| 455 | - } else $offset = '+00:00'; |
|
| 494 | + } else { |
|
| 495 | + $offset = '+00:00'; |
|
| 496 | + } |
|
| 456 | 497 | |
| 457 | 498 | if ($globalDBdriver == 'mysql') { |
| 458 | 499 | $query = "SELECT DISTINCT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) as date |
@@ -608,7 +649,9 @@ discard block |
||
| 608 | 649 | { |
| 609 | 650 | return false; |
| 610 | 651 | } |
| 611 | - } else $altitude = 0; |
|
| 652 | + } else { |
|
| 653 | + $altitude = 0; |
|
| 654 | + } |
|
| 612 | 655 | |
| 613 | 656 | if ($heading != "") |
| 614 | 657 | { |
@@ -647,8 +690,12 @@ discard block |
||
| 647 | 690 | $latitude = 0; |
| 648 | 691 | $longitude = 0; |
| 649 | 692 | } |
| 650 | - if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
| 651 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
| 693 | + if ($heading == '' || $Common->isInteger($heading) === false) { |
|
| 694 | + $heading = 0; |
|
| 695 | + } |
|
| 696 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) { |
|
| 697 | + $groundspeed = 0; |
|
| 698 | + } |
|
| 652 | 699 | $query = "INSERT INTO tracker_output (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, comment, type) |
| 653 | 700 | VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:speed,:date,:format_source, :source_name,:comment,:type)"; |
| 654 | 701 | |
@@ -813,12 +860,18 @@ discard block |
||
| 813 | 860 | $query = "SELECT DISTINCT tracker_output.ident, COUNT(tracker_output.ident) AS callsign_icao_count |
| 814 | 861 | FROM tracker_output".$filter_query." tracker_output.ident <> ''"; |
| 815 | 862 | if ($olderthanmonths > 0) { |
| 816 | - if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
| 817 | - else $query .= " AND tracker_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
| 863 | + if ($globalDBdriver == 'mysql') { |
|
| 864 | + $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
| 865 | + } else { |
|
| 866 | + $query .= " AND tracker_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
| 867 | + } |
|
| 818 | 868 | } |
| 819 | 869 | if ($sincedate != '') { |
| 820 | - if ($globalDBdriver == 'mysql') $query .= " AND tracker_output.date > '".$sincedate."'"; |
|
| 821 | - else $query .= " AND tracker_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
| 870 | + if ($globalDBdriver == 'mysql') { |
|
| 871 | + $query .= " AND tracker_output.date > '".$sincedate."'"; |
|
| 872 | + } else { |
|
| 873 | + $query .= " AND tracker_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
| 874 | + } |
|
| 822 | 875 | } |
| 823 | 876 | $query_values = array(); |
| 824 | 877 | if ($year != '') { |
@@ -849,7 +902,9 @@ discard block |
||
| 849 | 902 | } |
| 850 | 903 | } |
| 851 | 904 | $query .= " GROUP BY tracker_output.ident ORDER BY callsign_icao_count DESC"; |
| 852 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
| 905 | + if ($limit) { |
|
| 906 | + $query .= " LIMIT 10 OFFSET 0"; |
|
| 907 | + } |
|
| 853 | 908 | |
| 854 | 909 | $sth = $this->db->prepare($query); |
| 855 | 910 | $sth->execute($query_values); |
@@ -884,7 +939,9 @@ discard block |
||
| 884 | 939 | date_default_timezone_set($globalTimezone); |
| 885 | 940 | $datetime = new DateTime(); |
| 886 | 941 | $offset = $datetime->format('P'); |
| 887 | - } else $offset = '+00:00'; |
|
| 942 | + } else { |
|
| 943 | + $offset = '+00:00'; |
|
| 944 | + } |
|
| 888 | 945 | |
| 889 | 946 | if ($globalDBdriver == 'mysql') { |
| 890 | 947 | $query = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -934,7 +991,9 @@ discard block |
||
| 934 | 991 | date_default_timezone_set($globalTimezone); |
| 935 | 992 | $datetime = new DateTime(); |
| 936 | 993 | $offset = $datetime->format('P'); |
| 937 | - } else $offset = '+00:00'; |
|
| 994 | + } else { |
|
| 995 | + $offset = '+00:00'; |
|
| 996 | + } |
|
| 938 | 997 | $filter_query = $this->getFilter($filters,true,true); |
| 939 | 998 | if ($globalDBdriver == 'mysql') { |
| 940 | 999 | $query = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -980,7 +1039,9 @@ discard block |
||
| 980 | 1039 | date_default_timezone_set($globalTimezone); |
| 981 | 1040 | $datetime = new DateTime(); |
| 982 | 1041 | $offset = $datetime->format('P'); |
| 983 | - } else $offset = '+00:00'; |
|
| 1042 | + } else { |
|
| 1043 | + $offset = '+00:00'; |
|
| 1044 | + } |
|
| 984 | 1045 | $filter_query = $this->getFilter($filters,true,true); |
| 985 | 1046 | if ($globalDBdriver == 'mysql') { |
| 986 | 1047 | $query = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1028,7 +1089,9 @@ discard block |
||
| 1028 | 1089 | date_default_timezone_set($globalTimezone); |
| 1029 | 1090 | $datetime = new DateTime(); |
| 1030 | 1091 | $offset = $datetime->format('P'); |
| 1031 | - } else $offset = '+00:00'; |
|
| 1092 | + } else { |
|
| 1093 | + $offset = '+00:00'; |
|
| 1094 | + } |
|
| 1032 | 1095 | |
| 1033 | 1096 | if ($globalDBdriver == 'mysql') { |
| 1034 | 1097 | $query = "SELECT YEAR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count |
@@ -1077,7 +1140,9 @@ discard block |
||
| 1077 | 1140 | date_default_timezone_set($globalTimezone); |
| 1078 | 1141 | $datetime = new DateTime(); |
| 1079 | 1142 | $offset = $datetime->format('P'); |
| 1080 | - } else $offset = '+00:00'; |
|
| 1143 | + } else { |
|
| 1144 | + $offset = '+00:00'; |
|
| 1145 | + } |
|
| 1081 | 1146 | $filter_query = $this->getFilter($filters,true,true); |
| 1082 | 1147 | if ($globalDBdriver == 'mysql') { |
| 1083 | 1148 | $query = "SELECT MONTH(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count |
@@ -1126,7 +1191,9 @@ discard block |
||
| 1126 | 1191 | date_default_timezone_set($globalTimezone); |
| 1127 | 1192 | $datetime = new DateTime(); |
| 1128 | 1193 | $offset = $datetime->format('P'); |
| 1129 | - } else $offset = '+00:00'; |
|
| 1194 | + } else { |
|
| 1195 | + $offset = '+00:00'; |
|
| 1196 | + } |
|
| 1130 | 1197 | |
| 1131 | 1198 | $orderby_sql = ''; |
| 1132 | 1199 | if ($orderby == "hour") |
@@ -1195,7 +1262,9 @@ discard block |
||
| 1195 | 1262 | date_default_timezone_set($globalTimezone); |
| 1196 | 1263 | $datetime = new DateTime($date); |
| 1197 | 1264 | $offset = $datetime->format('P'); |
| 1198 | - } else $offset = '+00:00'; |
|
| 1265 | + } else { |
|
| 1266 | + $offset = '+00:00'; |
|
| 1267 | + } |
|
| 1199 | 1268 | |
| 1200 | 1269 | if ($globalDBdriver == 'mysql') { |
| 1201 | 1270 | $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1243,7 +1312,9 @@ discard block |
||
| 1243 | 1312 | date_default_timezone_set($globalTimezone); |
| 1244 | 1313 | $datetime = new DateTime(); |
| 1245 | 1314 | $offset = $datetime->format('P'); |
| 1246 | - } else $offset = '+00:00'; |
|
| 1315 | + } else { |
|
| 1316 | + $offset = '+00:00'; |
|
| 1317 | + } |
|
| 1247 | 1318 | |
| 1248 | 1319 | if ($globalDBdriver == 'mysql') { |
| 1249 | 1320 | $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1307,8 +1378,11 @@ discard block |
||
| 1307 | 1378 | $query_values = array_merge($query_values,array(':month' => $month)); |
| 1308 | 1379 | } |
| 1309 | 1380 | } |
| 1310 | - if (empty($query_values)) $queryi .= $this->getFilter($filters); |
|
| 1311 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 1381 | + if (empty($query_values)) { |
|
| 1382 | + $queryi .= $this->getFilter($filters); |
|
| 1383 | + } else { |
|
| 1384 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 1385 | + } |
|
| 1312 | 1386 | |
| 1313 | 1387 | $sth = $this->db->prepare($queryi); |
| 1314 | 1388 | $sth->execute($query_values); |
@@ -1330,7 +1404,9 @@ discard block |
||
| 1330 | 1404 | date_default_timezone_set($globalTimezone); |
| 1331 | 1405 | $datetime = new DateTime(); |
| 1332 | 1406 | $offset = $datetime->format('P'); |
| 1333 | - } else $offset = '+00:00'; |
|
| 1407 | + } else { |
|
| 1408 | + $offset = '+00:00'; |
|
| 1409 | + } |
|
| 1334 | 1410 | |
| 1335 | 1411 | if ($globalDBdriver == 'mysql') { |
| 1336 | 1412 | $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1434,7 +1510,9 @@ discard block |
||
| 1434 | 1510 | */ |
| 1435 | 1511 | public function parseDirection($direction = 0) |
| 1436 | 1512 | { |
| 1437 | - if ($direction == '') $direction = 0; |
|
| 1513 | + if ($direction == '') { |
|
| 1514 | + $direction = 0; |
|
| 1515 | + } |
|
| 1438 | 1516 | $direction_array = array(); |
| 1439 | 1517 | $temp_array = array(); |
| 1440 | 1518 | |
@@ -1523,7 +1601,9 @@ discard block |
||
| 1523 | 1601 | $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 1524 | 1602 | |
| 1525 | 1603 | $Connection = new Connection($this->db); |
| 1526 | - if (!$Connection->tableExists('countries')) return ''; |
|
| 1604 | + if (!$Connection->tableExists('countries')) { |
|
| 1605 | + return ''; |
|
| 1606 | + } |
|
| 1527 | 1607 | |
| 1528 | 1608 | try { |
| 1529 | 1609 | /* |
@@ -1543,9 +1623,13 @@ discard block |
||
| 1543 | 1623 | $sth->closeCursor(); |
| 1544 | 1624 | if (count($row) > 0) { |
| 1545 | 1625 | return $row; |
| 1546 | - } else return ''; |
|
| 1626 | + } else { |
|
| 1627 | + return ''; |
|
| 1628 | + } |
|
| 1547 | 1629 | } catch (PDOException $e) { |
| 1548 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
| 1630 | + if (isset($globalDebug) && $globalDebug) { |
|
| 1631 | + echo 'Error : '.$e->getMessage()."\n"; |
|
| 1632 | + } |
|
| 1549 | 1633 | return ''; |
| 1550 | 1634 | } |
| 1551 | 1635 | |
@@ -1563,7 +1647,9 @@ discard block |
||
| 1563 | 1647 | $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); |
| 1564 | 1648 | |
| 1565 | 1649 | $Connection = new Connection($this->db); |
| 1566 | - if (!$Connection->tableExists('countries')) return ''; |
|
| 1650 | + if (!$Connection->tableExists('countries')) { |
|
| 1651 | + return ''; |
|
| 1652 | + } |
|
| 1567 | 1653 | |
| 1568 | 1654 | try { |
| 1569 | 1655 | $query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1"; |
@@ -1575,9 +1661,13 @@ discard block |
||
| 1575 | 1661 | $sth->closeCursor(); |
| 1576 | 1662 | if (count($row) > 0) { |
| 1577 | 1663 | return $row; |
| 1578 | - } else return ''; |
|
| 1664 | + } else { |
|
| 1665 | + return ''; |
|
| 1666 | + } |
|
| 1579 | 1667 | } catch (PDOException $e) { |
| 1580 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
| 1668 | + if (isset($globalDebug) && $globalDebug) { |
|
| 1669 | + echo 'Error : '.$e->getMessage()."\n"; |
|
| 1670 | + } |
|
| 1581 | 1671 | return ''; |
| 1582 | 1672 | } |
| 1583 | 1673 | |
@@ -1595,7 +1685,9 @@ discard block |
||
| 1595 | 1685 | { |
| 1596 | 1686 | global $globalBitlyAccessToken; |
| 1597 | 1687 | |
| 1598 | - if ($globalBitlyAccessToken == '') return $url; |
|
| 1688 | + if ($globalBitlyAccessToken == '') { |
|
| 1689 | + return $url; |
|
| 1690 | + } |
|
| 1599 | 1691 | |
| 1600 | 1692 | $google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url; |
| 1601 | 1693 | |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | /** |
| 15 | 15 | * Get SQL query part for filter used |
| 16 | 16 | * @param Array $filter the filter |
| 17 | - * @return Array the SQL part |
|
| 17 | + * @return string the SQL part |
|
| 18 | 18 | */ |
| 19 | 19 | public function getFilter($filter = array(),$where = false,$and = false) { |
| 20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
@@ -759,10 +759,6 @@ discard block |
||
| 759 | 759 | * |
| 760 | 760 | * @param String $famtrackid the ID from flightaware |
| 761 | 761 | * @param String $ident the flight ident |
| 762 | - * @param String $aircraft_icao the aircraft type |
|
| 763 | - * @param String $departure_airport_icao the departure airport |
|
| 764 | - * @param String $arrival_airport_icao the arrival airport |
|
| 765 | - * @return String success or false |
|
| 766 | 762 | * |
| 767 | 763 | */ |
| 768 | 764 | public function addLiveTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '') |
@@ -29,7 +29,9 @@ discard block |
||
| 29 | 29 | if (isset($filter[0]['source'])) { |
| 30 | 30 | $filters = array_merge($filters,$filter); |
| 31 | 31 | } |
| 32 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 32 | + if (is_array($globalFilter)) { |
|
| 33 | + $filter = array_merge($filter,$globalFilter); |
|
| 34 | + } |
|
| 33 | 35 | $filter_query_join = ''; |
| 34 | 36 | $filter_query_where = ''; |
| 35 | 37 | foreach($filters as $flt) { |
@@ -76,8 +78,11 @@ discard block |
||
| 76 | 78 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 77 | 79 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
| 78 | 80 | } |
| 79 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
| 80 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
| 81 | + if ($filter_query_where == '' && $where) { |
|
| 82 | + $filter_query_where = ' WHERE'; |
|
| 83 | + } elseif ($filter_query_where != '' && $and) { |
|
| 84 | + $filter_query_where .= ' AND'; |
|
| 85 | + } |
|
| 81 | 86 | if ($filter_query_where != '') { |
| 82 | 87 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
| 83 | 88 | } |
@@ -119,7 +124,9 @@ discard block |
||
| 119 | 124 | } |
| 120 | 125 | } |
| 121 | 126 | |
| 122 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 127 | + if (!isset($globalLiveInterval)) { |
|
| 128 | + $globalLiveInterval = '200'; |
|
| 129 | + } |
|
| 123 | 130 | if ($globalDBdriver == 'mysql') { |
| 124 | 131 | //$query = "SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate"; |
| 125 | 132 | $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate'.$filter_query.$orderby_query; |
@@ -144,7 +151,9 @@ discard block |
||
| 144 | 151 | |
| 145 | 152 | $filter_query = $this->getFilter($filter,true,true); |
| 146 | 153 | |
| 147 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 154 | + if (!isset($globalLiveInterval)) { |
|
| 155 | + $globalLiveInterval = '200'; |
|
| 156 | + } |
|
| 148 | 157 | if ($globalDBdriver == 'mysql') { |
| 149 | 158 | $query = 'SELECT tracker_live.ident, tracker_live.type,tracker_live.famtrackid, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
| 150 | 159 | FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate'.$filter_query." tracker_live.latitude <> 0 AND tracker_live.longitude <> 0"; |
@@ -182,7 +191,9 @@ discard block |
||
| 182 | 191 | |
| 183 | 192 | $filter_query = $this->getFilter($filter,true,true); |
| 184 | 193 | |
| 185 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 194 | + if (!isset($globalLiveInterval)) { |
|
| 195 | + $globalLiveInterval = '200'; |
|
| 196 | + } |
|
| 186 | 197 | if ($globalDBdriver == 'mysql') { |
| 187 | 198 | $query = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
| 188 | 199 | FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' |
@@ -215,7 +226,9 @@ discard block |
||
| 215 | 226 | global $globalDBdriver, $globalLiveInterval; |
| 216 | 227 | $filter_query = $this->getFilter($filter,true,true); |
| 217 | 228 | |
| 218 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 229 | + if (!isset($globalLiveInterval)) { |
|
| 230 | + $globalLiveInterval = '200'; |
|
| 231 | + } |
|
| 219 | 232 | if ($globalDBdriver == 'mysql') { |
| 220 | 233 | $query = 'SELECT COUNT(DISTINCT tracker_live.famtrackid) as nb FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
| 221 | 234 | } else { |
@@ -243,7 +256,9 @@ discard block |
||
| 243 | 256 | { |
| 244 | 257 | global $globalDBdriver, $globalLiveInterval; |
| 245 | 258 | $Spotter = new Spotter($this->db); |
| 246 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 259 | + if (!isset($globalLiveInterval)) { |
|
| 260 | + $globalLiveInterval = '200'; |
|
| 261 | + } |
|
| 247 | 262 | $filter_query = $this->getFilter($filter); |
| 248 | 263 | |
| 249 | 264 | if (is_array($coord)) { |
@@ -251,7 +266,9 @@ discard block |
||
| 251 | 266 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 252 | 267 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 253 | 268 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 254 | - } else return array(); |
|
| 269 | + } else { |
|
| 270 | + return array(); |
|
| 271 | + } |
|
| 255 | 272 | if ($globalDBdriver == 'mysql') { |
| 256 | 273 | $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND tracker_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND tracker_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY tracker_live.famtrackid'.$filter_query; |
| 257 | 274 | } else { |
@@ -441,11 +458,15 @@ discard block |
||
| 441 | 458 | //$query = self::$global_query.' WHERE tracker_live.famtrackid = :id ORDER BY date'; |
| 442 | 459 | if ($globalDBdriver == 'mysql') { |
| 443 | 460 | $query = 'SELECT tracker_live.* FROM tracker_live WHERE tracker_live.famtrackid = :id'; |
| 444 | - if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
| 461 | + if ($liveinterval) { |
|
| 462 | + $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
| 463 | + } |
|
| 445 | 464 | $query .= ' ORDER BY date'; |
| 446 | 465 | } else { |
| 447 | 466 | $query = 'SELECT tracker_live.* FROM tracker_live WHERE tracker_live.famtrackid = :id'; |
| 448 | - if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
| 467 | + if ($liveinterval) { |
|
| 468 | + $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
| 469 | + } |
|
| 449 | 470 | $query .= ' ORDER BY date'; |
| 450 | 471 | } |
| 451 | 472 | |
@@ -540,7 +561,9 @@ discard block |
||
| 540 | 561 | $i++; |
| 541 | 562 | $j++; |
| 542 | 563 | if ($j == 30) { |
| 543 | - if ($globalDebug) echo "."; |
|
| 564 | + if ($globalDebug) { |
|
| 565 | + echo "."; |
|
| 566 | + } |
|
| 544 | 567 | try { |
| 545 | 568 | |
| 546 | 569 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
@@ -787,7 +810,9 @@ discard block |
||
| 787 | 810 | { |
| 788 | 811 | return false; |
| 789 | 812 | } |
| 790 | - } else return ''; |
|
| 813 | + } else { |
|
| 814 | + return ''; |
|
| 815 | + } |
|
| 791 | 816 | |
| 792 | 817 | if ($longitude != '') |
| 793 | 818 | { |
@@ -795,7 +820,9 @@ discard block |
||
| 795 | 820 | { |
| 796 | 821 | return false; |
| 797 | 822 | } |
| 798 | - } else return ''; |
|
| 823 | + } else { |
|
| 824 | + return ''; |
|
| 825 | + } |
|
| 799 | 826 | |
| 800 | 827 | if ($altitude != '') |
| 801 | 828 | { |
@@ -803,7 +830,9 @@ discard block |
||
| 803 | 830 | { |
| 804 | 831 | return false; |
| 805 | 832 | } |
| 806 | - } else $altitude = 0; |
|
| 833 | + } else { |
|
| 834 | + $altitude = 0; |
|
| 835 | + } |
|
| 807 | 836 | |
| 808 | 837 | if ($heading != '') |
| 809 | 838 | { |
@@ -811,7 +840,9 @@ discard block |
||
| 811 | 840 | { |
| 812 | 841 | return false; |
| 813 | 842 | } |
| 814 | - } else $heading = 0; |
|
| 843 | + } else { |
|
| 844 | + $heading = 0; |
|
| 845 | + } |
|
| 815 | 846 | |
| 816 | 847 | if ($groundspeed != '') |
| 817 | 848 | { |
@@ -819,9 +850,13 @@ discard block |
||
| 819 | 850 | { |
| 820 | 851 | return false; |
| 821 | 852 | } |
| 822 | - } else $groundspeed = 0; |
|
| 853 | + } else { |
|
| 854 | + $groundspeed = 0; |
|
| 855 | + } |
|
| 823 | 856 | date_default_timezone_set('UTC'); |
| 824 | - if ($date == '') $date = date("Y-m-d H:i:s", time()); |
|
| 857 | + if ($date == '') { |
|
| 858 | + $date = date("Y-m-d H:i:s", time()); |
|
| 859 | + } |
|
| 825 | 860 | |
| 826 | 861 | |
| 827 | 862 | $famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING); |
@@ -837,8 +872,12 @@ discard block |
||
| 837 | 872 | $comment = filter_var($comment,FILTER_SANITIZE_STRING); |
| 838 | 873 | $type = filter_var($type,FILTER_SANITIZE_STRING); |
| 839 | 874 | |
| 840 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 841 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 875 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) { |
|
| 876 | + $groundspeed = 0; |
|
| 877 | + } |
|
| 878 | + if ($heading == '' || $Common->isInteger($heading) === false ) { |
|
| 879 | + $heading = 0; |
|
| 880 | + } |
|
| 842 | 881 | |
| 843 | 882 | $query = 'INSERT INTO tracker_live (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) |
| 844 | 883 | VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:comment,:type)'; |
@@ -53,7 +53,12 @@ discard block |
||
| 53 | 53 | } else { |
| 54 | 54 | for (var i = 0; i < viewer.dataSources.get(dsn).entities.values.length; i++) { |
| 55 | 55 | var entity = viewer.dataSources.get(dsn).entities.values[i]; |
| 56 | - if (parseInt(entity.lastupdate) < Math.floor(Date.now()-<?php if (isset($globalMapRefresh)) print $globalMapRefresh*2000; else print '60000'; ?>)) { |
|
| 56 | + if (parseInt(entity.lastupdate) < Math.floor(Date.now()-<?php if (isset($globalMapRefresh)) { |
|
| 57 | + print $globalMapRefresh*2000; |
|
| 58 | +} else { |
|
| 59 | + print '60000'; |
|
| 60 | +} |
|
| 61 | +?>)) { |
|
| 57 | 62 | viewer.dataSources.get(dsn).entities.remove(entity); |
| 58 | 63 | } else { |
| 59 | 64 | //console.log(parseInt(entity.lastupdate)+' > '+Math.floor(Date.now()-100)); |
@@ -127,7 +132,12 @@ discard block |
||
| 127 | 132 | function(){ |
| 128 | 133 | updateMarineData(); |
| 129 | 134 | } |
| 130 | - ,<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000; else print '30000'; ?>); |
|
| 135 | + ,<?php if (isset($globalMapRefresh)) { |
|
| 136 | + print $globalMapRefresh*1000; |
|
| 137 | +} else { |
|
| 138 | + print '30000'; |
|
| 139 | +} |
|
| 140 | +?>); |
|
| 131 | 141 | } else { |
| 132 | 142 | var clockViewModel = new Cesium.ClockViewModel(viewer.clock); |
| 133 | 143 | var animationViewModel = new Cesium.AnimationViewModel(clockViewModel); |
@@ -3,11 +3,18 @@ discard block |
||
| 3 | 3 | require_once('../require/class.Language.php'); |
| 4 | 4 | |
| 5 | 5 | // Compressed GeoJson is used if true |
| 6 | -if (!isset($globalJsonCompress)) $compress = true; |
|
| 7 | -else $compress = $globalJsonCompress; |
|
| 6 | +if (!isset($globalJsonCompress)) { |
|
| 7 | + $compress = true; |
|
| 8 | +} else { |
|
| 9 | + $compress = $globalJsonCompress; |
|
| 10 | +} |
|
| 8 | 11 | |
| 9 | -if (isset($_GET['ident'])) $ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING); |
|
| 10 | -if (isset($_GET['flightaware_id'])) $flightaware_id = filter_input(INPUT_GET,'flightaware_id',FILTER_SANITIZE_STRING); |
|
| 12 | +if (isset($_GET['ident'])) { |
|
| 13 | + $ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING); |
|
| 14 | +} |
|
| 15 | +if (isset($_GET['flightaware_id'])) { |
|
| 16 | + $flightaware_id = filter_input(INPUT_GET,'flightaware_id',FILTER_SANITIZE_STRING); |
|
| 17 | +} |
|
| 11 | 18 | ?> |
| 12 | 19 | |
| 13 | 20 | |
@@ -72,9 +79,12 @@ discard block |
||
| 72 | 79 | |
| 73 | 80 | function update_airportsLayer() { |
| 74 | 81 | <?php |
| 75 | - if (isset($_COOKIE['AirportZoom'])) $getZoom = $_COOKIE['AirportZoom']; |
|
| 76 | - else $getZoom = '7'; |
|
| 77 | -?> |
|
| 82 | + if (isset($_COOKIE['AirportZoom'])) { |
|
| 83 | + $getZoom = $_COOKIE['AirportZoom']; |
|
| 84 | + } else { |
|
| 85 | + $getZoom = '7'; |
|
| 86 | + } |
|
| 87 | + ?> |
|
| 78 | 88 | if (typeof airportsLayer != 'undefined') { |
| 79 | 89 | if (map.hasLayer(airportsLayer) == true) { |
| 80 | 90 | map.removeLayer(airportsLayer); |
@@ -290,9 +300,13 @@ discard block |
||
| 290 | 300 | if (callsign != ""){ markerLabel += callsign; } |
| 291 | 301 | if (departure_airport_code != "" && arrival_airport_code != "" && departure_airport_code != "NA" && arrival_airport_code != "NA"){ markerLabel += ' ( '+departure_airport_code+' - '+arrival_airport_code+' )'; } |
| 292 | 302 | <?php |
| 293 | - if (isset($_COOKIE['IconColor'])) $IconColor = $_COOKIE['IconColor']; |
|
| 294 | - elseif (isset($globalAircraftIconColor)) $IconColor = $globalAircraftIconColor; |
|
| 295 | - else $IconColor = '1a3151'; |
|
| 303 | + if (isset($_COOKIE['IconColor'])) { |
|
| 304 | + $IconColor = $_COOKIE['IconColor']; |
|
| 305 | + } elseif (isset($globalAircraftIconColor)) { |
|
| 306 | + $IconColor = $globalAircraftIconColor; |
|
| 307 | + } else { |
|
| 308 | + $IconColor = '1a3151'; |
|
| 309 | + } |
|
| 296 | 310 | if (!isset($ident) && !isset($flightaware_id)) { |
| 297 | 311 | ?> |
| 298 | 312 | info_update(feature.properties.fc); |
@@ -340,7 +354,12 @@ discard block |
||
| 340 | 354 | <?php |
| 341 | 355 | } else { |
| 342 | 356 | ?> |
| 343 | - var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000); |
|
| 357 | + var movingtime = Math.round(<?php if (isset($archiveupdatetime)) { |
|
| 358 | + print $archiveupdatetime*1000; |
|
| 359 | +} else { |
|
| 360 | + print $globalMapRefresh*1000+20000; |
|
| 361 | +} |
|
| 362 | +?>+feature.properties.sqt*1000); |
|
| 344 | 363 | return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{ |
| 345 | 364 | <?php |
| 346 | 365 | } |
@@ -382,7 +401,12 @@ discard block |
||
| 382 | 401 | <?php |
| 383 | 402 | } else { |
| 384 | 403 | ?> |
| 385 | - var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000); |
|
| 404 | + var movingtime = Math.round(<?php if (isset($archiveupdatetime)) { |
|
| 405 | + print $archiveupdatetime*1000; |
|
| 406 | +} else { |
|
| 407 | + print $globalMapRefresh*1000+20000; |
|
| 408 | +} |
|
| 409 | +?>+feature.properties.sqt*1000); |
|
| 386 | 410 | return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{ |
| 387 | 411 | <?php |
| 388 | 412 | } |
@@ -422,7 +446,12 @@ discard block |
||
| 422 | 446 | <?php |
| 423 | 447 | } else { |
| 424 | 448 | ?> |
| 425 | - var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000); |
|
| 449 | + var movingtime = Math.round(<?php if (isset($archiveupdatetime)) { |
|
| 450 | + print $archiveupdatetime*1000; |
|
| 451 | +} else { |
|
| 452 | + print $globalMapRefresh*1000+20000; |
|
| 453 | +} |
|
| 454 | +?>+feature.properties.sqt*1000); |
|
| 426 | 455 | return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{ |
| 427 | 456 | <?php |
| 428 | 457 | } |
@@ -759,13 +788,23 @@ discard block |
||
| 759 | 788 | if (isset($archive) && $archive) { |
| 760 | 789 | ?> |
| 761 | 790 | //then load it again every 30 seconds |
| 762 | - // var reload = setInterval(function(){if (noTimeout) getLiveData(0)},<?php if (isset($globalMapRefresh)) print ($globalMapRefresh*1000)/2; else print '15000'; ?>); |
|
| 791 | + // var reload = setInterval(function(){if (noTimeout) getLiveData(0)},<?php if (isset($globalMapRefresh)) { |
|
| 792 | + print ($globalMapRefresh*1000)/2; |
|
| 793 | +} else { |
|
| 794 | + print '15000'; |
|
| 795 | +} |
|
| 796 | +?>); |
|
| 763 | 797 | reloadPage = setInterval(function(){if (noTimeout) getLiveData(0)},<?php print $archiveupdatetime*1000; ?>); |
| 764 | 798 | <?php |
| 765 | 799 | } else { |
| 766 | 800 | ?> |
| 767 | 801 | //then load it again every 30 seconds |
| 768 | - reloadPage = setInterval(function(){if (noTimeout) getLiveData(0)},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000; else print '30000'; ?>); |
|
| 802 | + reloadPage = setInterval(function(){if (noTimeout) getLiveData(0)},<?php if (isset($globalMapRefresh)) { |
|
| 803 | + print $globalMapRefresh*1000; |
|
| 804 | +} else { |
|
| 805 | + print '30000'; |
|
| 806 | +} |
|
| 807 | +?>); |
|
| 769 | 808 | var currentdate = new Date(); |
| 770 | 809 | var currentyear = new Date().getFullYear(); |
| 771 | 810 | var begindate = new Date(Date.UTC(currentyear,11,24,2,0,0,0)); |
@@ -777,7 +816,12 @@ discard block |
||
| 777 | 816 | if (!((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) && (isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) { |
| 778 | 817 | ?> |
| 779 | 818 | update_polarLayer(); |
| 780 | - setInterval(function(){map.removeLayer(polarLayer);update_polarLayer()},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000*2; else print '60000'; ?>); |
|
| 819 | + setInterval(function(){map.removeLayer(polarLayer);update_polarLayer()},<?php if (isset($globalMapRefresh)) { |
|
| 820 | + print $globalMapRefresh*1000*2; |
|
| 821 | +} else { |
|
| 822 | + print '60000'; |
|
| 823 | +} |
|
| 824 | +?>); |
|
| 781 | 825 | <?php |
| 782 | 826 | } |
| 783 | 827 | ?> |
@@ -792,7 +836,12 @@ discard block |
||
| 792 | 836 | if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) { |
| 793 | 837 | ?> |
| 794 | 838 | update_atcLayer(); |
| 795 | - setInterval(function(){map.removeLayer(atcLayer);update_atcLayer()},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000*2; else print '60000'; ?>); |
|
| 839 | + setInterval(function(){map.removeLayer(atcLayer);update_atcLayer()},<?php if (isset($globalMapRefresh)) { |
|
| 840 | + print $globalMapRefresh*1000*2; |
|
| 841 | +} else { |
|
| 842 | + print '60000'; |
|
| 843 | +} |
|
| 844 | +?>); |
|
| 796 | 845 | <?php |
| 797 | 846 | } |
| 798 | 847 | ?> |
@@ -53,7 +53,12 @@ discard block |
||
| 53 | 53 | } else { |
| 54 | 54 | for (var i = 0; i < viewer.dataSources.get(dsn).entities.values.length; i++) { |
| 55 | 55 | var entity = viewer.dataSources.get(dsn).entities.values[i]; |
| 56 | - if (parseInt(entity.lastupdate) < Math.floor(Date.now()-<?php if (isset($globalMapRefresh)) print $globalMapRefresh*2000; else print '60000'; ?>)) { |
|
| 56 | + if (parseInt(entity.lastupdate) < Math.floor(Date.now()-<?php if (isset($globalMapRefresh)) { |
|
| 57 | + print $globalMapRefresh*2000; |
|
| 58 | +} else { |
|
| 59 | + print '60000'; |
|
| 60 | +} |
|
| 61 | +?>)) { |
|
| 57 | 62 | viewer.dataSources.get(dsn).entities.remove(entity); |
| 58 | 63 | } else { |
| 59 | 64 | //console.log(parseInt(entity.lastupdate)+' > '+Math.floor(Date.now()-100)); |
@@ -127,7 +132,12 @@ discard block |
||
| 127 | 132 | function(){ |
| 128 | 133 | updateTrackerData(); |
| 129 | 134 | } |
| 130 | - ,<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000; else print '30000'; ?>); |
|
| 135 | + ,<?php if (isset($globalMapRefresh)) { |
|
| 136 | + print $globalMapRefresh*1000; |
|
| 137 | +} else { |
|
| 138 | + print '30000'; |
|
| 139 | +} |
|
| 140 | +?>); |
|
| 131 | 141 | } else { |
| 132 | 142 | var clockViewModel = new Cesium.ClockViewModel(viewer.clock); |
| 133 | 143 | var animationViewModel = new Cesium.AnimationViewModel(clockViewModel); |