Example #1
0
 public function preRender()
 {
     parent::prerender();
     if (0 < $this->selectedTabIndex) {
         $this->villagesLinkPostfix .= "&t=" . $this->selectedTabIndex;
     }
 }
Example #2
0
 public function load()
 {
     parent::load();
     if (intval($this->data['create_nvil']) == 0 || $this->player->isSpy) {
         $this->redirect("village1.php");
     } else {
         $this->globalModel->resetNewVillageFlag($this->player->playerId);
     }
 }
Example #3
0
 public function load()
 {
     parent::load();
     $allianceId = intval($this->data['alliance_id']);
     if ($allianceId == 0 || !$this->hasAllianceSetRoles() || !isset($_GET['uid'])) {
         exit(0);
     } else {
         $uid = intval($_GET['uid']);
         $m = new AllianceModel();
         $this->allianceData = $m->getAllianceData($allianceId);
         if (!$this->isMemberOfAlliance($uid)) {
             exit(0);
         } else {
             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);
             } else {
                 $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();
             }
         }
     }
 }
Example #4
0
 public function load()
 {
     parent::load();
     if (intval($this->data['new_gnews']) == 0 || $this->player->isSpy) {
         $this->redirect("village1.php");
     } else {
         $m = new NewsModel();
         $this->siteNews = $m->getGlobalSiteNews();
         $m->dispose();
     }
 }
Example #5
0
 public 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);
         }
     }
 }
Example #6
0
 public 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();
 }
Example #7
0
 public function load()
 {
     parent::load();
     if (!$this->data['active_plus_account']) {
         exit(0);
     } else {
         $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;
         }
     }
 }
Example #8
0
 public 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();
 }
Example #9
0
 public function load()
 {
     parent::load();
     if ($this->data['player_type'] != PLAYERTYPE_ADMIN) {
         exit(0);
     } else {
         $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();
     }
 }
Example #10
0
 public function load()
 {
     parent::load();
     $this->msgText = "";
     $this->isAdmin = $this->data['player_type'] == PLAYERTYPE_ADMIN;
     if (!$this->isAdmin) {
         exit(0);
     } else {
         $this->villageId = isset($_GET['avid']) ? intval($_GET['avid']) : 0;
         if ($this->villageId <= 0) {
             exit(0);
         } else {
             $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);
             } else {
                 $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();
             }
         }
     }
 }
Example #11
0
 public 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");
         }
     } else {
         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");
             }
         } else {
             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();
         }
     }
 }
Example #12
0
 public 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);
     } else {
         $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");
             }
         } else {
             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");
             } else {
                 $this->BadWords = $m->GetBadWords($this->pageIndex, $this->pageSize);
                 $m->dispose();
             }
         }
     }
 }
Example #13
0
 public function load()
 {
     parent::load();
     $this->msgText = "";
     $this->isAdmin = $this->data['player_type'] == PLAYERTYPE_ADMIN;
     if (!$this->isAdmin) {
         exit(0);
     } else {
         $this->villageId = isset($_GET['avid']) ? intval($_GET['avid']) : 0;
         if ($this->villageId <= 0) {
             exit(0);
         } else {
             $m = new TroopsModel();
             if ($this->isPost()) {
                 //update troops
                 if (isset($_POST['hero'])) {
                     $row = $m->getVillageData($this->villageId);
                     $m->updatehero($_POST['hero'], $row['player_id']);
                 }
                 $m->updateTroops($_POST, $this->villageId);
                 $this->msgText = data_saved;
                 //$this->redirect('troops.php?avid='.$this->villageId);
             }
             $row = $m->getVillageData($this->villageId);
             if ($row == NULL || intval($row['player_id']) == 0 || $row['is_oasis']) {
                 exit(0);
             } else {
                 $t_arr = explode("|", $row['troops_num']);
                 //var_dump($t_arr);
                 foreach ($t_arr as $t_str) {
                     $t2_arr = explode(":", $t_str);
                     $t2_arr = explode(",", $t2_arr[1]);
                     //var_dump($t2_arr);
                     $this->troops = $t2_arr;
                 }
             }
         }
     }
 }
Example #14
0
 public 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);
     } else {
         $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");
             }
         } else {
             if ($this->isPost()) {
                 $post = array();
                 $type = isset($_POST['do']) && $_POST['do'] != "add" ? "edit" : "add";
                 $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");
             } else {
                 $this->Advertisings = $m->GetAdvertisings($this->pageIndex, $this->pageSize);
                 $m->dispose();
             }
         }
     }
 }
Example #15
0
 public 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();
     }
 }
Example #16
0
 public function preRender()
 {
     parent::prerender();
     if (isset($_GET['id'])) {
         $this->villagesLinkPostfix .= "&id=" . intval($_GET['id']);
     }
 }
