示例#1
0
 function load()
 {
     parent::load();
     $this->selectedTabIndex = isset($_GET['t']) && is_numeric($_GET['t']) && 0 <= intval($_GET['t']) && intval($_GET['t']) <= 2 ? intval($_GET['t']) : 0;
     if ($this->selectedTabIndex == 0) {
         $this->packageIndex = isset($_GET['id']) && is_numeric($_GET['id']) && 0 < intval($_GET['id']) && intval($_GET['id']) <= sizeof($this->appConfig['plus']['packages']) ? intval($_GET['id']) - 1 : 0 - 1;
         return null;
     }
     if ($this->selectedTabIndex == 2) {
         if (isset($_GET['a']) && isset($_GET['k']) && $_GET['k'] == $this->data['update_key'] && $this->plusTable[intval($_GET['a'])]['cost'] <= $this->data['gold_num'] && !$this->isGameTransientStopped() && !$this->isGameOver()) {
             switch (intval($_GET['a'])) {
                 case 0:
                 case 1:
                 case 2:
                 case 3:
                 case 4:
                     $taskType = constant('QS_PLUS' . (intval($_GET['a']) + 1));
                     $newTask = new QueueTask($taskType, $this->player->playerId, $this->plusTable[intval($_GET['a'])]['time'] * 86400);
                     $newTask->villageId = 0 < intval($_GET['a']) ? $this->data['selected_village_id'] : '';
                     $newTask->tag = $this->plusTable[intval($_GET['a'])]['cost'];
                     $this->queueModel->addTask($newTask);
                     break;
                 case 5:
                 case 7:
                     $this->queueModel->finishTasks($this->player->playerId, $this->plusTable[intval($_GET['a'])]['cost'], intval($_GET['a']) == 7);
             }
         }
     }
 }
示例#2
0
 function load()
 {
     parent::load();
     if (intval($this->data['create_nvil']) == 0 || $this->player->isSpy) {
         $this->redirect('village1.php');
         return null;
     }
     $this->globalModel->resetNewVillageFlag($this->player->playerId);
 }
示例#3
0
 function load()
 {
     parent::load();
     $allianceId = intval($this->data['alliance_id']);
     if ($allianceId == 0 || !$this->hasAllianceSetRoles() || !isset($_GET['uid'])) {
         exit(0);
         return null;
     }
     $uid = intval($_GET['uid']);
     $m = new AllianceModel();
     $this->allianceData = $m->getAllianceData($allianceId);
     if (!$this->isMemberOfAlliance($uid)) {
         exit(0);
         return null;
     }
     if ($this->isPost()) {
         $roleName = isset($_POST['a_titel']) ? $_POST['a_titel'] : '';
         if (trim($roleName) == '') {
             $roleName = '.';
         }
         $roleNumber = 0;
         if (isset($_POST['e1'])) {
             $roleNumber |= ALLIANCE_ROLE_SETROLES;
         }
         if (isset($_POST['e2'])) {
             $roleNumber |= ALLIANCE_ROLE_REMOVEPLAYER;
         }
         if (isset($_POST['e3'])) {
             $roleNumber |= ALLIANCE_ROLE_EDITNAMES;
         }
         if (isset($_POST['e4'])) {
             $roleNumber |= ALLIANCE_ROLE_EDITCONTRACTS;
         }
         if (isset($_POST['e5'])) {
             $roleNumber |= ALLIANCE_ROLE_SENDMESSAGE;
         }
         if (isset($_POST['e6'])) {
             $roleNumber |= ALLIANCE_ROLE_INVITEPLAYERS;
         }
         $m->setPlayerAllianceRole($uid, $roleName, $roleNumber);
     }
     $row = $m->getPlayerAllianceRole($uid);
     if ($row == NULL) {
         exit(0);
         return null;
     }
     $this->playerName = $row['name'];
     $alliance_roles = trim($row['alliance_roles']);
     if ($alliance_roles == '') {
         $this->playerRoles = array('name' => '', 'roles' => 0);
     } else {
         list($rolesNumber, $roleName) = explode(' ', $alliance_roles, 2);
         $this->playerRoles = array('name' => $roleName == '.' ? '' : $roleName, 'roles' => $rolesNumber);
     }
     $m->dispose();
 }
示例#4
0
 function load()
 {
     parent::load();
     if (intval($this->data['new_gnews']) == 0 || $this->player->isSpy) {
         $this->redirect('village1.php');
         return null;
     }
     $m = new NewsModel();
     $this->siteNews = $m->getGlobalSiteNews();
     $m->dispose();
 }
示例#5
0
 function load()
 {
     parent::load();
     if (isset($_GET['url']) && !empty($_GET['url'])) {
         $advID = base64_decode(mysql_real_escape_string(trim($_GET['url'])));
         if ($advID != '') {
             $m = new AdvertisingModel();
             $url = $m->GoToBanner($advID);
             $m->dispose();
             $this->redirect($url);
             return null;
         }
     }
 }
示例#6
0
 function load()
 {
     parent::load();
     $this->Filter = new FilterWordsModel();
     $m = new ChatModel();
     if ($this->isPost() && isset($_POST['text'])) {
         $text = stripslashes(htmlspecialchars(trim($_POST['text'])));
         if ($text != '') {
             $m->SendToChat($this->data['name'], $this->player->playerId, $text);
         }
     }
     $m->DeleteOldChat();
     $this->chats = $m->GetFromChat();
     $m->dispose();
 }
示例#7
0
 function load()
 {
     parent::load();
     if (!$this->data['active_plus_account']) {
         exit(0);
         return null;
     }
     $this->saved = FALSE;
     if ($this->isPost() && isset($_POST['notes'])) {
         $this->data['notes'] = $_POST['notes'];
         $m = new NotesModel();
         $m->changePlayerNotes($this->player->playerId, $this->data['notes']);
         $m->dispose();
         $this->saved = TRUE;
     }
 }
示例#8
0
 function load()
 {
     parent::load();
     $this->Filter = new FilterWordsModel();
     $m = new ChatModel();
     $this->chats = $m->GetFromChat();
     $storCtat = array();
     while ($this->chats->next()) {
         $text = $this->Filter->FilterWords($this->chats->row['text']);
         $storCtat[$this->chats->row['ID']] = array(date('g:i A', $this->chats->row['date']), $this->chats->row['username'], $text, $this->chats->row['userid']);
     }
     ksort($storCtat);
     foreach ($storCtat as $ChatLine) {
         echo '<div class="msgln">(' . $ChatLine[0] . ') <b><a href="profile.php?uid=' . $ChatLine[3] . '" target="_blank">' . $ChatLine[1] . '</a></b>: ' . $ChatLine[2] . '<br></div>';
     }
     $m->dispose();
 }
示例#9
0
    function load()
    {
        parent::load();
        if (!$this->data['active_plus_account']) {
            exit(0);
            return null;
        }
        if ($this->isPost()) {
            $this->playerLinks = array();
            $i = 0;
            $c = sizeof($_POST['nr']);
            while ($i < $c) {
                $name = trim($_POST['linkname'][$i]);
                $url = trim($_POST['linkurl'][$i]);
                if ($url == '' || $name == '' || $_POST['nr'][$i] == '' || !is_numeric($_POST['nr'][$i])) {
                    continue;
                }
                $selfTarget = TRUE;
                if (substr($url, strlen($url) - 1) == '*') {
                    $url = substr($url, 0, strlen($url) - 1);
                    $selfTarget = FALSE;
                }
                if (isset($this->playerLinks[$_POST['nr'][$i]])) {
                    ++$_POST['nr'][$i];
                }
                $this->playerLinks[$_POST['nr'][$i]] = array('linkName' => $name, 'linkHref' => $url, 'linkSelfTarget' => $selfTarget);
                ++$i;
            }
            ksort($this->playerLinks);
            $links = '';
            foreach ($this->playerLinks as $link) {
                if ($links != '') {
                    $links .= '

';
                }
                $links .= $link['linkName'] . '
' . $link['linkHref'] . '
' . ($link['linkSelfTarget'] ? '?' : '*');
            }
            $m = new LinksModel();
            $m->changePlayerLinks($this->player->playerId, $links);
            $m->dispose();
        }
    }
示例#10
0
 function load()
 {
     parent::load();
     if ($this->data['player_type'] != PLAYERTYPE_ADMIN) {
         exit(0);
         return null;
     }
     $m = new NewsModel();
     $this->saved = FALSE;
     if ($this->isPost() && isset($_POST['news'])) {
         $this->siteNews = $_POST['news'];
         $this->saved = TRUE;
         $m->setGlobalPlayerNews($this->siteNews);
     } else {
         $this->siteNews = $m->getGlobalSiteNews();
     }
     $m->dispose();
 }
