| @@ 618-632 (lines=15) @@ | ||
| 615 | return $counts; |
|
| 616 | } |
|
| 617 | ||
| 618 | public function getPokemonSinceLastUpdate($pokemon_id, $last_update) { |
|
| 619 | $where = "WHERE p.pokemon_id = '".$pokemon_id."' AND (UNIX_TIMESTAMP(p.disappear_time) - (LENGTH(s.kind) - LENGTH( REPLACE ( kind, \"s\", \"\") )) * 900) > '".$last_update."'"; |
|
| 620 | $req = "SELECT count, (UNIX_TIMESTAMP(p.disappear_time) - (LENGTH(s.kind) - LENGTH( REPLACE ( kind, \"s\", \"\") )) * 900) as last_timestamp, (CONVERT_TZ(p.disappear_time, '+00:00', '".self::$time_offset."')) AS disappear_time_real, p.latitude, p.longitude |
|
| 621 | FROM pokemon p |
|
| 622 | JOIN spawnpoint s ON p.spawnpoint_id = s.id |
|
| 623 | JOIN (SELECT count(*) as count |
|
| 624 | FROM pokemon p |
|
| 625 | JOIN spawnpoint s ON p.spawnpoint_id = s.id |
|
| 626 | " . $where." |
|
| 627 | ) x |
|
| 628 | " . $where . " |
|
| 629 | ORDER BY last_timestamp DESC |
|
| 630 | LIMIT 0,1"; |
|
| 631 | $result = $this->mysqli->query($req); |
|
| 632 | $data = $result->fetch_object(); |
|
| 633 | return $data; |
|
| 634 | } |
|
| 635 | ||
| @@ 636-652 (lines=17) @@ | ||
| 633 | return $data; |
|
| 634 | } |
|
| 635 | ||
| 636 | public function getRaidsSinceLastUpdate($pokemon_id, $last_update) { |
|
| 637 | $where = "WHERE pokemon_id = '".$pokemon_id."' AND UNIX_TIMESTAMP(start) > '".$last_update."'"; |
|
| 638 | $req = "SELECT UNIX_TIMESTAMP(start) as start_timestamp, end, (CONVERT_TZ(end, '+00:00', '".self::$time_offset."')) AS end_time_real, latitude, longitude, count |
|
| 639 | FROM raid r |
|
| 640 | JOIN gym g |
|
| 641 | JOIN (SELECT count(*) as count |
|
| 642 | FROM raid |
|
| 643 | " . $where." |
|
| 644 | ) x |
|
| 645 | ON r.gym_id = g.gym_id |
|
| 646 | " . $where." |
|
| 647 | ORDER BY start DESC |
|
| 648 | LIMIT 0,1"; |
|
| 649 | $result = $this->mysqli->query($req); |
|
| 650 | $data = $result->fetch_object(); |
|
| 651 | return $data; |
|
| 652 | } |
|
| 653 | ||
| 654 | public function getCaptchaCount() { |
|
| 655 | $req = "SELECT SUM(accounts_captcha) AS total FROM mainworker"; |
|
| @@ 460-474 (lines=15) @@ | ||
| 457 | return $counts; |
|
| 458 | } |
|
| 459 | ||
| 460 | public function getPokemonSinceLastUpdate($pokemon_id, $last_update) { |
|
| 461 | $where = "WHERE p.pokemon_id = '".$pokemon_id."' AND p.expire_timestamp - (coalesce(CASE WHEN duration = 0 THEN NULL ELSE duration END ,30)*60) > '".$last_update."'"; |
|
| 462 | $req = "SELECT count, p.expire_timestamp - (coalesce(CASE WHEN duration = 0 THEN NULL ELSE duration END ,30)*60) AS last_timestamp, (FROM_UNIXTIME(p.expire_timestamp)) AS disappear_time_real, p.lat as latitude, p.lon as longitude |
|
| 463 | FROM sightings p |
|
| 464 | LEFT JOIN spawnpoints s ON p.spawn_id = s.spawn_id |
|
| 465 | JOIN (SELECT COUNT(*) AS count |
|
| 466 | FROM sightings p |
|
| 467 | LEFT JOIN spawnpoints s ON p.spawn_id = s.spawn_id |
|
| 468 | " . $where." |
|
| 469 | ) x |
|
| 470 | " . $where . " |
|
| 471 | ORDER BY last_timestamp DESC |
|
| 472 | LIMIT 0 , 1"; |
|
| 473 | $result = $this->mysqli->query($req); |
|
| 474 | $data = $result->fetch_object(); |
|
| 475 | return $data; |
|
| 476 | } |
|
| 477 | ||
| @@ 478-494 (lines=17) @@ | ||
| 475 | return $data; |
|
| 476 | } |
|
| 477 | ||
| 478 | public function getRaidsSinceLastUpdate($pokemon_id, $last_update) { |
|
| 479 | $where = "WHERE pokemon_id = '".$pokemon_id."AND".$last_update."'"; |
|
| 480 | $req = "SELECT time_battle AS start_timestamp, time_end as end, (FROM_UNIXTIME(time_end)) AS end_time_real, lat as latitude, lon as longitude, count |
|
| 481 | FROM raids r |
|
| 482 | JOIN forts g |
|
| 483 | JOIN (SELECT COUNT(*) AS count |
|
| 484 | FROM raids |
|
| 485 | " . $where." |
|
| 486 | ) x |
|
| 487 | ON r.fort_id = g.id |
|
| 488 | " . $where . " |
|
| 489 | ORDER BY time_battle DESC |
|
| 490 | LIMIT 0 , 1"; |
|
| 491 | $result = $this->mysqli->query($req); |
|
| 492 | $data = $result->fetch_object(); |
|
| 493 | return $data; |
|
| 494 | } |
|
| 495 | ||
| 496 | public function getCaptchaCount() { |
|
| 497 | $req = " SELECT COUNT(*) as total FROM accounts WHERE captchaed IS NOT NULL AND reason IS NULL"; |
|