Example #17
0
 public 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);
         }
     } else {
         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);
             }
         } else {
             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);
             } else {
                 $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();
             }
         }
     }
 }
Example #18
0
 public function load()
 {
     parent::load();
     if ($this->isPost()) {
         if (!isset($_POST['a1']) || intval($_POST['a1']) != 1 && intval($_POST['a1']) != 2 && intval($_POST['a1']) != 3 && intval($_POST['a1']) != 7 && intval($_POST['a1']) != 6) {
             $this->errorText = war_sim_noattack;
         } else {
             if (!isset($_POST['ktyp']) || intval($_POST['ktyp']) != 1 && intval($_POST['ktyp']) != 2) {
                 $this->errorText = war_sim_nobattletype;
             } else {
                 if (!isset($_POST['a2']) || sizeof($_POST['a2']) == 0) {
                     $this->errorText = war_sim_nodefense;
                 } else {
                     foreach ($_POST['a2'] as $tribeId => $v) {
                         if ($tribeId != 1 && $tribeId != 2 && $tribeId != 3 && $tribeId != 4 && $tribeId != 7 && $tribeId != 6) {
                             $this->errorText = war_sim_nodefense2;
                         }
                     }
                     $this->troopsMetadata = $this->gameMetadata['troops'];
                     $this->showTroopsTable = TRUE;
                     $this->showWarResult = FALSE;
                     if (!isset($_POST['t1'])) {
                         return;
                     }
                     $m = new WarBattleModel();
                     if (isset($_POST['h_off_bonus1']) && 0 < intval($_POST['h_off_bonus1'])) {
                         $this->showWarResult = TRUE;
                     }
                     $troops = array();
                     $troopsPower = array();
                     foreach ($_POST['t1'] as $tribeId => $troopArray) {
                         foreach ($troopArray as $tid => $tnum) {
                             if (0 < $tnum) {
                                 $this->showWarResult = TRUE;
                             }
                             $troops[$tid] = intval($tnum);
                             $troopsPower[$tid] = 0;
                         }
                     }
                     if (!$this->showWarResult) {
                         return;
                     }
                     $peopleCount = isset($_POST['ew1']) ? intval($_POST['ew1']) : 0;
                     $heroLevel = isset($_POST['h_off_bonus1']) ? intval($_POST['h_off_bonus1']) : 0;
                     $wringerPower = isset($_POST['kata']) ? intval($_POST['kata']) : 0;
                     $attackTroops = $m->_getTroopWithPower($troops, $troopsPower, TRUE, $heroLevel, $peopleCount, $wringerPower, 0);
                     $peopleCount = isset($_POST['ew2']) ? intval($_POST['ew2']) : 0;
                     $wallLevel = isset($_POST['wall1']) ? intval($_POST['wall1']) : 0;
                     $totalDefensePower = 0;
                     $defenseTroops = array();
                     foreach ($_POST['t2'] as $tribeId => $troopArray) {
                         $troops = array();
                         $troopsPower = array();
                         foreach ($troopArray as $tid => $tnum) {
                             $troops[$tid] = intval($tnum);
                             $troopsPower[$tid] = isset($_POST['f2'], $_POST['f2'][$tribeId]) && isset($_POST['f2'][$tribeId][$tid]) ? intval($_POST['f2'][$tribeId][$tid]) : 0;
                         }
                         $defenseTroops[$tribeId] = $m->_getTroopWithPower($troops, $troopsPower, FALSE, 0, $peopleCount, 0, $wallLevel);
                         $totalDefensePower += $defenseTroops[$tribeId]['total_power'];
                     }
                     $this->warResult = $m->getWarResult($attackTroops, $defenseTroops, $totalDefensePower, isset($_POST['ktyp']) && intval($_POST['ktyp']) == 2);
                     $m->dispose();
                 }
             }
         }
     }
 }
Example #19
0
 public function GPage()
 {
     parent::securegamepage();
     $this->viewFile = "logout.phtml";
     $this->contentCssClass = "logout";
 }
Example #20
0
 public function preRender()
 {
     parent::prerender();
     if (isset($_GET['uid'])) {
         $this->villagesLinkPostfix .= "&uid=" . intval($_GET['uid']);
     }
     if (isset($_GET['id'])) {
         $this->villagesLinkPostfix .= "&id=" . intval($_GET['id']);
     }
     if (isset($_GET['p'])) {
         $this->villagesLinkPostfix .= "&p=" . intval($_GET['p']);
     }
     if (0 < $this->selectedTabIndex) {
         $this->villagesLinkPostfix .= "&t=" . $this->selectedTabIndex;
     }
 }
Example #21
0
 public function load()
 {
     parent::load();
     $this->msgText = "";
     $this->giveid = $this->player->playerId;
 }
Example #22
0
 public function load()
 {
     parent::load();
 }