function getRemainingPlusTime($action) { $time = 0; $tasks = $this->queueModel->tasksInQueue; if (isset($tasks[constant('QS_PLUS' . ($action + 1))])) { $time = $tasks[constant('QS_PLUS' . ($action + 1))][0]['remainingSeconds']; } return 0 < $time ? time_remain_lang . ' <span id="timer1">' . WebHelper::secondstostring($time) . '</span> ' . time_hour_lang : ''; }
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(); }
public function getRemainingPlusTime($action) { $time = 0; $tasks = $this->queueModel->tasksInQueue; if (isset($tasks[constant("QS_PLUS" . ($action + 1))])) { $time = $tasks[constant("QS_PLUS" . ($action + 1))][0]['remainingSeconds']; } return 0 < $time ? time_remain_lang . " <span id=\"timer1\">" . WebHelper::secondstostring($time) . "</span> " . time_hour_lang : ""; }
/** * Perform the request against the api */ public function execute() { $endpointUrl = $this->endpointUri . "/" . $this->getRoute(); $response = WebHelper::getJsonWebRequest($endpointUrl, $this->requestDetails, array(CURLOPT_HTTPHEADER => array("Api-Key:" . $this->credentials->getApiKey(), "Authorization: " . $this->credentials->getAuthorizationHeaderValue()))); if ($response["http_code"] != 200) { throw new \Exception("Non 200 status code returned: " . $response["http_code"] . "\nBody: " . $response["body"]); } return $response["body"]; }
public function load() { parent::load(); $this->SNdata = 0; $this->success = FALSE; $ip = $_SERVER['REMOTE_ADDR']; if ($this->isPost()) { if ($this->globalModel->isGameOver()) { $this->redirect("over.php"); } else { $name = trim($_POST['name']); $email = trim($_POST['email']); $pwd = trim($_POST['pwd']); $this->err[0] = strlen($name) < 3 ? register_player_txt_notless3 : ""; if ($this->err[0] == "") { $this->err[0] = preg_match("/[:,\\. \\n\\r\\t\\s]+/", $name) ? register_player_txt_invalidchar : ""; } if ($name == "[ally]" || $name == "admin" || $name == "administrator" || $name == "مدير" || $name == "تتار" || $name == "التتار" || $name == "دعم" || $name == "الدعم" || $name == $this->appConfig['system']['adminName'] || $name == tatar_tribe_player) { $this->err[0] = register_player_txt_reserved; } $this->err[1] = !preg_match("/^[^@]+@[a-zA-Z0-9._-]+\\.[a-zA-Z]+\$/", $email) ? register_player_txt_invalidemail : ""; $this->err[2] = strlen($pwd) < 4 ? register_player_txt_notless4 : ""; $this->err[3] = !isset($_POST['tid']) || $_POST['tid'] != 1 && $_POST['tid'] != 2 && $_POST['tid'] != 3 && $_POST['tid'] != 6 && $_POST['tid'] != 7 ? "<li>" . register_player_txt_choosetribe . "</li>" : ""; $this->err[3] .= !isset($_POST['kid']) || !is_numeric($_POST['kid']) || $_POST['kid'] < 0 || 4 < $_POST['kid'] ? "<li>" . register_player_txt_choosestart . "</li>" : ""; if (0 < strlen($this->err[0]) || 0 < strlen($this->err[1]) || 0 < strlen($this->err[2]) || 0 < strlen($this->err[3])) { return; } $m = new RegisterModel(); $this->err[0] = $m->isPlayerNameExists($name) ? register_player_txt_usedname : ""; $this->err[1] = $m->isPlayerEmailExists($email) ? register_player_txt_usedemail : ""; $this->err[1] = $m->isPlayerIpExists($ip) ? "Canot Register IP address already in use" : ""; if (0 < strlen($this->err[0]) || 0 < strlen($this->err[1])) { $m->dispose(); } else { $ip = $_SERVER['REMOTE_ADDR']; $villageName = new_village_name_prefix . " " . $name; #removed 'PLAYERTYPE_NORMAL' right after map_size thing. Dunno why it doesnt make him player_type = 1 but owke. $result = $m->createNewPlayer($name, $email, $pwd, $_POST['tid'], $_POST['kid'], $villageName, $this->setupMetadata['map_size'], 1, 1, $this->SNdata, $ip); if ($result['hasErrors']) { $this->err[3] = register_player_txt_fullserver; $m->dispose(); } else { $m->dispose(); $link = WebHelper::getbaseurl() . "activate.php?id=" . $result['activationCode']; $to = $email; $from = $this->appConfig['system']['email']; $subject = register_player_txt_regmail_sub; $message = sprintf(register_player_txt_regmail_body, $name, $name, $pwd, $link, $link); WebHelper::sendmail($to, $from, $subject, $message); $this->success = TRUE; } } } } }
function load() { parent::load(); $this->SNdata = 0; $this->success = FALSE; if ($this->isPost()) { if ($this->globalModel->isGameOver()) { $this->redirect('over.php'); return null; } $name = trim($_POST['name']); $email = trim($_POST['email']); $pwd = trim($_POST['pwd']); $this->err[0] = strlen($name) < 3 ? register_player_txt_notless3 : ''; if ($this->err[0] == '') { $this->err[0] = preg_match('/[:,\\. \\n\\r\\t\\s]+/', $name) ? register_player_txt_invalidchar : ''; } if ($name == '[ally]' || $name == 'admin' || $name == 'administrator' || $name == 'مدير' || $name == 'تتار' || $name == 'التتار' || $name == 'دعم' || $name == 'الدعم' || $name == $this->appConfig['system']['adminName'] || $name == tatar_tribe_player) { $this->err[0] = register_player_txt_reserved; } $this->err[1] = !preg_match("/^[^@]+@[a-zA-Z0-9._-]+\\.[a-zA-Z]+\$/", $email) ? register_player_txt_invalidemail : ""; $this->err[2] = strlen($pwd) < 4 ? register_player_txt_notless4 : ""; $this->err[3] = !isset($_POST['tid']) || $_POST['tid'] != 1 && $_POST['tid'] != 2 && $_POST['tid'] != 3 && $_POST['tid'] != 6 && $_POST['tid'] != 8 && $_POST['tid'] != 7 && $_POST['tid'] != 8 && $_POST['tid'] != 9 ? "<li>" . register_player_txt_choosetribe . "</li>" : ""; $this->err[3] .= !isset($_POST['kid']) || !is_numeric($_POST['kid']) || $_POST['kid'] < 0 || 4 < $_POST['kid'] ? "<li>" . register_player_txt_choosestart . "</li>" : ""; if (0 < strlen($this->err[0]) || 0 < strlen($this->err[1]) || 0 < strlen($this->err[2]) || 0 < strlen($this->err[3])) { return null; } $m = new RegisterModel(); $this->err[0] = $m->isPlayerNameExists($name) ? register_player_txt_usedname : ''; $this->err[1] = $m->isPlayerEmailExists($email) ? register_player_txt_usedemail : ''; if (0 < strlen($this->err[0]) || 0 < strlen($this->err[1])) { $m->dispose(); return null; } $villageName = new_village_name_prefix . ' ' . $name; $result = $m->createNewPlayer($name, $email, $pwd, $_POST['tid'], $_POST['kid'], $villageName, $this->setupMetadata['map_size'], PLAYERTYPE_NORMAL, 1, $this->SNdata); if ($result['hasErrors']) { $this->err[3] = register_player_txt_fullserver; $m->dispose(); return null; } $m->dispose(); $link = WebHelper::getbaseurl() . 'activate.php?id=' . $result['activationCode']; $to = $email; $from = $this->appConfig['system']['email']; $subject = register_player_txt_regmail_sub; $message = sprintf(register_player_txt_regmail_body, $name, $name, $pwd, $link, $link); WebHelper::sendmail($to, $from, $subject, $message); $this->success = TRUE; } }
function processSetup($map_size, $adminEmail) { $this->_createTables(); $this->_createMap($map_size); if ($this->_createAdminPlayer($map_size, $adminEmail)) { $raiseTime = 10 / $GLOBALS['GameMetadata']['game_speed']; $raiseTime *= 2592000; $raiseTime = intval($raiseTime); if ($raiseTime < 2592000) { $raiseTime = 2592000; } $queueModel = new QueueModel(); new QueueTask($queueModel->addTask(QS_TATAR_RAISE, 0, $raiseTime)); GameLicense::set(WebHelper::getdomain()); } }
public function load() { parent::load(); $m = new PasswordModel(); if ($this->isPost() && isset($_POST['id']) && isset($_POST['email']) && is_numeric($_POST['id'])) { $playerId = intval($_POST['id']); $email = $_POST['email']; $this->pageState = $m->isPlayerIdHasEmail($playerId, $email) ? 3 : 2; if ($this->pageState == 3) { $name = $m->getPlayerName($playerId); $newPassword = substr(md5(dechex($playerId * mt_rand(10, 100))), mt_rand(1, 5), 7); $n = dechex(hexdec($newPassword) ^ hexdec(substr(md5($name), 2, 7))); $link = WebHelper::getbaseurl() . "password.php?id=" . $playerId . "&n=" . $n . "&c=" . substr(md5(dechex($playerId) . $name . "777"), 7, 7); $to = $email; $from = $this->appConfig['system']['email']; $subject = forget_password_subject; $message = sprintf(forget_password_body, $name, $name, $newPassword, $link, $link); WebHelper::sendmail($to, $from, $subject, $message); } } else { if (isset($_GET['id']) && is_numeric($_GET['id'])) { $this->playerId = intval($_GET['id']); $this->pageState = $m->isPlayerIdExists($this->playerId) ? 1 : 0 - 1; if (isset($_GET['n']) && trim($_GET['n']) != "" && isset($_GET['c'])) { if ($this->pageState == 1) { $name = $m->getPlayerName($this->playerId); if (trim($_GET['c']) == substr(md5(dechex($this->playerId) . $name . "777"), 7, 7)) { $newPassword = dechex(hexdec($_GET['n']) ^ hexdec(substr(md5($name), 2, 7))); $m->setPlayerPassword($this->playerId, $newPassword); $this->pageState = 4; } else { $this->pageState = 5; } } else { $this->pageState = 5; } } } } $m->dispose(); }
function getActionText($neededResources, $isField, $upgrade, &$item_id) { $needUpgradeType = $this->needMoreUpgrades($neededResources, $item_id); if (0 < $needUpgradeType) { switch ($needUpgradeType) { case 1: '<span class="none">' . buildings_p_upg0 . '</span>'; case 2: '<span class="none">' . buildings_p_upg1 . '</span>'; case 3: '<span class="none">' . buildings_p_upg2 . '</span>'; case 4: '<span class="none">' . buildings_p_upg3 . '</span>'; } return; } else { if ($this->isResourcesAvailable($neededResources)) { $pageNamePostfix = $isField ? '1' : '2'; $link = $upgrade ? '<a class="build" href="village' . $pageNamePostfix . '.php?id=' . $this->buildingIndex . '&k=' . $this->data['update_key'] . '">' . buildings_p_upg_tolevel . ' ' . $this->buildProperties['nextLevel'] . '</a>' : '<a class="build" href="village2.php?id=' . $this->buildingIndex . '&b=' . $item_id . '&k=' . $this->data['update_key'] . '">' . buildings_p_create_newbuild . '</a>'; $workerResult = $this->isWorkerBusy($isField); return $workerResult['isBusy'] ? '<span class="none">' . buildings_p_workersbusy . '</span>' : $link . ($workerResult['isPlusUsed'] ? ' <span class="none">(' . buildings_p_wait_buildqueue . ')</span>' : ''); } } $neededTime = $this->getNeededTime($neededResources); return '<span class="none">' . (0 < $neededTime ? buildings_p_willenoughresat . ' ' . WebHelper::secondstostring($neededTime) . ' ' . time_hour_lang : buildings_p_notenoughres2) . '</span>'; }
?> </td> </tr> <?php } ?> </tbody> </table> <?php } ?> <div class="smallMargins"> <?php WebHelper::linkButton(array('linkClass' => 'btnAdd', 'text' => 'Agregar Contacto', 'target' => url_for('contacto/new?cliente_id=' . $cliente->getId()))); ?> </div> </div> <hr/> <div class="smallMargins"> <?php WebHelper::linkButton(array('linkClass' => 'btnBack', 'text' => 'Volver', 'target' => url_for('cliente/index'))); ?> </div>
public function handleMarketplace() { $this->selectedTabIndex = isset($_GET['t']) && is_numeric($_GET['t']) && 1 <= intval($_GET['t']) && intval($_GET['t']) <= 3 ? intval($_GET['t']) : 0; $itemId = $this->buildings[$this->buildingIndex]['item_id']; $itemLevel = $this->buildings[$this->buildingIndex]['level']; $tribeMetadata = $this->gameMetadata['tribes'][$this->data['tribe_id']]; $tradeOfficeLevel = $this->_getMaxBuildingLevel(28); $capacityFactor = $tradeOfficeLevel == 0 ? 1 : $this->gameMetadata['items'][28]['levels'][$tradeOfficeLevel - 1]['value'] / 100; $capacityFactor *= $this->gameMetadata['game_speed']; $total_merchants_num = $this->gameMetadata['items'][$itemId]['levels'][$itemLevel - 1]['value']; $exist_num = $total_merchants_num - $this->queueModel->tasksInQueue['out_merchants_num'] - $this->data['offer_merchants_count']; if ($exist_num < 0) { $exist_num = 0; } $this->merchantProperty = array("speed" => $tribeMetadata['merchants_velocity'] * $this->gameMetadata['game_speed'], "capacity" => floor($tribeMetadata['merchants_capacity'] * $capacityFactor), "total_num" => $total_merchants_num, "exits_num" => $exist_num, "confirm_snd" => FALSE, "same_village" => FALSE, "vRow" => NULL); if ($this->selectedTabIndex == 0) { $m = new BuildModel(); if ($this->isPost() || isset($_GET['vid2'])) { $resources = array("1" => isset($_POST['r1']) ? intval($_POST['r1']) : 0, "2" => isset($_POST['r2']) ? intval($_POST['r2']) : 0, "3" => isset($_POST['r3']) ? intval($_POST['r3']) : 0, "4" => isset($_POST['r4']) ? intval($_POST['r4']) : 0); $this->merchantProperty['confirm_snd'] = $this->isPost() ? isset($_POST['act']) && $_POST['act'] == 1 : isset($_GET['vid2']); $map_size = $this->setupMetadata['map_size']; $doSend = FALSE; if ($this->merchantProperty['confirm_snd']) { $vRow = NULL; if (trim($_POST['y']) != "") { $vid = $this->__getVillageId($map_size, $this->__getCoordInRange($map_size, intval($_POST['x'])), $this->__getCoordInRange($map_size, intval($_POST['y']))); $vRow = $m->getVillageDataById($vid); } else { if (isset($_POST['vname']) && trim($_POST['vname']) != "") { $vRow = $m->getVillageDataByName(trim($_POST['vname'])); } else { if (isset($_GET['vid2'])) { $vRow = $m->getVillageDataById(intval($_GET['vid2'])); if ($vRow != NULL) { $_POST['x'] = $vRow['rel_x']; $_POST['y'] = $vRow['rel_y']; } } } } } else { $doSend = TRUE; $vRow = $m->getVillageDataById(intval($_POST['vid2'])); $this->merchantProperty['showError'] = FALSE; $_POST['r1'] = $_POST['r2'] = $_POST['r3'] = $_POST['r4'] = ""; } if (0 < intval($vRow['player_id']) && $m->getPlayType(intval($vRow['player_id'])) == PLAYERTYPE_ADMIN) { $this->merchantProperty['showError'] = FALSE; $this->merchantProperty['confirm_snd'] = FALSE; } else { $this->merchantProperty['vRow'] = $vRow; $vid = $this->merchantProperty['to_vid'] = $vRow != NULL ? $vRow['id'] : 0; $rel_x = $vRow['rel_x']; $rel_y = $vRow['rel_y']; $this->merchantProperty['same_village'] = $vid == $this->data['selected_village_id']; $this->merchantProperty['available_res'] = $this->isResourcesAvailable($resources); $this->merchantProperty['vRow_merchant_num'] = ceil(($resources[1] + $resources[2] + $resources[3] + $resources[4]) / $this->merchantProperty['capacity']); $this->merchantProperty['confirm_snd'] = 0 < $vid && $this->merchantProperty['available_res'] && 0 < $this->merchantProperty['vRow_merchant_num'] && $this->merchantProperty['vRow_merchant_num'] <= $this->merchantProperty['exits_num'] && !$this->merchantProperty['same_village']; $this->merchantProperty['showError'] = !$this->merchantProperty['confirm_snd']; $distance = WebHelper::getdistance($this->data['rel_x'], $this->data['rel_y'], $rel_x, $rel_y, $this->setupMetadata['map_size'] / 2); $this->merchantProperty['vRow_time'] = intval($distance / $this->merchantProperty['speed'] * 3600); if (!$this->merchantProperty['showError'] && $doSend && !$this->isGameTransientStopped() && !$this->isGameOver()) { $this->merchantProperty['confirm_snd'] = FALSE; $this->merchantProperty -= "exits_num"; $newTask = new QueueTask(QS_MERCHANT_GO, $this->player->playerId, $this->merchantProperty['vRow_time']); $newTask->villageId = $this->data['selected_village_id']; $newTask->toPlayerId = $vRow['player_id']; $newTask->toVillageId = $vid; $newTask->procParams = $this->merchantProperty['vRow_merchant_num'] . "|" . ($resources[1] . " " . $resources[2] . " " . $resources[3] . " " . $resources[4]); $newTask->tag = $resources; $this->queueModel->addTask($newTask); } } } $m->dispose(); } else { if ($this->selectedTabIndex == 1) { $m = new BuildModel(); $showOfferList = TRUE; if (isset($_GET['oid']) && 0 < intval($_GET['oid'])) { $oRow = $m->getOffer2(intval($_GET['oid']), $this->data['rel_x'], $this->data['rel_y'], $this->setupMetadata['map_size'] / 2); if ($oRow != NULL) { $aid = 0; if ($oRow['alliance_only'] && 0 < intval($this->data['alliance_id'])) { $aid = $m->getPlayerAllianceId($oRow['player_id']); } $res2 = explode("|", $oRow['offer']); $res1 = explode("|", $oRow['offer']); list($res1, $res2) = $res1; $resArr1 = explode(" ", $res1); $needResources = array("1" => $resArr1[0], "2" => $resArr1[1], "3" => $resArr1[2], "4" => $resArr1[3]); $res1_item_id = 0; $res1_value = 0; $i = 0; $_c = sizeof($resArr1); while ($i < $_c) { if (0 < $resArr1[$i]) { $res1_item_id = $i + 1; $res1_value = $resArr1[$i]; break; } ++$i; } $resArr1 = explode(" ", $res2); $giveResources = array("1" => $resArr1[0], "2" => $resArr1[1], "3" => $resArr1[2], "4" => $resArr1[3]); $res2_item_id = 0; $res2_value = 0; $i = 0; $_c = sizeof($resArr1); while ($i < $_c) { if (0 < $resArr1[$i]) { $res2_item_id = $i + 1; $res2_value = $resArr1[$i]; break; } ++$i; } $distance = $oRow['timeInSeconds'] / 3600 * $oRow['merchants_speed']; $acceptResult = $this->_canAcceptOffer($needResources, $giveResources, $oRow['village_id'], $oRow['alliance_only'], $aid, $oRow['max_time'], $distance); if ($acceptResult == 5 && !$this->isGameTransientStopped() && !$this->isGameOver()) { $showOfferList = FALSE; $this->merchantProperty['offerProperty'] = array("player_id" => $oRow['player_id'], "player_name" => $oRow['player_name'], "res1_item_id" => $res1_item_id, "res1_value" => $res1_value, "res2_item_id" => $res2_item_id, "res2_value" => $res2_value); $merchantNum = ceil(($giveResources[1] + $giveResources[2] + $giveResources[3] + $giveResources[4]) / $this->merchantProperty['capacity']); $newTask = new QueueTask(QS_MERCHANT_GO, $this->player->playerId, $distance / ($this->gameMetadata['tribes'][$this->data['tribe_id']]['merchants_velocity'] * $this->gameMetadata['game_speed']) * 3600); $newTask->villageId = $this->data['selected_village_id']; $newTask->toPlayerId = $oRow['player_id']; $newTask->toVillageId = $oRow['village_id']; $newTask->procParams = $merchantNum . "|" . ($giveResources[1] . " " . $giveResources[2] . " " . $giveResources[3] . " " . $giveResources[4]); $newTask->tag = $giveResources; $this->queueModel->addTask($newTask); $newTask = new QueueTask(QS_MERCHANT_GO, $oRow['player_id'], $oRow['timeInSeconds']); $newTask->villageId = $oRow['village_id']; $newTask->toPlayerId = $this->player->playerId; $newTask->toVillageId = $this->data['selected_village_id']; $newTask->procParams = $oRow['merchants_num'] . "|" . ($needResources[1] . " " . $needResources[2] . " " . $needResources[3] . " " . $needResources[4]); $newTask->tag = array("1" => 0, "2" => 0, "3" => 0, "4" => 0); $this->queueModel->addTask($newTask); $m->removeMerchantOffer(intval($_GET['oid']), $oRow['player_id'], $oRow['village_id']); } } } $this->merchantProperty['showOfferList'] = $showOfferList; if ($showOfferList) { $rowsCount = $m->getAllOffersCount($this->data['selected_village_id'], $this->data['rel_x'], $this->data['rel_y'], $this->setupMetadata['map_size'] / 2, $this->gameMetadata['tribes'][$this->data['tribe_id']]['merchants_velocity'] * $this->gameMetadata['game_speed']); $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->merchantProperty['all_offers'] = $m->getAllOffers($this->data['selected_village_id'], $this->data['rel_x'], $this->data['rel_y'], $this->setupMetadata['map_size'] / 2, $this->gameMetadata['tribes'][$this->data['tribe_id']]['merchants_velocity'] * $this->gameMetadata['game_speed'], $this->pageIndex, $this->pageSize); } $m->dispose(); } else { if ($this->selectedTabIndex == 2) { $m = new BuildModel(); $this->merchantProperty['showError'] = FALSE; $this->merchantProperty['showError2'] = FALSE; $this->merchantProperty['showError3'] = FALSE; if ($this->isPost()) { if (isset($_POST['m1']) && 0 < intval($_POST['m1']) && isset($_POST['m2']) && 0 < intval($_POST['m2']) && isset($_POST['rid1']) && 0 < intval($_POST['rid1']) && isset($_POST['rid2']) && 0 < intval($_POST['rid2'])) { $resources1 = array("1" => isset($_POST['rid1']) && intval($_POST['rid1']) == 1 ? intval($_POST['m1']) : 0, "2" => isset($_POST['rid1']) && intval($_POST['rid1']) == 2 ? intval($_POST['m1']) : 0, "3" => isset($_POST['rid1']) && intval($_POST['rid1']) == 3 ? intval($_POST['m1']) : 0, "4" => isset($_POST['rid1']) && intval($_POST['rid1']) == 4 ? intval($_POST['m1']) : 0); $resources2 = array("1" => isset($_POST['rid2']) && intval($_POST['rid2']) == 1 ? intval($_POST['m2']) : 0, "2" => isset($_POST['rid2']) && intval($_POST['rid2']) == 2 ? intval($_POST['m2']) : 0, "3" => isset($_POST['rid2']) && intval($_POST['rid2']) == 3 ? intval($_POST['m2']) : 0, "4" => isset($_POST['rid2']) && intval($_POST['rid2']) == 4 ? intval($_POST['m2']) : 0); if (intval($_POST['rid1']) == intval($_POST['rid2']) || intval($resources1[1] + $resources1[2] + $resources1[3] + $resources1[4]) <= 0 || intval($resources2[1] + $resources2[2] + $resources2[3] + $resources2[4]) <= 0) { $this->merchantProperty['showError'] = TRUE; } else { if (10 < ceil(($resources2[1] + $resources2[2] + $resources2[3] + $resources2[4]) / ($resources1[1] + $resources1[2] + $resources1[3] + $resources1[4]))) { $this->merchantProperty['showError'] = TRUE; $this->merchantProperty['showError3'] = TRUE; } } $this->merchantProperty['available_res'] = $this->isResourcesAvailable($resources1); if ($this->merchantProperty['available_res'] && !$this->merchantProperty['showError']) { $this->merchantProperty['vRow_merchant_num'] = ceil(($resources1[1] + $resources1[2] + $resources1[3] + $resources1[4]) / $this->merchantProperty['capacity']); if (0 < $this->merchantProperty['vRow_merchant_num'] && $this->merchantProperty['vRow_merchant_num'] <= $this->merchantProperty['exits_num']) { $this->merchantProperty -= "exits_num"; $this->data += "offer_merchants_count"; $offer = $resources1[1] . " " . $resources1[2] . " " . $resources1[3] . " " . $resources1[4] . "|" . ($resources2[1] . " " . $resources2[2] . " " . $resources2[3] . " " . $resources2[4]); $m->addMerchantOffer($this->player->playerId, $this->data['name'], $this->data['selected_village_id'], $this->data['rel_x'], $this->data['rel_y'], $this->merchantProperty['vRow_merchant_num'], $offer, isset($_POST['ally']), 0 < intval($_POST['d2']) ? intval($_POST['d2']) : 0, $this->gameMetadata['tribes'][$this->data['tribe_id']]['merchants_velocity'] * $this->gameMetadata['game_speed']); foreach ($resources1 as $k => $v) { $this->resources[$k] -= "current_value"; } $this->queueModel->_updateVillage(FALSE, FALSE); } else { $this->merchantProperty['showError'] = TRUE; } } else { $this->merchantProperty['showError'] = TRUE; } } else { $this->merchantProperty['showError'] = TRUE; $this->merchantProperty['showError2'] = TRUE; } } else { if (isset($_GET['d']) && 0 < intval($_GET['d'])) { $row = $m->getOffer(intval($_GET['d']), $this->player->playerId, $this->data['selected_village_id']); if ($row != NULL) { $this->merchantProperty += "exits_num"; $this->data -= "offer_merchants_count"; $resources2 = explode("|", $row['offer']); $resources1 = explode("|", $row['offer']); list($resources1, $resources2) = $resources1; $resourcesArray1 = explode(" ", $resources1); $res = array(); $i = 0; $_c = sizeof($resourcesArray1); while ($i < $_c) { $res[$i + 1] = $resourcesArray1[$i]; ++$i; } foreach ($res as $k => $v) { $this->resources[$k] += "current_value"; } $this->queueModel->_updateVillage(FALSE, FALSE); $m->removeMerchantOffer(intval($_GET['d']), $this->player->playerId, $this->data['selected_village_id']); } } } $this->merchantProperty['offers'] = $m->getOffers($this->data['selected_village_id']); $m->dispose(); } else { if ($this->selectedTabIndex == 3 && $this->isPost() && isset($_POST['m2']) && is_array($_POST['m2']) && sizeof($_POST['m2']) == 4 && $this->gameMetadata['plusTable'][6]['cost'] <= $this->data['gold_num']) { $resources = array("1" => intval($_POST['m2'][0]), "2" => intval($_POST['m2'][1]), "3" => intval($_POST['m2'][2]), "4" => intval($_POST['m2'][3])); $oldSum = $this->resources[1]['current_value'] + $this->resources[2]['current_value'] + $this->resources[3]['current_value'] + $this->resources[4]['current_value']; $newSum = $resources[1] + $resources[2] + $resources[3] + $resources[4]; if ($newSum <= $oldSum) { foreach ($resources as $k => $v) { $this->resources[$k]['current_value'] = $v; } $this->queueModel->_updateVillage(FALSE, FALSE); $m = new BuildModel(); $m->decreaseGoldNum($this->player->playerId, $this->gameMetadata['plusTable'][6]['cost']); $m->dispose(); } } } } } }
function getPlayerDeletionTime() { return WebHelper::secondsToString($this->queueModel->tasksInQueue[QS_ACCOUNT_DELETE][0]['remainingSeconds']); }
public function handleTroopBack() { $qstr = ""; $fromVillageId = 0; $toVillageId = 0; $action = 0; if (isset($_GET['d1'])) { $action = 1; $qstr = "d1=" . intval($_GET['d1']); if (isset($_GET['o'])) { $qstr .= "&o=" . intval($_GET['o']); $fromVillageId = intval($_GET['o']); } else { $fromVillageId = $this->data['selected_village_id']; } $toVillageId = intval($_GET['d1']); } else { if (isset($_GET['d2'])) { $action = 2; $qstr = "d2=" . intval($_GET['d2']); $fromVillageId = $this->data['selected_village_id']; $toVillageId = intval($_GET['d2']); } else { if (isset($_GET['d3'])) { $action = 3; $qstr = "d3=" . intval($_GET['d3']); $fromVillageId = intval($_GET['d3']); $toVillageId = $this->data['selected_village_id']; } else { $this->redirect("build.php?id=39"); return; } } } $this->backTroopsProperty['queryString'] = $qstr; $m = new WarModel(); $fromVillageData = $m->getVillageData2ById($fromVillageId); $toVillageData = $m->getVillageData2ById($toVillageId); if ($fromVillageData == NULL || $toVillageData == NULL) { $m->dispose(); $this->redirect("build.php?id=39"); } else { $vid = $toVillageId; $_backTroopsStr = ""; $this->backTroopsProperty['headerText'] = v2v_p_backtroops; $this->backTroopsProperty['action1'] = "<a href=\"village3.php?id=" . $fromVillageData['id'] . "\">" . $fromVillageData['village_name'] . "</a>"; $this->backTroopsProperty['action2'] = "<a href=\"profile.php?uid=" . $fromVillageData['player_id'] . "\">" . v2v_p_troopsinvillagenow . "</a>"; $column1 = ""; $column2 = ""; if ($action == 1) { $_backTroopsStr = $fromVillageData['troops_num']; $column1 = "troops_num"; $column2 = "troops_out_num"; } else { if ($action == 2) { $this->backTroopsProperty['headerText'] = v2v_p_backcaptivitytroops; $_backTroopsStr = $fromVillageData['troops_intrap_num']; $column1 = "troops_intrap_num"; $column2 = "troops_out_intrap_num"; } else { if ($action == 3) { $_backTroopsStr = $toVillageData['troops_out_num']; $vid = $fromVillageId; $column1 = "troops_num"; $column2 = "troops_out_num"; } } } $this->backTroopsProperty['backTroops'] = $this->_getTroopsForVillage($_backTroopsStr, $vid); if ($this->backTroopsProperty['backTroops'] == NULL) { $m->dispose(); $this->redirect("build.php?id=39"); } else { $distance = WebHelper::getdistance($fromVillageData['rel_x'], $fromVillageData['rel_y'], $toVillageData['rel_x'], $toVillageData['rel_y'], $this->setupMetadata['map_size'] / 2); if ($this->isPost()) { $canSend = FALSE; $troopsGoBack = array(); foreach ($this->backTroopsProperty['backTroops']['troops'] as $tid => $tnum) { if (isset($_POST['t'], $_POST['t'][$tid])) { $selNum = intval($_POST['t'][$tid]); if ($selNum < 0) { $selNum = 0; } if ($tnum < $selNum) { $selNum = $tnum; } $troopsGoBack[$tid] = $selNum; if (0 < $selNum) { $canSend = TRUE; } } else { $troopsGoBack[$tid] = 0; } } $sendTroopsArray = array("troops" => $troopsGoBack, "hasHero" => FALSE, "heroTroopId" => 0); $hasHeroTroop = $this->backTroopsProperty['backTroops']['hasHero'] && isset($_POST['_t']) && intval($_POST['_t']) == 1; if ($hasHeroTroop) { $sendTroopsArray['hasHero'] = TRUE; $sendTroopsArray['heroTroopId'] = $this->backTroopsProperty['backTroops']['heroTroopId']; $canSend = TRUE; } if (!$canSend) { $m->dispose(); $this->redirect("build.php?id=39"); } else { if (!$this->isGameTransientStopped() && !$this->isGameOver()) { $troops1 = $this->_getTroopsAfterReduction($fromVillageData[$column1], $toVillageId, $sendTroopsArray); $troops2 = $this->_getTroopsAfterReduction($toVillageData[$column2], $fromVillageId, $sendTroopsArray); $m->backTroopsFrom($fromVillageId, $column1, $troops1, $toVillageId, $column2, $troops2); $timeInSeconds = intval($distance / $this->_getTheSlowestTroopSpeed2($sendTroopsArray) * 3600); $procParams = $this->_getTroopAsString($sendTroopsArray) . "|0||||||1"; $newTask = new QueueTask(QS_WAR_REINFORCE, intval($fromVillageData['player_id']), $timeInSeconds); $newTask->villageId = $fromVillageId; $newTask->toPlayerId = intval($toVillageData['player_id']); $newTask->toVillageId = $toVillageId; $newTask->procParams = $procParams; $newTask->tag = array("troops" => NULL, "hasHero" => FALSE, "resources" => NULL); $affectCropConsumption = TRUE; if ($fromVillageData['is_oasis'] && trim($toVillageData['village_oases_id']) != "") { $oArr = explode(",", trim($toVillageData['village_oases_id'])); foreach ($oArr as $oid) { if (!($oid == $fromVillageData['id'])) { continue; } $affectCropConsumption = FALSE; break; break; } } if ($affectCropConsumption) { $newTask->tag['troopsCropConsume'] = $this->_getTroopCropConsumption($sendTroopsArray); } $this->queueModel->addTask($newTask); $m->dispose(); $this->redirect("build.php?id=39"); return; } } } else { $this->backTroopsProperty['time'] = intval($distance / $this->_getTheSlowestTroopSpeed2($this->backTroopsProperty['backTroops']) * 3600); } $m->dispose(); } } }
?> </td> <td> <?php WebHelper::linkButton(array('target' => url_for('cliente/delete?id=' . $cliente->getId()), 'confirmMessage' => '¿Está seguro de eliminar este Cliente?', 'linkClass' => 'btnX')); ?> </td> </tr> <?php } ?> </tbody> </table> <?php } else { ?> <p>No existe información de Clientes</p> <?php } ?> </div> <div class="smallMargins"> <?php WebHelper::linkButton(array('text' => 'Nuevo Cliente', 'target' => url_for('cliente/new'), 'linkClass' => 'btnAdd')); ?> </div>
function getBaseUrl() { return (WebHelper::isssl() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . strrev(strstr(strrev($_SERVER['PHP_SELF']), '/')); }
?> </td> <td> <?php WebHelper::linkButton(array('target' => url_for('puntoVenta/delete?id=' . $punto_venta->getId()), 'confirmMessage' => '¿Está seguro de eliminar este Punto de Venta?', 'linkClass' => 'btnX')); ?> </td> </tr> <?php } ?> </tbody> </table> <?php } else { ?> <p>No se han definido Puntos de Venta</p> <?php } ?> </div> <div class="smallMargins"> <?php WebHelper::linkButton(array('text' => 'Nuevo Punto de Venta', 'target' => url_for('puntoVenta/new'), 'linkClass' => 'btnAdd')); ?> </div>
function handleTroopBack() { $qstr = ''; $fromVillageId = 0; $toVillageId = 0; $action = 0; if (isset($_GET['d1'])) { $action = 1; $qstr = 'd1=' . intval($_GET['d1']); if (isset($_GET['o'])) { $qstr .= '&o=' . intval($_GET['o']); $fromVillageId = intval($_GET['o']); } else { $fromVillageId = $this->data['selected_village_id']; } $toVillageId = intval($_GET['d1']); } else { if (isset($_GET['d2'])) { $action = 2; $qstr = 'd2=' . intval($_GET['d2']); $fromVillageId = $this->data['selected_village_id']; $toVillageId = intval($_GET['d2']); } else { if (isset($_GET['d3'])) { $action = 3; $qstr = 'd3=' . intval($_GET['d3']); $fromVillageId = intval($_GET['d3']); $toVillageId = $this->data['selected_village_id']; } else { $this->redirect('build.php?id=39'); //return null; } } } $this->backTroopsProperty['queryString'] = $qstr; $m = new WarModel(); $fromVillageData = $m->getVillageData2ById($fromVillageId); $toVillageData = $m->getVillageData2ById($toVillageId); if ($fromVillageData == NULL or $toVillageData == NULL) { $m->dispose(); $this->redirect('build.php?id=39'); //return null; } $vid = $toVillageId; $_backTroopsStr = ''; $this->backTroopsProperty['headerText'] = v2v_p_backtroops; $this->backTroopsProperty['action1'] = '<a href="village3.php?id=' . $fromVillageData['id'] . '">' . $fromVillageData['village_name'] . '</a>'; $this->backTroopsProperty['action2'] = '<a href="profile.php?uid=' . $fromVillageData['player_id'] . '">' . v2v_p_troopsinvillagenow . '</a>'; $column1 = ''; $column2 = ''; if ($action == 1) { $_backTroopsStr = $fromVillageData['troops_num']; $column1 = 'troops_num'; $column2 = 'troops_out_num'; } else { if ($action == 2) { $this->backTroopsProperty['headerText'] = v2v_p_backcaptivitytroops; $_backTroopsStr = $fromVillageData['troops_intrap_num']; $column1 = 'troops_intrap_num'; $column2 = 'troops_out_intrap_num'; } else { if ($action == 3) { $_backTroopsStr = $toVillageData['troops_out_num']; $vid = $fromVillageId; $column1 = 'troops_num'; $column2 = 'troops_out_num'; } } } $this->backTroopsProperty['backTroops'] = $this->_getTroopsForVillage($_backTroopsStr, $vid); if ($this->backTroopsProperty['backTroops'] == NULL) { $m->dispose(); $this->redirect('build.php?id=39'); //return null; } $distance = WebHelper::getdistance($fromVillageData['rel_x'], $fromVillageData['rel_y'], $toVillageData['rel_x'], $toVillageData['rel_y'], $this->setupMetadata['map_size'] / 2); if ($this->isPost()) { $canSend = FALSE; $troopsGoBack = array(); foreach ($this->backTroopsProperty['backTroops']['troops'] as $tid => $tnum) { if (isset($_POST['t']) and isset($_POST['t'][$tid])) { $selNum = intval($_POST['t'][$tid]); if ($selNum < 0) { $selNum = 0; } if ($tnum < $selNum) { $selNum = $tnum; } $troopsGoBack[$tid] = $selNum; if (0 < $selNum) { $canSend = TRUE; continue; } continue; } else { $troopsGoBack[$tid] = 0; continue; } } $sendTroopsArray = array('troops' => $troopsGoBack, 'hasHero' => FALSE, 'heroTroopId' => 0); $hasHeroTroop = ($this->backTroopsProperty['backTroops']['hasHero'] and isset($_POST['_t']) and intval($_POST['_t']) == 1); if ($hasHeroTroop) { $sendTroopsArray['hasHero'] = TRUE; $sendTroopsArray['heroTroopId'] = $this->backTroopsProperty['backTroops']['heroTroopId']; $canSend = TRUE; } if (!$canSend) { $m->dispose(); $this->redirect('build.php?id=39'); //return null; } if (!$this->isGameTransientStopped() and !$this->isGameOver()) { $troops1 = $this->_getTroopsAfterReduction($fromVillageData[$column1], $toVillageId, $sendTroopsArray); $troops2 = $this->_getTroopsAfterReduction($toVillageData[$column2], $fromVillageId, $sendTroopsArray); $m->backTroopsFrom($fromVillageId, $column1, $troops1, $toVillageId, $column2, $troops2); $timeInSeconds = intval($distance / $this->_getTheSlowestTroopSpeed2($sendTroopsArray) * 3600); $procParams = $this->_getTroopAsString($sendTroopsArray) . '|0||||||1'; $newTask = new QueueTask(QS_WAR_REINFORCE, intval($fromVillageData['player_id']), $timeInSeconds); $newTask->villageId = $fromVillageId; $newTask->toPlayerId = intval($toVillageData['player_id']); $newTask->toVillageId = $toVillageId; $newTask->procParams = $procParams; $newTask->tag = array('troops' => NULL, 'hasHero' => FALSE, 'resources' => NULL, 'troopsCropConsume' => $this->_getTroopCropConsumption($sendTroopsArray)); $this->queueModel->addTask($newTask); $m->dispose(); $this->redirect('build.php?id=39'); //return null; } } else { $this->backTroopsProperty['time'] = intval($distance / $this->_getTheSlowestTroopSpeed2($this->backTroopsProperty['backTroops']) * 3600); } $m->dispose(); }
?> <input type="hidden" name="sf_method" value="put" /> <?php } ?> <table> <tfoot> <tr> <td colspan="2"> <div style="float:left" class="smallMargins"> <?php WebHelper::linkButton(array('linkClass' => 'btnBack', 'text' => 'Cancelar', 'target' => url_for('cliente/show/?id=' . $cliente->getId()))); ?> </div> <div style="float:left" class="smallMargins"> </div> <div class="smallMargins"> <?php WebHelper::linkButton(array('linkClass' => 'btnOk', 'text' => 'Confirmar', 'target' => "#", 'clickAction' => 'document.contactoForm.submit()')); ?> </td> </tr> </tfoot> <tbody> <?php echo $form; ?> </tbody> </table> </form>
function handleNoQuiz($m, $quizStep) { $time = floor(36000 / $this->gameMetadata['game_speed']); $this->guideData['quiztime'] = WebHelper::secondstostring($time); $result = 0; switch ($quizStep) { case 0: if (isset($_GET['v']) && trim($_GET['v']) == 'y') { $result = 1; $newTask = new QueueTask(QS_PLUS1, $this->player->playerId, 86400); $newTask->villageId = ''; $newTask->tag = 0; $this->queueModel->addTask($newTask); $m->increaseGoldNumber($this->player->playerId, 15); $newTask = new QueueTask(QS_GUIDENOQUIZ, $this->player->playerId, $time); $this->queueModel->addTask($newTask); } break; case 1: case 2: case 3: case 4: case 5: if (!isset($this->queueModel->tasksInQueue[QS_GUIDENOQUIZ]) && isset($_GET['v']) && trim($_GET['v']) == 'y') { $result = 1; $m->addResourcesTo($this->data['selected_village_id'], array(217, 247, 177, 207)); $newTask = new QueueTask(QS_GUIDENOQUIZ, $this->player->playerId, $time); $this->queueModel->addTask($newTask); } break; case 6: if (!isset($this->queueModel->tasksInQueue[QS_GUIDENOQUIZ]) && isset($_GET['v']) && trim($_GET['v']) == 'y') { $this->clientAction = 100; $this->quiz = GUIDE_QUIZ_COMPLETED; $m->setGuideTask($this->player->playerId, $this->quiz); $newTask = new QueueTask(QS_PLUS1, $this->player->playerId, 172800); $newTask->villageId = ''; $newTask->tag = 0; $this->queueModel->addTask($newTask); $m->increaseGoldNumber($this->player->playerId, 20); } } if ($result == 1 && $quizStep < 6) { ++$quizStep; $this->quiz = '0,201,' . $quizStep; $m->setGuideTask($this->player->playerId, $this->quiz); } $this->guideData['quizStep'] = $quizStep; $this->guideData['pended'] = isset($this->queueModel->tasksInQueue[QS_GUIDENOQUIZ]); if ($this->guideData['pended']) { $this->guideData['remainingSeconds'] = $this->queueModel->tasksInQueue[QS_GUIDENOQUIZ][0]['remainingSeconds']; } }
function getKey() { return md5(WebHelper::getdomain()); }