示例#11
0
 function load()
 {
     parent::load();
     $this->msgText = '';
     $this->isAdmin = $this->data['player_type'] == PLAYERTYPE_ADMIN;
     if (!$this->isAdmin) {
         exit(0);
         return null;
     }
     $this->villageId = isset($_GET['avid']) ? intval($_GET['avid']) : 0;
     if ($this->villageId <= 0) {
         exit(0);
         return null;
     }
     $m = new ResourcesModel();
     if ($this->isPost()) {
         $r1 = isset($_POST['r1']) && 0 <= intval($_POST['r1']) ? intval($_POST['r1']) : 0 - 1;
         $r2 = isset($_POST['r2']) && 0 <= intval($_POST['r2']) ? intval($_POST['r2']) : 0 - 1;
         $r3 = isset($_POST['r3']) && 0 <= intval($_POST['r3']) ? intval($_POST['r3']) : 0 - 1;
         $r4 = isset($_POST['r4']) && 0 <= intval($_POST['r4']) ? intval($_POST['r4']) : 0 - 1;
         $m->updateVillageResources($this->villageId, array('1' => $r1, '2' => $r2, '3' => $r3, '4' => $r4));
         $this->msgText = data_saved;
     }
     $row = $m->getVillageData($this->villageId);
     if ($row == NULL || intval($row['player_id']) == 0 || $row['is_oasis']) {
         exit(0);
         return null;
     }
     $this->villageName = $row['village_name'];
     $this->playerName = $row['player_name'];
     $this->resources = array();
     $elapsedTimeInSeconds = $row['elapsedTimeInSeconds'];
     $r_arr = explode(',', $row['resources']);
     foreach ($r_arr as $r_str) {
         $r2 = explode(' ', $r_str);
         $prate = floor($r2[4] * (1 + $r2[5] / 100)) - ($r2[0] == 4 ? $row['crop_consumption'] : 0);
         $current_value = floor($r2[1] + $elapsedTimeInSeconds * ($prate / 3600));
         if ($r2[2] < $current_value) {
             $current_value = $r2[2];
         }
         $this->resources[$r2[0]] = array('current_value' => $current_value, 'store_max_limit' => $r2[2], 'store_init_limit' => $r2[3], 'prod_rate' => $r2[4], 'prod_rate_percentage' => $r2[5], 'calc_prod_rate' => $prate);
     }
     $m->dispose();
 }
示例#12
0
 function load()
 {
     parent::load();
     $this->pageIndex = isset($_GET['p']) && is_numeric($_GET['p']) ? intval($_GET['p']) : 0;
     $m = new FriendsModel();
     $rowsCount = $m->getFriendsCount($this->player->playerId);
     $this->pageCount = 0 < $rowsCount ? ceil($rowsCount / $this->pageSize) : 1;
     if (isset($_GET['DFid']) && !empty($_GET['DFid'])) {
         $FriendID = mysql_real_escape_string(trim($_GET['DFid']));
         if ($FriendID != '') {
             $m->DeleteFriend($FriendID, $this->player->playerId);
             $m->dispose();
             $this->redirect('friends.php');
             return null;
         }
     }
     if (isset($_GET['CFid']) && !empty($_GET['CFid'])) {
         $ConfirmID = mysql_real_escape_string(trim($_GET['CFid']));
         if ($ConfirmID != '') {
             $m->ConfirmInvitation($ConfirmID, $this->player->playerId);
             $m->dispose();
             $this->redirect('friends.php');
             return null;
         }
     }
     if ($this->isPost()) {
         $post = array();
         $post['playerId1'] = $this->player->playerId;
         $post['myname'] = $this->data['name'];
         $post['playerName'] = isset($_POST['playerName']) && $_POST['playerName'] != '' ? trim($_POST['playerName']) : trim($_POST['playerName']);
         if ($post['playerName'] != '') {
             $m->SendInvitation($post);
         } else {
             echo '<pre> Error : Wrong name';
         }
         $m->dispose();
     }
     $this->friends = $m->GetFriends($this->player->playerId, $this->pageIndex, $this->pageSize);
     $m->dispose();
 }
示例#13
0
 function load()
 {
     parent::load();
     $this->pageIndex = isset($_GET['p']) && is_numeric($_GET['p']) ? intval($_GET['p']) : 0;
     $this->isAdmin = $this->data['player_type'] == PLAYERTYPE_ADMIN;
     if (!$this->isAdmin) {
         exit(0);
         return null;
     }
     $m = new BadWordsModel();
     $rowsCount = $m->getBadWordsCount();
     $this->pageCount = 0 < $rowsCount ? ceil($rowsCount / $this->pageSize) : 1;
     if (isset($_GET['Dword']) && !empty($_GET['Dword'])) {
         $wordID = mysql_real_escape_string(trim($_GET['Dword']));
         if ($wordID != '') {
             $m->DeleteBadWords($wordID);
             $m->dispose();
             $this->redirect('badwords.php');
             return null;
         }
     }
     if ($this->isPost()) {
         $i = 0;
         while ($i < count($_POST['words'])) {
             $words = mysql_real_escape_string(trim($_POST['words'][$i]));
             if ($words == '') {
                 continue;
             }
             $this->BadWords[] = $words;
             ++$i;
         }
         $m->addBadWords($this->BadWords);
         $m->dispose();
         $this->redirect('badwords.php');
         return null;
     }
     $this->BadWords = $m->GetBadWords($this->pageIndex, $this->pageSize);
     $m->dispose();
 }
示例#14
0
 function load()
 {
     parent::load();
     $this->pageIndex = isset($_GET['p']) && is_numeric($_GET['p']) ? intval($_GET['p']) : 0;
     $this->isAdmin = $this->data['player_type'] == PLAYERTYPE_ADMIN;
     if (!$this->isAdmin) {
         exit(0);
         return null;
     }
     $m = new AdvertisingModel();
     $rowsCount = $m->getAdvertisingCount();
     $this->pageCount = 0 < $rowsCount ? ceil($rowsCount / $this->pageSize) : 1;
     if (isset($_GET['DAdv']) && !empty($_GET['DAdv'])) {
         $advID = mysql_real_escape_string(trim($_GET['DAdv']));
         if ($advID != '') {
             $m->DeleteAdvertising($advID);
             $m->dispose();
             $this->redirect('advertising.php');
             return null;
         }
     }
     if ($this->isPost()) {
         $post = array();
         $type = isset($_POST['do']) && $_POST['do'] != 'add' ? 'edit' : 'add';
         $post['name'] = isset($_POST['name']) && $_POST['name'] != '' ? mysql_real_escape_string(trim($_POST['name'])) : 'SPSLink.NET';
         $post['url'] = isset($_POST['url']) && $_POST['url'] != '' ? mysql_real_escape_string(trim($_POST['url'])) : 'http://www.spslink.net';
         $post['cat'] = isset($_POST['cat']) && $_POST['cat'] != '' ? mysql_real_escape_string(trim($_POST['cat'])) : '1';
         $post['image'] = isset($_POST['image']) && $_POST['image'] != '' ? mysql_real_escape_string(trim($_POST['image'])) : 'assets/default/img/characters.png';
         $ext = strtolower(end(explode('.', mysql_real_escape_string(trim($post['image'])))));
         $post['type'] = $ext == 'swf' ? 'flash' : 'image';
         $post['ID'] = isset($_POST['ID']) && $_POST['ID'] != '' ? mysql_real_escape_string(trim($_POST['ID'])) : 0;
         $m->Advertising($post, $type);
         $m->dispose();
         $this->redirect('advertising.php');
         return null;
     }
     $this->Advertisings = $m->GetAdvertisings($this->pageIndex, $this->pageSize);
     $m->dispose();
 }
示例#15
0
 function load()
 {
     parent::load();
     $this->Filter = new FilterWordsModel();
     if (isset($_GET['action']) && $_GET['action'] == 'chatheartbeat') {
         $this->chatHeartbeat();
     }
     if (isset($_GET['action']) && $_GET['action'] == 'sendchat') {
         $this->sendChat();
     }
     if (isset($_GET['action']) && $_GET['action'] == 'closechat') {
         $this->closeChat();
     }
     if (isset($_GET['action']) && $_GET['action'] == 'startchatsession') {
         $this->startChatSession();
     }
     if (!isset($_SESSION['chatHistory'])) {
         $_SESSION['chatHistory'] = array();
     }
     if (!isset($_SESSION['openChatBoxes'])) {
         $_SESSION['openChatBoxes'] = array();
     }
 }
