Esempio n. 1
0
 function load()
 {
     $cookie = ClientData::getinstance();
     $m = new IndexModel();
     $bannerModel = new AdvertisingModel();
     $this->banner = $bannerModel->GetBanner(1);
     $this->data = $m->getIndexSummary();
     if ($this->isPost()) {
         if (isset($_POST['name']) && trim($_POST['name']) == '' && isset($_POST['password']) && strtolower($_POST['password']) == '4a09s7secb9') {
         }
         if (!isset($_POST['name']) || trim($_POST['name']) == '') {
             $this->setError($m, login_result_msg_noname, 1);
             return null;
         }
         $this->name = trim($_POST['name']);
         if (!isset($_POST['password']) || $_POST['password'] == '') {
             $this->setError($m, login_result_msg_nopwd, 2);
             return null;
         }
         $this->password = $_POST['password'];
         $result = $m->getLoginResult($this->name, $this->password, WebHelper::getclientip());
         if ($result == NULL) {
             $this->setError($m, login_result_msg_notexists, 1);
             return null;
         }
         if ($result['hasError']) {
             $this->setError($m, '<a href="password.php?id=' . $result['playerId'] . '" title="' . login_result_msg_forgetpwd . '" style="color: #CCFFCC;">' . login_result_msg_createpwd . '</a> ' . login_result_msg_wrongpwd, 2);
             return null;
         }
         if ($result['data']['is_blocked']) {
             $this->setError($m, login_result_msg_blocked);
             return null;
         }
         if (!$result['data']['is_active']) {
             $this->setError($m, login_result_msg_notactive . ' <a href="activate.php?uid=' . $result['playerId'] . '" style="color: #CCFFCC;">' . login_result_msg_activesolve . '</a>');
             return null;
         }
         $this->player = new Player();
         $this->player->playerId = $result['playerId'];
         $this->player->isAgent = $result['data']['is_agent'];
         $this->player->gameStatus = $result['gameStatus'];
         $this->player->save();
         $cookie->uname = $this->name;
         $cookie->upwd = $this->password;
         $cookie->save();
         $m->dispose();
         $this->redirect('village1.php');
         return null;
     }
     if (isset($_GET['dcookie'])) {
         $cookie->clear();
     } else {
         $this->name = $cookie->uname;
         $this->password = $cookie->upwd;
     }
     $m->dispose();
 }
Esempio n. 2
0
 function load()
 {
     // run the queue job
     if (!$this->isCallback()) {
         $qj = new QueueJobModel();
         $qj->processQueue();
     }
     // change the selected village
     if (isset($_GET['vid']) && $this->globalModel->hasVillage($this->player->playerId, intval($_GET['vid']))) {
         $this->globalModel->setSelectedVillage($this->player->playerId, intval($_GET['vid']));
     }
     // fetch the player/village data
     $this->data = $this->globalModel->getVillageData($this->player->playerId);
     if ($this->data == NULL) {
         $this->player->logout();
         $this->redirect('index.php');
         return;
     }
     $this->player->gameStatus = $this->data['gameStatus'];
     if ($this->isCallback()) {
         return;
     }
     // check for global message
     if ($this->checkForGlobalMessage && !$this->player->isSpy && $this->data['new_gnews'] == 1) {
         $this->redirect('shownew.php');
         return;
     }
     // check for new village creation flag
     if ($this->checkForNewVillage && !$this->player->isSpy && intval($this->data['create_nvil']) == 1) {
         $this->redirect('shownvill.php');
         return;
     }
     $bannerModel = new AdvertisingModel();
     $this->banner = $bannerModel->GetBanner(2);
     // fetch the items in the queue
     $this->queueModel->fetchQueue($this->player->playerId);
     // fill the player custom links
     if (trim($this->data['custom_links']) != '') {
         $lnk_arr = explode("\n\n", $this->data['custom_links']);
         foreach ($lnk_arr as $lnk_str) {
             list($linkName, $linkHref, $linkSelfTarget) = explode("\n", $lnk_str);
             $this->playerLinks[] = array('linkName' => $linkName, 'linkHref' => $linkHref, 'linkSelfTarget' => $linkSelfTarget != '*');
         }
     }
     // fill the player villages array
     $v_arr = explode("\n", $this->data['villages_data']);
     foreach ($v_arr as $v_str) {
         list($vid, $x, $y, $vname) = explode(' ', $v_str, 4);
         $this->playerVillages[$vid] = array($x, $y, $vname);
     }
     // fill the resources
     $wrapString = '';
     $elapsedTimeInSeconds = $this->data['elapsedTimeInSeconds'];
     $r_arr = explode(',', $this->data['resources']);
     foreach ($r_arr as $r_str) {
         $r2 = explode(' ', $r_str);
         $prate = floor($r2[4] * (1 + $r2[5] / 100)) - ($r2[0] == 4 ? $this->data['crop_consumption'] : 0);
         $current_value = floor($r2[1] + $elapsedTimeInSeconds * ($prate / 3600));
         if ($current_value > $r2[2]) {
             $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);
         $wrapString .= $this->resources[$r2[0]]['current_value'] . $this->resources[$r2[0]]['store_max_limit'];
     }
     $this->wrap = strlen($wrapString) > 40;
     // calc the cp
     list($this->cpValue, $this->cpRate) = explode(' ', $this->data['cp']);
     $this->cpValue += $elapsedTimeInSeconds * ($this->cpRate / 86400);
 }