public function moveUnit($target) { // Calculate distance $distance = Dolumar_Map_Map::getDistanceBetweenVillages($this->getLocation(), $target); $duration = $this->getTravelDuration($distance); // Update $db = Neuron_Core_Database::__getInstance(); $db->update('villages_specialunits', array('vsu_moveStart' => Neuron_Core_Tools::timestampToMysqlDatetime(time()), 'vsu_moveEnd' => Neuron_Core_Tools::timestampToMysqlDatetime(time() + $duration), 'vsu_location' => $target->getId()), "vsu_id = " . $this->getId()); }
public static function cleanServer() { $db = Neuron_Core_Database::__getInstance(); $log = array(); // Kill players $last = Neuron_Core_Tools::timestampToMysqlDatetime(time() - 60 * 60 * 24 * 45); $l = $db->select('n_players', array('plid', 'killCounter'), "lastRefresh < '" . $last . "' AND isPlaying = 1"); foreach ($l as $v) { if ($v['killCounter'] < 5) { $db->update('n_players', array('killCounter' => '++'), "plid = '" . $v['plid'] . "'"); } else { // Kill! $player = Neuron_GameServer::getPlayer($v['plid']); if (!$player->isModerator()) { $player->doResetAccount(); /* $log[] = array ( 'action' => 'reset', 'subject' => 'account', 'name' => $player->getNickname () ); */ $player->__destruct(); } } } // Kill villages $last = Neuron_Core_Tools::timestampToMysqlDatetime(time() - 60 * 60 * 24 * 5); //$last = Neuron_Core_Tools::timestampToMysqlDatetime (time ()); $l = $db->select('villages', array('vid'), "isActive = '0' AND (removalDate < '{$last}' OR removalDate IS NULL)"); foreach ($l as $v) { $village = Dolumar_Players_Village::getVillage($v['vid'], false, true, true); $village->destroyVillage(); $village->__destruct(); } // Remove old login data (2 weeks old) $rem = $db->remove('n_login_log', "l_datetime < '" . date('Y-m-d H:i:s', time() - 60 * 60 * 24 * 7 * 2) . "'"); $log[] = "Removed " . $rem . " login logs.\n"; // Remove old game log data (2 months old) //$db->remove ('game_log', "l_date < '".date ('Y-m-d H:i:s', time () - 60*60*31*2)."'"); // Remove old battle reports (2 months old) $rem = $db->remove('battle_report', "fightDate < '" . (time() - 60 * 60 * 24 * 31 * 2) . "'"); $log[] = "Removed " . $rem . " battle reports.\n"; return $log; }
public static function setTemporaryKey(Neuron_GameServer_Player $player, $key, $timeout) { $db->update('n_players', array('tmp_key' => $key, 'tmp_key_end' => Neuron_Core_Tools::timestampToMysqlDatetime($timeout)), "plid = " . $player->getId()); }
public function sendLostPassword($email) { // Check the database for this user $db = Neuron_Core_Database::__getInstance(); $user = $db->select('n_players', array('plid', 'email', 'nickname'), "email = '" . $db->escape($email) . "' AND email_cert = 1 AND isRemoved = 0"); if (count($user) != 1) { $this->warning = 'user_not_found'; return false; } // User is found: let's continue the process. $password = substr($this->getRandomPassword(), 0, 6); // Remove all other temporary password from this user $db->remove('n_temp_passwords', "p_plid = " . $user[0]['plid'] . " OR p_expire < NOW()"); // Add this new one $db->insert('n_temp_passwords', array('p_plid' => $user[0]['plid'], 'p_pass' => $password, 'p_expire' => Neuron_Core_Tools::timestampToMysqlDatetime(time() + 60 * 60 * 24 * 2))); // Send this temporary password to the user. $this->sendLostPasswordMail($user[0]['email'], $user[0]['nickname'], $password); return true; }