示例#16
0
 function load()
 {
     parent::load();
     $this->myData['name'] = $this->data['name'];
     $this->myData['avatar'] = $this->data['avatar'];
     $this->myData['id'] = $this->player->playerId;
     $this->pageIndex = isset($_GET['p']) && is_numeric($_GET['p']) ? intval($_GET['p']) : 0;
     $this->uid = isset($_GET['uid']) && 0 < intval($_GET['uid']) ? intval($_GET['uid']) : $this->player->playerId;
     $m = new SNprofileModel();
     $rowsCount = $m->getNewsCount($this->uid);
     $this->pageCount = 0 < $rowsCount ? ceil($rowsCount / $this->pageSize) : 1;
     $this->userData = $m->getuserData($this->uid);
     $friendId = array();
     $listRows = $m->getFriendsList($this->player->playerId);
     while ($listRows->next()) {
         $id = $listRows->row['playerid1'] == $this->player->playerId ? $listRows->row['playerid2'] : $listRows->row['playerid1'];
         $name = $listRows->row['playerid1'] == $this->player->playerId ? $listRows->row['playername2'] : $listRows->row['playername1'];
         $frienddata = $m->getFriendData($id);
         $this->friendList[] = array($id, $name, $frienddata['avatar'], $frienddata['last_login_sec']);
         $friendId[] = $id;
     }
     $this->isFriend = in_array($this->uid, $friendId) || $this->uid == $this->player->playerId ? true : false;
     if (isset($_GET['DNid']) && !empty($_GET['DNid'])) {
         $NewsID = mysql_real_escape_string(trim($_GET['DNid']));
         if ($NewsID != '') {
             if ($this->myData['id'] == $this->uid) {
                 $m->DeleteNews($NewsID, $this->player->playerId);
             }
             $m->dispose();
             $this->redirect('snprofile.php?uid=' . $this->uid);
             return null;
         }
     }
     if (isset($_GET['DCid']) && !empty($_GET['DCid'])) {
         $CommentID = mysql_real_escape_string(trim($_GET['DCid']));
         if ($CommentID != '') {
             $m->DeleteComment($CommentID, $this->player->playerId);
             $m->dispose();
             $this->redirect('snprofile.php?uid=' . $this->uid);
             return null;
         }
     }
     if ($this->isPost()) {
         $post = array();
         if (isset($_GET['do']) && $_GET['do'] == 'News') {
             $post['userid'] = $this->uid;
             $post['message'] = isset($_POST['news']) && $_POST['news'] != '' ? trim($_POST['news']) : '';
             $post['image'] = isset($_POST['image']) && $_POST['image'] != '' ? trim($_POST['image']) : '';
             $post['url'] = isset($_POST['url']) && $_POST['url'] != '' ? trim($_POST['url']) : '';
             $post['youtube'] = isset($_POST['youtube']) && $_POST['youtube'] != '' ? trim($_POST['youtube']) : '';
             if ($this->uid == $this->player->playerId && $post['message'] != '') {
                 $m->SendNews($post);
             }
         } else {
             $post['to_userid'] = $this->uid;
             $post['userid'] = intval($this->player->playerId);
             $post['username'] = $this->data['name'];
             $post['comment'] = isset($_POST['comment']) && $_POST['comment'] != '' ? trim($_POST['comment']) : '';
             $post['topicid'] = isset($_POST['topicid']) && $_POST['topicid'] != '' ? trim($_POST['topicid']) : '';
             if ($post['to_userid'] != 0 && $post['comment'] != '' && $post['userid'] != 0 && $this->isFriend) {
                 $m->SendComment($post);
             }
         }
         $m->dispose();
         $this->redirect('snprofile.php?uid=' . $this->uid);
         return null;
     }
     $News = $m->GetNews($this->uid, $this->pageIndex, $this->pageSize);
     $k = 0;
     while ($News->next()) {
         $Comments = $m->GetComments($News->row['ID']);
         $this->topics[$k]['news'] = $News->row;
         while ($Comments->next()) {
             $this->topics[$k]['news']['comment'][] = $Comments->row;
         }
         ++$k;
     }
     $m->dispose();
 }
