function reportOp(&$objSrcUser, &$objTrgUser, $op, $done = false) { $orkTime = $GLOBALS['orkTime']; $tick = clsBlock::getTick(); $cutoff = $tick - 8; $srcId = $objSrcUser->get_userid(); $trgId = $objTrgUser->get_userid(); $srcIp = $_SERVER['REMOTE_ADDR']; $op = mysql_real_escape_string($op); $ops = mysql_query("SELECT * FROM blocks WHERE tick > {$cutoff} AND target_id = {$trgId} AND source_id != {$srcId} AND source_ip = '{$srcIp}' ORDER BY id DESC"); $post = "***Target***\r\nUserid: {$trgId}\r\nTribe: " . $objTrgUser->get_stat(TRIBE) . '(#' . $objTrgUser->get_stat(ALLIANCE) . ")\r\n\r\n"; $post .= "***Offender***\r\nUserid: {$srcId}\r\nTribe: " . $objSrcUser->get_stat(TRIBE) . '(#' . $objSrcUser->get_stat(ALLIANCE) . ")\r\nIP: " . $srcIp . "\r\n"; if ($done) { $post .= "Successfully Performed:"; } else { $post .= "Trying to perform:"; } $post .= "{$op}\r\n At tick: {$tick}\r\n\r\n"; $post .= "***Previous ops from the same IP below\r\n\r\n"; while ($row = mysql_fetch_assoc($ops)) { $objTmpUser = new clsUser($row['source_id']); $post .= "Userid: " . $row['source_id'] . "\r\nTribe: " . $objTmpUser->get_stat(TRIBE) . '(#' . $objTmpUser->get_stat(ALLIANCE) . ")" . "\r\nPerformed: " . $row['op'] . "\r\nAt tick: " . $row['tick'] . "\r\n\r\n"; } $alliance = 2; if ($done) { $title = "Blocking system: Successful ops"; } else { $title = "Blocking system: Blocked ops"; } $thread = mysql_query("SELECT post_id FROM forum WHERE poster_kd = {$alliance} AND parent_id = 0 AND title = '{$title}' AND type = 0") or die('mysql error: ' . mysql_error()); if (mysql_num_rows($thread) == 0) { mysql_query("INSERT INTO forum (poster_kd,title,post,date_time,updated,poster_name,poster_tribe) VALUES ({$alliance},'{$title}','Automated report thread','{$orkTime}','{$orkTime}','Reporter','Reporter')") or die('mysql error: ' . mysql_error()); $thread = mysql_query("SELECT post_id FROM forum WHERE poster_kd = {$alliance} AND parent_id = 0 AND title = '{$title}' AND type = 0") or die('mysql error: ' . mysql_error()); } $thread = mysql_fetch_assoc($thread); $thread = $thread['post_id']; make_post($objSrcUser->get_userid(), $thread, $alliance, 0, $post); }
function call_tour_move_text() { global $local_stats, $id, $confirm, $target, $tool; include_once 'inc/functions/resort_tools.php'; check_access($tool); $alli_id = ''; if (isset($_POST['alli_id'])) { $alli_id = intval($_POST['alli_id']); } echo '<h2>ORKFiA Tour!</h2>'; $strForm = "<form method=\"post\" action=\"" . $_SERVER['REQUEST_URI'] . "\">" . '<label>Where is our touring tribe? Alliance #</label> ' . '<input name="alli_id" size="3" value="' . $alli_id . '"/><br /><br />'; if (isset($_POST['alli_id']) && !empty($_POST['alli_id'])) { $iAlliance = intval($_POST['alli_id']); include 'inc/functions/vote.php'; // select everyone in this alliance $strSQL = "SELECT * " . " FROM stats " . " WHERE kingdom = " . $iAlliance . " ORDER BY tribe ASC"; $result = mysql_query($strSQL) or die("Elder Defect:" . mysql_error()); $strForm .= "<label>Select the lucky tribe</label>: " . '<select name="id" size="1">' . render_option_list($result, TRIBE, ID, 0) . '</select><br /><br />' . '<label>Where will they apparate to? Alliance #</label>: ' . '<input name="target" size="5" /><br /><br />' . '<input type="submit" value="Move Tourer" name="confirm">'; } else { $strForm .= '<input type="submit" value="Choose Alliance" name="confirm">'; } $strForm .= "</form>"; echo $strForm; if (isset($_POST['confirm']) && isset($_POST['id']) && !empty($_POST['id']) && isset($_POST['target']) && !empty($_POST['target'])) { $id = intval($_POST['id']); $target = intval($_POST['target']); $trgTmpUser = new clsUser($id); $strTribeName = ucwords(stripslashes($trgTmpUser->get_stat(TRIBE))); if ($trgTmpUser->get_build(LAND) != 1) { echo '<p>"W-T-F mate?" That was not a tourer tribe.</p></div>'; include_game_down(); exit; } elseif ($target < 11) { echo '<p>"W-T-F mate?" No apparating into staff alliances.</p></div>'; include_game_down(); exit; } echo "<p>Leader! The tribe of " . $strTribeName . " has now apparated to alliance #<strong>{$target}</strong>. Let us hope that neither of their citizens got splinched.</p>"; $orkTime = date(TIMESTAMP_FORMAT); $search = mysql_query("SELECT * FROM stats WHERE id = {$id}"); $search = mysql_fetch_array($search); //mysql_query("UPDATE stats SET kingdom = $target, type ='player', invested = 0 where id = $id"); //mysql_query("UPDATE rankings_personal SET alli_id = $target where id = $id"); //mysql_query("UPDATE stats SET vote = 0, invested = 0 WHERE vote = $id"); //mysql_query("UPDATE goods SET credits = 0, market_money = 0, market_food = 0, market_soldiers = 0, market_wood = 0 WHERE id = $id"); include_once 'inc/staff/move.inc.php'; move_tribe($id, $target); mysql_query("INSERT INTO news (id, time, ip, type, duser, ouser, result, text, kingdom_text, kingdoma, kingdomb) VALUES ('', '{$orkTime}', '---', 'Tour Move', '0', '0', '1', '', '<span class=\"indicator\">{$search['tribe']} has joined our alliance. Long live Orkfia! Long live the tour!</span>', '', '{$target}')"); } }
function call_tourers_text() { require_once 'inc/functions/resort_tools.php'; check_access($_GET['tool']); require_once 'inc/functions/mail.php'; // first the "actually do something if asked" thing if (isset($_POST['id']) && isset($_POST['submit']) && isset($_POST['sure']) && $_POST['sure'] == 'yes') { //get the old values $objTrgUser = new clsUser($_POST['id']); $arrBuilds = $objTrgUser->get_builds(); $arrArmys = $objTrgUser->get_armys(); $intFame = $objTrgUser->get_stat(FAME); //make the new values $keysBuilds = array_keys($arrBuilds); $valsBuilds = array_fill(0, count($arrBuilds), 0); $arrBuilds = array_combine($keysBuilds, $valsBuilds); $arrBuilds[ID] = $_POST['id']; //DO NOT FORGET $arrBuilds[LAND] = 1; //prevent div0s $keysArmys = array_keys($arrArmys); $valsArmys = array_fill(0, count($arrArmys), 0); $arrArmys = array_combine($keysArmys, $valsArmys); $arrArmys[ID] = $_POST['id']; //DO NOT FORGET $intFame = 0; $arrUserInfo = array(NEXT_ATTACK => 1, PAUSE_ACCOUNT => 48); //set the new values $objTrgUser->set_builds($arrBuilds); $objTrgUser->set_armys($arrArmys); $objTrgUser->set_stat(FAME, $intFame); //update the tribe too require_once 'inc/functions/update.php'; require_once 'inc/functions/update_ranking.php'; doUpdateRankings($objTrgUser, true); check_to_update($objTrgUser->get_userid()); //do this afterwards, otherwise the updaterankings doesn't work too well $objTrgUser->set_user_infos($arrUserInfo); //tell them about it send_mail($GLOBALS['objSrcUser']->get_userid(), $_POST['id'], "You have been tourified", "This is an automated message indicating that I have used the 'Tourify' tool to turn your tribe into a tourer tribe."); echo "User {$_POST['id']} has been tourified. ORKFiA mail has been sent to let him know.<br /><br /><br />"; } echo "'Tourifying' a tribe means setting it to 1 land, 0 fame, removing all military and suspending it. " . "Please make sure you're tourifying the right tribe, because the only way to undo this is resetting." . "<br /><br /><form method=\"post\" action=\"{$_SERVER['REQUEST_URI']}\">" . "<label for=\"id\">User id of tribe to tourify </label>" . "<input type=\"text\" id=\"id\" name=\"id\" size=\"5\" maxlength=\"5\" /><br />" . "<input type=\"checkbox\" id=\"sure\" name=\"sure\" value=\"yes\" />" . "<label for=\"sure\"> I'm sure I want to tourify this tribe</label><br />" . "<input type=\"submit\" name=\"submit\" value=\"tourify\" />" . "</form>"; }
function unset_external_votes($iAlliance) { include_once('inc/classes/clsAlliance.php'); $objAlliance = new clsAlliance($iAlliance); $arrUserids = $objAlliance->get_userids(); // Unset votes for tribes that are no longer in the alliance foreach ($arrUserids as $iUserid) { $objTempUser = new clsUser($iUserid); if (! in_array($objTempUser->get_stat(VOTE), $arrUserids)) $objTempUser->set_stat(VOTE, 0); } }
function include_mail_text() { global $Host, $d_stats, $tribe, $mid, $subject, $set, $type, $action, $userid, $submit, $kingdom, $userid, $message, $inputBody, $orkTime, $local_stats, $connection, $posts, $replyid; include_once 'inc/functions/forums.php'; require_once 'inc/functions/mail.php'; $objSrcUser =& $GLOBALS['objSrcUser']; $local_stats = $objSrcUser->get_stats(); if (!$set) { $set = "view"; } if (!$kingdom) { $kingdom = $local_stats['kingdom']; } $count = '0'; $topLinks = '<div class="center">' . "| " . "<a href=\"main.php?cat=game&page=mail&set=compose\">" . "Compose Mail" . "</a>" . " | " . "<a href=\"main.php?cat=game&page=mail&set=view\">" . "View Inbox" . "</a>" . " | " . "<a href=\"main.php?cat=game&page=mail&set=outbox\">" . "View Outbox" . "</a>" . " | " . "<a href=\"main.php?cat=game&page=message&tribe=1&alliance=1\">" . "Send a Report" . "</a>" . " | " . "<a href=\"main.php?cat=game&page=mail&set=block\">" . "Block Mail" . "</a>"; if ($local_stats['type'] == 'elder') { $topLinks .= " | " . "<a href=\"main.php?cat=game&page=mail&set=eldermail\">" . "Alliance Mail" . "</a>"; } $topLinks .= " |</div>"; echo $topLinks; if ($set == "sendmail") { send_mail($userid, $tribe, $subject, $message); //changed to use send_mail function - AI 10/12/2006 } if ($set == "eldermailsend") { $message = safeHTML($message); $subject = safeHTML($subject); $message = "{$message}<br /><br />Your elder: " . $local_stats['name']; if (!$subject) { $subject = "No Subject"; } $query = mysql_query("SELECT id FROM stats WHERE kingdom = {$local_stats['kingdom']}"); while ($datas = mysql_fetch_array($query)) { if ($datas["id"] != $userid) { $create['message'] = mysql_query("INSERT INTO messages (id, for_user, from_user, date, subject, text, new, action) VALUES ('', '" . $datas['id'] . "', '" . $userid . "', '" . $orkTime . "', '" . $subject . "', '" . $message . "', 'new', 'received')"); $update['timestamp'] = mysql_query("UPDATE preferences SET last_m ='{$orkTime}' WHERE id= {$tribe}"); } } $create['message'] = mysql_query("INSERT INTO messages (id, for_user, from_user, date, subject, text, new, action) VALUES ('', '0', '" . $userid . "', '" . $orkTime . "', '" . $subject . "', '" . $message . "', 'old', 'sent')"); $set = "eldermail"; echo '<div class="center">' . "<h3>Message sent to all your alliance members.</h3></div>"; } if ($set == "eldermail") { $eldermail = '<div id="textBig">' . "<h2>Mail your alliance</h2>" . "<form action=\"main.php?cat=game&page=mail&set=eldermailsend\" method=\"post\">" . "<br />" . "Subject: <input type=\"text\" name=\"subject\" size=\"30\" />" . "<br />" . "<textarea name=\"message\" rows=\"10\" cols=\"70\" wrap=\"on\"></textarea>" . "<br />" . "<input type=\"submit\" value=\"Send Message\" />" . "</form>" . "</div>"; echo $eldermail; } if ($set == "compose") { $sendMailTargets = "<option value=\"spacer\">"; if (isset($_GET['aid']) && !empty($_GET['aid'])) { $kingdom = intval($_GET['aid']); } if (isset($_GET['tribe']) && !empty($_GET['tribe'])) { $replyid = intval($_GET['tribe']); } $result = mysql_query("SELECT * FROM stats WHERE kingdom = {$kingdom} ORDER BY tribe"); while ($kdstats = mysql_fetch_array($result, MYSQL_ASSOC)) { $kdstats["tribe"] = stripslashes($kdstats["tribe"]); if ($kdstats["id"] == $replyid) { $sendMailTargets .= "<option value=\"" . $kdstats['id'] . "\" selected>" . $kdstats['tribe']; } else { $sendMailTargets .= "<option value=\"" . $kdstats['id'] . "\">" . $kdstats['tribe']; } } $compose = "<br />" . "<table cellspacing=\"0\" cellpadding=\"0\" class=\"small\">" . "<tr class=\"header\">" . "<th colspan=\"2\">" . "Compose Mail" . "</th>" . "</tr>" . "<tr class=\"subheader\">" . "<th colspan=\"2\" class=\"center\">" . "Select Target" . "</th>" . "</tr>" . "<tr class=\"data\">" . "<form action=\"main.php?cat=game&page=mail&set=compose\" method=\"post\">" . "<th>" . "Alliance:" . "</th>" . "<td>" . "<input maxlength=\"4\" size=\"3\" name=\"kingdom\" value=\"{$kingdom}\" />" . "<input type=\"submit\" value=\"Change\" />" . "</td>" . "</form>" . "</tr>" . "<form id=\"center\" action=\"main.php?cat=game&page=mail&set=sendmail\" method=\"post\">" . "<tr class=\"data\">" . "<th>" . "Tribe:" . "</th>" . "<td>" . "<select name=\"tribe\">" . $sendMailTargets . "</select>" . "</td>" . "</tr>" . "</table>" . "<br />" . '<div class="center">' . "Subject: <input type=\"text\" name=\"subject\" size=\"30\" />" . "<br />" . "<textarea name=\"message\" rows=\"10\" cols=\"70\" wrap=\"on\"></textarea>" . "<br />" . "<input type=\"submit\" value=\"Send Message\" />" . "</form>" . "</div>"; echo $compose; } if ($set == "view") { $result = mysql_query("SELECT * from messages WHERE for_user ='******' AND action = 'received' AND new != 'deleted' ORDER BY date DESC") or die(mysql_error()); $num_mail = mysql_num_rows($result); if ($num_mail <= "0") { echo "You have no mail in your inbox.<br />"; include_game_down(); exit; } $update['timestamp'] = mysql_query("UPDATE preferences SET last_m_check ='{$orkTime}' WHERE id= {$userid}"); $updated['timestamp'] = mysql_query($update['timestamp'], $connection); $inbox = "<form id=\"center\" name=\"mail\" method=\"post\" action=\"main.php?cat=game&page=mail&set=delete2\">" . "<table cellpadding=\"0\" cellspacing=\"0\" class=\"big\">" . "<tr class=\"header\">" . "<th colspan=\"5\">" . "Inbox" . "</th>" . "</tr>" . "<tr class=\"subheader\">" . "<th>" . "Subject" . "</th>" . "<td class=\"left\">" . "From" . "</td>" . "<td class=\"left\">" . "Date" . "</td>" . "<td class=\"left\">" . "Status" . "</td>" . "<td class=\"center\">" . "Delete" . "</td>" . "</tr>"; while ($mail = mysql_fetch_array($result)) { $count++; if ($count == '1') { $class = ""; } else { $class = "bsup"; } mysql_grab($mail['from_user'], 'd', 'stats'); if (empty($mail['subject'])) { $mail['subject'] = 'No Subject'; } $inbox .= "<tr class=\"data\">" . "<th class=\"" . $class . "\">" . "<a href=\"main.php?cat=game&page=mail&set=read&mid=" . $mail['id'] . "\">" . cleanHTML($mail['subject']) . "</a>" . "</th>" . "<td class=\"" . $class . " left\">" . cleanHTML($d_stats['tribe']) . "(#" . $d_stats['kingdom'] . ")</td>" . "<td class=\"" . $class . " left\">" . $mail['date'] . "</td>" . "<td class=\"" . $class . " left\">" . $mail['new'] . "</td>" . "<td class=\"" . $class . " center\">" . "<input name=\"posts[]\" type=\"checkbox\" value=\"" . $mail['id'] . "\" />" . "</td>" . "</tr>"; } $inbox .= "</table>" . '<br /><div class="center">' . "| <a href='#' onclick=\"var posts=document.getElementsByName('mail')[0]['posts[]']; for(var i=0,len=posts.length;i<len;i++) posts[i].checked=true;\">Check All</a>" . " | <a href='#' onclick=\"var posts=document.getElementsByName('mail')[0]['posts[]']; for(var i=0,len=posts.length;i<len;i++) posts[i].checked=false;\">Uncheck All</a> |" . "</div><br />" . "<input type=\"submit\" name=\"submit\" value=\"Delete\" />" . "</form>"; echo $inbox; } if ($set == "outbox") { $result = mysql_query("SELECT * from messages WHERE from_user ='******' AND action = 'sent' AND new != 'deleted' ORDER BY date DESC") or die(mysql_error()); $num_mail = mysql_num_rows($result); if ($num_mail <= "0") { echo "<div class=\"center\">You have no mail in your outbox.</div>"; include_game_down(); exit; } $outbox = "<form id=\"center\" name=\"mail\" method=\"post\" action=\"main.php?cat=game&page=mail&set=deleteout2\">" . "<table cellpadding=\"0\" cellspacing=\"0\" class=\"big\">" . "<tr class=\"header\">" . "<th colspan=\"5\">" . "Outbox" . "</th>" . "</tr>" . "<tr class=\"subheader\">" . "<th>" . "Subject" . "</th>" . "<td class=\"left\">" . "To" . "</td>" . "<td class=\"left\">" . "Date" . "</td>" . "<td class=\"left\">" . "Status" . "</td>" . "<td class=\"center\">" . "Delete" . "</td>" . "</tr>"; while ($mail = mysql_fetch_array($result)) { $count++; if ($count == '1') { $class = ""; } else { $class = "bsup"; } if ($mail['for_user'] == "0") { $receiver = "Your Alliance"; } else { $foruser = mysql_query("SELECT tribe, kingdom FROM stats WHERE id = {$mail['for_user']}"); $foruser = mysql_fetch_array($foruser); $receiver = cleanHTML($foruser['tribe']) . "(#{$foruser['kingdom']})"; } if (empty($mail['subject'])) { $mail['subject'] = 'No Subject'; } $outbox .= "<tr class=\"data\">" . "<th class=\"" . $class . "\">" . "<a href=\"main.php?cat=game&page=mail&set=readout&mid=" . $mail['id'] . "\">" . cleanHTML($mail['subject']) . "</a>" . "</th>" . "<td class=\"" . $class . " left\">" . $receiver . "</td>" . "<td class=\"" . $class . " left\">" . $mail['date'] . "</td>" . "<td class=\"" . $class . " left\">" . $mail['new'] . "</td>" . "<td class=\"" . $class . " center\">" . "<input name=\"posts[]\" type=\"checkbox\" value=\"" . $mail['id'] . "\" />" . "</td>" . "</tr>"; } $outbox .= "</table>" . "<br /><br />" . "| <a href='#' onclick=\"var posts=document.getElementsByName('mail')[0]['posts[]']; for(var i=0,len=posts.length;i<len;i++) posts[i].checked=true;\">Check All</a>" . " | <a href='#' onclick=\"var posts=document.getElementsByName('mail')[0]['posts[]']; for(var i=0,len=posts.length;i<len;i++) posts[i].checked=false;\">Uncheck All</a> |" . "<br /><br />" . "<input type=\"submit\" name=\"submit\" value=\"Delete\" />" . "</form>"; echo $outbox; } if ($set == "readout") { $result = mysql_query("SELECT * from messages WHERE from_user ='******' AND id = '{$mid}' AND action = 'sent' AND new != 'deleted'"); $read = mysql_fetch_array($result); $read['subject'] = stripslashes(stripslashes($read['subject'])); $read['text'] = stripslashes(stripslashes($read['text'])); if ($read['for_user'] == "0") { $receiver = "Your Alliance"; } else { $foruser = mysql_query("SELECT tribe, kingdom FROM stats WHERE id = {$read['for_user']}"); $foruser = mysql_fetch_array($foruser); $receiver = "{$foruser['tribe']}(#{$foruser['kingdom']})"; } $readout = "<table cellpadding=\"0\" cellspacing=\"0\" class=\"medium\">" . "<tr class=\"header\">" . "<th>" . "Message to: " . $receiver . "</th>" . "</tr>" . "<tr class=\"subheader\">" . "<th>" . "Subject: " . cleanHTML($read['subject']) . "</th>" . "</tr>" . "<tr class=\"message\">" . "<td>" . "<br />" . cleanHTML($read['text']) . "<br />" . "</td>" . "</tr>" . "</table>" . "<br />" . '<div class="center">' . "| <a href=main.php?cat=game&page=mail&set=deleteout&mid={$mid}>Delete</a> | " . "<a href=main.php?cat=game&page=mail&set=outbox>Return To Outbox</a> |</div>"; echo $readout; } if ($set == "read") { $result = mysql_query("SELECT * from messages WHERE for_user ='******' AND id = '{$mid}' AND action = 'received' AND new != 'deleted'"); $read = mysql_fetch_array($result); mysql_grab($read['from_user'], 'd', 'stats'); $read['subject'] = stripslashes(stripslashes($read['subject'])); $read['text'] = stripslashes(stripslashes($read['text'])); $readin = "<br /><table cellpadding=\"0\" cellspacing=\"0\" class=\"medium\">" . "<tr class=\"header\">" . "<th>" . "Message from: " . stripslashes($d_stats['name']) . "</th>" . "</tr>" . "<tr class=\"subheader\">" . "<th>" . "Subject: " . cleanHTML($read['subject']) . "</th>" . "</tr>" . "<tr class=\"message\">" . "<td>" . "<br />" . cleanHTML($read['text']) . "<br />" . "</td>" . "</tr>" . "</table>" . "<br />" . '<div class="center">' . "| <a href=main.php?cat=game&page=mail&set=reply&mid={$mid}>Reply</a> | " . "<a href=main.php?cat=game&page=mail&set=delete&mid={$mid}>Delete</a> | " . "<a href=main.php?cat=game&page=mail&set=view&mid={$d_stats['id']}>Return To Inbox</a> | " . '</div>'; echo $readin; $old = mysql_query("UPDATE messages SET new ='old' WHERE id ='{$mid}'"); $mid2 = $mid + 1; $select = mysql_query("SELECT action FROM messages WHERE id = '{$mid2}'"); $select = mysql_fetch_array($select); if ($select['action'] == 'sent') { $old = mysql_query("UPDATE messages SET new ='old' WHERE id ='{$mid2}'"); } } if ($set == "delete") { $email_name = "UPDATE messages SET new = 'deleted' WHERE id ='{$mid}' AND for_user = '******' AND action = 'received'"; $delete = mysql_query($email_name, $connection); echo '<div id="textMedium"><p>' . "The message has been deleted.<br /><br />"; echo "<a href=main.php?cat=game&page=mail&set=view>Return To Inbox</a></p>" . '</div'; } if ($set == "delete2") { $sql = "UPDATE messages SET new = 'deleted' WHERE for_user = '******' AND action = 'received' "; $sql .= " AND id IN ("; $posts = $_POST["posts"]; $postcount = count($posts); for ($i = 0; $i < $postcount; $i++) { $sql .= "{$posts[$i]}"; if ($i != $postcount - 1) { $sql .= ","; } } $sql .= ")"; $delete = mysql_query($sql, $connection); echo '<div id="textMedium"><p>' . "The selected messages are deleted.<br /><br />"; echo "<a href=main.php?cat=game&page=mail&set=view>Return To Inbox</a></p>" . '</div'; } if ($set == "deleteout") { $email_name = "UPDATE messages SET new = 'deleted' WHERE id ='{$mid}' AND from_user = '******' AND action = 'sent'"; $delete = mysql_query($email_name, $connection); echo '<div id="textMedium"><p>' . "The message has been deleted.<br /><br />"; echo "<a href=main.php?cat=game&page=mail&set=outbox>Return To Outbox</a></p>" . '</div'; } if ($set == "deleteout2") { $sql = "UPDATE messages SET new = 'deleted' WHERE from_user = '******' AND action = 'sent' "; $sql .= " AND id IN ("; $posts = $_POST["posts"]; $postcount = count($posts); for ($i = 0; $i < $postcount; $i++) { $sql .= "{$posts[$i]}"; if ($i != $postcount - 1) { $sql .= ","; } } $sql .= ")"; $delete = mysql_query($sql, $connection); echo '<div id="textMedium"><p>' . "The selected messages are deleted.<br /><br />"; echo "<a href=main.php?cat=game&page=mail&set=outbox>Return To Outbox</a></p>" . '</div'; } if ($set == "reply") { if ($action != "post") { $result = mysql_query("SELECT * from messages WHERE for_user ='******' AND id = '{$mid}' AND action = 'received'"); $reply = mysql_fetch_array($result); $subject = "Re: " . cleanHTML($reply['subject']) . " "; $replyText = "<form action=\"main.php?cat=game&page=mail&set=reply&mid={$mid}&action=post\" method=\"post\">" . "<br />" . "Subject: <input type=\"text\" name=\"subject\" size=\"30\" value=\"" . $subject . "\" />" . "<br />" . "<textarea name=\"message\" rows=\"10\" cols=\"70\" wrap=\"virtual\"></textarea>" . "<br />" . "<input type=\"submit\" name=\"submit\" value=\"Send Message\" />" . "</form>"; echo $replyText; } if ($action == "post") { $result = mysql_query("SELECT * from messages WHERE for_user ='******' AND id = '{$mid}' AND action = 'received'"); $reply = mysql_fetch_array($result); send_mail($userid, $reply['from_user'], $subject, $message); echo "<a href=main.php?cat=game&page=mail>Return To Mailbox</a>"; } } if ($set == "block") { if (isset($_POST['tribe']) && $_POST['tribe'] != 'spacer' && $action == "block") { $blocker_id = $objSrcUser->get_userid(); $blocked_id = quote_smart($_POST['tribe']); $objTrgUser = new clsUser($blocked_id); $blocked_name = $objTrgUser->get_stat(TRIBE); echo '<br /><div class="center">' . "You have blocked {$blocked_name} from sending you any more mail.</div>"; block_mail($blocker_id, $blocked_id); } if (isset($_GET['id']) && $_GET['id'] > 0 && $action == "unblock") { $blocker_id = $objSrcUser->get_userid(); $blocked_id = quote_smart($_GET['id']); $objTrgUser = new clsUser($blocked_id); $blocked_name = $objTrgUser->get_stat(TRIBE); echo '<br /><div class="center">' . "You have unblocked {$blocked_name}, they can send you mail again.</div>"; unblock_mail($blocker_id, $blocked_id); } $tribes = mysql_query("select tribe,id from stats where kingdom = {$kingdom} order by tribe"); $blockTargets = "<option value=\"spacer\"></option"; while ($allistats = mysql_fetch_assoc($tribes)) { $tribe = stripslashes($allistats['tribe']); $id = $allistats['id']; $blockTargets .= "<option value=\"{$id}\">{$tribe}</option>"; } echo "<br /><table cellspacing=\"0\" cellpadding=\"0\" class=\"small\">" . "<tr class=\"header\"><th colspan=\"2\">Block Mail</th></tr>" . "<tr class=\"subheader\"><th colspan=\"2\" class=\"center\">Select spammer</th></tr>" . "<tr class=\"data\"><form action=\"main.php?cat=game&page=mail&set=block\" method=\"post\">" . "<th>Alliance:</th><td><input maxlength=\"4\" size=\"3\" name=\"kingdom\" value=\"{$kingdom}\" />" . "<input type=\"submit\" value=\"Change\" /></td></form></tr>" . "<form action=\"main.php?cat=game&page=mail&set=block&action=block\" method=\"post\">" . "<tr class=\"data\"><th>Tribe:</th><td><select name=\"tribe\">{$blockTargets}</select>" . "<input type=\"submit\" value=\"Block\" name=\"Block\" /></td></tr></form>" . "</table><br /><br />"; $blocked_users = get_blocks_mail($objSrcUser->get_userid()); echo "<table cellspacing=\"0\" cellpadding=\"0\" class=\"small\">" . "<tr class=\"header\"><th colspan=\"2\">Blocked users</th></tr>" . "<tr class=\"subheader\"><th colspan=\"2\" class=\"center\">Remove?</th></tr>"; foreach ($blocked_users as $blocked_user) { echo "<tr class=\"data\"><th>{$blocked_user['tribe']}</th>" . "<td><a href=\"main.php?cat=game&page=mail&set=block&" . "action=unblock&id={$blocked_user['blocked_id']}\">Remove?</td></tr>"; } echo "</table>"; } }
function include_external_affairs_text() { $objSrcUser =& $GLOBALS['objSrcUser']; $objSrcAlliance = $objSrcUser->get_alliance(); //========================================================================== // Validate GET input //========================================================================== if (empty($_GET['tribe'])) { $tribe = $objSrcUser->get_userid(); } else { $tribe = intval($_GET['tribe']); } if (empty($_GET['aid'])) { $aid = $objSrcUser->get_stat(ALLIANCE); } else { $aid = intval($_GET['aid']); } //========================================================================== // Start Output //========================================================================== if ($aid > 10) { // Target user object include_once 'inc/classes/clsUser.php'; if ($tribe == $objSrcUser->get_userid()) { $objTrgUser = $objSrcUser; } elseif ($tribe > 0) { $objTrgUser = new clsUser($tribe); } // Target alliance object $objTrgAlliance = $objTrgUser->get_alliance(); $aid = $objTrgUser->get_stat(ALLIANCE); // Update user include_once 'inc/functions/update.php'; check_to_update($objTrgUser->get_userid()); // Update rankings include_once 'inc/functions/update_ranking.php'; doUpdateRankings($objTrgUser); // Div starts here ?> <div id="columns"> <!-- Start left column --> <div id="leftcolumn"> <br /> <?php // Show mini-vision table echo get_small_tribe_table($objTrgUser); $arrStats = $objSrcUser->get_stats(); $arrRankingsPersonal = $objTrgUser->get_rankings_personals(); // Show advisor message echo '<div id="textSmall">' . '<p><strong>The General</strong> tells you: <br />'; if ($tribe == $objSrcUser->get_userid()) { echo 'This is <em>our</em> tribe, leader =)'; } elseif ($objTrgUser->get_stat(KILLED) == 0 && $objTrgUser->get_stat(RESET_OPTION) == 'yes') { echo 'This tribe has <em>reset</em>.'; } elseif ($objTrgUser->get_user_info(HOURS) < PROTECTION_HOURS) { $iRemaining = PROTECTION_HOURS - $objTrgUser->get_user_info(HOURS); echo 'This tribe is performing the summoning ritual and their ' . 'borders will be protected for another <strong>' . $iRemaining . ' months.</strong>'; } elseif ($objTrgUser->get_stat(KILLED) > 0 && $objTrgUser->get_stat(KILLED) != 3) { echo 'This tribe is <em>dead</em>.'; } elseif ($objTrgUser->isPaused()) { echo 'This tribe is <em>paused</em>.'; } elseif ($objTrgUser->get_stat(ALLIANCE) == $objSrcUser->get_stat(ALLIANCE)) { echo 'This is a friendly <em>allied</em> tribe.'; } elseif ($objTrgUser->get_stat(ALLIANCE) == $objSrcAlliance->get_war(TARGET)) { echo 'We are in a declared <em class="negative">war</em> with this tribe!'; } elseif ($objTrgAlliance->get_war(TARGET) > 0) { echo 'This tribe is in <em class="negative">war</em> with another alliance.'; } elseif ($objTrgUser->get_stat(ALLIANCE) != $objSrcUser->get_stat(ALLIANCE)) { echo 'This <em>enemy</em> tribe may remain neutral towards us if we let them be. Be careful with your actions against them leader.'; } if ($objTrgUser->get_stat(ALLIANCE) == $objSrcUser->get_stat(ALLIANCE) || $objTrgUser->get_stat(KILLED) > 0 || $objTrgUser->isPaused()) { /* say nothing */ } elseif ($objTrgUser->get_build(LAND) < 0.8 * $objSrcUser->get_build(LAND)) { echo '</p><p>Also, due to their small size we will gain less land on attacks and do less damage with our operations and spells.'; } elseif ($objTrgUser->get_build(LAND) > 2.0 * $objSrcUser->get_build(LAND)) { echo '</p><p>Also, due to their large size our operations will have very high fail rates.'; } elseif ($objTrgUser->get_build(LAND) > 1.2 * $objSrcUser->get_build(LAND)) { echo '</p><p>Also, due to their large size our operations and spells will do less damage and we will gain less on attacks.'; } echo '</p>' . '</div>'; ?> </div> <!-- end left column --> <!-- start right column --> <div id="rightcolumn"> <?php echo '<div class="tableLinkSmall"><a href="main.php?cat=game&page=alliance&aid=' . $aid . '">Back to alliance #' . $aid . '</a>' . '</div>'; // Show action links echo '<div id="textSmall" style="margin-top: 0px;">' . '<h2>Tribe Actions</h2>'; echo '<ul>' . '<li>' . '<a href="main.php?cat=game&page=mystic&magekd=' . $aid . '&tribe=' . $tribe . '">Prepare Mystics</a>' . '</li>' . '<li>' . '<a href="main.php?cat=game&page=thievery&kd=' . $aid . '&tribe=' . $tribe . '">Prepare Thieves</a>' . '</li>' . '<li>' . '<a href="main.php?cat=game&page=invade&atkid=' . $aid . '&tribe=' . $tribe . '">Prepare Invasion</a>' . '</li>' . '<li>' . '<a href="main.php?cat=game&page=mail&set=compose&aid=' . $aid . '&tribe=' . $tribe . '">Orkfia Mail</a>' . '</li>' . '</ul>'; echo '</div>'; ?> </div> <!-- End of the right column--> </div> <!-- end of 2 column layout --> <?php } elseif ($aid < 11) { echo '<div class="tableLinkMedium">' . '<a href="main.php?cat=game&page=alliance&aid=' . $aid . '">Alliance #' . $aid . '</a>' . '</div>'; // Show action links echo '<div id="textMedium" style="margin-top: 0px;">'; echo '<p><strong>Tribe Actions</strong></p>'; echo '<ul>' . '<li>' . '<a href="main.php?cat=game&page=message&alliance=' . $aid . '&tribe=' . $tribe . '">Submit a Report</a>' . '</li>' . '<li>' . '<a href="main.php?cat=game&page=mail&set=compose&aid=' . $aid . '&tribe=' . $tribe . '">Orkfia Mail</a>' . '</li>' . '</ul>'; echo '</div>'; } }
function check_to_update($user) { //========================================================================== // Martel, July 09, 2006 // Use global src object if the source == the tribe triggering this update // (self update) //========================================================================== $objSrcUser =& $GLOBALS["objSrcUser"]; if ($user != $objSrcUser->get_userid()) { $objUser = new clsUser($user); } else { $objUser =& $objSrcUser; } //========================================================================== // Calculate updates owed //========================================================================== $Last_update_hour = $objUser->get_user_info(LAST_UPDATE_HOUR); $Last_update_day = $objUser->get_user_info(LAST_UPDATE_DAY); // $iTribeTick = $objUser->get_user_info(LAST_UPDATE_TICK); $day = date("d"); $hour = date("H"); $month = date("m"); $year = date("y"); $lmonth = $month - 1; if ($day < $Last_update_day) { if ($lmonth == 0) { $lmonth = 12; } if ($lmonth == 1 || $lmonth == 3 || $lmonth == 5 || $lmonth == 7 || $lmonth == 8 || $lmonth == 10 || $lmonth == 12) { $day = $day + 31; } elseif ($lmonth == 2) { if ($year % 4 == 0) { $day = $day + 29; } else { $day = $day + 28; } } elseif ($lmonth == 4 || $lmonth == 6 || $lmonth == 9 || $lmonth == 11) { $day = $day + 30; } } $iUpdatesOwed = ($day - $Last_update_day) * 24 + ($hour - $Last_update_hour); if ($iUpdatesOwed > 36) { $iUpdatesOwed = 36; } $objUser->set_user_info(LAST_UPDATE_DAY, date('d')); $objUser->set_user_info(LAST_UPDATE_HOUR, date('H')); // $objUser->set_user_info(LAST_UPDATE_TICK, $iGameTick); // Preparing for new method to count owed updates include_once 'inc/classes/clsGame.php'; $objGame = new clsGame(); // $iGameTick = $objGame->get_game_time(HOUR_COUNTER); // $iUpdatesOwed = floor($iGameTick - $iTribeTick); //========================================================================== // FORGET UPDATES - setting updatesOwed to 0 is permanent and will be saved // Until the new update system is implemented this is the only feasible way. //========================================================================== if ($objGame->get_game_switch(GLOBAL_PAUSE) == ON) { $iUpdatesOwed = 0; } // Tribes who are either killed, waiting to be reset or paused $strReset = $objUser->get_stat(RESET_OPTION); $blnKilled = $objUser->get_stat(KILLED); $iPaused = $objUser->get_user_info(PAUSE_ACCOUNT); if ($strReset == 'yes' || $blnKilled == 1) { $iUpdatesOwed = 0; } elseif ($iPaused > 0) { // Counter to see how long tribe has left in "forced" protection // Expl: only after these updates a tribe can choose to un-pause $iPaused -= $iUpdatesOwed; if ($iPaused <= 1) { $iPaused = 1; } // Save the last update info $objUser->set_user_info(PAUSE_ACCOUNT, $iPaused); } //========================================================================== // Time to hand out updates... //========================================================================== if ($iUpdatesOwed > 0) { // 6 Week limit for Infinity ORKFiA Martel, July 09, 2006 $iHours = $objUser->get_user_info(HOURS); $objRace = $objUser->get_race(); $intLifespan = $objRace->getLifespan(); // M: Perform near-death updates until the tribe is dead if ($iHours + $iUpdatesOwed > $intLifespan) { include_once 'inc/functions/tribe.php'; $blnReturn = FALSE; // Updates that should be used to determine chance of death $iMaxAfter100Owed = $iHours + $iUpdatesOwed - $intLifespan + $iUpdatesOwed; $iUpdatesAfter100Owed = min($iUpdatesOwed, $iMaxAfter100Owed); // Iterate through each update to see if it's time to die for ($i = 1; $i <= $iUpdatesAfter100Owed; $i++) { // Correct hour of news event $event = $iUpdatesAfter100Owed - $i; $event_time = date(TIMESTAMP_FORMAT, strtotime("-{$event} hours")); $iRand = rand(1, max(1, 24 - $iMaxAfter100Owed)); if ($iRand == 1) { // Give remaining updates to tribe $iUpdatesOwedBeforeDeath = $i + ($iUpdatesOwed - $iUpdatesAfter100Owed); call_update_script($iUpdatesOwedBeforeDeath, $objUser); // For use in Alliance News $iRulerAge = getRulerAge($objUser); $strTribe = $objUser->get_stat(TRIBE); // Code for death due to age $objUser->set_stat(KILLED, 1); obj_kill_user($objUser); // Alliance News $strAlliNews = "<b class=\"negative\">The ruler of " . $strTribe . " has died at an age of " . $iRulerAge . ".</b>"; $iShowAlli = $objUser->get_stat(ALLIANCE); // Tribe News $strTribeNews = "The death of the old and tired tribe ruler comes as " . "no surprise. Most citizens have left the lands, and " . "the leaderless military rampantly plundered what " . "they could. The citizens remaining wish to " . "contribute goods they hid to support your cause." . "<br /><br />" . $strAlliNews . "<br /><br />" . "Below are the news that your previous tribe recieved:"; $blnReturn = TRUE; } else { $strAlliNews = ''; $iShowAlli = ''; $strTribeNews = 'Leader, your age is becoming a problem! The citizens ' . 'are preparing for the worst and your general openly ' . 'disobey you.'; } $strSQL = 'INSERT INTO ' . "news" . ' SET ' . "time" . " = '{$event_time}', " . "type" . " = 'death', " . "duser" . " = {$user}, " . "result" . " = 1, " . "text" . " = '{$strTribeNews}', " . "kingdom_text" . " = '{$strAlliNews}', " . "kingdoma" . " = {$iShowAlli}"; mysql_query($strSQL); if ($blnReturn) { break; } } } // Vacation mode 48 hours (+6 hours enter-phase = 54 hours) if ($iPaused > 0 && $objUser->get_stat(KILLED) == 0) { // (Martel: paused accs will still age - "fair ranking" fix) $iNewHours = $objUser->get_user_info(HOURS) + $iUpdatesOwed; $objUser->set_user_info(HOURS, $iNewHours); // Only "forget" updates while in protection, not during enter-phase // Bug-fix February 27, 2008 Martel if ($iPaused <= 48) { $iUpdatesOwed = 0; } } //====================================================================== // Update Tribe // Martel: Moving this to a separate file - February 27, 2008 //====================================================================== require_once 'inc/functions/update_script.php'; generate_updates($objUser, $iUpdatesOwed); } }
function include_alliance_text() { // This bugs pretty badly if the alliance tables are missing // Same thing further down too, but for target alliance obj. $objSrcUser =& $GLOBALS["objSrcUser"]; $objSrcAlli = $objSrcUser->get_alliance(); //========================================================================== // Martel: Validate the alliance number so we get an absolutely safe one //========================================================================== $iAid = intval($objSrcUser->get_stat(ALLIANCE)); if (isset($_POST['aid'])) { $iAid = intval($_POST['aid']); if (strlen($_POST['aid']) > 4) { require_once 'inc/pages/logout.inc.php'; include_logout_text(); } } elseif (isset($_GET['aid'])) { $iAid = intval($_GET['aid']); if (strlen($_GET['aid']) > 4) { require_once 'inc/pages/logout.inc.php'; include_logout_text(); } } if ($iAid < 1) { $iAid = 1; } //========================================================================== $result = mysql_query("SELECT alli_id FROM rankings_personal WHERE alli_id < {$iAid} ORDER BY alli_id DESC LIMIT 1"); if (mysql_num_rows($result) == '0') { $prevAlli['0'] = $iAid; } else { $prevAlli = mysql_fetch_row($result); } $result = mysql_query("SELECT alli_id FROM rankings_personal WHERE alli_id > {$iAid} ORDER BY alli_id ASC LIMIT 1"); if (mysql_num_rows($result) == '0') { $nextAlli['0'] = $iAid; } else { $nextAlli = mysql_fetch_row($result); } echo $chooseAlliance = "<div class=\"tableLinkMini\">" . "<a href=\"main.php?cat=game&page=alliance\">Home</a>" . "</div>" . "<form method=\"post\" action=\"main.php?cat=game&page=alliance\" style=\"margin-top: 0pt;\">" . "<table cellpadding=\"0\" cellspacing=\"0\" class=\"mini\">" . "<tr class=\"header\">" . "<th colspan=\"4\">" . "Alliance" . "</th>" . "</tr>" . "<tr class=\"data\">" . "<td>" . "<a id=\"arrowl\" href=\"main.php?cat=game&page=alliance&aid=" . $prevAlli[0] . "\">" . "<span class=\"alt\">" . "<" . "</span>" . "</a>" . "</td>" . "<td>" . "<input type=\"text\" name=\"aid\" size=\"4\" maxlength=\"4\" value=\"" . $iAid . "\" />" . "</td>" . "<td>" . "<input type=\"submit\" name=\"submit\" value=\"View\" />" . "</td>" . "<td>" . "<a id=\"arrowr\" href=\"main.php?cat=game&page=alliance&aid=" . $nextAlli[0] . "\">" . "<span class=\"alt\">" . ">" . "</span>" . "</a>" . "</td>" . "</tr>" . "</table>" . "</form>"; $res = mysql_query("SELECT COUNT(id) AS cnt FROM rankings_personal WHERE alli_id = {$iAid}"); $line = mysql_fetch_assoc($res); if ($line["cnt"] == '0') { $res = mysql_query("SELECT id FROM rankings_alliance ORDER BY id DESC LIMIT 1"); $max = mysql_fetch_assoc($res); $res = mysql_query("SELECT id FROM rankings_alliance ORDER BY id ASC LIMIT 1"); $min = mysql_fetch_assoc($res); echo "Selections range from " . $min["id"] . "-" . $max["id"]; include_game_down(); exit; } ?> <div class="center"> <?php //========================================================================== // Alliance Banner //========================================================================== $objTrgAlli = new clsAlliance($iAid); $arrAlliance = $objTrgAlli->get_alliance_infos(); $arrRankingsAlliance = $objTrgAlli->get_rankings_alliances(); if (trim($arrAlliance[IMAGE]) != '') { $arrAlliance[IMAGE] = stripslashes($arrAlliance[IMAGE]); $arrAlliance[IMAGE] = htmlspecialchars($arrAlliance[IMAGE]); $arrAlliance[IMAGE] = escapeshellcmd($arrAlliance[IMAGE]); echo "<img src =\"" . $arrAlliance[IMAGE] . "\" width =\"" . $arrAlliance[IMAGEWIDTH] . "\" height =\"" . $arrAlliance[IMAGEHEIGHT] . "\" alt=\"\" /><br />"; } //========================================================================== // War status display //========================================================================== $arrSrcWar = $objTrgAlli->get_wars(); if ($arrSrcWar[TARGET] != 0) { $targetLink = " (<a href=\"main.php?cat=game&page=alliance&aid=" . $arrSrcWar[TARGET] . "\">#" . $arrSrcWar[TARGET] . "</a>)"; $objWarTrg = new clsAlliance($arrSrcWar[TARGET]); $strAlliName = stripslashes($objWarTrg->get_rankings_alliance('alli_name')); echo '<br /><strong class="negative">At war with ' . $strAlliName . $targetLink . '</strong>'; } //========================================================================== if ($iAid < 10) { $iSpan = 3; ?> <span style="font-size: 0.8em"><a href="main.php?cat=game&page=message&alliance=<?php echo $iAid; ?> ">Submit a report here</a>.</span> <br /> <?php } else { $iSpan = 6; if ($iAid == $objSrcUser->get_stat(ALLIANCE)) { $iSpan = 7; } // bootcamp indication if ($arrAlliance[BOOTCAMP] == 'yes') { ?> <br /><strong class='positive'>[ Boot Camp ]</strong><br /> <?php } // M: Graveyard indication if ($iAid == 10) { echo '<h2>The Graveyard in #10 - Beware of the DEAD.</h2>'; } ?> <?php } ?> </div> <br /> <table cellpadding="0" cellspacing="0" class="big"> <tr class="header"> <th colspan="<?php echo $iSpan; ?> "> <?php $strAllianceName = stripslashes($arrRankingsAlliance[ALLI_NAME]); echo "{$strAllianceName} (#{$iAid})"; if (trim($arrRankingsAlliance[ALLI_DESC]) != '') { $allianceDesc = stripslashes(trim($arrRankingsAlliance[ALLI_DESC])); ?> <br /><span style="font-size: 0.8em;"><?php echo $allianceDesc; ?> </span> <?php } if ($iAid < 10) { ?> </th> </tr> <tr class="subheader"> <th width="17"></th> <td align="left" class="left" width="34%">Staff Tribe</td> <td align="left" class="left">Online < 48 hours ago</td> </tr> <?php // Martel: Sort 1-10 on staff ranks and name instead of acres $res = mysql_query("SELECT rankings_personal.id, alli_id, tribe_name, hours, rankings_personal.race, land, nw, rankings_personal.fame, player_type, stats.level FROM rankings_personal, stats WHERE alli_id = {$iAid} AND stats.id = rankings_personal.id ORDER BY level DESC, tribe_name ASC"); } else { // Output alliance Rankings include_once 'inc/functions/alli_ranking.php'; if ($iAid != 10) { $arrRanking = get_rank_data($iAid); echo "<br />Land: " . $arrRanking[LAND] . " Strength: " . $arrRanking[STRENGTH] . " Fame: " . $arrRanking[FAME]; } ?> </th> </tr> <tr class="subheader"> <th width="17"></th> <th>Tribe Name</th> <?php if ($iAid == $objSrcUser->get_stat(ALLIANCE)) { echo ' <td><em>Ruler Age</em></td> '; } ?> <td>Race</td> <td>Size</td> <td>Strength</td> <td>Fame</td> </tr> <?php // Sort tribes by acreage, strength, fame $res = mysql_query("SELECT id FROM rankings_personal WHERE alli_id = {$iAid} ORDER BY land DESC, nw DESC, fame DESC"); } $inactivitycheck = $objSrcUser->get_rankings_personals(); $iCount = 0; $inactiveCounter = 0; $objTmpUser = new clsUser(0); while ($line = mysql_fetch_assoc($res)) { // Clear the temporary object to assign a new user $iUserid = $line[ID]; $objTmpUser->set_userid($iUserid); $arrTmpRanking = $objTmpUser->get_rankings_personals(); $arrTmpRanking[TRIBE_NAME] = stripslashes($arrTmpRanking[TRIBE_NAME]); $strFame = (string) number_format($arrTmpRanking[FAME]); if ($arrTmpRanking[FAME] < 5000) { $strFame = '<span class="negative">' . $strFame . '</span>'; } elseif ($arrTmpRanking[FAME] > 5000) { $strFame = '<span class="positive">' . $strFame . '</span>'; } ?> <tr class="data"> <th> <?php $online = $objTmpUser->get_onlines(); $old = date(TIMESTAMP_FORMAT, strtotime('-5 minutes')); // Martel: New inactivity check. // Works with both month changes and leap years ;) $inactive = date(TIMESTAMP_FORMAT, strtotime('-2 days')); if ($online['time'] < $inactive && $inactivitycheck[PLAYER_TYPE] == "elder" && $inactivitycheck[ALLI_ID] == $iAid) { ?> <img src="<?php echo HOST_PICS; ?> tribe_inactive.gif" alt="*" height="13" width="13" /> <?php } elseif ($online['time'] < $old) { ?> <img src="<?php echo HOST_PICS; ?> tribe_offline.gif" alt="" height="13" width="13" /> <?php } else { $inactiveCounter++; ?> <img src="<?php echo HOST_PICS; ?> tribe_online.gif" alt="»" height="13" width="13" /> <?php } ?> </th> <th> <?php // Begin output of <tr> for each tribe if ($iAid >= 10) { $strClass = $arrTmpRanking[PLAYER_TYPE] . ""; if ($objTmpUser->isPaused() || $arrTmpRanking[HOURS] < PROTECTION_HOURS) { $strClass = "protected"; } echo '<a href="main.php?cat=game&page=external_affairs&tribe=' . $arrTmpRanking[ID] . "&aid=" . $arrTmpRanking[ALLI_ID] . '" class="' . $strClass . '">' . $arrTmpRanking[TRIBE_NAME] . '</a></th>'; if ($iAid == $objSrcUser->get_stat(ALLIANCE)) { echo "<td><em>" . $objTmpUser->get_ruler_age() . "</em></td>"; } echo "<td>" . $arrTmpRanking[RACE] . "</td>" . "<td>" . number_format($arrTmpRanking[LAND]) . "</td>" . "<td>" . number_format($arrTmpRanking[NW]) . "</td>" . "<td>" . $strFame . "</td>" . "</tr>"; } else { $strClass = "staff"; if ($objTmpUser->get_stat(LEVEL) > 5) { $strClass = "admin"; } elseif ($objTmpUser->get_stat(LEVEL) == 5) { $strClass = "head"; } echo '<a href="main.php?cat=game&page=message&tribe=' . $arrTmpRanking[ID] . "&alliance=" . $arrTmpRanking[ALLI_ID] . '" class="' . $strClass . '">' . $arrTmpRanking[TRIBE_NAME] . '</a></th>'; if ($online['time'] < $inactive) { echo '<td class="left"><em>No</em></td>'; } else { echo '<td class="left"><em class="positive">Yes</em></td>'; } echo '</tr>'; } $iCount++; } ?> </table> <div class="center" style="font-size: 0.8em"> There are <?php echo $iCount; ?> tribes in this alliance. </div> <br /> <table cellpadding="0" cellspacing="0" class="small"> <tr class="header"> <th colspan="2">Legend</th> </tr> <tr class="subheader"> <th>Mark</th> <td>Meaning</td> </tr> <?php if ($iAid >= 10) { ?> <tr class="data"> <th class="elder">Gold:</th> <td>Elder</td> </tr> <tr class="data"> <th class="coelder">Copper:</th> <td>Co-elder</td> </tr> <tr class="data"> <th class="protected">Light Green:</th> <td>In Protection</td> </tr> <?php } else { ?> <tr class="data"> <th class="admin">White:</th> <td>Orkfian God</td> </tr> <tr class="data"> <th class="head">Pink:</th> <td>Orkfian Lord</td> </tr> <tr class="data"> <th class="staff">Blue:</th> <td>ORKFiA Staff</td> </tr> <?php } ?> <tr class="data"> <th><img src="<?php echo HOST_PICS; ?> tribe_online.gif" alt="»" height="13" width="13" /></th> <td>Online</td> </tr> <?php if ($inactivitycheck[PLAYER_TYPE] == "elder" && $inactivitycheck['alli_id'] == $iAid && $inactiveCounter > 0) { ?> <tr class="data"> <th><img src="<?php echo HOST_PICS; ?> tribe_inactive.gif" alt="*" height="13" width="13" /></th> <td>Inactive</td> </tr> <?php } ?> </table> <?php }
function include_invade2_text() { global $ip; $objSrcUser =& $GLOBALS["objSrcUser"]; $arrSrcUser = $objSrcUser->get_user_infos(); $arrSrcStats = $objSrcUser->get_stats(); //========================================================================== // Secure user input from the invasion form //========================================================================== if (isset($_POST['TrgPlayer']) && !empty($_POST['TrgPlayer']) && $_POST['TrgPlayer'] != 'spacer') { // Selected Target $iTrgUserId = abs(intval($_POST['TrgPlayer'])); } else { echo $strDiv = '<div id="textMedium"><p>' . "Your army walk back to their homes, you should give them a " . "target next time!" . '</p><p>' . '<a href="main.php?cat=game&page=invade">' . "Try Again ?" . "</a>" . '</p></div>'; include_game_down(); exit; } $arrWhite = array('1', '2', '3', '4', '5'); $arrWhite2 = array(1 => 'standard', 'raid', 'barren', 'hitnrun', 'bc'); // Selected Target if (isset($_POST['invade_type']) && in_array($_POST['invade_type'], $arrWhite)) { $iAttack = intval($_POST['invade_type']); } else { echo $strDiv = '<div id="textMedium"><p>' . "Your army walk back to their homes, you should give them a " . "target next time!" . '</p><p>' . '<a href="main.php?cat=game&page=invade">' . "Try Again ?" . "</a>" . '</p></div>'; include_game_down(); exit; } // Army Sent $arrUnitVars = getUnitVariables($arrSrcStats[RACE]); $arrUnitOffence = $arrUnitVars['offence']; $arrUnitVar = $arrUnitVars['variables']; if (isset($_POST["arrArmySent"])) { $arrArmySent = $_POST["arrArmySent"]; foreach ($arrUnitOffence as $i => $iUnitOffence) { if ($iUnitOffence > 0) { $arrArmySent[$arrUnitVar[$i]] = max(0, intval($arrArmySent[$arrUnitVar[$i]])); } else { $arrArmySent[$arrUnitVar[$i]] = 0; } } } //========================================================================== // Verify attacker's status //========================================================================== obj_check_protection($objSrcUser, "invade"); $iTotalSentArmy = array_sum($arrArmySent); if ($iTotalSentArmy < 1) { echo $strDiv = '<div id="textMedium"><p>' . 'Sorry, but you did not send any units to battle.<br />' . 'This attack has been aborted.' . '</p><p>' . '<a href="main.php?cat=game&page=invade">' . "Try Again ?" . "</a>" . '</p></div>'; include_game_down(); exit; } if (verifyArmyAvailable($objSrcUser, $arrArmySent) == 1) { echo $strDiv = '<div id="textMedium"><p>' . 'Sorry, you do not have that many units to send.<br />' . 'This attack has been aborted.' . '</p><p>' . '<a href="main.php?cat=game&page=invade">' . "Try Again ?" . "</a>" . '</p></div>'; include_game_down(); exit; } if ($arrSrcStats[RACE] == "Oleg Hai" && verifyArmyAvailableOleg($objSrcUser, $arrArmySent) == 1) { $mercsTrainedThisHour = $objSrcUser->get_army_merc(MERC_T3); echo $strDiv = '<div id="textMedium"><p>' . "Sorry, but you did only train {$mercsTrainedThisHour} " . "mercs this update and that's the maximum you may use for an " . "attack.<br />" . "This attack has been aborted." . '</p><p>' . '<a href="main.php?cat=game&page=invade">' . "Try Again ?" . "</a>" . '</p></div>'; include_game_down(); exit; } if ($arrSrcUser[NEXT_ATTACK] > 0) { echo $strDiv = '<div id="textMedium"><p>' . 'Sorry, but you cannot attack for at least ' . $arrSrcUser[NEXT_ATTACK] . ' more updates.' . '</p><p>' . '<a href="main.php?cat=game&page=invade">' . 'Try Again ?' . '</a>' . '</p></div>'; include_game_down(); exit; } if ($arrSrcUser[HOURS] < PROTECTION_HOURS) { echo $strDiv = '<div id="textMedium"><p>' . 'You are not allowed to attack while in protection!' . '</p><p>' . '<a href="main.php?cat=game&page=invade">' . 'Try Again ?' . '</a>' . '</p></div>'; include_game_down(); exit; } //========================================================================== // Verify defender's status //========================================================================== include_once 'inc/functions/update.php'; check_to_update($iTrgUserId); $objTrgUser = new clsUser($iTrgUserId); $arrTrgStats = $objTrgUser->get_stats(); if ($arrTrgStats[ALLIANCE] == $objSrcUser->get_stat(ALLIANCE)) { echo $strDiv = '<div id="textMedium"><p>' . 'Sorry, honor before might. Do not attack into your own alliance.' . '</p><p>' . '<a href="main.php?cat=game&page=invade">' . 'Try Again ?' . '</a>' . '</p></div>'; include_game_down(); exit; } elseif ($objTrgUser->get_stat(ALLIANCE) < 11) { echo $strDiv = '<div id="textMedium"><p>' . 'I hope you did not think that you would get away with ' . 'attacking into a staff alliance, did you?' . '</p><p>' . '<a href="main.php?cat=game&page=invade">' . 'Try Again ?' . '</a>' . '</p></div>'; include_game_down(); exit; } // Frost: Added a global protection mode include_once 'inc/classes/clsGame.php'; $objGame = new clsGame(); if ($objGame->get_game_switch(GLOBAL_PROTECTION) == 'on') { echo $strDiv = '<div id="textMedium"><p>' . 'Because of a global event all tribes in ORKFiA are under ' . 'protection. Please check the community forum for an announcement.' . '</p><p>' . '<a href="main.php?cat=game&page=invade">' . 'Try Again ?' . '</a>' . '</p></div>'; include_game_down(); exit; } $iTrgHours = $objTrgUser->get_user_info(HOURS); if ($iTrgHours < PROTECTION_HOURS) { $iTrgHoursRemaining = PROTECTION_HOURS - $iTrgHours; echo $strDiv = '<div id="textMedium"><p>' . 'It appears that the tribe you wish to target is still ' . 'materializing. Our general estimates that it will ' . 'take another ' . $iTrgHoursRemaining . ' updates for the area ' . 'to become a stable part of reality.' . '</p><p>' . '<a href="main.php?cat=game&page=invade">' . 'Try Again ?' . '</a>' . '</p></div>'; include_game_down(); exit; } if ($objTrgUser->get_stat(ALLIANCE) == 0) { echo $strDiv = '<div id="textMedium"><p>' . 'This player has either been deleted or suspended.' . '</p><p>' . '<a href="main.php?cat=game&page=invade">' . 'Try Again ?' . '</a>' . '</p></div>'; include_game_down(); exit; } // Frost: added jan -04 // Martel: updated July 08, 2006 if ($objTrgUser->get_stat(KILLED) == 1 || $objTrgUser->get_stat(RESET_OPTION) == 'yes') { echo $strDiv = '<div id="textMedium"><p>' . 'This tribe is dead.' . '</p><p>' . '<a href="main.php?cat=game&page=invade">' . 'Try Again ?' . '</a>' . '</p></div>'; include_game_down(); exit; } // Paused account Martel, July 13, 2006 if ($objTrgUser->isPaused()) { echo $strDiv = '<div id="textMedium"><p>' . 'This tribe is paused.' . '</p><p>' . '<a href="main.php?cat=game&page=invade">' . 'Return' . '</a>' . '</p></div>'; return; } // Blocking system - AI 11/02/2007 if (!clsBlock::isOpAllowed($objSrcUser, $objTrgUser)) { echo '<div id="textMedium"><p>' . 'Someone else from the same IP has already opped this tribe during the last 8 hours.' . '</p><p>' . '<a href="main.php?cat=game&page=invade">Return</a>' . '</p></div>'; clsBlock::reportOp($objSrcUser, $objTrgUser, 'Attack: ' . $arrWhite2[$iAttack], false); return; } $iTrgLand = $objTrgUser->get_build(LAND); $iSrcLand = $objSrcUser->get_build(LAND); $breakoff = round($iSrcLand * 0.7); // Barren attack has 70% bottom feed limit if smaller than 2000 acres if ($iAttack == ATTACK_BARREN && $iTrgLand <= $breakoff && $iTrgLand < 2000) { echo $strDiv = '<div id="textMedium"><p>' . 'Sorry but you can not bash the small ones. Barren grabs are not ' . 'allowed against smaller tribes unless they are within 70% ' . 'of your own size.' . '</p><p>' . '<a href="main.php?cat=game&page=invade">' . 'Try Again ?' . '</a>' . '</p></div>'; include_game_down(); exit; } if ($iAttack == ATTACK_HNR && $iTrgLand < $iSrcLand) { echo $strDiv = '<div id="textMedium"><p>' . 'What kind of coward are you who try to make a Hit \'n\' Run ' . 'attack against a smaller tribe?' . '</p><p>' . 'Shame on you!' . '</p><p>' . '<a href="main.php?cat=game&page=invade">' . 'Return' . '</a>' . '</p></div>'; include_game_down(); exit; } $quick_check = mysql_query("Select * from user where id = 1"); $quick_check = mysql_fetch_array($quick_check); if ($quick_check[STOPGAMETRIGGER] == 99) { echo $strDiv = '<div id="textMedium"><p>' . 'The game has been paused by staff, possibly due to technical ' . 'maintenance. Please look in the announcements ' . 'forum or the admin game message for more information.' . '</p><p>' . '<a href="main.php?cat=game&page=invade">' . 'Return' . '</a>' . '</p></div>'; include_game_down(); exit; } else { //====================================================================== // Do Battle //====================================================================== /* include the code for the attack about to be done */ include_once "inc/attacks/" . $arrWhite2[$iAttack] . ".php"; // Damadm00 19-03-2004, check here the result from the viking check // Martel: Notify thieves about attack only if not viking+25% luck if ($arrSrcStats[RACE] == 'Viking' && getVikingCheck() == 1) { $viking = 1; } else { $viking = 0; getMonitoringCheck($objSrcUser); } include_once 'inc/functions/military.php'; $defence = getArmyDefence($objTrgUser, $iAttack); $defence = $defence['total_home']; $offence = getSentOffence($objSrcUser, $arrArmySent); //Attacking Templars kills mystics, not thieves - AI $thieves = 'thieves'; if ($objTrgUser->get_stat(RACE) == 'Templar') { $thieves = 'mystics'; } // Eagle 30% auto force retreat feature if ($objTrgUser->get_stat(RACE) == "Eagle" && getEagleCheck() == 1) { doRetreat($objSrcUser, $objTrgUser, $arrArmySent, 1, 0); return; } elseif ($offence < $defence && $iAttack != ATTACK_HNR) { doRetreat($objSrcUser, $objTrgUser, $arrArmySent, 0, $viking); return; } elseif ($offence < $defence && $iAttack == ATTACK_HNR) { if ($offence > 0.5 * $defence) { if ($defence == 0) { $defence = 1; } $arrSrcArmyLost = getSrcLosses($objSrcUser, $arrArmySent, $offence / $defence, $arrWhite2[$iAttack]); $arrTrgArmyLost = getTrgLosses($objTrgUser, $objSrcUser, $offence / $defence, $arrWhite2[$iAttack]); $arrReport = doAttack($objSrcUser, $objTrgUser, $arrArmySent); } else { doRetreat($objSrcUser, $objTrgUser, $arrArmySent, 0, $viking); return; } } else { if ($defence == 0) { $defence = 1; } $arrSrcArmyLost = getSrcLosses($objSrcUser, $arrArmySent, $offence / $defence, $arrWhite2[$iAttack]); $arrTrgArmyLost = getTrgLosses($objTrgUser, $objSrcUser, $offence / $defence, $arrWhite2[$iAttack]); $arrReport = doAttack($objSrcUser, $objTrgUser, $arrArmySent); } // Spread Pestilence $arrSpreadPest = checkPestilence($objSrcUser, $objTrgUser); $pestSrc = $arrSpreadPest['attacker']; $pestTrg = $arrSpreadPest['defender']; //====================================================================== // Begin creating the invade report //====================================================================== $strTribe = stripslashes($objTrgUser->get_rankings_personal(TRIBE_NAME)); $iAlliance = $arrTrgStats[ALLIANCE]; $strReport = '<div id="textMedium">' . '<h2>' . "Invade Report" . '</h2>' . '<p>' . 'Your invasion of <strong>' . $strTribe . ' (#' . $iAlliance . ')</strong> was successful, ' . 'below follows a report from your general.' . '</p>'; //====================================================================== // Report: Gains //====================================================================== // Acres if (isset($arrReport['gained_acres']) && $arrReport['gained_acres'] != 0) { $strReport .= '<p>' . "Our army has gained control over " . "<strong>" . $arrReport['gained_acres'] . " acres</strong>. "; // Explored Acres if (isset($arrReport['explored_acres']) && $arrReport['explored_acres'] != 0) { $strReport .= "Also <strong>" . $arrReport['explored_acres'] . " acres</strong> was " . "explored and can be used to build on now."; } $strReport .= '</p>'; } // Citizens Killed (raid or hnr) if (isset($arrReport['killed_citizens']) && $arrReport['killed_citizens'] != 0) { $strReport .= '<p>' . "Our army storm into their lands, killing <strong>" . $arrReport['killed_citizens'] . "</strong> of their citizens." . '</p>'; } // Money (raid) if (isset($arrReport['gained_crowns']) && $arrReport['gained_crowns'] != 0) { $strReport .= '<p>' . "The army report having stolen <strong class=\"indicator\">" . number_format($arrReport['gained_crowns']) . " crowns</strong>." . '</p>'; } // Buildings Razed (blasphemy crusade) if (isset($arrReport['damaged_total']) && $arrReport['damaged_total'] != 0) { $strReport .= '<p>' . "Your loyal army charges into their lands, destroying <strong>" . $arrReport['damaged_total'] . " buildings</strong> of witchcraft " . "and deception. ("; // Academies if (isset($arrReport['damaged_academies']) && $arrReport['damaged_academies'] != 0) { $strReport .= " <strong>" . $arrReport['damaged_academies'] . " academies</strong>"; } // Guilds if (isset($arrReport['damaged_guilds']) && $arrReport['damaged_guilds'] != 0) { $strReport .= " <strong>" . $arrReport['damaged_guilds'] . " guilds</strong>"; } // Hideouts if (isset($arrReport['damaged_hideouts']) && $arrReport['damaged_hideouts'] != 0) { $strReport .= " <strong>" . $arrReport['damaged_hideouts'] . " hideouts</strong>"; } $strReport .= ').</p>'; } // Thieves Killed (blasphemy crusade) if (isset($arrReport['killed_thieves']) && $arrReport['killed_thieves'] != 0) { $strReport .= '<p>' . "Your general reports having killed <strong>" . $arrReport['killed_thieves'] . " {$thieves} of the enemy</strong>." . '</p>'; } // Fame Gained if (isset($arrReport['gained_fame']) && $arrReport['gained_fame'] != 0) { $strReport .= '<p>' . "This invasion gave our tribe <strong class=\"positive\">" . $arrReport['gained_fame'] . " fame</strong>." . '</p>'; } //====================================================================== // Begin enemy defence estimation (report) //====================================================================== if ($offence > $defence * 2) { $strReport .= '<p>' . "Our army is more than double the power of the " . "defending army, causing the enemy to run in fear. (Victory " . "by more than 100%)" . '</p>'; } elseif ($offence > $defence * 1.8) { $strReport .= '<p>' . "Our army is almost double the power of the defending " . "army. (Victory by more than 80%)" . '</p>'; } elseif ($offence > $defence * 1.6) { $strReport .= '<p>' . "Our army has easily broken the enemies defences, " . "overpowering them by more than 3 to 2. (Victory by more " . "than 60%)" . '</p>'; } elseif ($offence > $defence * 1.4) { $strReport .= '<p>' . "Our army has broken the enemies defences, overpowering " . "them by around 3 to 2. (Victory by more than 40%)" . '</p>'; } elseif ($offence > $defence * 1.2) { $strReport .= '<p>' . "Our army has broken through the line of defence, but it was " . "a hard battle. (Victory by more than 20%)" . '</p>'; } elseif ($offence > $defence * 1.1) { $strReport .= '<p>' . "Our army has broken through the line of defence, but it was " . "a very tough battle. (Victory by more than 10%)" . '</p>'; } elseif ($offence >= $defence) { $strReport .= '<p>' . "Our army fought hard, winning only after a lengthy and very " . "difficult battle. (Victory by less than 10%)" . '</p>'; } //====================================================================== // Report: Army Losses //====================================================================== $arrUnitVars = getUnitVariables($objSrcUser->get_stat(RACE)); $arrUnitNames = $arrUnitVars['output']; $strPlural = 's'; $strReport .= '<p>' . "The captains report that we have lost "; if ($arrSrcArmyLost[UNIT1] > 0) { $strReport .= $arrSrcArmyLost[UNIT1] . " " . $arrUnitNames[2] . $strPlural . ", "; } if ($arrSrcArmyLost[UNIT2] > 0) { if ($arrUnitNames[3] == 'Swordmen') { $strPlural = ''; } elseif ($arrUnitNames[3] == 'Pikemen') { $strPlural = ''; } $strReport .= $arrSrcArmyLost[UNIT2] . " " . $arrUnitNames[3] . $strPlural . ", "; } if ($arrSrcArmyLost[UNIT3] > 0) { if ($arrUnitNames[4] == 'Crossbowmen') { $strPlural = ''; } elseif ($arrUnitNames[4] == 'Longbowmen') { $strPlural = ''; } elseif ($arrUnitNames[4] == 'Mummy') { $arrUnitNames[4] = 'Mummie'; } $strReport .= $arrSrcArmyLost[UNIT3] . " " . $arrUnitNames[4] . $strPlural . ", "; } if ($arrSrcArmyLost[UNIT4] > 0) { if ($arrUnitNames[5] == 'Priestess') { $strPlural = ''; } $strReport .= $arrSrcArmyLost[UNIT4] . " " . $arrUnitNames[5] . $strPlural . ", "; } if ($arrSrcArmyLost[UNIT5] > 0) { if ($arrUnitNames[6] == 'Thief') { $arrUnitNames[6] = 'Thieve'; } $strReport .= $arrSrcArmyLost[UNIT5] . " " . $arrUnitNames[6] . $strPlural . ", "; } if (array_sum($arrSrcArmyLost) < 1) { $strReport .= " no military at all, "; } $totalkilled = round(array_sum($arrTrgArmyLost), -2); if ($totalkilled > 0) { $strReport .= " and they estimate the enemy's losses to be {$totalkilled} units"; if ($objSrcUser->get_stat(RACE) == "Undead") { $strReport .= ", who joined our cursed army as soldiers."; } } else { $strReport .= " and they estimate the enemy's losses to be near zero"; } $strReport .= '.</p>'; //====================================================================== // Report: Army available again //====================================================================== $wait = $objSrcUser->get_user_info(NEXT_ATTACK); $strReport .= '<p>' . "Our generals report our army will be able to attack again " . "in " . $wait . " updates. "; if ($wait > 4) { // Assuming that an attack with more than 4 hours is a BC or Hitnrun $wait -= 2; $strReport .= "However, our army will be home to defend our lands after " . $wait . " updates."; } $strReport .= '</p>'; //====================================================================== // Report: Pestilence //====================================================================== if ($pestSrc == "yes") { $strReport .= '<p>' . "<strong class=\"negative\">During your invasion your military " . "got infected with pestilence.</strong>" . '</p>'; } //====================================================================== // frost: added suicide detection | modified for age 18. only one update // loss of 25% citizens //====================================================================== $suicide = getSuicideCheck($objSrcUser, $arrArmySent); if ($arrSrcStats[RACE] != "Raven" && $suicide == 1) { $citz = $objSrcUser->get_pop(CITIZENS); $leavingCitz = floor($citz * 0.25); $strReport .= '<p>' . "<strong class=\"negative\">Your citizens are getting tired of " . "their tax money going to far-away military campaigns " . "instead of defending their homes. " . number_format($leavingCitz) . " citizens have left your lands.</strong>" . '</p>'; $objSrcUser->set_pop(CITIZENS, $citz - $leavingCitz); } //====================================================================== // Report: Viking Stealth Attack //====================================================================== if ($viking == 1) { $strReport .= '<p>' . "<strong class=\"positive\">You got lucky. Your location " . "doesn't end up in the news.</strong>" . '</p>'; } //====================================================================== // Report: War effects //====================================================================== require_once 'inc/functions/war.php'; $objSrcAlliance = $objSrcUser->get_alliance(); if (checkWarBetween($objSrcAlliance, $objTrgUser->get_stat(ALLIANCE))) { $objTrgAlliance = $objTrgUser->get_alliance(); if ($arrGains = testWarVictory($objSrcAlliance, $objTrgAlliance)) { // Append war-win message require_once 'inc/pages/war_room2.inc.php'; $strReport .= '<p><strong class="positive">Your alliance has won the war!</strong></p>' . getVictoryReport($arrGains); } } $strReport .= '<p>' . '<a href="main.php?cat=game&page=tribe">Continue</a>' . '</p>' . '</div>'; echo $strReport; //====================================================================== // Defender tribe news (damage report) //====================================================================== $srcDisplay = $arrSrcStats[TRIBE] . " (#" . $arrSrcStats[ALLIANCE] . ")"; $trgDisplay = $arrTrgStats[TRIBE] . " (#" . $arrTrgStats[ALLIANCE] . ")"; $strStrategy = $arrWhite2[$iAttack]; switch ($strStrategy) { case "standard": if ($viking == 0) { $strTrgTribe = "<span class=\"positive\">{$srcDisplay} has successfully marched into our lands and conquered " . $arrReport['gained_acres'] . " acres</span>"; $strTrgAlliance = "<span class=\"newsattack\">{$srcDisplay} has successfully marched into the lands of {$trgDisplay} and conquered " . $arrReport['gained_acres'] . " acres</span>"; } else { $strTrgTribe = "<span class=\"positive\">An unidentified tribe of vikings has successfully marched into our lands and conquered " . $arrReport['gained_acres'] . " acres</span>"; $strTrgAlliance = "<span class=\"newsattack\">An unidentified tribe of vikings has successfully marched into the lands of {$trgDisplay} and conquered " . $arrReport['gained_acres'] . " acres</span>"; } break; case "raid": if ($viking == 0) { $strTrgTribe = "<span class=\"positive\">{$srcDisplay} has successfully stormed into our lands and conquered " . $arrReport['gained_acres'] . " acres, stolen " . $arrReport['gained_crowns'] . " crowns and slaughtered " . $arrReport['killed_citizens'] . " citizens</span>"; $strTrgAlliance = "<span class=\"newsattack\">{$srcDisplay} has successfully stormed into the lands of {$trgDisplay} and conquered " . $arrReport['gained_acres'] . " acres, stolen " . $arrReport['gained_crowns'] . " crowns and slaughtered " . $arrReport['killed_citizens'] . " citizens</span>"; } else { $strTrgTribe = "<span class=\"positive\">An unidentified tribe of vikings has successfully stormed into our lands and conquered " . $arrReport['gained_acres'] . " acres, stolen " . $arrReport['gained_crowns'] . " crowns and slaughtered " . $arrReport['killed_citizens'] . " citizens</span>"; $strTrgAlliance = "<span class=\"newsattack\">An unidentified tribe of vikings has Successfully stormed into the lands of {$trgDisplay} and conquered " . $arrReport['gained_acres'] . " acres, stolen " . $arrReport['gained_crowns'] . " crowns and slaughtered " . $arrReport['killed_citizens'] . " citizens</span>"; } break; case "barren": if ($viking == 0) { $strTrgTribe = "<span class=\"newsattack\">{$srcDisplay} has successfully sneaked into our lands and claimed " . $arrReport['gained_acres'] . " acres</span>"; $strTrgAlliance = "<span class=\"newsattack\">{$srcDisplay} has successfully sneaked into the lands of {$trgDisplay} and claimed " . $arrReport['gained_acres'] . " acres</span>"; } else { $strTrgTribe = "<span class=\"newsattack\">An unidentified tribe of vikings has successfully sneaked into our lands and claimed " . $arrReport['gained_acres'] . " acres</span>"; $strTrgAlliance = "<span class=\"newsattack\">An unidentified tribe of vikings has successfully sneaked into the lands of {$trgDisplay} and claimed " . $arrReport['gained_acres'] . " acres</span>"; } break; case "bc": if ($viking == 0) { $strTrgTribe = "<span class=\"newsbc\">{$srcDisplay} has successfully charged into our lands and destroyed " . $arrReport['damaged_total'] . " buildings and killed " . $arrReport['killed_thieves'] . " {$thieves}. Our lands will be avaliable for building again after they have been cleared</span>"; $strTrgAlliance = "<span class=\"newsbc\">{$srcDisplay} has successfully charged into the lands of {$trgDisplay} and destroyed " . $arrReport['damaged_total'] . " buildings and slaughtered " . $arrReport['killed_thieves'] . " {$thieves}</span>"; } else { $strTrgTribe = "<span class=\"newsbc\">An unidentified tribe of vikings has successfully charged into our lands and destroyed " . $arrReport['damaged_total'] . " buildings and killed " . $arrReport['killed_thieves'] . " {$thieves}. Our lands will be avaliable for building again after they have been cleared</span>"; $strTrgAlliance = "<span class=\"newsbc\">An unidentified tribe of vikings has successfully charged into the lands of {$trgDisplay} and destroyed " . $arrReport['damaged_total'] . " buildings and killed " . $arrReport['killed_thieves'] . " {$thieves}</span>"; } break; case "hitnrun": $strAdd = ""; if ($offence >= $defence) { $strAdd = " and " . $arrReport['killed_citizens'] . " citizens"; } if ($viking == 0) { $strTrgTribe = "<span class=\"newsattack\">{$srcDisplay} has cowardly ambushed our lands, killing many troops" . $strAdd . "</span>"; $strTrgAlliance = "<span class=\"newsattack\">{$srcDisplay} has cowardly attacked and rained arrows over {$trgDisplay}, killing many troops" . $strAdd . "</span>"; } else { $strTrgTribe = "<span class=\"newsattack\">An unidentified tribe of vikings has cowardly ambushed our lands, killing many troops" . $strAdd . "</span></span>"; $strTrgAlliance = "<span class=\"newsattack\">An unidentified tribe of vikings has cowardly attacked and rained arrows over {$trgDisplay}, killing many troops" . $strAdd . "</span>"; } break; } $trgId = $objTrgUser->get_userid(); $srcId = $objSrcUser->get_userid(); $trgKd = $objTrgUser->get_stat(ALLIANCE); $srcKd = $objSrcUser->get_stat(ALLIANCE); if ($viking == 0) { $result = "INSERT INTO `news` VALUES ('', NOW(), '{$ip}', '{$strStrategy}', '{$trgId}', '{$srcId}', '1', " . quote_smart($strTrgTribe) . ", " . quote_smart($strTrgAlliance) . ",'{$trgKd}','{$srcKd}',1)"; } else { $result = "INSERT INTO `news` VALUES ('', NOW(), '{$ip}', '{$strStrategy}', '{$trgId}', '{$srcId}', '1', " . quote_smart($strTrgTribe) . ", " . quote_smart($strTrgAlliance) . ",'{$trgKd}',0,1)"; } mysql_query($result); $arrUnitVars = getUnitVariables($objTrgUser->get_stat(RACE)); $arrUnitNames = $arrUnitVars['output']; $strPlural = 's'; $strPlural2 = 's'; $strPlural3 = 's'; $strPlural4 = 's'; $strPlural5 = 's'; if ($arrUnitNames[3] == 'Swordmen') { $strPlural2 = ''; } elseif ($arrUnitNames[3] == 'Pikemen') { $strPlural2 = ''; } if ($arrUnitNames[4] == 'Crossbowmen') { $strPlural3 = ''; } elseif ($arrUnitNames[4] == 'Longbowmen') { $strPlural3 = ''; } elseif ($arrUnitNames[4] == 'Mummy') { $arrUnitNames[4] = 'Mummie'; } if ($arrUnitNames[5] == 'Priestess') { $strPlural4 = 'es'; } if ($arrUnitNames[6] == 'Thief') { $arrUnitNames[6] = 'Thieve'; } $strTrgNews = "A report has been collected, our losses are listed as follows: " . "<br />" . $arrUnitNames[2] . $strPlural . " killed: " . "<span class=\"negative\">" . $arrTrgArmyLost[UNIT1] . "</span>," . "<br />" . $arrUnitNames[3] . $strPlural2 . " killed: " . "<span class=\"negative\">" . $arrTrgArmyLost[UNIT2] . "</span>," . "<br />" . $arrUnitNames[4] . $strPlural3 . " killed: " . "<span class=\"negative\">" . $arrTrgArmyLost[UNIT3] . "</span>," . "<br />" . $arrUnitNames[5] . $strPlural4 . " killed: " . "<span class=\"negative\">" . $arrTrgArmyLost[UNIT4] . "</span>."; //Add mystic losses for templars - AI 24/04/2007 if ($arrTrgArmyLost[UNIT5] > 0) { $strTrgNews .= "<br />" . $arrUnitNames[6] . $strPlural5 . " killed: " . "<span class=\"negative\">" . $arrTrgArmyLost[UNIT5] . "</span>."; } if ($pestTrg == "yes") { $strTrgNews .= "<br />" . "<strong class=\"negative\">" . "During this invasion pestilence " . "was spread into our lands for 12 updates" . "</strong>."; } // create tribe news for attack mysql_query("INSERT INTO `news` (`id`, `time`, `ip`, `type`, `duser`, `ouser`, `result`, `text`, `kingdom_text`) VALUES ('', NOW(), '{$ip}', 'invade report', '{$arrTrgStats['id']}', '{$arrSrcStats['id']}', 1, '{$strTrgNews}', '')"); $orkTime = date(TIMESTAMP_FORMAT); $objTrgUser->set_user_info(LAST_NEWS, $orkTime); // Update target rankings include_once 'inc/functions/update_ranking.php'; doUpdateRankings($objTrgUser, 'yes'); // Log the op for blocking system - AI 11/02/2007 clsBlock::logOp($objSrcUser, $objTrgUser, 'Attack: ' . $arrWhite2[$iAttack]); } }
function include_vote_text() { $objSrcUser =& $GLOBALS["objSrcUser"]; $iSrcVote = $objSrcUser->get_stat(VOTE); $objSrcAlli = $objSrcUser->get_alliance(); $arrUserIds = $objSrcAlli->get_userids(); // M: Show advisor text $strAdvisorText = '<div id="textMedium" style="margin-top: 0;">' . '<p>' . "Please vote for whom you think should be the elder and control your alliance." . '</p>' . '</div><br />'; echo $strAdvisorText; // M: Populate arrVotes - this array contains information about all voters $objTmpUser = new clsUser(1); foreach ($arrUserIds as $iUserId) { $objTmpUser->set_userid($iUserId); $arrVotes[$iUserId]["tribename"] = $objTmpUser->get_stat(TRIBE); $arrVotes[$iUserId]["playertype"] = $objTmpUser->get_stat(TYPE); $arrVotes[$iUserId]["votes"] = 0; $arrVotes[$iUserId]["votefor"] = ''; } // M: Count their votes (also verify that they voted for an alliance member) $iValidVotes = 0; foreach ($arrUserIds as $iUserId) { $objTmpUser->set_userid($iUserId); $iTmpVote = $objTmpUser->get_stat(VOTE); if ($iTmpVote > 0 && in_array($iTmpVote, $arrUserIds)) { $iValidVotes++; $arrVotes[$iTmpVote]["votes"]++; $arrVotes[$iUserId]["votefor"] = stripslashes($arrVotes[$iTmpVote]["tribename"]); } } // M: Create table rows for each tribe $strTableRows = ''; foreach ($arrUserIds as $iUserId) { $objTmpUser->set_userid($iUserId); $arrTmpStats = $objTmpUser->get_stats(); $strTmpTribe = stripslashes($arrTmpStats[TRIBE]); // M: Fetch information about this tribe's votes $strVoted = stripslashes($arrVotes[$iUserId]["votefor"]); $strType = $arrVotes[$iUserId]["playertype"]; $iVotes = $arrVotes[$iUserId]["votes"]; if ($iSrcVote == $iUserId) { $strChecked = " checked"; } else { $strChecked = ""; } // M: Column for elder to elect co-elder $strCoelderTD = ''; if ($objSrcUser->get_stat(TYPE) == 'elder') { if ($strType == "coelder") { $strChecked2 = " checked"; } else { $strChecked2 = ""; } $strCoelderTD = '<td>' . '<input type="checkbox" name="voteforcoelder[]" value="' . $iUserId . '"' . $strChecked2 . " />" . "</td>"; } $strTableRows .= '<tr class="data">' . '<th>' . '<label>' . '<input type="radio" name="votefor" value="' . $iUserId . '"' . $strChecked . ' /> <span class="' . $strType . '">' . $strTmpTribe . '</span></label>' . '</th>' . '<td class="left">' . floor($iVotes / max(1, $iValidVotes) * 100) . '%' . '</td>' . '<td class="left">' . $strVoted . '</td>' . $strCoelderTD . "</tr>"; } // M: Vote for donkey (default) if ($iSrcVote == '' || $iSrcVote == 0) { $strChecked = " checked"; } else { $strChecked = ''; } // M: Extra column for elder to elect co-elders if ($objSrcUser->get_stat(TYPE) == 'elder') { $iColumns = '4'; $strThCoelder = "<th class=\"center\">" . "Co-elder" . "</td>"; } else { $iColumns = '3'; $strThCoelder = ''; } // M: "Elect your elder"-table $strElderTable = "<form method=\"post\" action=\"main.php?cat=game&page=vote2\" id=\"center\">" . "<table cellspacing=\"0\" cellpadding=\"0\" class=\"medium\">" . "<tr class=\"header\">" . "<th colspan=\"" . $iColumns . "\">" . "Elect Your Elder" . "</th>" . "</tr>" . "<tr class=\"subheader\">" . "<th>" . "Tribe" . "</th>" . "<th>" . "Votes" . "</th>" . "<th>" . "Voted For" . "</th>" . $strThCoelder . "</tr>" . $strTableRows . "<tr class=\"data\">" . '<th class="bsup" colspan="' . $iColumns . '">' . "<input type=\"radio\" name=\"votefor\" value=\"0\" id=\"0\"" . $strChecked . " /> " . "<label for=\"0\">" . "No Vote" . "</label>" . "</th>" . "</tr>" . "</table><br />" . "<input type=\"submit\" value=\"Vote\" />" . "</form>"; echo $strElderTable; }
function get_sponsor_list($strItemId = 'Blue Dragon') { $strReturn = ''; $objTmpUser = new clsUser(1); $resSQL = mysql_query("SELECT item_number as rank, quantity, option_selection1 as username, unix_timestamp, payment_gross as money FROM phpsuppo_3.paypal WHERE (item_name = 'One Week Sponsorship' OR item_name = 'Three Months Sponsorship') AND item_number = '{$strItemId}' AND payment_status = 'Completed' ORDER BY unix_timestamp DESC") or die(mysql_error()); while ($arrPayPal = mysql_fetch_array($resSQL)) { if (check_valid_sponsor($arrPayPal) && $arrPayPal['username'] != 'NULL') { $strSafe = quote_smart($arrPayPal['username']); $resSQL2 = mysql_query("SELECT id FROM " . TBL_USER . " WHERE username = {$strSafe}") or die(mysql_error()); $arrRes2 = mysql_fetch_array($resSQL2); if ($arrRes2[ID] > 0) { $objTmpUser->set_userid($arrRes2[ID]); $strReturn .= stripslashes($objTmpUser->get_stat(NAME)) . '<br />'; } else { // Missing an acc in one server, or if deleted (missing user) // $strReturn .= 'Fierce ' . $arrPayPal['rank'] . '<br />'; } } elseif (check_valid_sponsor($arrPayPal)) { $strReturn .= 'Anonymous ' . $arrPayPal['rank'] . '<br />'; } } return $strReturn; }
function doWarSurrender(&$objSuxAlli, &$objWinAlli) { global $orkTime; $winner = $objWinAlli->get_allianceid(); $looser = $objSuxAlli->get_allianceid(); // Clear events $iEventid1 = $objWinAlli->get_war('event_id'); $iEventid2 = $objSuxAlli->get_war('event_id'); clearEvents($iEventid1, $iEventid2); // Get game hours require_once 'inc/classes/clsGame.php'; $objGame = new clsGame(); $arrGameTime = $objGame->get_game_times(); // M: Update winner alli $arrWinWar = $objWinAlli->get_wars(); $arrNewWinWar = array('target' => 0, 'last_target' => $looser, 'last_outgoing' => 'victory', 'last_end' => $arrGameTime['hour_counter'], 'victory' => $arrWinWar['victory'] + 1, 'event_id' => ''); $objWinAlli->set_wars($arrNewWinWar); // M: Update looser alli $arrSuxWar = $objSuxAlli->get_wars(); $arrNewSuxWar = array('target' => 0, 'last_target' => $winner, 'last_outgoing' => 'surrender', 'last_end' => $arrGameTime['hour_counter'], 'surrender' => $arrSuxWar['surrender'] + 1, 'event_id' => ''); $objSuxAlli->set_wars($arrNewSuxWar); // M: Update winner alli fame $objTmpUser = new clsUser(0); $arrUserId = $objWinAlli->get_userids(); foreach ($arrUserId as $iUserid) { $objTmpUser->set_userid($iUserid); $iNewFame = $objTmpUser->get_stat('fame') + WAR_SURRENDER_FAME; $objTmpUser->set_stat('fame', $iNewFame); } // M: Update looser alli fame $arrUserId = $objSuxAlli->get_userids(); foreach ($arrUserId as $iUserid) { $objTmpUser->set_userid($iUserid); $iNewFame = max(0, $objTmpUser->get_stat('fame') - WAR_SURRENDER_FAME); $objTmpUser->set_stat('fame', $iNewFame); } // M: Transfer research $arrResearch = moveResearch($objSuxAlli, $objWinAlli, WAR_SURRENDER_LOSSES); // M: Transfer market goods (Atm this is the same % as regular victory) $arrMarket = moveMarketGoods($objSuxAlli, $objWinAlli, WAR_VICTORY_GOODS); // News for winner, looser and global mysql_query("INSERT INTO news (id, time, ip, type, duser, ouser, result, text, kingdom_text, kingdoma, kingdomb) VALUES ('', '{$orkTime}', '---', 'war-end', '0', '0', '1', '', '<strong class=\"positive\">We were victorious in the war with alliance #{$looser}!</strong>', '{$winner}', '')"); mysql_query("INSERT INTO news (id, time, ip, type, duser, ouser, result, text, kingdom_text, kingdoma, kingdomb) VALUES ('', '{$orkTime}', '---', 'war-end', '0', '0', '1', '', '<strong class=\"negative\">We have surrendered in the war with #{$winner}!</strong>', '{$looser}', '')"); mysql_query("INSERT INTO news (id, time, ip, type, duser, ouser, result, text, kingdom_text, kingdoma, kingdomb) VALUES ('', '{$orkTime}', '---', 'global', '0', '0', '1', '', '<strong class=\"positive\">Alliance #{$looser} have surrendered! #{$winner} wins!</strong>', '0', '')"); return array($arrResearch, $arrMarket); }