예제 #1
0
 public function setWeeklyMedals($week)
 {
     require_once MODEL_PATH . "statistics.php";
     $keyArray = array("week_dev_points" => 1, "week_attack_points" => 2, "week_defense_points" => 3, "week_thief_points" => 4);
     $sm = new StatisticsModel();
     foreach ($keyArray as $columnName => $index) {
         $result = $sm->getTop10(TRUE, $columnName);
         if ($result != NULL) {
             $i = 0;
             while ($result->next()) {
                 $medal = $index . ":" . ++$i . ":" . $week;
                 $this->provider->executeQuery("UPDATE p_players SET medals=CONCAT_WS(',', medals, '%s') WHERE id=%s", array($medal, $result->row['id']));
             }
         }
         $result = $sm->getTop10(FALSE, $columnName);
         if (!($result != NULL)) {
             continue;
         }
         $i = 0;
         while ($result->next()) {
             $medal = $index + 4 . ":" . ++$i . ":" . $week;
             $this->provider->executeQuery("UPDATE p_alliances SET medals=CONCAT_WS(',', medals, '%s') WHERE id=%s", array($medal, $result->row['id']));
         }
     }
     $this->provider->executeQuery("UPDATE p_players   SET week_dev_points=0, week_attack_points=0, week_defense_points=0, week_thief_points=0");
     $this->provider->executeQuery("UPDATE p_alliances SET week_dev_points=0, week_attack_points=0, week_defense_points=0, week_thief_points=0");
     $sm->dispose();
 }
예제 #2
0
 function setWeeklyMedals($week)
 {
     require_once MODEL_PATH . 'statistics.php';
     $keyArray = array('week_dev_points' => 1, 'week_attack_points' => 2, 'week_defense_points' => 3, 'week_thief_points' => 4);
     $sm = new StatisticsModel();
     foreach ($keyArray as $columnName => $index) {
         $result = $sm->getTop10(TRUE, $columnName);
         if ($result != NULL) {
             $i = 0;
             while ($result->next()) {
                 $medal = $index . ':' . ++$i . ':' . $week;
                 $this->provider->executeQuery('UPDATE p_players SET medals=CONCAT_WS(\',\', medals, \'%s\') WHERE id=%s', array($medal, $result->row['id']));
             }
         }
         $result = $sm->getTop10(FALSE, $columnName);
         if ($result != NULL) {
             $i = 0;
             while ($result->next()) {
                 $medal = $index + 4 . ':' . ++$i . ':' . $week;
                 $this->provider->executeQuery('UPDATE p_alliances SET medals=CONCAT_WS(\',\', medals, \'%s\') WHERE id=%s', array($medal, $result->row['id']));
             }
             continue;
         }
     }
     $this->provider->executeQuery('UPDATE p_players   SET week_dev_points=0, week_attack_points=0, week_defense_points=0, week_thief_points=0');
     $this->provider->executeQuery('UPDATE p_alliances SET week_dev_points=0, week_attack_points=0, week_defense_points=0, week_thief_points=0');
     $sm->dispose();
 }
예제 #3
0
파일: main.php 프로젝트: davpal/Kuriex
 public function index()
 {
     $view = new ViewModel('main/index');
     $stats = new StatisticsModel();
     foreach ($stats->getStatistics() as $stat => $value) {
         $view->assign($stat, $value);
     }
     $view->display();
 }