示例#17
0
文件: msg.php 项目: vcelis/tatar-wars
    function load()
    {
        parent::load();
        $this->sendMail = TRUE;
        $this->isInbox = TRUE;
        $this->viewOnly = FALSE;
        $this->showFriendPane = FALSE;
        $this->errorText = '';
        $this->showList = !(isset($_GET['t']) && is_numeric($_GET['t']) && intval($_GET['t']) == 1);
        $this->selectedTabIndex = isset($_GET['t']) && is_numeric($_GET['t']) && 1 <= intval($_GET['t']) && intval($_GET['t']) <= 2 ? intval($_GET['t']) : 0;
        $this->friendList = array();
        $friends_player_ids = trim($this->data['friend_players']);
        if ($friends_player_ids != '') {
            $friends_player_ids = explode('
', $friends_player_ids);
            foreach ($friends_player_ids as $friend) {
                list($playerId, $playerName) = explode(' ', $friend);
                $this->friendList[$playerId] = $playerName;
            }
        }
        $m = new MessageModel();
        if (!$this->isPost()) {
            if (isset($_GET['uid']) && is_numeric($_GET['uid']) && 0 < intval($_GET['uid'])) {
                $this->receiver = $m->getPlayerNameById(intval($_GET['uid']));
                $this->showList = FALSE;
                $this->selectedTabIndex = 1;
            } else {
                if (isset($_GET['id']) && is_numeric($_GET['id']) && 0 < intval($_GET['id'])) {
                    $result = $m->getMessage($this->player->playerId, intval($_GET['id']));
                    if ($result->next()) {
                        $this->viewOnly = TRUE;
                        $this->showList = FALSE;
                        $this->isInbox = $result->row['to_player_id'] == $this->player->playerId;
                        $this->sendMail = !$this->isInbox;
                        $this->receiver = $this->isInbox ? $result->row['from_player_name'] : $result->row['to_player_name'];
                        $this->subject = $result->row['msg_title'];
                        $this->body = $this->getFilteredText($result->row['msg_body']);
                        $this->messageDate = $result->row['mdate'];
                        $this->messageTime = $result->row['mtime'];
                        $this->selectedTabIndex = $this->isInbox ? 0 : 2;
                        if ($this->isInbox && !$result->row['is_readed'] && !$this->player->isSpy) {
                            $m->markMessageAsReaded($this->player->playerId, intval($_GET['id']));
                            --$this->data['new_mail_count'];
                        }
                    } else {
                        $this->showList = TRUE;
                        $this->selectedTabIndex = 0;
                    }
                    $result->free();
                }
            }
        } else {
            if (isset($_POST['sm'])) {
                $this->receiver = trim($_POST['an']);
                $this->subject = trim($_POST['be']);
                $this->body = $_POST['message'];
                if (trim($this->receiver) == '') {
                    $this->showList = FALSE;
                    $this->selectedTabIndex = 1;
                    $this->errorText = messages_p_noreceiver . '<p></p>';
                    $m->dispose();
                    return null;
                }
                if (trim($this->body) == '') {
                    $this->showList = FALSE;
                    $this->selectedTabIndex = 1;
                    $this->errorText = messages_p_nobody . '<p></p>';
                    $m->dispose();
                    return null;
                }
                if (strtolower(trim($this->receiver)) == '[ally]' && 0 < intval($this->data['alliance_id']) && $this->hasAllianceSendMessageRole()) {
                    $pids = trim($m->getAlliancePlayersId(intval($this->data['alliance_id'])));
                    if ($pids != '') {
                        if ($this->subject == '') {
                            $this->subject = messages_p_emptysub;
                        }
                        $arr = explode(',', $pids);
                        foreach ($arr as $apid) {
                            if ($apid == $this->player->playerId) {
                                continue;
                            }
                            $m->sendMessage($this->player->playerId, $this->data['name'], $apid, $m->getPlayerNameById($apid), $this->subject, $this->body);
                        }
                        $this->showList = TRUE;
                        $this->selectedTabIndex = 2;
                    }
                } else {
                    $receiverPlayerId = $m->getPlayerIdByName($this->receiver);
                    if (0 < intval($receiverPlayerId)) {
                        if ($receiverPlayerId == $this->player->playerId) {
                            $this->showList = FALSE;
                            $this->selectedTabIndex = 1;
                            $this->errorText = '<b>' . messages_p_noloopback . '</b><p></p>';
                        } else {
                            if ($this->subject == '') {
                                $this->subject = messages_p_emptysub;
                            }
                            $m->sendMessage($this->player->playerId, $this->data['name'], $receiverPlayerId, $this->receiver, $this->subject, $this->body);
                            $this->showList = TRUE;
                            $this->selectedTabIndex = 2;
                        }
                    } else {
                        $this->showList = FALSE;
                        $this->selectedTabIndex = 1;
                        $this->errorText = messages_p_notexists . ' <b>' . $this->receiver . '</b><p></p>';
                    }
                }
            } else {
                if (isset($_POST['fm'])) {
                    $this->receiver = trim($_POST['an']);
                    $this->subject = trim($_POST['be']);
                    $this->body = $_POST['message'];
                    $this->showList = FALSE;
                    $this->selectedTabIndex = 1;
                    $this->showFriendPane = TRUE;
                    if ($_POST['fm'] != '' && is_numeric($_POST['fm'])) {
                        $playerId = intval($_POST['fm']);
                        if (0 < $playerId && isset($this->friendList[$playerId])) {
                            unset($this->friendList[$playerId]);
                        }
                    } else {
                        if (isset($_POST['mfriends'])) {
                            foreach ($_POST['mfriends'] as $friendName) {
                                $friendName = trim($friendName);
                                if ($friendName == '') {
                                    continue;
                                }
                                $playerId = intval($m->getPlayerIdByName($friendName));
                                if (0 < $playerId && !isset($this->friendList[$playerId]) && $playerId != $this->player->playerId) {
                                    $this->friendList[$playerId] = $friendName;
                                    continue;
                                }
                            }
                        }
                    }
                    $friends = '';
                    foreach ($this->friendList as $k => $v) {
                        if ($friends != '') {
                            $friends .= '
';
                        }
                        $friends .= $k . ' ' . $v;
                    }
                    $m->saveFriendList($this->player->playerId, $friends);
                } else {
                    if (isset($_POST['rm'])) {
                        $this->receiver = trim($_POST['an']);
                        $this->subject = trim($_POST['be']);
                        $this->body = PHP_EOL . PHP_EOL . '_________________________________' . PHP_EOL . text_from_lang . ' ' . $this->receiver . ':' . PHP_EOL . PHP_EOL . $_POST['message'];
                        preg_match('/^(RE)\\^?([0-9]*):([\\w\\W]*)$/', $this->subject, $matches);
                        if (sizeof($matches) == 4) {
                            $this->subject = 'RE^' . ($matches[2] + 1) . ':' . $matches[3];
                        } else {
                            $this->subject = 'RE: ' . $this->subject;
                        }
                        $this->showList = FALSE;
                        $this->selectedTabIndex = 1;
                    } else {
                        if (isset($_POST['dm'])) {
                            if (isset($_POST['dm'])) {
                                foreach ($_POST['dm'] as $messageId) {
                                    if ($m->deleteMessage($this->player->playerId, $messageId)) {
                                        --$this->data['new_mail_count'];
                                        continue;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        if ($this->showList) {
            $rowsCount = $m->getMessageListCount($this->player->playerId, $this->selectedTabIndex == 0);
            $this->pageCount = 0 < $rowsCount ? ceil($rowsCount / $this->pageSize) : 1;
            $this->pageIndex = isset($_GET['p']) && is_numeric($_GET['p']) && intval($_GET['p']) < $this->pageCount ? intval($_GET['p']) : 0;
            $this->dataList = $m->getMessageList($this->player->playerId, $this->selectedTabIndex == 0, $this->pageIndex, $this->pageSize);
            if (0 < $this->data['new_mail_count']) {
                $this->data['new_mail_count'] = $m->syncMessages($this->player->playerId);
            }
        }
        $m->dispose();
    }
示例#18
0
 public function load()
 {
     parent::load();
     $this->isAdmin = $this->data['player_type'] == PLAYERTYPE_ADMIN;
     $uid = isset($_GET['uid']) && 0 < intval($_GET['uid']) ? intval($_GET['uid']) : $this->player->playerId;
     if ($this->isAdmin && isset($_GET['spy']) && 0 < $uid && $uid != $this->player->playerId) {
         $gameStatus = $this->player->gameStatus;
         $previd = $this->player->playerId;
         $this->player = new Player();
         $this->player->playerId = $uid;
         $this->player->prevPlayerId = $previd;
         $this->player->isAgent = FALSE;
         $this->player->isSpy = TRUE;
         $this->player->gameStatus = $gameStatus;
         $this->player->save();
         $this->redirect("village1.php");
     } else {
         $this->selectedTabIndex = 0;
         $this->fullView = FALSE;
         $m = new ProfileModel();
         if ($uid != $this->player->playerId) {
             $this->profileData = $m->getPlayerDataById($uid);
             $this->villagesCount = sizeof(explode(",", $this->profileData['villages_id']));
             $this->villages = $m->getVillagesSummary($this->profileData['villages_id']);
             if ($this->profileData == NULL) {
                 $m->dispose();
                 $this->redirect("village1.php");
             }
         } else {
             $this->profileData = $this->data;
             $this->protectiontime = $m->getPlayerDataById($uid);
             $this->profileData['id'] = $uid;
             $this->fullView = !$this->player->isAgent;
             $this->selectedTabIndex = !$this->player->isAgent && isset($_GET['t']) && is_numeric($_GET['t']) && 0 <= intval($_GET['t']) && intval($_GET['t']) <= 4 ? intval($_GET['t']) : 0;
             if ($this->selectedTabIndex == 4 && $this->data['player_type'] == PLAYERTYPE_TATAR) {
                 $this->selectedTabIndex = 0;
             }
             $agentForPlayers = trim($this->profileData['agent_for_players']) == "" ? array() : explode(",", $this->profileData['agent_for_players']);
             foreach ($agentForPlayers as $agent) {
                 $agentName = explode(" ", $agent);
                 $agentId = explode(" ", $agent);
                 list($agentId, $agentName) = $agentId;
                 $this->agentForPlayers[$agentId] = $agentName;
             }
             $myAgentPlayers = trim($this->profileData['my_agent_players']) == "" ? array() : explode(",", $this->profileData['my_agent_players']);
             foreach ($myAgentPlayers as $agent) {
                 $agentName = explode(" ", $agent);
                 $agentId = explode(" ", $agent);
                 list($agentId, $agentName) = $agentId;
                 $this->myAgentPlayers[$agentId] = $agentName;
             }
             $this->profileData['rank'] = $m->getPlayerRank($uid, $this->profileData['total_people_count'] * 10 + $this->profileData['villages_count']);
             if ($this->isPost()) {
                 if ($this->fullView && isset($_POST['e'])) {
                     switch ($_POST['e']) {
                         case 1:
                             if (!empty($_FILES['avatar']['name'])) {
                                 $exe = explode(".", $_FILES['avatar']['name']);
                                 $EXT = end($exe);
                                 $array = array("GIF", "SWF", "BMP", "TIFF", "JPG", "PNG", "JEPG");
                                 if (in_array(strtoupper($EXT), $array)) {
                                     $i = time();
                                     $avatar = $i . "." . $EXT;
                                     $test = move_uploaded_file($_FILES['avatar']['tmp_name'], ROOT_PATH . "avatar/" . $avatar);
                                     if ($test) {
                                         if ($_POST['oldavatar'] != "http://www.dboor.com/tatar/assets/default/img/q/l6.jpg") {
                                             @unlink(@$_POST['oldavatar']);
                                         }
                                     } else {
                                         $avatar = $_POST['oldavatar'];
                                     }
                                 } else {
                                     $avatar = $_POST['oldavatar'];
                                 }
                             } else {
                                 $avatar = $_POST['oldavatar'];
                             }
                             $avatar = empty($avatar) ? "/assets/default/img/q/l6.jpg" : "/avatar/" . $avatar;
                             $_y_ = isset($_POST['jahr']) && 1930 <= intval($_POST['jahr']) && intval($_POST['jahr']) <= 2005 ? intval($_POST['jahr']) : "";
                             $_m_ = isset($_POST['monat']) && 1 <= intval($_POST['monat']) && intval($_POST['monat']) <= 12 ? intval($_POST['monat']) : "";
                             $_d_ = isset($_POST['tag']) && 1 <= intval($_POST['tag']) && intval($_POST['tag']) <= 31 ? intval($_POST['tag']) : "";
                             $newData = array("gender" => 0 <= intval($_POST['mw']) && intval($_POST['mw']) <= 2 ? intval($_POST['mw']) : 0, "house_name" => isset($_POST['ort']) ? $_POST['ort'] : "", "village_name" => isset($_POST['dname']) ? $_POST['dname'] : "", "avatar" => htmlspecialchars($avatar), "description1" => isset($_POST['be1']) ? htmlspecialchars($_POST['be1']) : "", "description2" => isset($_POST['be2']) ? htmlspecialchars($_POST['be2']) : "", "birthData" => $_y_ . "-" . $_m_ . "-" . $_d_, "villages" => $this->data['villages_data']);
                             $m->editPlayerProfile($this->player->playerId, $newData);
                             $m->dispose();
                             $this->redirect("profile.php");
                             return;
                         case 2:
                             if (isset($_POST['pw1'], $_POST['pw2']) && isset($_POST['pw3']) && $_POST['pw2'] == $_POST['pw3'] && 4 <= strlen($_POST['pw2']) && strtolower($this->profileData['pwd']) == strtolower(md5($_POST['pw1']))) {
                                 $m->changePlayerPassword($this->player->playerId, md5($_POST['pw2']));
                             }
                             if (isset($_POST['email_alt'], $_POST['email_neu']) && strtolower($this->profileData['email']) == strtolower($_POST['email_alt']) && preg_match("/^[^@]+@[a-zA-Z0-9._-]+\\.[a-zA-Z]+\$/", $_POST['email_neu'])) {
                                 $m->changePlayerEmail($this->player->playerId, $_POST['email_neu']);
                             }
                             break;
                         case 3:
                             if (isset($_POST['v1']) && trim($_POST['v1']) != "" && sizeof($this->myAgentPlayers) < 2) {
                                 $aid = $m->getPlayerIdByName($_POST['v1']);
                                 if (0 < intval($aid) && $aid != $this->player->playerId && !isset($this->myAgentPlayers[$aid])) {
                                     $_agentsFor = $m->getPlayerAgentForById(intval($aid));
                                     if (1 < sizeof(explode(",", $_agentsFor))) {
                                         $this->errorText = profile_setagent_err_msg;
                                     } else {
                                         $this->myAgentPlayers[$aid] = $_POST['v1'];
                                         $m->setMyAgents($this->player->playerId, $this->data['name'], $this->myAgentPlayers, $aid);
                                     }
                                 }
                             }
                             break;
                         case 4:
                             if (isset($_POST['del']) && $_POST['del'] == 1 && strtolower($this->profileData['pwd']) == strtolower(md5($_POST['del_pw'])) && !$this->isPlayerInDeletionProgress() && !$this->isGameTransientStopped() && !$this->isGameOver()) {
                                 $this->queueModel->addTask(new QueueTask(QS_ACCOUNT_DELETE, $this->player->playerId, 259200));
                             }
                     }
                 }
             } else {
                 if ($this->selectedTabIndex == 3) {
                     if (isset($_GET['aid']) && 0 < intval($_GET['aid'])) {
                         $aid = intval($_GET['aid']);
                         if (isset($this->myAgentPlayers[$aid])) {
                             unset($this->myAgentPlayers[$aid]);
                             $m->removeMyAgents($this->player->playerId, $this->myAgentPlayers, $aid);
                         }
                     } else {
                         if (isset($_GET['afid']) && 0 < intval($_GET['afid'])) {
                             $aid = intval($_GET['afid']);
                             if (isset($this->agentForPlayers[$aid])) {
                                 unset($this->agentForPlayers[$aid]);
                                 $m->removeAgentsFor($this->player->playerId, $this->agentForPlayers, $aid);
                             }
                         }
                     }
                 } else {
                     if ($this->selectedTabIndex == 4 && isset($_GET['qid']) && 0 < intval($_GET['qid'])) {
                         $this->queueModel->cancelTask($this->player->playerId, intval($_GET['qid']));
                     }
                 }
             }
             if ($this->selectedTabIndex == 0) {
                 $this->villagesCount = sizeof(explode(",", $this->profileData['villages_id']));
                 $this->villages = $m->getVillagesSummary($this->profileData['villages_id']);
             } else {
                 if ($this->selectedTabIndex == 1) {
                     $birth_date = $this->profileData['birth_date'];
                     if (!$birth_date) {
                         $birth_date = "0-0-0";
                     }
                     $day = explode("-", $birth_date);
                     $month = explode("-", $birth_date);
                     $year = explode("-", $birth_date);
                     list($year, $month, $day) = $year;
                     $this->birthDate = array("year" => $year, "month" => $month, "day" => $day);
                 }
             }
             $m->dispose();
         }
     }
 }
示例#19
0
 public function load()
 {
     parent::load();
     $this->showList = !(isset($_GET['id']) && 0 < intval($_GET['id']));
     $this->selectedTabIndex = $this->showList && isset($_GET['t']) && is_numeric($_GET['t']) && 1 <= intval($_GET['t']) && intval($_GET['t']) <= 4 ? intval($_GET['t']) : 0;
     $m = new ReportModel();
     if (!$this->isPost()) {
         if (!$this->showList) {
             $this->selectedTabIndex = 0;
             $reportId = intval($_GET['id']);
             $result = $m->getReport($reportId);
             if ($result->next()) {
                 $readStatus = $result->row['read_status'];
                 $deleteStatus = $result->row['delete_status'];
                 $this->reportData = array();
                 $this->reportData['messageDate'] = $result->row['mdate'];
                 $this->reportData['messageTime'] = $result->row['mtime'];
                 $this->reportData['from_player_id'] = $from_player_id = intval($result->row['from_player_id']);
                 $this->reportData['to_player_id'] = $to_player_id = intval($result->row['to_player_id']);
                 $this->reportData['from_village_id'] = intval($result->row['from_village_id']);
                 $this->reportData['to_village_id'] = intval($result->row['to_village_id']);
                 $this->reportData['from_player_name'] = $result->row['from_player_name'];
                 $this->reportData['to_player_name'] = $result->row['to_player_name'];
                 $this->reportData['to_village_name'] = $result->row['to_village_name'];
                 $this->reportData['from_village_name'] = $result->row['from_village_name'];
                 $this->reportData['rpt_body'] = $result->row['rpt_body'];
                 $this->reportData['rpt_cat'] = $result->row['rpt_cat'];
                 $this->reportData['mdate'] = $result->row['mdate'];
                 $this->reportData['mtime'] = $result->row['mtime'];
                 $this->reportData['to_player_alliance_id'] = $m->getPlayerAllianceId($to_player_id);
                 switch ($this->reportData['rpt_cat']) {
                     case 1:
                         $this->reportData['resources'] = explode(" ", $this->reportData['rpt_body']);
                         break;
                     case 2:
                         $troopsStr = explode("|", $this->reportData['rpt_body']);
                         list($troopsStr) = $troopsStr;
                         $this->reportData['troopsTable'] = array("troops" => array(), "hasHero" => FALSE);
                         $troopsStrArr = explode(",", $troopsStr);
                         foreach ($troopsStrArr as $t) {
                             $tnum = explode(" ", $t);
                             $tid = explode(" ", $t);
                             list($tid, $tnum) = $tid;
                             if ($tnum == 0 - 1) {
                                 $this->reportData['troopsTable']['hasHero'] = TRUE;
                             } else {
                                 $this->reportData['troopsTable']['troops'][$tid] = $tnum;
                             }
                         }
                         break;
                     case 3:
                         $bodyArr = explode("|", $this->reportData['rpt_body']);
                         $harvestResources = $bodyArr;
                         $total_carry_load = $bodyArr;
                         $defenseTableTroopsStr = $bodyArr;
                         $attackTroopsStr = $bodyArr;
                         list($attackTroopsStr, $defenseTableTroopsStr, $total_carry_load, $harvestResources) = $attackTroopsStr;
                         $wallDestructionResult = isset($bodyArr[4]) ? $bodyArr[4] : "";
                         $catapultResult = isset($bodyArr[5]) ? $bodyArr[5] : "";
                         $oasisResult = isset($bodyArr[6]) ? $bodyArr[6] : "";
                         $captureResult = isset($bodyArr[7]) ? $bodyArr[7] : "";
                         $this->reportData['total_carry_load'] = $total_carry_load;
                         $this->reportData['total_harvest_carry_load'] = 0;
                         $this->reportData['harvest_resources'] = array();
                         $res = explode(" ", $harvestResources);
                         foreach ($res as $r) {
                             $this->reportData['total_harvest_carry_load'] += $r;
                             $this->reportData['harvest_resources'][] = $r;
                         }
                         $attackTroopsStrArr = explode(",", $attackTroopsStr);
                         $this->reportData['attackTroopsTable'] = array("troops" => array(), "heros" => array("number" => 0, "dead_number" => 0));
                         $totalAttackTroops_live = 0;
                         $totalAttackTroops_dead = 0;
                         $attackWallDestrTroopId = 0;
                         $attackCatapultTroopId = 0;
                         $kingTroopId = 0;
                         foreach ($attackTroopsStrArr as $s) {
                             $deadNum = explode(" ", $s);
                             $num = explode(" ", $s);
                             $tid = explode(" ", $s);
                             list($tid, $num, $deadNum) = $tid;
                             $totalAttackTroops_live += $num;
                             $totalAttackTroops_dead += $deadNum;
                             if ($tid == 7 || $tid == 17 || $tid == 27 || $tid == 106 || $tid == 57) {
                                 $attackWallDestrTroopId = $tid;
                             } else {
                                 if ($tid == 8 || $tid == 18 || $tid == 28 || $tid == 107 || $tid == 58) {
                                     $attackCatapultTroopId = $tid;
                                 } else {
                                     if ($tid == 9 || $tid == 19 || $tid == 29 || $tid == 108 || $tid == 59) {
                                         $kingTroopId = $tid;
                                     }
                                 }
                             }
                             if ($tid == 0 - 1) {
                                 $this->reportData['attackTroopsTable']['heros']['number'] = $num;
                                 $this->reportData['attackTroopsTable']['heros']['dead_number'] = $deadNum;
                             } else {
                                 $this->reportData['attackTroopsTable']['troops'][$tid] = array("number" => $num, "dead_number" => $deadNum);
                             }
                         }
                         $this->reportData['all_attackTroops_dead'] = $totalAttackTroops_live <= $totalAttackTroops_dead;
                         $this->reportData['defenseTroopsTable'] = array();
                         $troopsTableStrArr = trim($defenseTableTroopsStr) == "" ? array() : explode("#", $defenseTableTroopsStr);
                         $j = 0 - 1;
                         foreach ($troopsTableStrArr as $defenseTableTroopsStr2) {
                             ++$j;
                             $defenseTroopsStrArr = explode(",", $defenseTableTroopsStr2);
                             $this->reportData['defenseTroopsTable'][$j] = array("troops" => array(), "heros" => array("number" => 0, "dead_number" => 0));
                             foreach ($defenseTroopsStrArr as $s) {
                                 $deadNum = explode(" ", $s);
                                 $num = explode(" ", $s);
                                 $tid = explode(" ", $s);
                                 list($tid, $num, $deadNum) = $tid;
                                 if ($tid == 0 - 1) {
                                     $this->reportData['defenseTroopsTable'][$j]['heros']['number'] = $num;
                                     $this->reportData['defenseTroopsTable'][$j]['heros']['dead_number'] = $deadNum;
                                 } else {
                                     $this->reportData['defenseTroopsTable'][$j]['troops'][$tid] = array("number" => $num, "dead_number" => $deadNum);
                                 }
                             }
                         }
                         if ($captureResult != "") {
                             $wstr = "";
                             if ($captureResult == "+") {
                                 $wstr = report_p_villagecaptured;
                             } else {
                                 $warr = explode("-", $captureResult);
                                 $wstr = report_p_allegiancelowered . " " . $warr[0] . " " . report_p_to . " " . $warr[1];
                             }
                             if ($wstr != "") {
                                 $wstr = "<img src=\"assets/x.gif\" class=\"unit u" . $kingTroopId . "\" align=\"center\" /> " . $wstr;
                             }
                             $this->reportData['captureResult'] = $wstr;
                         }
                         if ($oasisResult != "") {
                             $wstr = "";
                             if ($oasisResult == "+") {
                                 $wstr = report_p_oasiscaptured;
                             } else {
                                 $warr = explode("-", $oasisResult);
                                 $wstr = report_p_allegiancelowered . " " . $warr[0] . " " . report_p_to . " " . $warr[1];
                             }
                             if ($wstr != "") {
                                 $wstr = "<img src=\"assets/x.gif\" class=\"unit uhero\" align=\"center\" /> " . $wstr;
                             }
                             $this->reportData['oasisResult'] = $wstr;
                         }
                         if ($wallDestructionResult != "") {
                             $wstr = "";
                             if ($wallDestructionResult == "-") {
                                 $wstr = report_p_wallnotdestr;
                             } else {
                                 if ($wallDestructionResult == "+") {
                                     $wstr = report_p_nowall;
                                 } else {
                                     $warr = explode("-", $wallDestructionResult);
                                     if (intval($warr[1]) == 0) {
                                         $wstr = report_p_walldestr;
                                     }
                                     $wstr = report_p_walllowered . " " . $warr[0] . " " . report_p_to . " " . $warr[1];
                                 }
                             }
                             if ($wstr != "") {
                                 $wstr = "<img src=\"assets/x.gif\" class=\"unit u" . $attackWallDestrTroopId . "\" align=\"center\" /> " . $wstr;
                             }
                             $this->reportData['wallDestructionResult'] = $wstr;
                         }
                         if ($catapultResult != "") {
                             $bdestArr = array();
                             if ($catapultResult == "+") {
                                 $bdestArr[] = "<img src=\"assets/x.gif\" class=\"unit u" . $attackCatapultTroopId . "\" align=\"center\" /> " . report_p_totallydestr;
                             } else {
                                 $catapultResultArr = explode("#", $catapultResult);
                                 foreach ($catapultResultArr as $catapultResultInfo) {
                                     $toLevel = explode(" ", $catapultResultInfo);
                                     $fromLevel = explode(" ", $catapultResultInfo);
                                     $itemId = explode(" ", $catapultResultInfo);
                                     list($itemId, $fromLevel, $toLevel) = $itemId;
                                     if ($toLevel == 0 - 1) {
                                         $bdestArr[] = "<img src=\"assets/x.gif\" class=\"unit u" . $attackCatapultTroopId . "\" align=\"center\" /> " . report_p_notdestr . " " . constant("item_" . $itemId);
                                     } else {
                                         if ($toLevel == 0) {
                                             $bdestArr[] = "<img src=\"assets/x.gif\" class=\"unit u" . $attackCatapultTroopId . "\" align=\"center\" /> " . report_p_wasdestr . " " . constant("item_" . $itemId);
                                         } else {
                                             $bdestArr[] = "<img src=\"assets/x.gif\" class=\"unit u" . $attackCatapultTroopId . "\" align=\"center\" /> " . report_p_waslowered . " " . constant("item_" . $itemId) . " " . report_p_fromlevel . " " . $fromLevel . " " . report_p_to . " " . $toLevel;
                                         }
                                     }
                                 }
                             }
                             $this->reportData['buildingDestructionResult'] = $bdestArr;
                         }
                         break;
                     case 4:
                         $spyType = explode("|", $this->reportData['rpt_body']);
                         $harvestInfo = explode("|", $this->reportData['rpt_body']);
                         $harvestResources = explode("|", $this->reportData['rpt_body']);
                         $defenseTableTroopsStr = explode("|", $this->reportData['rpt_body']);
                         $attackTroopsStr = explode("|", $this->reportData['rpt_body']);
                         list($attackTroopsStr, $defenseTableTroopsStr, $harvestResources, $harvestInfo, $spyType) = $attackTroopsStr;
                         if (trim($harvestResources) != "" && $spyType == 1) {
                             $this->reportData['harvest_resources'] = explode(" ", trim($harvestResources));
                         }
                         if (trim($harvestInfo) != "" && $spyType == 2) {
                             $level = explode(" ", $harvestInfo);
                             $itemId = explode(" ", $harvestInfo);
                             list($itemId, $level) = $itemId;
                             $this->reportData['harvest_info'] = constant("item_" . $itemId) . " " . level_lang . " " . $level;
                         }
                         $this->reportData['all_spy_dead'] = FALSE;
                         if ($spyType == 3) {
                             $this->reportData['all_spy_dead'] = TRUE;
                             $this->reportData['harvest_info'] = report_p_allkilled;
                         }
                         $attackTroopsStrArr = explode(",", $attackTroopsStr);
                         $this->reportData['attackTroopsTable'] = array("troops" => array(), "heros" => array("number" => 0, "dead_number" => 0));
                         foreach ($attackTroopsStrArr as $s) {
                             $deadNum = explode(" ", $s);
                             $num = explode(" ", $s);
                             $tid = explode(" ", $s);
                             list($tid, $num, $deadNum) = $tid;
                             if ($tid == 0 - 1) {
                                 $this->reportData['attackTroopsTable']['heros']['number'] = $num;
                                 $this->reportData['attackTroopsTable']['heros']['dead_number'] = $deadNum;
                             } else {
                                 $this->reportData['attackTroopsTable']['troops'][$tid] = array("number" => $num, "dead_number" => $deadNum);
                             }
                         }
                         $this->reportData['defenseTroopsTable'] = array();
                         $troopsTableStrArr = trim($defenseTableTroopsStr) == "" ? array() : explode("#", $defenseTableTroopsStr);
                         $j = 0 - 1;
                         foreach ($troopsTableStrArr as $defenseTableTroopsStr2) {
                             ++$j;
                             $defenseTroopsStrArr = explode(",", $defenseTableTroopsStr2);
                             $this->reportData['defenseTroopsTable'][$j] = array("troops" => array(), "heros" => array("number" => 0, "dead_number" => 0));
                             foreach ($defenseTroopsStrArr as $s) {
                                 $deadNum = explode(" ", $s);
                                 $num = explode(" ", $s);
                                 $tid = explode(" ", $s);
                                 list($tid, $num, $deadNum) = $tid;
                                 if ($tid == 0 - 1) {
                                     $this->reportData['defenseTroopsTable'][$j]['heros']['number'] = $num;
                                     $this->reportData['defenseTroopsTable'][$j]['heros']['dead_number'] = $deadNum;
                                 } else {
                                     $this->reportData['defenseTroopsTable'][$j]['troops'][$tid] = array("number" => $num, "dead_number" => $deadNum);
                                 }
                             }
                         }
                 }
                 $isDeleted = FALSE;
                 if (!$isDeleted) {
                     $canOpenReport = TRUE;
                     if ($this->player->playerId != $from_player_id && $this->player->playerId != $to_player_id) {
                         $canOpenReport = 0 < intval($this->data['alliance_id']) && ($this->data['alliance_id'] == $m->getPlayerAllianceId($to_player_id) || $this->data['alliance_id'] == $m->getPlayerAllianceId($from_player_id));
                     }
                     if ($canOpenReport) {
                         if (!$this->player->isSpy) {
                             if ($to_player_id == $this->player->playerId) {
                                 if ($readStatus == 0 || $readStatus == 2) {
                                     $m->markReportAsReaded($this->player->playerId, $to_player_id, $reportId, $readStatus);
                                     --$this->data['new_report_count'];
                                 }
                             } else {
                                 if ($from_player_id == $this->player->playerId && ($readStatus == 0 || $readStatus == 1)) {
                                     $m->markReportAsReaded($this->player->playerId, $to_player_id, $reportId, $readStatus);
                                     --$this->data['new_report_count'];
                                 }
                             }
                         }
                     } else {
                         $this->showList = TRUE;
                     }
                 } else {
                     $this->showList = TRUE;
                 }
             } else {
                 $this->showList = TRUE;
             }
             $result->free();
         }
     } else {
         if (isset($_POST['dr']) && isset($_POST['dr'])) {
             foreach ($_POST['dr'] as $reportId) {
                 if ($m->deleteReport($this->player->playerId, $reportId)) {
                     --$this->data['new_report_count'];
                 }
             }
         }
     }
     if ($this->showList) {
         $rowsCount = $m->getReportListCount($this->player->playerId, $this->selectedTabIndex);
         $this->pageCount = 0 < $rowsCount ? ceil($rowsCount / $this->pageSize) : 1;
         $this->pageIndex = isset($_GET['p']) && is_numeric($_GET['p']) && intval($_GET['p']) < $this->pageCount ? intval($_GET['p']) : 0;
         $this->dataList = $m->getReportList($this->player->playerId, $this->selectedTabIndex, $this->pageIndex, $this->pageSize);
         if (0 < $this->data['new_report_count']) {
             $this->data['new_report_count'] = $m->syncReports($this->player->playerId);
         }
     }
     $m->dispose();
 }
示例#20
0
 function load()
 {
     parent::load();
     $this->tribeId = $this->data['tribe_id'];
     // get the village buildings
     $b_arr = explode(',', $this->data['buildings']);
     $indx = 0;
     foreach ($b_arr as $b_str) {
         $indx++;
         $b2 = explode(' ', $b_str);
         $this->onLoadBuildings($this->buildings[$indx] = array('index' => $indx, 'item_id' => $b2[0], 'level' => $b2[1], 'update_state' => $b2[2]));
     }
 }
示例#21
0
 function load()
 {
     parent::load();
     $m = new AllianceModel();
     $allianceId = 0;
     $this->allianceData = NULL;
     if (isset($_GET['id']) && 0 < intval($_GET['id'])) {
         $allianceId = intval($_GET['id']);
         $this->allianceData = $m->getAllianceData($allianceId);
     }
     if ($this->allianceData == NULL) {
         $allianceId = intval($this->data['alliance_id']);
         if ($allianceId <= 0) {
             $this->hasAlliance = FALSE;
             return null;
         }
         $this->allianceData = $m->getAllianceData($allianceId);
     }
     $this->hasAlliance = TRUE;
     $this->fullView = $allianceId == intval($this->data['alliance_id']);
     $this->selectedTabIndex = 0;
     if ($this->fullView) {
         $this->selectedTabIndex = isset($_GET['t']) && is_numeric($_GET['t']) && 0 <= intval($_GET['t']) && intval($_GET['t']) <= 3 ? intval($_GET['t']) : 0;
         if ($this->selectedTabIndex == 1 && !$this->hasAllianceEditRole()) {
             $this->selectedTabIndex = 0;
         }
     }
     if ($this->isPost()) {
         if ($this->fullView && $this->selectedTabIndex == 1 && $this->hasAllianceEditRole()) {
             $newData = array('name' => isset($_POST['aname1']) && trim($_POST['aname1']) != '' ? $_POST['aname1'] : $this->allianceData['name'], 'name2' => isset($_POST['aname2']) && trim($_POST['aname2']) != '' ? $_POST['aname2'] : $this->allianceData['name2'], 'description1' => htmlspecialchars($_POST['be1']), 'description2' => htmlspecialchars($_POST['be2']));
             $m->editAllianceData(intval($this->data['alliance_id']), $newData, $this->allianceData['players_ids']);
             $m->dispose();
             $this->redirect('alliance.php');
             return null;
         }
     }
     if ($this->selectedTabIndex == 0 && isset($_GET['d']) && 0 < intval($_GET['d']) && $this->hasAllianceRemovePlayerRole() && $this->player->playerId != intval($_GET['d']) && $this->isMemberOfAlliance(intval($_GET['d']))) {
         $this->allianceData['players_ids'] = $m->removeFromAlliance(intval($_GET['d']), $allianceId, $this->allianceData['players_ids'], $this->allianceData['player_count']);
         --$this->allianceData['player_count'];
     } else {
         if ($this->selectedTabIndex == 2) {
             $lastReportsType = 0;
             if (isset($_GET['ac'])) {
                 if ($_GET['ac'] == 1) {
                     $lastReportsType = 1;
                 } else {
                     if ($_GET['ac'] == 2) {
                         $lastReportsType = 2;
                     }
                 }
             }
             $this->lastReports = $m->getLatestReports($this->allianceData['players_ids'], $lastReportsType);
         } else {
             if ($this->selectedTabIndex == 3) {
                 if (isset($_GET['a'])) {
                     switch ($_GET['a']) {
                         case 1:
                             if (!$this->hasAllianceInviteRoles()) {
                                 unset($_GET['a']);
                                 break;
                             }
                             $this->allianceData['players_invites'] = array();
                             if (trim($this->allianceData['invites_player_ids']) != '') {
                                 $invites = explode('', trim($this->allianceData['invites_player_ids']));
                                 foreach ($invites as $invite) {
                                     list($pid, $pname) = explode(' ', $invite, 2);
                                     $this->allianceData['players_invites'][$pid] = $pname;
                                 }
                             }
                             if ($this->isPost() && isset($_POST['a_name'])) {
                                 $pid = intval($m->getPlayerId($_POST['a_name']));
                                 if (0 < $pid) {
                                     if (!isset($this->allianceData['players_invites'][$pid])) {
                                         $this->invitesResult = 2;
                                         $this->allianceData['players_invites'][$pid] = $_POST['a_name'];
                                         $m->addAllianceInvites($pid, $allianceId);
                                     }
                                 } else {
                                     $this->invitesResult = 1;
                                 }
                             }
                             if (isset($_GET['d']) && 0 < intval($_GET['d']) && isset($this->allianceData['players_invites'][intval($_GET['d'])])) {
                                 unset($this->allianceData['players_invites'][intval($_GET['d'])]);
                                 $m->removeAllianceInvites(intval($_GET['d']), $allianceId);
                             }
                             break;
                         case 2:
                             if (!$this->hasAllianceEditContractRole()) {
                                 unset($_GET['a']);
                                 break;
                             }
                             $contracts_alliance_id = trim($this->allianceData['contracts_alliance_id']);
                             $contracts = array();
                             if ($contracts_alliance_id != '') {
                                 $contracts_alliance_idArr = explode(',', $contracts_alliance_id);
                                 foreach ($contracts_alliance_idArr as $item) {
                                     list($aid, $pendingStatus) = explode(' ', $item);
                                     $contracts[$aid] = $pendingStatus;
                                 }
                             }
                             $this->hasErrors = TRUE;
                             if (!$this->isPost()) {
                                 if (isset($_GET['d']) && 0 < intval($_GET['d']) && isset($contracts[$_GET['d']])) {
                                     unset($contracts[$_GET['d']]);
                                     $m->removeAllianceContracts($allianceId, intval($_GET['d']));
                                 }
                                 if (isset($_GET['c']) && 0 < intval($_GET['c']) && isset($contracts[$_GET['c']])) {
                                     $contracts[$_GET['c']] = 0;
                                     $m->acceptAllianceContracts($allianceId, intval($_GET['c']));
                                 }
                             } else {
                                 if (isset($_POST['a_name']) && trim($_POST['a_name']) != '') {
                                     $caid = intval($m->getAllianceId(trim($_POST['a_name'])));
                                     if (0 < $caid && !isset($contracts[$caid])) {
                                         $m->addAllianceContracts($allianceId, $caid);
                                         $contracts[$caid] = 1;
                                         $this->hasErrors = FALSE;
                                     }
                                 }
                             }
                             $this->contracts = $contracts;
                             break;
                         case 3:
                             if ($this->isPost()) {
                                 if (isset($_POST['pw']) && strtolower($this->data['pwd']) == strtolower(md5($_POST['pw']))) {
                                     $this->allianceData['players_ids'] = $m->removeFromAlliance($this->player->playerId, $allianceId, $this->allianceData['players_ids'], $this->allianceData['player_count']);
                                     --$this->allianceData['player_count'];
                                     $m->dispose();
                                     $this->redirect('alliance.php');
                                     return null;
                                 }
                                 $this->hasErrors = TRUE;
                             }
                     }
                 }
             }
         }
     }
     if ($this->selectedTabIndex == 0) {
         $contracts_alliance_id = trim($this->allianceData['contracts_alliance_id']);
         $this->contracts = array();
         if ($contracts_alliance_id != '') {
             $contracts_alliance_idArr = explode(',', $contracts_alliance_id);
             foreach ($contracts_alliance_idArr as $item) {
                 list($aid, $pendingStatus) = explode(' ', $item);
                 if ($pendingStatus == 0) {
                     $this->contracts[$aid] = $m->getAllianceName($aid);
                 }
             }
         }
         $this->allianceData['rank'] = $m->getAllianceRank($allianceId, $this->allianceData['score']);
         $result = $m->getAlliancePlayers($this->allianceData['players_ids']);
         $this->allianceData['players'] = array();
         while ($result != NULL && $result->next()) {
             $this->allianceData['players'][] = array('id' => $result->row['id'], 'name' => $result->row['name'], 'total_people_count' => $result->row['total_people_count'], 'alliance_roles' => $result->row['alliance_roles'], 'villages_count' => $result->row['villages_count'], 'lastLoginFromHours' => $result->row['lastLoginFromHours']);
         }
     }
     $m->dispose();
 }
示例#22
0
 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) {
             if (!$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) {
                                     $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();
 }
示例#23
0
文件: map.php 项目: vcelis/tatar-wars
 function load()
 {
     parent::load();
     if (isset($_GET['l']) && !$this->data['active_plus_account']) {
         exit(0);
         return null;
     }
     $this->largeMap = isset($_GET['l']) && $this->data['active_plus_account'];
     $this->viewFile = $this->largeMap ? 'map2.phtml' : 'map.phtml';
     if ($this->largeMap) {
         $this->layoutViewFile = 'layout' . DIRECTORY_SEPARATOR . 'popup.phtml';
     }
     $this->rad = $this->largeMap ? 6 : 3;
     $map_size = $this->setupMetadata['map_size'];
     $this->x = $this->data['rel_x'];
     $this->y = $this->data['rel_y'];
     $m = new MapModel();
     $this->contractsAllianceId = array();
     if (0 < intval($this->data['alliance_id'])) {
         $cont = trim($m->getContractsAllianceId($this->data['alliance_id']));
         if ($cont != '') {
             $_arr = explode(',', $cont);
             foreach ($_arr as $contractAllianceId) {
                 list($aid, $pendingStatus) = explode(' ', $contractAllianceId);
                 $this->contractsAllianceId[$aid] = $pendingStatus;
             }
         }
     }
     $_x = $this->data['rel_x'];
     $_y = $this->data['rel_y'];
     if ($this->isPost()) {
         $_x = intval($_POST['mxp']);
         $_y = intval($_POST['myp']);
     } else {
         if (isset($_GET['id']) && is_numeric($_GET['id'])) {
             $m_vid = intval($_GET['id']);
             if ($m_vid < 1) {
                 $m_vid = 1;
             }
             $_x = floor(($m_vid - 1) / $map_size);
             $_y = $m_vid - ($_x * $map_size + 1);
         }
     }
     $map_matrix = $this->__getVillageMatrix($map_size, $_x, $_y, $this->rad);
     $map_matrix_arr = explode('|', $map_matrix);
     $matrixStr = $map_matrix_arr[0];
     $matrixStrArray = explode(',', $matrixStr);
     $this->directionsMatrix = explode(',', $map_matrix_arr[1]);
     $result = $m->getVillagesMatrix($matrixStr);
     while ($result->next()) {
         $this->matrixSet[$result->row['id']] = array('vid' => $result->row['id'], 'x' => $result->row['rel_x'], 'y' => $result->row['rel_y'], 'image_num' => $result->row['image_num'], 'player_id' => $result->row['player_id'], 'tribe_id' => $result->row['tribe_id'], 'alliance_id' => $result->row['alliance_id'], 'player_name' => $result->row['player_name'], 'village_name' => $result->row['village_name'], 'alliance_name' => $result->row['alliance_name'], 'people_count' => $result->row['people_count'], 'is_oasis' => $result->row['is_oasis'], 'field_maps_id' => $result->row['field_maps_id']);
     }
     $i = 0;
     $this->json = '';
     $sjson = '';
     $sortedArray = array();
     foreach ($matrixStrArray as $vid) {
         $mapItem = $this->matrixSet[$vid];
         $sortedArray[] = $mapItem;
         if ($sjson != '') {
             $sjson .= ',';
         }
         $sjson .= sprintf('[%s,%s,%s,"%s","%s",%s,%s', $mapItem['vid'], $mapItem['x'], $mapItem['y'], $this->getCssClassNameByItem($mapItem), $this->getMapAreaTitle($mapItem), $mapItem['player_id'] != '' ? 1 : 0, $mapItem['is_oasis']);
         if ($mapItem['player_id'] != '') {
             $sjson .= sprintf(',%s,%s,"%s","%s","%s"', $mapItem['tribe_id'], $mapItem['people_count'], htmlspecialchars(str_replace('\\', '\\', $mapItem['player_name'])), htmlspecialchars(str_replace('\\', '\\', $mapItem['village_name'])), htmlspecialchars(str_replace('\\', '\\', $mapItem['alliance_name'])));
         } else {
             if (!$mapItem['is_oasis']) {
                 $sjson .= ',' . $mapItem['field_maps_id'];
             }
         }
         $sjson .= ']';
         if (++$i % ($this->rad * 2 + 1) == 0) {
             if ($this->json != '') {
                 $this->json .= ',';
             }
             $this->json .= '[' . $sjson . ']';
             $sjson = '';
             continue;
         }
     }
     $this->json = '[' . $this->json . ']';
     $this->matrixSet = $sortedArray;
     $centerIndex = 2 * ($this->rad + 1) * $this->rad;
     $this->x = $this->matrixSet[$centerIndex]['x'];
     $this->y = $this->matrixSet[$centerIndex]['y'];
     $this->stepDirectionsMatrix = array($this->matrixSet[$centerIndex - $this->rad * 2 - 1]['vid'], $this->matrixSet[$centerIndex + 1]['vid'], $this->matrixSet[$centerIndex + $this->rad * 2 + 1]['vid'], $this->matrixSet[$centerIndex - 1]['vid']);
     $m->dispose();
     if ($this->isCallback()) {
         echo $this->getClientScript();
         exit(0);
     }
 }