/** * Checks whether an attack is legal or not. * DEPRECATED. * */ function attack_legal() { global $attacked, $attackee, $user_turns, $required_turns, $username, $player_id, $sql; global $attackee_ip, $attacker_ip, $attackee_confirmed, $attacker_health, $attackee_health, $attackee_status; $second_interval_limiter_on_attacks = '.20'; $sel_last_started_attack = "select player_id from players\n \twhere player_id = '" . intval($player_id) . "'\n \tand ((now() - interval '" . $second_interval_limiter_on_attacks . " second') >= last_started_attack) limit 1"; $attack_later_than_limit = $sql->QueryItem($sel_last_started_attack); // Returns a player id if the enough time has passed, or else or false/null. // *** TODO: Take in and require energy in this function. switch (true) { // *** START OF ILLEGAL ATTACK ERROR LIST *** case !$attack_later_than_limit: echo "You cannot attack more than five times in a second."; return false; case $attacked != 1: return false; break; case $attackee == "": echo "Your victim does not exist.<br>\n"; return false; break; case $attackee == $username: echo "Commiting suicide is a tactic reserved for samurai.<br>\n"; return false; break; case $user_turns < $required_turns: echo "You do not have enough turns to execute the attack you chose.<br>\n"; return false; break; case $attackee_ip == $_SESSION['ip'] && $_SESSION['ip'] != '127.0.0.1': echo "You can not attack a ninja from the same domain.<br>\n"; return false; break; case $attackee_confirmed == 0: echo "You can not attack an inactive ninja.<br>\n"; return false; break; case $attackee_health < 1: echo "You can not attack a corpse.<br>\n"; return false; break; case $attackee_status['Stealth']: echo "Your victim is stealthed. You cannot attack this ninja by normal means.<br>\n"; return false; break; case getClan($attackee) == getClan($username) && getClan($username) != "": echo "You cannot attack a ninja in the same clan as you.\n"; return false; break; case getClan($attackee) != getClan($username) || getClan($username) == "": return true; // *** ATTACK IS LEGAL *** break; default: // *** CATCHALL ERROR MESSAGE *** echo "There was a problem with your attack.<br>\n"; return false; break; } }
function message_to_clan($message) { global $sql; $error = null; $user_id = get_user_id(); $username = get_username(); $clan = getClan($username); $sql->Query("SELECT player_id, uname from players where clan = '" . sql($clan) . "'"); $clan_members = $sql->fetchAll(); $messaged_to = ''; $comma = ''; foreach ($clan_members as $loop_member) { send_message($user_id, $loop_member['player_id'], "CLAN: " . $message); $messaged_to .= $comma . $loop_member['uname']; $comma = ', '; } return $messaged_to; }
$private = true; $alive = false; $quickstat = false; $page_title = "Messages"; include SERVER_ROOT . "interface/header.php"; $to = in('to'); // The target of the message, if any were specified. $to_clan = in('toclan'); $messenger = in('messenger'); // naive spam detection attempt $message = in('message', null, 'toMessage'); // Special filtering to a message. $target_id = $to ? get_user_id($to) : null; $user_id = get_user_id(); $username = get_username(); $clan = getClan($username); $has_clan = $clan ? true : false; $page = in('page', 1, 'toInt'); $limit = 25; $offset = ($page - 1) * $limit; $delete = in('delete'); $message_sent_to = null; // Sending mail section. if ($message && $messenger) { if ($to_clan && $has_clan) { $message_sent_to = message_to_clan($message); } elseif (!!$target_id) { send_message($user_id, $target_id, $message); $message_sent_to = $to; // ( }
/** * Display the full form for item use/dropdowns/give/ **/ function render_item_use_on_another($target, $sql) { $username = get_username(); $res = "<form id=\"inventory_form\" action=\"inventory_mod.php\" method=\"post\" name=\"inventory_form\">\n\n <input id=\"target\" type=\"hidden\" name=\"target\" value=\"{$target}\">\n <input type=\"submit\" value=\"Use\" class=\"formButton\">\n\n <select id=\"item\" name=\"item\">\n"; $res .= render_inventory_options($username, $sql); $res .= "</select>"; $targets_clan = getClan($target); if ($targets_clan && $targets_clan == getClan($username)) { // Only allow giving items within the same clan. $res .= "\n <input id=\"give\" type=\"submit\" value=\"Give\" name=\"give\" class=\"formButton\">\n"; } $res .= "</form>\n"; return $res; }
function deleteAccount($who) { global $sql; if (getClan($who) == $who) { disbandClan($who); } $sql->Delete("DELETE FROM players WHERE uname = '{$who}'"); $sql->Delete("DELETE FROM inventory WHERE owner = '{$who}'"); $sql->Delete("DELETE FROM mail WHERE send_to = '{$who}'"); $_SESSION['username'] = false; session_destroy(); echo "Your account has been removed from Ninja Wars. If you wish to sign back up you may do so. <br>If not, we would be glad to receive an email telling us why you choose to leave the game,<br>Thank you.<br><br>Admin@NinjaWars.net\n"; }
$alive = false; $private = false; $quickstat = false; $page_title = "Accept a New Clan Member"; include SERVER_ROOT . "interface/header.php"; ?> <span class="brownHeading">Accept A New Clan Member</span> <hr> <?php $confirm = in('confirm'); $username = get_username(); $clan_name = getClan($username); $clan_l_name = getClanLongName($username); $clan_joiner = in('clan_joiner'); $agree = in('agree'); $random = rand(1001, 9990); if (!$clan_name) { echo "You have no clan."; } elseif (!$clan_joiner) { echo "There is no potential ninja specified, so the induction cannot occur."; } else { if (!$clan_l_name) { $clan_l_name = $clan_name . "'s Clan"; } echo "{$clan_joiner} has requested to join your clan, {$clan_l_name}.<br>\n"; if (!$agree) { echo "<form action=\"clan_confirm.php?clan_name={$clan_name}&clan_joiner={$clan_joiner}&confirm={$confirm}\" method=\"post\">\n";