예제 #4
0
 public function load()
 {
     parent::load();
     $this->selectedTabIndex = isset($_GET['t']) && is_numeric($_GET['t']) && 0 <= intval($_GET['t']) && intval($_GET['t']) <= 11 ? intval($_GET['t']) : 0;
     $this->isAdmin = $this->data['player_type'] == PLAYERTYPE_ADMIN;
     $this->_tb = isset($_GET['tb']) ? intval($_GET['tb']) : 0;
     $m = new StatisticsModel();
     $this->tatarRaised = $m->tatarRaised();
     if ($this->selectedTabIndex == 11 && !$this->tatarRaised) {
         $this->selectedTabIndex = 0;
     }
     $this->selectedRank = 0;
     if ($this->selectedTabIndex == 0) {
         if ($this->isPost() && isset($_POST['rank']) && isset($_POST['name'])) {
             if (trim($_POST['name']) != "") {
                 $this->selectedRank = intval($m->getPlayerRankByName(trim($_POST['name']), $this->_tb));
             } else {
                 if (0 < intval($_POST['rank'])) {
                     $this->selectedRank = intval($_POST['rank']);
                 }
             }
         } else {
             if (!isset($_GET['p'])) {
                 $this->selectedRank = 0 < $this->_tb && $this->data['tribe_id'] != $this->_tb ? 1 : intval($m->getPlayerRankById($this->player->playerId, $this->_tb));
             }
         }
         if ($this->isAdmin && !$this->isPost()) {
             if (isset($_GET['_cs']) && 0 < intval($_GET['_cs'])) {
                 $m->togglePlayerStatus(intval($_GET['_cs']));
                 $this->adminActionMessage = statistics_p_playerstatusch;
             } else {
                 if (isset($_GET['_dp']) && 0 < intval($_GET['_dp'])) {
                     if ($m->getPlayerType(intval($_GET['_dp'])) == PLAYERTYPE_NORMAL) {
                         $qm = new QueueJobModel();
                         $qm->deletePlayer(intval($_GET['_dp']));
                         $this->adminActionMessage = statistics_p_playerdeleted;
                     }
                 } else {
                     if (isset($_GET['_gd']) && 0 < intval($_GET['_gd']) && isset($_GET['_g']) && 0 <= intval($_GET['_g'])) {
                         $m->setPlayerGold(intval($_GET['_gd']), intval($_GET['_g']));
                         $this->adminActionMessage = statistics_p_goldwaschanged;
                     }
                 }
             }
         }
     } else {
         if ($this->selectedTabIndex == 1) {
             if ($this->isPost() && isset($_POST['rank']) && isset($_POST['name'])) {
                 if (trim($_POST['name']) != "") {
                     $this->selectedRank = intval($m->getAllianceRankByName(trim($_POST['name'])));
                 } else {
                     if (0 < intval($_POST['rank'])) {
                         $this->selectedRank = intval($_POST['rank']);
                     }
                 }
             } else {
                 if (!isset($_GET['p'])) {
                     $this->selectedRank = intval($m->getAllianceRankById(intval($this->data['alliance_id'])));
                 }
             }
         } else {
             if ($this->selectedTabIndex == 2) {
                 if ($this->isPost() && isset($_POST['rank']) && isset($_POST['name'])) {
                     if (trim($_POST['name']) != "") {
                         $this->selectedRank = intval($m->getVillageRankByName(trim($_POST['name'])));
                     } else {
                         if (0 < intval($_POST['rank'])) {
                             $this->selectedRank = intval($_POST['rank']);
                         }
                     }
                 } else {
                     if (!isset($_GET['p'])) {
                         $this->selectedRank = intval($m->getVillageRankById($this->data['selected_village_id']));
                     }
                 }
             } else {
                 if ($this->selectedTabIndex == 3) {
                     if ($this->isPost() && isset($_POST['rank']) && isset($_POST['name'])) {
                         if (trim($_POST['name']) != "") {
                             $this->selectedRank = intval($m->getHeroRankByName(trim($_POST['name'])));
                         } else {
                             if (0 < intval($_POST['rank'])) {
                                 $this->selectedRank = intval($_POST['rank']);
                             }
                         }
                     } else {
                         if (!isset($_GET['p'])) {
                             $this->selectedRank = intval($m->getHeroRankById($this->player->playerId));
                         }
                     }
                 } else {
                     if ($this->selectedTabIndex == 6 || $this->selectedTabIndex == 7) {
                         if ($this->isPost() && isset($_POST['rank']) && isset($_POST['name'])) {
                             if (trim($_POST['name']) != "") {
                                 $this->selectedRank = intval($m->getPlayersPointsByName(trim($_POST['name']), $this->selectedTabIndex == 6));
                             } else {
                                 if (0 < intval($_POST['rank'])) {
                                     $this->selectedRank = intval($_POST['rank']);
                                 }
                             }
                         } else {
                             if (!isset($_GET['p'])) {
                                 $this->selectedRank = intval($m->getPlayersPointsById($this->player->playerId, $this->selectedTabIndex == 6));
                             }
                         }
                     } else {
                         if ($this->selectedTabIndex == 9 || $this->selectedTabIndex == 10) {
                             if ($this->isPost() && isset($_POST['rank']) && isset($_POST['name'])) {
                                 if (trim($_POST['name']) != "") {
                                     $this->selectedRank = intval($m->getAlliancePointsRankByName(trim($_POST['name']), $this->selectedTabIndex == 9));
                                 } else {
                                     if (0 < intval($_POST['rank'])) {
                                         $this->selectedRank = intval($_POST['rank']);
                                     }
                                 }
                             } else {
                                 if (!isset($_GET['p'])) {
                                     $this->selectedRank = intval($m->getAlliancePointsRankById(intval($this->data['alliance_id']), $this->selectedTabIndex == 9));
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     if ($this->selectedTabIndex == 0) {
         $rowsCount = $m->getPlayerListCount($this->_tb);
         $this->pageCount = 0 < $rowsCount ? ceil($rowsCount / $this->pageSize) : 1;
         $this->pageIndex = 0 < $this->selectedRank ? floor(($this->selectedRank - 1) / $this->pageSize) : isset($_GET['p']) && is_numeric($_GET['p']) ? intval($_GET['p']) : 0;
         if ($this->pageCount <= $this->pageIndex) {
             $this->pageIndex = $this->pageCount - 1;
             $this->selectedRank = 0 - 1;
         }
         $this->dataList = $m->getPlayerList($this->pageIndex, $this->pageSize, $this->_tb);
     } else {
         if ($this->selectedTabIndex == 1) {
             $rowsCount = $m->getAllianceListCount();
             $this->pageCount = 0 < $rowsCount ? ceil($rowsCount / $this->pageSize) : 1;
             $this->pageIndex = 0 < $this->selectedRank ? floor(($this->selectedRank - 1) / $this->pageSize) : isset($_GET['p']) && is_numeric($_GET['p']) ? intval($_GET['p']) : 0;
             if ($this->pageCount <= $this->pageIndex) {
                 $this->pageIndex = $this->pageCount - 1;
                 $this->selectedRank = 0 - 1;
             }
             $this->dataList = $m->getAlliancesList($this->pageIndex, $this->pageSize);
         } else {
             if ($this->selectedTabIndex == 2) {
                 $rowsCount = $m->getVillageListCount();
                 $this->pageCount = 0 < $rowsCount ? ceil($rowsCount / $this->pageSize) : 1;
                 $this->pageIndex = 0 < $this->selectedRank ? floor(($this->selectedRank - 1) / $this->pageSize) : isset($_GET['p']) && is_numeric($_GET['p']) ? intval($_GET['p']) : 0;
                 if ($this->pageCount <= $this->pageIndex) {
                     $this->pageIndex = $this->pageCount - 1;
                     $this->selectedRank = 0 - 1;
                 }
                 $this->dataList = $m->getVillagesList($this->pageIndex, $this->pageSize);
             } else {
                 if ($this->selectedTabIndex == 3) {
                     $rowsCount = $m->getHeroListCount();
                     $this->pageCount = 0 < $rowsCount ? ceil($rowsCount / $this->pageSize) : 1;
                     $this->pageIndex = 0 < $this->selectedRank ? floor(($this->selectedRank - 1) / $this->pageSize) : isset($_GET['p']) && is_numeric($_GET['p']) ? intval($_GET['p']) : 0;
                     if ($this->pageCount <= $this->pageIndex) {
                         $this->pageIndex = $this->pageCount - 1;
                         $this->selectedRank = 0 - 1;
                     }
                     $this->dataList = $m->getHerosList($this->pageIndex, $this->pageSize);
                 } else {
                     if ($this->selectedTabIndex == 4) {
                         $this->generalData = $m->getGeneralSummary();
                     } else {
                         if ($this->selectedTabIndex == 6 || $this->selectedTabIndex == 7) {
                             $rowsCount = $m->getPlayersPointsListCount();
                             $this->pageCount = 0 < $rowsCount ? ceil($rowsCount / $this->pageSize) : 1;
                             $this->pageIndex = 0 < $this->selectedRank ? floor(($this->selectedRank - 1) / $this->pageSize) : isset($_GET['p']) && is_numeric($_GET['p']) ? intval($_GET['p']) : 0;
                             if ($this->pageCount <= $this->pageIndex) {
                                 $this->pageIndex = $this->pageCount - 1;
                                 $this->selectedRank = 0 - 1;
                             }
                             $this->dataList = $m->getPlayersPointsList($this->pageIndex, $this->pageSize, $this->selectedTabIndex == 6);
                         } else {
                             if ($this->selectedTabIndex == 9 || $this->selectedTabIndex == 10) {
                                 $rowsCount = $m->getAlliancePointsListCount();
                                 $this->pageCount = 0 < $rowsCount ? ceil($rowsCount / $this->pageSize) : 1;
                                 $this->pageIndex = 0 < $this->selectedRank ? floor(($this->selectedRank - 1) / $this->pageSize) : isset($_GET['p']) && is_numeric($_GET['p']) ? intval($_GET['p']) : 0;
                                 if ($this->pageCount <= $this->pageIndex) {
                                     $this->pageIndex = $this->pageCount - 1;
                                     $this->selectedRank = 0 - 1;
                                 }
                                 $this->dataList = $m->getAlliancePointsList($this->pageIndex, $this->pageSize, $this->selectedTabIndex == 9);
                             } else {
                                 if ($this->selectedTabIndex == 5 || $this->selectedTabIndex == 8) {
                                     if ($this->selectedTabIndex == 5) {
                                     }
                                     $this->top10Result = array("URL" => $this->selectedTabIndex == 5 ? "profile.php?uid=" : "alliance.php?id=", "TARGETNAME" => $this->selectedTabIndex == 5 ? $this->data['name'] : $this->data['alliance_name'], "TARGETID" => $this->selectedTabIndex == 5 ? $this->player->playerId : intval($this->data['alliance_id']), "TARGEPOINT_ATTACK" => $this->selectedTabIndex == 5 ? $this->data['week_attack_points'] : $m->getAlliancePoint(intval($this->data['alliance_id']), "week_attack_points"), "TARGEPOINT_DEFENSE" => $this->selectedTabIndex == 5 ? $this->data['week_defense_points'] : $m->getAlliancePoint(intval($this->data['alliance_id']), "week_defense_points"), "TARGEPOINT_DEV" => $this->selectedTabIndex == 5 ? $this->data['week_dev_points'] : $m->getAlliancePoint(intval($this->data['alliance_id']), "week_dev_points"), "TARGEPOINT_THIEF" => $this->selectedTabIndex == 5 ? $this->data['week_thief_points'] : $m->getAlliancePoint(intval($this->data['alliance_id']), "week_thief_points"), "ATTACK" => $m->getTop10($this->selectedTabIndex == 5, "week_attack_points"), "DEFENSE" => $m->getTop10($this->selectedTabIndex == 5, "week_defense_points"), "DEV" => $m->getTop10($this->selectedTabIndex == 5, "week_dev_points"), "THIEF" => $m->getTop10($this->selectedTabIndex == 5, "week_thief_points"));
                                 } else {
                                     if ($this->selectedTabIndex == 11) {
                                         $this->dataList = $m->getTatarVillagesList();
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     $m->dispose();
 }