/** * Returns the state of the player from the database, * uses a user_id if one is present, otherwise * defaults to the currently logged in player, but can act on any player * if another username is passed in. * @param $user user_id or username * @param @password Unless true, wipe the password. **/ function get_player_info($user = null, $password = false) { $sql = new DBAccess(); $player_data = null; if (is_numeric($user)) { $sel_player = "select * from players where player_id = '" . $user . "' limit 1"; } else { $username = either($user, SESSION::is_set('username') ? SESSION::get('username') : null); // Default to current session user. $sel_player = "select * from players where uname = '" . sql($username) . "' limit 1"; } $player_data = $sql->QueryRowAssoc($sel_player); if (!$password) { unset($player_data['pname']); } return $player_data; }
/** * Update the information of a viewing observer, or player. **/ function update_activity_info() { // ******************** Usage Information of the browser ********************* Request::setTrustedProxies(Constants::$trusted_proxies); $request = Request::createFromGlobals(); $remoteAddress = $request->getClientIp(); $userAgent = isset($_SERVER['HTTP_USER_AGENT']) ? substr($_SERVER['HTTP_USER_AGENT'], 0, 250) : NULL; // Truncated at 250 char. $referer = isset($_SERVER['HTTP_REFERER']) ? substr($_SERVER['HTTP_REFERER'], 0, 250) : ''; // Truncated at 250 char. // ************** Setting anonymous and player usage information $dbconn = DatabaseConnection::getInstance(); if (!SESSION::is_set('online')) { // *** Completely new session, update latest activity log. *** if ($remoteAddress) { // *** Delete prior to trying to re-insert into the people online. *** $statement = DatabaseConnection::$pdo->prepare('DELETE FROM ppl_online WHERE ip_address = :ip OR session_id = :sessionID'); $statement->bindValue(':ip', $remoteAddress); $statement->bindValue(':sessionID', session_id()); $statement->execute(); } // *** Update viewer data. *** $statement = DatabaseConnection::$pdo->prepare('INSERT INTO ppl_online (session_id, activity, ip_address, refurl, user_agent) VALUES (:sessionID, now(), :ip, :referer, :userAgent)'); $statement->bindValue(':sessionID', session_id()); $statement->bindValue(':ip', $remoteAddress); $statement->bindValue(':referer', $referer); $statement->bindValue(':userAgent', $userAgent); $statement->execute(); SESSION::set('online', true); } else { // *** An already existing session. *** $statement = DatabaseConnection::$pdo->prepare('UPDATE ppl_online SET activity = now(), member = :member WHERE session_id = :sessionID'); $statement->bindValue(':sessionID', session_id()); $statement->bindValue(':member', is_logged_in(), PDO::PARAM_BOOL); $statement->execute(); } }
/* * Deals with the non-skill based attacks and stealthed attacks. * * @package combat * @subpackage attack */ $private = true; $alive = true; $page_title = "Battle Status"; $quickstat = "player"; include SERVER_ROOT . "interface/header.php"; $recent_attack = null; $start_of_attack = microtime(true); $attack_spacing = 0.2; // fraction of a second if (SESSION::is_set('recent_attack')) { $recent_attack = SESSION::get('recent_attack'); } if ($recent_attack && $recent_attack > $start_of_attack - $attack_spacing) { echo "<p>Even the best of ninjas cannot attack that quickly.</p>"; echo "<a href='attack_player.php'>Return to combat</a>"; SESSION::set('recent_attack', $start_of_attack); die; } else { SESSION::set('recent_attack', $start_of_attack); } ?> <span class="brownHeading">Battle Status</span> <hr>
function get_username() { return SESSION::is_set('username') ? SESSION::get('username') : NULL; }
// Stage of delete process. $in_changePass = in('changepass'); $changePass = $in_changePass && $in_changePass == 1 ? 1 : null; $newPass = in('newpass', null, 'toPassword'); $passW = in('passw', null, 'toPassword'); // *** To verify whether there's a password put in. $changeprofile = in('changeprofile'); $newprofile = in('newprofile', null, 'toMessage'); $username = get_username(); $user_id = get_user_id(); $player = get_player_info(); $confirm_delete = false; $profile_changed = false; $profile_max_length = 500; // Should match the limit in limitStatChars.js $delete_attempts = SESSION::is_set('delete_attempts') ? SESSION::get('delete_attempts') : null; if ($deleteAccount) { $verify = false; $verify = is_authentic($username, $passW); if ($verify == true && !$delete_attempts) { // *** Username&password matched, on the first attempt. pauseAccount($username); // This may redirect and stuff? } else { if ($deleteAccount == 2) { SESSION::set('delete_attempts', 1); $error = 'Deleting of account failed, please email ' . SUPPORT_EMAIL; } else { $confirm_delete = true; } }
$guard_gold = rand(1, $attacker_str + 40); // *** Guard Gold *** addGold($username, $guard_gold); echo "The guard is defeated!<br>\n"; echo "Guard does {$guard_attack} points of damage.<br>\n"; echo "You have gained {$guard_gold} gold.<br>\n"; if (getLevel($username) > 15) { $added_bounty = floor((getLevel($username) - 10) / 5); echo "You have slain a member of the military! A bounty of " . $added_bounty * 10 . " gold has been placed on your head!<br>\n"; addBounty($username, $added_bounty * 10); } } } else { if ($victim == "thief") { // Check the counter to see whether they've attacked a thief multiple times in a row. if (SESSION::is_set('counter')) { $counter = SESSION::get('counter'); } else { $counter = 1; } $counter = $counter + 1; SESSION::set('counter', $counter); // Save the current state of the counter. if ($counter > 20 && rand(1, 3) == 3) { // Only after many attacks do you have the chance to be attacked back by the group of theives. SESSION::set('counter', 0); // Reset the counter to zero. echo "<img src='images/scenes/KunitsunaTrainingWithTengu.jpg' alt='' style='width:1000px'>"; echo "<p>A group of tengu thieves is waiting for you. They seem to be angered by your attacks on their brethren.</p>"; $group_attack = rand(50, 150); if (!subtractHealth($username, $group_attack)) {
$private = false; $alive = false; if ($error = init($private, $alive)) { display_error($error); } else { require_once LIB_ROOT . "control/lib_player_list.php"; require_once LIB_ROOT . "control/lib_player.php"; DatabaseConnection::getInstance(); $username = self_name(); $char_id = self_char_id(); $searched = in('searched', null, 'no filter'); // Don't filter the search setting. $list_by_rank = $searched && substr_compare($searched, '#', 0, 1) === 0; // Whether the search is by rank. $hide_setting = !$searched && SESSION::is_set('hide_dead') ? SESSION::get('hide_dead') : 'dead'; // Defaults to hiding dead via session. $hide = $searched ? 'none' : in('hide', $hide_setting); // search override > get setting > session setting $alive_only = $hide == 'dead'; $page = in('page', 1); // Page will get changed down below. $alive_count = 0; $record_limit = 20; // *** The number of players that gets shown per page. $view_type = in('view_type'); $rank = get_rank($char_id); $dead_count = query_item("SELECT count(player_id) FROM rankings WHERE alive = false"); $page = in('page'); if (!$searched && $hide_setting != $hide) { SESSION::set('hide_dead', $hide);