| @@ 557-576 (lines=20) @@ | ||
| 554 | return $trainers; |
|
| 555 | } |
|
| 556 | ||
| 557 | public function getTrainerLevelRanking() { |
|
| 558 | $exclue = ""; |
|
| 559 | if (!empty(self::$config->system->trainer_blacklist)) { |
|
| 560 | $exclue .= " AND owner_name NOT IN ('".implode("','", self::$config->system->trainer_blacklist)."')"; |
|
| 561 | } |
|
| 562 | $req = "SELECT COUNT(*) AS count, level FROM (SELECT MAX(owner_level) as level FROM gym_defenders WHERE owner_level IS NOT NULL ".$exclue." GROUP BY owner_level, owner_name) x GROUP BY level"; |
|
| 563 | $result = $this->mysqli->query($req); |
|
| 564 | $levelData = array(); |
|
| 565 | while ($data = $result->fetch_object()) { |
|
| 566 | $levelData[$data->level] = $data->count; |
|
| 567 | } |
|
| 568 | for ($i = 5; $i <= 40; $i++) { |
|
| 569 | if (!isset($levelData[$i])) { |
|
| 570 | $levelData[$i] = 0; |
|
| 571 | } |
|
| 572 | } |
|
| 573 | # sort array again |
|
| 574 | ksort($levelData); |
|
| 575 | return $levelData; |
|
| 576 | } |
|
| 577 | ||
| 578 | public function getActivePokemon($trainer_name) { |
|
| 579 | $req = "SELECT pokemon_id, cp, atk_iv AS iv_attack, sta_iv AS iv_stamina, def_iv AS iv_defense, FROM_UNIXTIME(deployment_time) AS deployment_time, '1' AS active, fort_id as gym_id, FLOOR((UNIX_TIMESTAMP() - created) / 86400) AS last_scanned |
|
| @@ 604-623 (lines=20) @@ | ||
| 601 | return $pokemon; |
|
| 602 | } |
|
| 603 | ||
| 604 | public function getTrainerLevelCount($team_id) { |
|
| 605 | $exclue = ""; |
|
| 606 | if (!empty(self::$config->system->trainer_blacklist)) { |
|
| 607 | $exclue .= " AND owner_name NOT IN ('".implode("','", self::$config->system->trainer_blacklist)."')"; |
|
| 608 | } |
|
| 609 | $req = "SELECT COUNT(*) AS count, level FROM (SELECT MAX(owner_level) as level FROM gym_defenders WHERE owner_level IS NOT NULL AND team = '".$team_id."' ".$exclue." GROUP BY owner_level, owner_name) x GROUP BY level"; |
|
| 610 | $result = $this->mysqli->query($req); |
|
| 611 | $levelData = array(); |
|
| 612 | while ($data = $result->fetch_object()) { |
|
| 613 | $levelData[$data->level] = $data->count; |
|
| 614 | } |
|
| 615 | for ($i = 5; $i <= 40; $i++) { |
|
| 616 | if (!isset($levelData[$i])) { |
|
| 617 | $levelData[$i] = 0; |
|
| 618 | } |
|
| 619 | } |
|
| 620 | # sort array again |
|
| 621 | ksort($levelData); |
|
| 622 | return $levelData; |
|
| 623 | } |
|
| 624 | ||
| 625 | ||
| 626 | ///////// |
|
| @@ 561-580 (lines=20) @@ | ||
| 558 | return $trainers; |
|
| 559 | } |
|
| 560 | ||
| 561 | public function getTrainerLevelRanking() { |
|
| 562 | $exclue = ""; |
|
| 563 | if (!empty(self::$config->system->trainer_blacklist)) { |
|
| 564 | $exclue .= " AND owner_name NOT IN ('".implode("','", self::$config->system->trainer_blacklist)."')"; |
|
| 565 | } |
|
| 566 | $req = "SELECT COUNT(*) AS count, level FROM (SELECT MAX(owner_level) as level FROM gym_defenders WHERE owner_level IS NOT NULL ".$exclue." GROUP BY owner_level, owner_name) x GROUP BY level"; |
|
| 567 | $result = $this->mysqli->query($req); |
|
| 568 | $levelData = array(); |
|
| 569 | while ($data = $result->fetch_object()) { |
|
| 570 | $levelData[$data->level] = $data->count; |
|
| 571 | } |
|
| 572 | for ($i = 5; $i <= 40; $i++) { |
|
| 573 | if (!isset($levelData[$i])) { |
|
| 574 | $levelData[$i] = 0; |
|
| 575 | } |
|
| 576 | } |
|
| 577 | # sort array again |
|
| 578 | ksort($levelData); |
|
| 579 | return $levelData; |
|
| 580 | } |
|
| 581 | ||
| 582 | public function getActivePokemon($trainer_name) { |
|
| 583 | $req = "SELECT pokemon_id, cp, atk_iv AS iv_attack, sta_iv AS iv_stamina, def_iv AS iv_defense, TO_TIMESTAMP(deployment_time) AS deployment_time, '1' AS active, fort_id as gym_id, FLOOR((UNIX_TIMESTAMP() - created) / 86400) AS last_scanned |
|
| @@ 608-627 (lines=20) @@ | ||
| 605 | return $pokemon; |
|
| 606 | } |
|
| 607 | ||
| 608 | public function getTrainerLevelCount($team_id) { |
|
| 609 | $exclue = ""; |
|
| 610 | if (!empty(self::$config->system->trainer_blacklist)) { |
|
| 611 | $exclue .= " AND owner_name NOT IN ('".implode("','", self::$config->system->trainer_blacklist)."')"; |
|
| 612 | } |
|
| 613 | $req = "SELECT COUNT(*) AS count, level FROM (SELECT MAX(owner_level) as level FROM gym_defenders WHERE owner_level IS NOT NULL AND team = '".$team_id."' ".$exclue." GROUP BY owner_level, owner_name) x GROUP BY level"; |
|
| 614 | $result = $this->mysqli->query($req); |
|
| 615 | $levelData = array(); |
|
| 616 | while ($data = $result->fetch_object()) { |
|
| 617 | $levelData[$data->level] = $data->count; |
|
| 618 | } |
|
| 619 | for ($i = 5; $i <= 40; $i++) { |
|
| 620 | if (!isset($levelData[$i])) { |
|
| 621 | $levelData[$i] = 0; |
|
| 622 | } |
|
| 623 | } |
|
| 624 | # sort array again |
|
| 625 | ksort($levelData); |
|
| 626 | return $levelData; |
|
| 627 | } |
|
| 628 | ||
| 629 | ||
| 630 | ///////// |
|