function call_userpw_text() { global $id, $confirm, $level, $tool; include_once('inc/functions/resort_tools.php'); if (! user_has_access($tool)) { echo "Sorry, this page is restricted to ORKFiA Staff"; include_game_down(); exit; } echo "<form method=\"post\" action=\"".$_SERVER['REQUEST_URI']."\">"; ECHO "Input user id: <input name=id size=5><br>"; ECHO "<br><br>This function will randomize a new password and send it by mail."; ECHO "<br><br>"; ECHO "<input type=submit value=Save name=confirm>"; ECHO "</form>"; IF($confirm && $id) { $objUser = new clsUser ($id); $email = $objUser->get_preference(EMAIL); $password = generatePassword(); $cpassword = $password; mysql_query("UPDATE user SET password = sha1('$cpassword') WHERE id = $id"); $username = $objUser->get_user_info(USERNAME); mail("$email","ORKFiA New Password","Hello, \nYour password has been updated with a new one =) \n\nUsername: $username \nPassword: $password \n\n- The ORKFiA Team\n\n\nThis email is php generated, you cannot successfully reply." , "From: registration@orkfia.org\r\nX-Mailer: PHP/4.3.0\r\nX-Priority: Normal"); echo "User " . $id . " will have a new pw sent within minutes to: " . $email; } }
public function getUsername() { $objUser = new clsUser($this->get('user_id')); if ($objUser->isNew()) { return $this->get('username'); } return $objUser->get('username'); }
function move_tribe($id, $target){ $objSrcUser = new clsUser($id); $local_stats = $objSrcUser->get_stats(); if ($target == 1 && $local_stats[LEVEL] < 5) $target = 2; mysql_query("UPDATE stats SET kingdom = $target, type ='player', invested = 0, vote = 0 where id = $id"); mysql_query("UPDATE rankings_personal SET alli_id = $target where id = $id"); mysql_query("UPDATE goods SET credits = 0, market_money = 0, market_food = 0, market_soldiers = 0, market_wood = 0 WHERE id = $id"); }
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 include_thievery2_text() { global $op, $dplayer, $action, $amount, $amount_sent, $stop; include_once 'inc/functions/ops.php'; include_once 'inc/functions/thievery.php'; $objSrcUser =& $GLOBALS["objSrcUser"]; if ($objSrcUser->get_stat(RACE) == 'Templar') { echo '<div id="textMedium"><p>' . 'Your proud Templar people will not lower themselves to thievery practices.' . '</p></div>'; include_game_down(); exit; } if (!$dplayer) { $objTrgUser = $objSrcUser; } else { $objTrgUser = new clsUser($dplayer); } $arrTrgStats = $objTrgUser->get_stats(); if ($arrTrgStats[KILLED] == 0 && $arrTrgStats[RESET_OPTION] != 'yes' && !$objTrgUser->isPaused()) { set_op_vars(); // Verify attacker's status obj_check_protection($objSrcUser, 'thievery'); $op_level = get_op_level($objSrcUser); if ($op > $op_level) { echo "Please Do Not Edit Forms"; // make something to notifiy the admin if this happens include_game_down(); exit; } make_thievery($objSrcUser, $objTrgUser, $action[$op], $amount_sent, $amount, $stop); //====================================================================== // 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'; echo $strReport = '<div id="textMedium">' . '<p><strong class="positive">Your alliance has won the war!</strong></p>' . getVictoryReport($arrGains) . '</div>'; } } } else { echo $strDiv = '<div id="textMedium"><p>' . 'This tribe is either dead or paused.' . '<br /><br />' . '<a href="main.php?cat=game&page=thievery">' . 'Return' . '</a>' . '</p></div>'; } }
function call_unsuspend_text() { $tool = $_GET['tool']; include_once 'inc/functions/resort_tools.php'; check_access($tool); echo "<form method='post' action='{$_SERVER['REQUEST_URI']}'>" . "User id to unsuspend: <input name='id' size='5' /><br /><br />" . "<input type='submit' value='Unsuspend' name='op' />" . "</form>"; if (isset($_POST['op']) && !empty($_POST['id'])) { $id = $_POST['id']; $objTrgUser = new clsUser($id); $arrTrgUser = array(PAUSE_ACCOUNT => 0); $objTrgUser->set_user_infos($arrTrgUser); // Forced Ranking Update include_once 'inc/functions/update_ranking.php'; doUpdateRankings($objTrgUser, 'yes'); echo "<br /><br />User " . $objTrgUser->get_userid() . " unsuspended =)"; } }
function call_suspension_text() { global $tool; include_once 'inc/functions/resort_tools.php'; if (!user_has_access($tool)) { echo "Sorry, this page is restricted to ORKFiA Staff"; include_game_down(); exit; } echo $strHeader = '<h2>L&O: Player Suspension (aka Forced Vacation Mode)</h2>'; echo $strForm = '<form method="post" action="' . $_SERVER['REQUEST_URI'] . '">' . 'User-id: ' . '<input type="text" size="11" name="suspend_id">' . '<br />' . 'Updates: ' . '<select name="suspend_updates">' . '<option>12</option>' . '<option>24</option>' . '<option selected>48</option>' . '</select>' . '<br /><br />' . '<input type="submit" value="Suspend Tribe!">' . '</form>' . '<br /><br />'; if (isset($_POST['suspend_id']) && $_POST['suspend_id'] > 1) { include_once 'inc/classes/clsUser.php'; $objTmpUser = new clsUser($_POST['suspend_id']); // Pause Account Routines. Martel July 13, 2006 $arrSrcUser = $objTmpUser->get_user_infos(); if ($arrSrcUser[NEXT_ATTACK] <= 1) { $arrSrcUser[NEXT_ATTACK] = 1; } $arrNewSrcUser = array(NEXT_ATTACK => $arrSrcUser[NEXT_ATTACK], PAUSE_ACCOUNT => $_POST['suspend_updates']); $objTmpUser->set_user_infos($arrNewSrcUser); // Empty Magic and Thievery Points $objTmpUser->set_spell(POWER, 0); $objTmpUser->set_thievery(CREDITS, 0); // Forced Ranking Update include_once 'inc/functions/update_ranking.php'; doUpdateRankings($objTmpUser, 'yes'); echo stripslashes($objTmpUser->get_stat(TRIBE)) . " will be paused for " . $_POST['suspend_updates'] . " updates. Don't forget to send a notice."; echo '<div id="textSmall">' . '<p><b>' . 'Standard notice to copy+paste:' . '</b></p>' . '<p>' . 'Your account has been suspended by the Law & Order Resort (found in alliance #2), you will not recieve updates, or be able to interact with the game, this may be because of a Code of Conduct violation or for some other action. Usually a staff member will contact you, if they have not, it is highly advised that you contact them, especially if you are not guilty of what you have been suspended for.' . '</p>' . '</div>'; } }
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 send_mail($from_id, $to_id, $subject, $message) { $orkTime = $GLOBALS['orkTime']; $objSrcUser = new clsUser($from_id); $objTrgUser = new clsUser($to_id); $arrSrcStats = $objSrcUser->get_stats(); $arrTrgStats = $objTrgUser->get_stats(); // we should check for the blocking system around here if (is_blocked_mail($from_id, $to_id)) { echo "<br /><br />You cannot mail {$arrTrgStats['tribe']} because you have been blocked from doing so."; include_game_down(); exit; } $subject = safeHTML($subject); $message = safeHTML($message); $message = "{$message}<br /><br /><i>~{$arrSrcStats['tribe']}(#{$arrSrcStats['kingdom']})"; if (!$subject) { $subject = "No Subject"; } mysql_query("INSERT INTO messages (for_user, from_user, date, subject, text, new, action) VALUES ('{$to_id}', '{$from_id}', '{$orkTime}', '{$subject}', '{$message}', 'new', 'received')"); mysql_query("INSERT INTO messages (for_user, from_user, date, subject, text, new, action) VALUES ('{$to_id}', '{$from_id}', '{$orkTime}', '{$subject}', '{$message}', 'new', 'sent')"); echo "<h3>Message sent to {$arrTrgStats['tribe']}(#{$arrTrgStats['kingdom']})</h3><br />"; mysql_query("UPDATE preferences SET last_m ='{$orkTime}' WHERE id = {$to_id}"); }
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 get_market_history_table(&$objAlliance) { $strMarketHistoryTable = "<table cellspacing=\"0\" cellpadding=\"0\" class=\"medium\">" . "<tr class=\"header\">" . "<th colspan=\"5\">" . "Market History" . "</th>" . "</tr>" . "<tr class=\"subheader\">" . "<th>" . "Tribe" . "</th>" . "<td>" . "Money" . "</td>" . "<td>" . "Food" . "</td>" . "<td>" . "Wood" . "</td>" . "<td>" . "Soldiers" . "</td>" . "</tr>"; $arrSum = array(MARKET_MONEY => 0, MARKET_FOOD => 0, MARKET_WOOD => 0, MARKET_SOLDIERS => 0); $objTmpUser = new clsUser(1); foreach ($objAlliance->get_userids() as $iUser) { $objTmpUser->set_userid($iUser); // This might speed it up a bit.. Reuse $arrTmpGoods = $objTmpUser->get_goods(); $arrTmpStats = $objTmpUser->get_stats(); $strMarketHistoryTable .= "<tr class=\"data\">" . "<th>" . stripslashes($arrTmpStats[TRIBE]) . "</th>" . "<td>" . number_format($arrTmpGoods[MARKET_MONEY]) . "</td>" . "<td>" . number_format($arrTmpGoods[MARKET_FOOD]) . "</td>" . "<td>" . number_format($arrTmpGoods[MARKET_WOOD]) . "</td>" . "<td>" . number_format($arrTmpGoods[MARKET_SOLDIERS]) . "</td>" . "</tr>"; // M: Add to total for each resource type foreach ($arrSum as $str => $i) { $arrSum[$str] += $arrTmpGoods[$str]; } } $arrAlli = $objAlliance->get_alliance_infos(); $strMarketHistoryTable .= "<tr class=\"data\">" . "<th class=bsup>" . "Unaccounted For:" . "</th>" . "<td class=bsup>" . number_format($arrAlli[MONEY] - $arrSum[MARKET_MONEY]) . "</td>" . "<td class=bsup>" . number_format($arrAlli[FOOD] - $arrSum[MARKET_FOOD]) . "</td>" . "<td class=bsup>" . number_format($arrAlli[WOOD] - $arrSum[MARKET_WOOD]) . "</td>" . "<td class=bsup>" . number_format($arrAlli[SOLDIERS] - $arrSum[MARKET_SOLDIERS]) . "</td>" . "</tr>" . "</table>"; return $strMarketHistoryTable; }
function call_mergers_text() { global $userid, $task, $mergerid, $checker, $listtribeid, $changedname, $declinereason, $local_stats, $tool; include_once 'inc/functions/resort_tools.php'; // we're abstracting the actual moving out to there include_once 'inc/staff/move.inc.php'; //if (! user_has_access($tool)) //{ // echo "Sorry, this page is restricted to ORKFiA Staff"; // include_game_down(); // exit; //} check_access($tool); $orkTime = date('YmdHis'); echo "<h2>Select task:</h2><br />| <a href='main.php?cat=game&page=resort_tools&tool=mergers&task=pending'>View Pending Mergers</a> | <a href='main.php?cat=game&page=resort_tools&tool=mergers&task=done'>View Done Mergers</a> | <a href='main.php?cat=game&page=resort_tools&tool=mergers&task=rejected'>View Declined Mergers</a> | <a href='main.php?cat=game&page=resort_tools&tool=mergers&task=requested'>View Requested Mergers</a> |<br /><br />"; if ($task == "changename") { // loads a form where you can change the requested name of a tribe $seek = mysql_query("SELECT newname FROM mergers WHERE id = {$mergerid}"); $seek = mysql_fetch_array($seek); echo "<form method=\"post\" action=\"main.php?cat=game&page=resort_tools&tool=mergers&task=changed&mergerid={$mergerid}\">"; echo "<br /><br /><table border=0 cellspacing=0 cellpadding=0 class='small'>"; echo "<tr class='header'><th colspan=2> Change Requested Name </th></tr>"; echo "<tr class='subheader'><th> Current Requested Name </th><td> New Name </td></tr>"; echo "<tr class='data'><th> {$seek['newname']} </th><td> <input type='text' name='changedname' maxLength='30'></td> </tr>"; echo "<tr class='data'><td colspan='2'><input type=submit value='Change requested name'></td></tr>"; echo "</table>"; echo "</form>"; } if ($task == "changed") { // the queries part for changing the requested name of a tribe //check if someone else already has that name first $changedname = quote_smart(strip_tags(trim($changedname))); $check = mysql_query("SELECT * FROM stats WHERE tribe = {$changedname} AND id != {$mergerid}"); if (mysql_num_rows($check) != 0) { echo "<br /><br />Some tribe is already using that name<br /><br />"; } else { $update = mysql_query("UPDATE mergers SET newname = {$changedname} WHERE id = {$mergerid}"); echo "<br /><br />The Requested tribe name is changed<br /><br />"; $task = "pending"; } } if ($task == "decline") { // loads a form where you can give a reason for not merging a tribe echo "<form method=\"post\" action=\"main.php?cat=game&page=resort_tools&tool=mergers&task=delete&mergerid={$mergerid}\">"; echo "<br /><br /><table border=0 cellspacing=0 cellpadding=0 class='small'>"; echo "<tr class='header'><th colspan=2> Decline Merge </th></tr>"; echo "<tr class='subheader'><th>Decline Reason</th></tr>"; echo "<tr class='data'><td><input type='text' name='declinereason' maxLength='100'></td></tr>"; echo "<tr class='data'><td><input type=submit value='Decline Merge'></td></tr>"; echo "</table>"; echo "</form>"; } if ($task == "delete") { // the queries part for the decline option $seek = mysql_query("SELECT * FROM mergers WHERE id = {$mergerid}"); $seek = mysql_fetch_array($seek); $message1 = "Your merge request to {$seek['target']} has been declined.<br />The reason for this is: {$declinereason} .<br />"; $message2 = "The merge from {$seek['oldname']}(#{$seek['origin']}) has been declined.<br />The reason for this is: {$declinereason} .<br />"; $bleh2 = mysql_query("SELECT id FROM stats WHERE type='elder' AND kingdom='{$seek['target']}'"); $bleh2 = mysql_fetch_array($bleh2); $sendmessage1 = mysql_query("INSERT INTO messages (id, for_user, from_user, date, subject, text, new, action) VALUES ('', '{$seek['tribe']}', '0', '" . $orkTime . "', 'Merge Request Declined', '" . $message1 . "', 'new', 'received')"); $sendmessage2 = mysql_query("INSERT INTO messages (id, for_user, from_user, date, subject, text, new, action) VALUES ('', '{$bleh2['id']}', '0', '" . $orkTime . "', 'Merge Request Declined', '" . $message2 . "', 'new', 'received')"); $update = mysql_query("UPDATE mergers SET request_status = 'declined', declined_reason = '{$declinereason}', mod_id = {$local_stats['id']} WHERE id = {$mergerid}"); $task = "pending"; } if ($task == "accept") { // doing the merge itself $fetch = mysql_query("Select * from mergers where id = {$mergerid}"); $fetch = mysql_fetch_array($fetch); $search = mysql_query("Select * from stats where id = {$fetch['tribe']}"); $search = mysql_fetch_array($search); $newname = "'" . $fetch['newname'] . "'"; //$update = mysql_query("UPDATE goods SET credits = 0, market_money = 0, market_food = 0, market_soldiers = 0, market_wood = 0 WHERE id = {$fetch['tribe']}"); //$update = mysql_query("UPDATE stats set kingdom = {$fetch['target']}, type = 'player', vote = 0, invested = 0, tribe = $newname where id = {$fetch['tribe']}"); //$update = mysql_query("UPDATE rankings_personal set alli_id = {$fetch['target']} where id = {$fetch['tribe']}"); mysql_query("UPDATE stats SET tribe = {$newname} where id = {$fetch['tribe']}"); move_tribe($fetch['tribe'], $fetch['target']); $update = mysql_query("UPDATE mergers set request_status = 'done', merge_time = '{$orkTime}', mod_id = '{$local_stats['id']}' where id = {$fetch['id']}"); $strSQL = mysql_query("INSERT INTO news (id, time, ip, type, duser, ouser, result, text, kingdom_text, kingdoma, kingdomb) VALUES ('', '{$orkTime}', '---', 'Mod Move', '0', '0', '1', '', '<font class = \"positive\">{$search['tribe']}(#{$fetch['origin']}) has been merged into {$newname}(#{$fetch['target']})! </font>', '{$fetch['origin']}', '{$fetch['target']}')"); echo "<br /><br />Merge was done =D<br /><br />"; $task = "pending"; } elseif ($task == "done") { // show list with all done mergers $fetch = mysql_query("SELECT * FROM mergers WHERE request_status = 'done' order by merge_time desc"); $mergers = array(); while ($arrmergers = mysql_fetch_array($fetch, MYSQL_ASSOC)) { $mergers[$arrmergers["id"]] = $arrmergers; } echo "<br /><br /><table border=0 cellspacing=0 cellpadding=0 class='big'>"; echo "<tr class='header'><th colspan='5'> Done Mergers </th></tr>"; echo "<tr class='subheader'><th> Merge Time </td><td> Tribe ID </td><td> Old Location </td><td> New Location </td><td> Staff </td></tr>"; foreach ($mergers as $strKey => $value) { $mod = mysql_query("SELECT name FROM stats WHERE id={$value['mod_id']}"); $mod = mysql_fetch_array($mod); echo "<tr class='data'><th> {$value['merge_time']} </th><td> {$value['tribe']} </td><td> {$value['oldname']}(#{$value['origin']}) </td><td> {$value['newname']}(#{$value['target']}) </td><td> {$mod['name']} </td></tr>"; } echo "</table>"; } elseif ($task == "rejected") { // show list with all rejected mergers and the reason to reject it $fetch = mysql_query("SELECT * FROM mergers WHERE request_status = 'declined' order by merge_time desc"); $mergers = array(); while ($arrmergers = mysql_fetch_array($fetch, MYSQL_ASSOC)) { $mergers[$arrmergers["id"]] = $arrmergers; } echo "<br /><br /><table border=0 cellspacing=0 cellpadding=0 class='big'>"; echo "<tr class='header'><th colspan=5> Declined Mergers </th></tr>"; echo "<tr class='subheader'><th> Merge Time </th><td> Tribe ID </td><td> Location </td><td> Staff </td><td> Reason </td></tr>"; foreach ($mergers as $strKey => $value) { $mod = mysql_query("SELECT name FROM stats WHERE id={$value['mod_id']}"); $mod = mysql_fetch_array($mod); echo "<tr class='data'><th> {$value['merge_time']} </th><td> {$value['tribe']} </td><td> {$value['oldname']}(#{$value['origin']}) </td><td> {$mod['name']} </td><td>{$value['declined_reason']}</td></tr>"; } echo "</table>"; } elseif ($task == "requested") { // show list with all mergers not accepted by the elder yet $fetch = mysql_query("SELECT * FROM mergers WHERE request_status = 'not ready' order by merge_time desc"); $mergers = array(); while ($arrmergers = mysql_fetch_array($fetch, MYSQL_ASSOC)) { $mergers[$arrmergers["id"]] = $arrmergers; } echo "<br /><br /><table border=0 cellspacing=0 cellpadding=0 class='big'>"; echo "<tr class='header'><th colspan=4> Requested Mergers </th></tr>"; echo "<tr class='subheader'><th> Merge Time </th><td> Tribe ID </td><td> Current Location </td><td> Wanted Location </td></tr>"; foreach ($mergers as $strKey => $value) { echo "<tr class='data'><th> {$value['merge_time']} </th><td> {$value['tribe']} </td><td> {$value['oldname']}(#{$value['origin']}) </td><td>{$value['newname']}(#{$value['target']})</td></tr>"; } echo "</table>"; } elseif ($task == "pending") { // show list of all tribes ready to get merged $fetch = mysql_query("SELECT * FROM mergers WHERE request_status = 'ready' order by merge_time desc"); $mergers = array(); while ($arrmergers = mysql_fetch_array($fetch, MYSQL_ASSOC)) { $mergers[$arrmergers["id"]] = $arrmergers; } echo "<br /><br />" . '<table border="0" cellspacing="0" cellpadding="0" class="big">' . '<tr class="header">' . '<th colspan="8">New Mergers</th>' . '</tr>' . '<tr class="subheader">' . '<th> Merge Time </th>' . '<td> Tribe ID </td>' . '<td> Old Location </td>' . '<td> New Location </td>' . '<td class="center"> §1 </td>' . '<td class="center"> Ruler<br />Age </td>' . '<td> War </td>' . '<td> Actions </td>' . '</tr>'; foreach ($mergers as $strKey => $value) { // $age = mysql_query("SELECT land FROM build WHERE id = $value[tribe]"); // $age = mysql_fetch_array($land); // $ltxt = $land['land']; $bExists = TRUE; $strSQL = "SELECT id FROM " . TBL_USER . " WHERE id = {$value['tribe']}"; $resSQL = mysql_query($strSQL); if (mysql_num_rows($resSQL) == 1) { $objTmpUser = new clsUser($value['tribe']); } else { $bExists = FALSE; } // 21 YEARS OLD ==================================================== if ($bExists) { $iHours = $objTmpUser->get_user_info(HOURS); } else { $iHours = 11808; } if (($iYears = ceil(($iHours + 192) / 12)) > 21) { $strTmpYears = '<span class="negative">' . $iYears . '</span>'; } else { $strTmpYears = '<span class="positive">' . $iYears . '</span>'; } // WEEKS JOINED < 6 ================================================ if ($bExists) { $strDate = $objTmpUser->get_gamestat(SIGNUP_TIME); } else { $strDate = '0000-00-00 00:00:00'; } if (ceil((strtotime($strDate) - strtotime('-6 weeks')) / 86400) < 0) { $strTmpSignup = '<span class="negative">Veteran</span>'; } else { $strTmpSignup = '<span class="positive">Novice</span>'; } include_once "inc/functions/war.php"; $seek1['war_target'] = war_target($value['origin']); $seek2['war_target'] = war_target($value['target']); $seek4 = mysql_query("Select count(id) as bleh from stats where kingdom = {$value['target']}"); $seek4 = mysql_fetch_array($seek4); if ($seek1['war_target'] > 0 || $seek2['war_target'] > 0) { $war = '<font class="negative">At War</font>'; } else { $war = '<font class="positive">Ok!</font>'; } if ($seek1['war_target'] > 0 || $seek2['war_target'] > 0 || $seek4['bleh'] >= MAX_ALLIANCE_SIZE) { $accept = "<font class=\"negative\">No Merging *</font>"; $show = true; } else { $accept = "<a href='main.php?cat=game&page=resort_tools&tool=mergers&task=accept&mergerid={$value['id']}'>Accept</a>"; } echo "<tr class='data'>\n <th class='bsdown'> {$value['merge_time']} </th>\n <td class='bsdown'> {$value['tribe']} </td>\n <td class='bsdown'> {$value['oldname']}(#{$value['origin']}) </td>\n <td class='bsdown'> {$value['newname']}(#{$value['target']}) </td>\n <td class='bsdown center'> " . $strTmpSignup . " </td>\n <td class='bsdown center'> " . $strTmpYears . " </td>\n <td class='bsdown'> {$war} </td>\n <td class='bsdown'> <a href='main.php?cat=game&page=resort_tools&tool=mergers&task=changename&mergerid={$value['id']}'>Change Name</a><br />\n {$accept}<br />\n <a href='main.php?cat=game&page=resort_tools&tool=mergers&task=decline&mergerid={$value['id']}'>Decline</a>\n </td>\n </tr>"; } echo "</table>"; if (isset($show)) { echo "* = The no merging means that his alliance or the alliance he want to go to is at war, or that the alliance he want to merge to is already at " . MAX_ALLIANCE_SIZE . " tribes.<br />"; } } }
function make_magic2(&$objSrcUser, $i_intTargetid, &$arrSpells, $i_strSpellName, $i_intSpelltimes, $i_blnStopOnSuccess, $i_blnMinHours, $i_minHours) { $iUserID = $objSrcUser->get_userid(); $damageModifier = 1; mt_srand((double) microtime() * 1000000); $objTrgUser = new clsUser($i_intTargetid); $arrSrcStats = $objSrcUser->get_stats(); $arrTrgStats = $objTrgUser->get_stats(); $arrTrgBuild = $objTrgUser->get_builds(); $intCasterMageLevel = get_mage_level($objSrcUser); $intTargetMageLevel = get_mage_level($objTrgUser); if ($arrTrgStats[ALLIANCE] == "0") { echo "This Player Has Either Been Deleted Or Suspended"; free_casting_now($iUserID); include_game_down(); exit; } // war check include_once "inc/functions/war.php"; // Gotland was here $warmodifier = war_alli($objTrgUser->get_stat(ALLIANCE), $objSrcUser->get_stat(ALLIANCE)); if ($warmodifier > 1) { $res = mysql_query("SELECT defiance FROM spells WHERE id = {$iUserID}"); $line = mysql_fetch_assoc($res); $damageModifier = $damageModifier * 1.1; if ($line["defiance"] > 0) { $damageModifier = $damageModifier * 1.1; } } $target = war_target($arrTrgStats[ALLIANCE]); if ($target != 0 && $damageModifier == 0) { //what is this supposed to do? right now it does nothing at all - AI $damageModifier = $damageModifier * 0.95; } $lastWar = mysql_query("SELECT last_target, last_end FROM war WHERE id = " . $arrSrcStats[ALLIANCE]); $lastWar = mysql_fetch_array($lastWar); $timeCounter = mysql_query("SELECT hour_counter FROM admin_global_time"); $timeCounter = mysql_fetch_array($timeCounter); // Spell type = SPELL_SELF, SPELL_ALLIANCE, SPELL_ENEMY etc (integers) $strSpellType = $arrSpells[$i_strSpellName]['type']; // Spell Display = full name of spell $strSpellDisplay = $arrSpells[$i_strSpellName]['display']; if ($arrTrgStats[ALLIANCE] == $lastWar['last_target'] && $strSpellType == SPELL_ENEMY) { if ($timeCounter['hour_counter'] <= $lastWar['last_end'] + 12) { echo '<div class="center">The war is not even over for 12 hours. Give them some time to recover!</div>'; free_casting_now($iUserID); include_game_down(); exit; } } include_once 'inc/functions/update.php'; check_to_update($objTrgUser->get_userid()); // Include the code for the spell about to be cast require_once "inc/spells/" . $i_strSpellName . ".php"; // Check for casting "harmful" spells on yourself if ($iUserID == $objTrgUser->get_userid() && ($strSpellType == SPELL_ENEMY || $strSpellType == SPELL_ALL || $strSpellType == SPELL_WAR)) { echo '<div class="center">' . "I'm sorry you cannot cast " . $strSpellDisplay . " upon yourself.\n"; echo "<br /><br /><br /><a href=main.php?cat=game&page=mystic&magekd=" . $objSrcUser->get_stat(ALLIANCE) . ">Back to Mystics</a></div>"; free_casting_now($iUserID); include_game_down(); exit; } // Martel: Heal may only target alliance members // SPELL_ALLIANCE only on allimates $iSrcAlli = $objSrcUser->get_stat(ALLIANCE); $iTrgAlli = $objTrgUser->get_stat(ALLIANCE); if ($strSpellType == SPELL_ALLIANCE && $iTrgAlli != $iSrcAlli) { echo '<div class="center">' . "Sorry but you cannot cast " . $strSpellDisplay . " on non-allies.<br />"; echo "<br /><br /><br /><a href=\"main.php?cat=game&page=mystic&magekd=" . $objTrgUser->get_stat(ALLIANCE) . "\">Back to Mystics</a></div>"; free_casting_now($iUserID); include_game_down(); exit; } // SPELL_ENEMY not on own alli if ($strSpellType == SPELL_ENEMY && $iTrgAlli == $iSrcAlli) { echo '<div class="center">' . "Sorry, but I refuse to do harm to our alliance members.<br />"; echo "<br /><br /><br /><a href=\"main.php?cat=game&page=mystic&magekd=" . $objTrgUser->get_stat(ALLIANCE) . "\">Back to Mystics</a></div>"; free_casting_now($iUserID); include_game_down(); exit; } // Check for target protection period if ($objTrgUser->get_user_info(HOURS) < PROTECTION_HOURS) { // Removed code-reuse of the copy-paste variety - AI 30/09/06 if ($strSpellType != SPELL_SELF) { $iRemaining = PROTECTION_HOURS - $objTrgUser->get_user_info(HOURS); echo '<div id="textMedium"><p>' . 'It appears that the tribe you wish to target is still ' . 'materializing. Our Mage estimates that it will take another ' . $iRemaining . ' updates for the area to become a stable part of ' . 'our reality.' . "</p><p>" . '<a href="main.php?cat=game&page=mystic&magekd=' . $objTrgUser->get_stat(ALLIANCE) . '">Back to Mystics</a>' . '</p>' . '</div>'; free_casting_now($iUserID); include_game_down(); exit; } } // Check for own protection period (this is also checked in mystic2.inc.php if ($objSrcUser->get_user_info(HOURS) < PROTECTION_HOURS) { if ($strSpellType != SPELL_SELF) { echo '<div id="textMedium"><p>' . 'You are still under protection.' . "</p><p>" . '<a href="main.php?cat=game&page=mystic&magekd=' . $objSrcUser->get_stat(ALLIANCE) . '">Back to Mystics</a>' . '</p>' . '</div>'; free_casting_now($iUserID); include_game_down(); exit; } } // Check for visioning a spirit if ($objTrgUser->get_stat(RACE) == 'Spirit' && $i_strSpellName == 'vision') { echo '<div id="textMedium"><p>' . "Your mystics are confused, they can't see anything at all." . "</p><p>" . '<a href="main.php?cat=game&page=mystic&magekd=' . $objSrcUser->get_stat(ALLIANCE) . '">Back to Mystics</a>' . '</p>' . '</div>'; free_casting_now($iUserID); include_game_down(); exit; } // Check for casting jura on a Templar - AI 11/02/2007 if ($objTrgUser->get_stat(RACE) == 'Templar' && $i_strSpellName == "juranimosity") { echo "Sorry, but " . $objTrgUser->get_stat(TRIBE) . " does not have any thieves for me to disband."; echo "<br /><br /><br /><a href=\"main.php?cat=game&page=mystic&magekd=" . $objTrgUser->get_stat(ALLIANCE) . ">Back to Mystics</a>"; free_casting_now($iUserID); include_game_down(); exit; } // check the user has cast it at lest 1 time if ($i_intSpelltimes <= 0) { echo "Sorry but you must cast this spell at least 1 time.<br />"; echo "<br /><br /><br /><a href=main.php?cat=game&page=mystic&magekd=" . $objTrgUser->get_stat(ALLIANCE) . ">Back to Mystics</a>"; free_casting_now($iUserID); include_game_down(); exit; } // Added by Genia4, checks that the user didnt ask to cast a self-spell until it succeeds for less than 1 hours. if ($i_blnMinHours && $i_minHours <= 0) { echo "Sorry but you must tell your mage for how much time you want the self spell.<br />"; echo "<br /><br /><br /><a href=main.php?cat=game&page=mystic&magekd=" . $objTrgUser->get_stat(ALLIANCE) . ">Back to Mystics</a>"; free_casting_now($iUserID); include_game_down(); exit; } // check the user has cast it no more than X times if ($i_intSpelltimes > MAX_SPELL_CASTS) { echo "Sorry but you can't auto-cast more than " . MAX_SPELL_CASTS . " times in a row in the interests of reducing server lag.<br />"; echo "<br /><br /><br /><a href=main.php?cat=game&page=mystic&magekd=" . $objTrgUser->get_stat(ALLIANCE) . ">Back to Mystics</a>"; free_casting_now($iUserID); include_game_down(); exit; } // check they aren't trying to cast a spell beyond their level, they must've modified the // form directly to do this....TSKTSK! $iMageLevel = get_mage_level($objSrcUser); // Martel: Added age 22 to implement high acreage spells // And removed again - AI 30/09/06 //$arrSrcBuild = $objSrcUser->get_builds(); //$iTotalAcres = $arrSrcBuild[LAND]; if ($iMageLevel < $arrSpells[$i_strSpellName]['level']) { echo "I'm sorry, you cannot cast " . $strSpellDisplay . "."; echo "<br /><br /><br /><a href=main.php?cat=game&page=mystic&magekd=" . $objSrcUser->get_stat(ALLIANCE) . ">Back to Mystics</a>"; free_casting_now($iUserID); include_game_down(); exit; } if (!clsBlock::isOpAllowed($objSrcUser, $objTrgUser) && $strSpellType != SPELL_SELF) { 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=mystic">Return</a>' . '</p></div>'; clsBlock::reportOp($objSrcUser, $objTrgUser, 'Spell: ' . $i_strSpellName, false); free_casting_now($iUserID); include_game_down(); exit; } $intOldPower = $objSrcUser->get_spell(POWER); //Check for Thwart $trgThwart = 1; if ($strSpellType != SPELL_SELF) { $arrTrgSpells = $objTrgUser->get_spells(); if ($arrTrgSpells[THWART] > 0) { $trgThwart = 0.75; } } //Churches // Tragedy: april 20th 2002: // adding a cap of max 80% effectiveness on churches, ergo max 20% of land $church_percentage = min(0.2, $arrTrgBuild['churches'] / $arrTrgBuild['land']); //frost: added high elves church bonus if ($objTrgUser->get_stat(RACE) == 'High Elf') { $church_bonus = $church_percentage * 4; } else { $church_bonus = $church_percentage * 3.5; } // Skathen: May 10th 2002: // Stop churches affecting self spells // Stop selected target affecting self spells // Martel: version 2.0, same purpose if ($strSpellType == SPELL_SELF) { //next line a small hack to prevent possible future bugs $objTrgUser = $objSrcUser; $church_bonus = 0; $trgThwart = 1; $intTargetMageLevel = 12 - $intCasterMageLevel; if ($intTargetMageLevel <= 4) { $intTargetMageLevel = 4; } if ($objSrcUser->get_user_info(HOURS) < PROTECTION_HOURS) { $intTargetMageLevel = 3; } } $chance_to_cast = formulate_chance($intCasterMageLevel, $intTargetMageLevel, $arrSpells[$i_strSpellName]); //========================================================================== // Main block - calculates success-rates, calls the specific spell-function //========================================================================== //How many spells can we cast ? //since we don't have 'infinity', we'll use an arbitrarily large number $totalAvailable = $arrSpells[$i_strSpellName]['cost'] > 0 ? floor($intOldPower / $arrSpells[$i_strSpellName]['cost']) : 9999999999.0; if ($totalAvailable > $i_intSpelltimes) { $totalAvailable = $i_intSpelltimes; } /* check the tribe still has the power to cast one time*/ if ($totalAvailable <= 0) { echo '<div class="center">' . "I'm sorry, you don't have enough Magic Power to cast that spell."; echo "<br /><br /><br /><a href=main.php?cat=game&page=mystic&magekd=" . $objTrgUser->get_stat(ALLIANCE) . ">Back to Mystics</a></div>"; free_casting_now($iUserID); include_game_down(); exit; } /* check for casting on a Nazgul, but only if its not a self spell */ if ($strSpellType != SPELL_SELF && $objTrgUser->get_stat(RACE) == "Nazgul") { $nazgulBonus = 0.2; } else { $nazgulBonus = 0; } // added nazgul casting failures if ($objSrcUser->get_stat(RACE) == "Nazgul") { $nazgulPenalty = 0.25; } else { $nazgulPenalty = 0; } /* check for casting on a Dragon, casting on dragon gives 50% less damage */ if ($objTrgUser->get_stat(RACE) == "Dragon") { $damageModifier *= 0.5; } // Roar of the horde fireball if ($strSpellType == SPELL_ENEMY && ($objTrgUser->get_stat(RACE) == "Uruk Hai" || $objTrgUser->get_stat(RACE) == "Oleg Hai" || $objTrgUser->get_stat(RACE) == "Mori Hai")) { $id = $objTrgUser->get_userid(); $seek = mysql_query("Select * from spells where id = {$id}"); $seek = mysql_fetch_array($seek); if ($seek['roar'] > 0 && $seek['forest'] == 0) { $rothBonus = 1 / 7; } else { $rothBonus = 0; } } else { $rothBonus = 0; } //Formulate the independent failure-chances. ML=magelevel, CH=Church-protection, race=race-protection, etc... $P_ML = 1 - $trgThwart * min($chance_to_cast, 290) / 300; $P_CH = $church_bonus; //$P_race1 -- used to be dragon protection $P_race2 = $nazgulBonus; $P_race3 = $nazgulPenalty; $P_roth = $rothBonus; // Martel: Adding exceptions here (alliance spell) if ($strSpellType == SPELL_ALLIANCE) { $P_CH = 0; $P_roth = 0; } //Calculate total chance of success per spell $P_success = (1 - $P_ML) * (1 - $P_CH) * (1 - $P_race2) * (1 - $P_race3) * (1 - $P_roth); //Loop through the number of spells casted, randomly decide wether it succeeds or fails. //When it fails, randomly choose a reason based on the relative failure-rates of all possible failure-reasons //Note that Stop-On-Success will be dealt with later on, by the spell-include-function $cntSpellSuccess = 0; $cntSF_total = 0; $cntSF_ML = 0; $cntSF_CH = 0; $cntSF_race2 = 0; $cntSF_race3 = 0; $cntSF_roth = 0; //Don't worry too much about the math behind it. It's correct and assures a fair distribution over the various 'reasons for failure' $P_fail_Total = $P_ML + $P_CH + $P_race2 + $P_race3 + $P_roth; $P_fail_ML = $P_ML / $P_fail_Total; $P_fail_CH = $P_CH / $P_fail_Total; $P_fail_race2 = $P_race2 / $P_fail_Total; $P_fail_race3 = $P_race3 / $P_fail_Total; $P_fail_roth = $P_roth / $P_fail_Total; if ($i_blnStopOnSuccess && $i_blnMinHours && $strSpellType == SPELL_SELF) { $i_blnStopOnSuccess = FALSE; } if ($i_blnMinHours && $strSpellType != SPELL_SELF) { $i_blnStopOnSuccess = TRUE; } for ($x = 1; $x <= $totalAvailable; $x++) { $random = rand(1, 10000) / 10000; if ($random < $P_success) { $cntSpellSuccess++; //Stop-On-Success check if ($i_blnStopOnSuccess == 1) { $totalAvailable = $x; break; } } else { $cntSF_total++; //Why did the spell fail ? Default ML-difference, CHs, race-protection, roth-protection, etc... $random = rand(1, 10000) / 10000; if ($random <= $P_fail_ML) { $cntSF_ML++; } if ($random > $P_fail_ML && $random <= $P_fail_ML + $P_fail_CH) { $cntSF_CH++; } if ($random > $P_fail_ML + $P_fail_CH && $random <= $P_fail_ML + $P_fail_CH + $P_fail_race2) { $cntSF_race2++; } if ($random > $P_fail_ML + $P_fail_CH + $P_fail_race2 && $random <= $P_fail_ML + $P_fail_CH + $P_fail_race2 + $P_fail_race3) { $cntSF_race3++; } if ($random > $P_fail_ML + $P_fail_CH + $P_fail_race2 + $P_fail_race3) { $cntSF_roth++; } } } // Ok, now we're done with calcing how many spells will succeed and why they will fail, we proceed to actually casting the spells // Call with: SpellCaster-object, Target-object, Spellname, Times-to-cast, Minimum-hours if (!$i_blnMinHours) { $minHours = 0; } else { $minHours = $i_minHours; } if ($cntSpellSuccess > 0) { $spellResult = cast_spell($objSrcUser, $objTrgUser, $arrSpells[$i_strSpellName], $cntSpellSuccess, $minHours, $damageModifier); } else { // Gotland: initialize the spellresult to avoid error message in case all attempts failed $spellResult["casted"] = 0; $spellResult["damage"] = 0; $spellResult["text_news"] = ""; $spellResult["text_screen"] = ""; } // $spellResult structure: (it's an array) // ["damage"] = 'Damage' done, could be used to calculate fame, not used for that right now. // ["casted"] = Amount of spells casted // ["text_screen"] = Return-text for the spell, to be outputted on the screen // ["text_news"] = text for the tribenews of the victim // Spend the mana and save back to to the db $manaSpent = ($spellResult["casted"] + $cntSF_total) * $arrSpells[$i_strSpellName]['cost']; $objSrcUser->set_spell(POWER, $intOldPower - $manaSpent); $dtTimestamp = date(TIMESTAMP_FORMAT); // Print out spell-casting-report if ($cntSpellSuccess == 0) { $spellResult["casted"] = 0; } $strReport = "<p>" . "Your mage has casted the spell " . ($spellResult["casted"] + $cntSF_total) . " times.<br />" . "He succeeded " . $spellResult["casted"] . " times and failed " . $cntSF_total . " times.<br />"; if ($cntSF_ML > 0) { $strReport .= $cntSF_ML . " failures he blames on lack of training.<br />"; } if ($cntSF_CH > 0) { $strReport .= $cntSF_CH . " of his cast-attempts were stopped by the Gods.<br />"; } if ($cntSF_race2 > 0) { $strReport .= $cntSF_race2 . " spells failed due to ancient Nazgul protection.<br />"; } if ($cntSF_race3 > 0) { $strReport .= $cntSF_race3 . " times your mage was hindered by our Nazgul curse.<br />"; } if ($cntSF_roth > 0) { // Roar of the Hoard "fireball bonus" // M: Updated to use objects. August 05, 2007 $citizens = $objSrcUser->get_pop(CITIZENS); $totalKilled = 0; for ($x = 1; $x <= $cntSF_roth; $x++) { $killed = ceil($citizens * 0.05); if ($citizens - $killed < 2000) { $killed = rand(10, 45); } if ($citizens - $killed < 100) { $killed = rand(2, 4); } if ($citizens - $killed < 50) { $killed = 0; } $citizens -= $killed; $totalKilled += $killed; } $objSrcUser->set_pop(CITIZENS, $citizens); $strReport .= '</p><p>Those orks must be under the influence of some spell. ' . $cntSF_roth . ' spells were returned by them in the form of ' . 'fireballs! <strong class="negative">' . number_format($totalKilled) . '</strong> citizens were killed.</p><p>'; } if ($cntSpellSuccess > 0) { $strReport .= "</p><p>Your mage reports the following results:<br />"; $strReport .= $spellResult["text_screen"] . "<br />"; } if ($spellResult["damage"] == 0) { $intFameWon = fame_win($objSrcUser, $objTrgUser, 0); } else { if ($i_strSpellName == "enforced") { $fame = floor($spellResult["damage"] * 0.1); } else { $fame = floor($spellResult["casted"] * $arrSpells[$i_strSpellName][FAME]); } $intFameWon = fame_win($objSrcUser, $objTrgUser, $fame); $strReport .= "</p><p>Your Mage gained a total of <strong class='positive'>" . number_format($intFameWon) . " fame</strong>.</p><p>"; } // Add spell-message to target tribenews if (isset($spellResult["text_news"])) { if ($spellResult["text_news"] != "" && $spellResult["casted"] > 0) { // Insert upwards compatibility with spells that do allinews // - AI 02/12/06 $strAlliMsgTemp = ""; if (isset($spellResult["alli_news"])) { $strAlliMsgTemp = $spellResult["alli_news"]; } $strMsgTemp = $spellResult["text_news"]; insert_news_item($i_strSpellName, $objTrgUser->get_userid(), $iUserID, 2, $strMsgTemp, $strAlliMsgTemp); //trigger news flag of defender $objTrgUser->set_user_info(LAST_NEWS, 1); } } // Add failed-spells message to target tribenews if ($strSpellType != SPELL_SELF && $i_strSpellName != "vision" && $cntSF_total > 0) { if ($cntSF_total > 1) { $plural = "s"; } else { $plural = ""; } $strMsgTemp = "Our Mage has detected {$cntSF_total} failed " . $strSpellDisplay . " spell{$plural} coming from " . $arrSrcStats[TRIBE] . "(#" . $arrSrcStats[ALLIANCE] . ")."; $strAlliMsgTemp = ""; insert_news_item($i_strSpellName, $objTrgUser->get_userid(), $iUserID, 2, $strMsgTemp, $strAlliMsgTemp); //trigger news flag of defender $objTrgUser->set_user_info(LAST_NEWS, 1); } // Check for kill-by-fireball. if ($spellResult["damage"] <= -100) { obj_test_for_kill($objTrgUser, $objSrcUser); } // AI's block system if ($strSpellType != SPELL_SELF) { clsBlock::logOp($objSrcUser, $objTrgUser, 'Spell: ' . $i_strSpellName); } $strReport .= "</p>" . "<p>" . "<a href=main.php?cat=game&page=mystic&magekd=" . $objTrgUser->get_stat(ALLIANCE) . ">Back to Mystics</a>" . "</p>"; // Print out the Report echo '<div id="textBig">' . '<h2>' . "Mystics Report " . '</h2>' . $strReport . '</div>'; // As requested... Show spells on success. Will people ever be satisfied? :p if ($spellResult["casted"] > 0 && $strSpellType == SPELL_SELF) { include_once 'inc/pages/advisors.inc.php'; echo '<br/>' . get_effecting_spells_table($objSrcUser); } free_casting_now($iUserID); include_game_down(); exit; }
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 include_mystic_text() { global $Host; $objSrcUser =& $GLOBALS["objSrcUser"]; $iSrcId = $objSrcUser->get_userid(); $arrSrcStats = $objSrcUser->get_stats(); $arrSrcBuild = $objSrcUser->get_builds(); //========================================================================== // M: Verify Alliance & Tribe ID from GET or POST //========================================================================== $iTrgAid = $arrSrcStats[ALLIANCE]; if (isset($_GET['magekd'])) { $iTrgAid = intval($_GET['magekd']); } elseif (isset($_POST['magekd'])) { $iTrgAid = intval($_POST['magekd']); } if ($iTrgAid < 11) { $iTrgAid = rand(11, 100); } if (isset($_GET['tribe'])) { $_GET['tribe'] = intval($_GET['tribe']); } //========================================================================== // Stop people from avoiding the tribe page so they dont get updated //========================================================================== include_once 'inc/functions/update_ranking.php'; doUpdateRankings($objSrcUser); $iMageLevel = get_mage_level($objSrcUser); $growth = mage_power_growth($iSrcId); $arrSpells = set_spell_vars($objSrcUser); //========================================================================== // Remove 'casting now' from here, so just clicking try again should fix // their problem - AI 30/09/06 //========================================================================== $objSrcUser->set_spell(CASTING_NOW, "'free'"); //========================================================================== // Max Mana Points for Output //========================================================================== $max_mp = (1 + $arrSrcBuild[GUILDS] / (2 * $arrSrcBuild[LAND])) * $arrSrcBuild[GUILDS]; if ($arrSrcStats[RACE] == "Eagle") { $max_mp *= 1.3; } $max_mp = round($max_mp); //========================================================================== // M: Links at top of page //========================================================================== echo $topLinks = '<div class="center">' . '<strong>Mystics</strong> | ' . '<a href="main.php?cat=game&page=thievery">Thievery</a> | ' . '<a href="main.php?cat=game&page=invade">Invasion</a>' . '</div>'; //========================================================================== // M: Advisor Welcome Text //========================================================================== $advisorText = '<div id="textBig">' . '<p>' . '<img src="' . $Host . 'wizard.gif" style="float: left; margin-right: 10px;" alt="Fighter" />' . "<strong>Your mage</strong> greets you: <br />" . "Magic can be a useful and powerful tool to for both offensive " . "and defensive purposes. While a SELF-spell can be a blessing, an " . "attack from high level mystics can be devastating. Build more " . "academies as you grow and we will be able to channel more and " . "stronger spells." . "</p>" . "<p>" . "Our guilds can hold a maximum of <strong>{$max_mp} mana points</strong>, right now " . "they hold <strong class=\"indicator\">" . $objSrcUser->get_spell(POWER) . "</strong>. According to our estimation we will " . "regenerate <strong>" . $growth . "</strong> per month." . "</p>" . "<p>"; if ($arrSrcStats[RACE] == 'Templar') { $advisorText .= 'You have <strong class="indicator">' . round($arrSrcBuild[ACADEMIES] * 100 / $arrSrcBuild[LAND], 0) . '</strong> academies per 100 acres and <strong class="indicator">' . round($objSrcUser->get_army_home(UNIT5) / ($arrSrcBuild[LAND] * 1.5), 0) . '</strong> mystics per 0.66 acres.<br />'; } $advisorText .= 'Your mystics are capable of using <strong class="indicator">level ' . $iMageLevel . '</strong> spells.' . "</p>" . "</div>"; echo $advisorText; /* ?> <table class="mini" cellspacing="0" cellpadding="0"> <tr class="header"> <th colspan="2">Quick Stats</td> </tr> <? ECHO ' <tr class="data"> <th>Mage Level:</th> <td>' . $iMageLevel . '</td> </tr> <tr class="data"> <th>Mana Points:</th> <td>' . $objSrcUser->get_spell(POWER) . '</td> </tr> <tr class="data"> <th>Regrowth:</th> <td>+' . $growth . '</td> </tr> <tr class="data"> <th>Max MPs:</th> <td>' . $max_mp . '</td> </tr>'; ?> </table> <br /><br /> <? */ //========================================================================== // M: Mystics Table //========================================================================== echo $strColumnDivs = '<div id="columns">' . '<!-- Start left column -->' . '<div id="leftcolumn">'; // Advisor Link echo $advisorLink = '<br />' . '<div class="tableLinkSmall">' . '<a href="main.php?cat=game&page=advisors&show=actions">The Mage</a>' . '</div>'; $tableTarget = ' <table width="40%" cellpadding="0" cellspacing="0" class="small"> <form action="main.php?cat=game&page=mystic" method="post"> <tr class="header"> <th colspan="2">Mystics</th> </tr> <tr class="subheader"> <th colspan="2" class="center">Select Target</th> </tr> <tr class="data"> <th>Alliance:</th>'; $tableTarget .= ' <td> <input maxlength="4" size="3" name="magekd" value="' . $iTrgAid . '" /> <input type="submit" value="Change" />'; if ($iTrgAid < 11) { $iTrgAid = rand(11, 100); } $tableTarget .= ' </td> </tr> </form> <tr class="data"> <form action="main.php?cat=game&page=mystic2" method="post"> <th>Tribe:</th> <td><select size="1" name="selTarget"><option value="spacer"></option>'; //====================================================================== // New version of Damadm00's code Martel, July 10, 2006 //====================================================================== include_once 'inc/classes/clsAlliance.php'; $objTrgAlliance = new clsAlliance($iTrgAid); $arrTrgIUsers = $objTrgAlliance->get_userids(); if (!empty($arrTrgIUsers)) { foreach ($arrTrgIUsers as $iUserId) { $objTmpUser = new clsUser($iUserId); $strTribe = stripslashes($objTmpUser->get_rankings_personal(TRIBE_NAME)); if (isset($_GET['tribe']) && $_GET['tribe'] == $iUserId) { $tableTarget .= sprintf('<option value="%d" selected>%s</option>', $iUserId, $strTribe); } elseif (!isset($_GET['tribe']) || isset($_GET['tribe']) && $_GET['tribe'] != $iUserId) { $tableTarget .= sprintf('<option value="%d">%s</option>', $iUserId, $strTribe); } elseif (isset($_GET['tribe'])) { echo "Trying to exploit bugs/loopholes will get you suspended!"; } } } $tableTarget .= ' </select> </td> </tr> <tr class="data"> <td colspan="2" class="right"> <select size="1" name="selSpellname">'; echo $tableTarget; reset($arrSpells); while (list($strSpellName, $arrSpell) = each($arrSpells)) { ///// //display spells ////// if ($iMageLevel >= $arrSpells[$strSpellName]['level'] && in_array($arrSrcStats['race'], $arrSpells[$strSpellName]['race']) && $arrSrcBuild[LAND] >= $arrSpells[$strSpellName]['acres']) { //============================================== // 'tags' are dynamic from now on - AI 30/06/09 //============================================== $type = ""; switch ($arrSpells[$strSpellName]['type']) { case SPELL_SELF: $type = " (SELF)"; break; case SPELL_ALLIANCE: $type = " (ALLIES)"; break; case SPELL_WAR: $type = " (WAR)"; break; case SPELL_ENEMY: case SPELL_ALL: } printf("<option value=\"%s\">%s%s - %d</option>\r\n", $strSpellName, $arrSpells[$strSpellName]['display'], $type, $arrSpells[$strSpellName]['cost']); } } $tableTarget = ' </select> </td> </tr> </table>'; echo $tableTarget; echo $strColumnDivs = '</div>' . '<!-- Start right column -->' . '<div id="rightcolumn">' . '<br /><br />'; $tableTarget2 = ' <table class="small" width="60%" cellpadding="0" cellspacing="0"> <tr class="header"> <th colspan="2">Prepare Mystics</th> </tr> <tr class="subheader"> <th>Instruction</th> <td>Select</td> </tr> <tr class="data"> <th>Times to Cast Spell:</th> <td><select size="1" name="txtAmount">'; for ($i = 1; $i <= 20; $i++) { $tableTarget2 .= '<option value="' . $i . '"> ' . $i . ' </option>'; } $tableTarget2 .= ' </select> </td> </tr> <tr class="data"> <th>Stop when spell succeeds for at least <input type="text" name="minHours" value="1" size="1" /> hours:</th> <td><input type="checkbox" name="chkMin" value="yes" /></td> </tr> <tr class="data"> <th>Stop on Success:</th> <td><input type="checkbox" name="chkStop" value="yes" /></td> </tr> </table>'; echo $tableTarget2; ?> <input type="hidden" value="yes" name="SELF_CHECK" /> <br /> <div class="center"><input type="submit" value='Request mystics to cast spell' /></div> </form> <?php echo $strColumnDivs = '</div>' . '</div><div class="clear"><hr /></div>'; }
$result_user_details = mysql_query($select_user_details) or die(mysql_error()); if (mysql_num_rows($result_user_details) > 0) { $user_details_row = mysql_fetch_assoc($result_user_details); $txtBillingFirstName = $user_details_row['first_name']; $txtBillingLastName = $user_details_row['last_name']; $txtBillingAddress1 = $user_details_row['address1']; $txtBillingAddress2 = $user_details_row['address2']; $txtBillingCity = $user_details_row['city']; $txtBillingState = $user_details_row['state']; $txtBillingZIP = $user_details_row['zip']; $txtBillingFAX = $user_details_row['fax']; $txtBillingPhone = $user_details_row['phone']; $txtBillingEmail = $user_details_row['email']; $ddlBillingCountry = $user_details_row['country']; } $shippingAddress = clsUser::getShippingAddress($_SESSION["sess_userid"]); $txtShippingFirstName = $shippingAddress["shipping_first_name"]; $txtShippingLastName = $shippingAddress["shipping_last_name"]; $txtShippingAddress1 = $shippingAddress["shipping_address1"]; $txtShippingAddress2 = $shippingAddress["shipping_address2"]; $txtShippingCity = $shippingAddress["shipping_city"]; $txtShippingZIP = $shippingAddress["shipping_zip"]; $txtShippingFAX = $shippingAddress["shipping_fax"]; $txtShippingPhone = $shippingAddress["shipping_phone"]; $txtShippingEmail = $shippingAddress["shipping_email"]; $ddlShippingCountry = $shippingAddress["shipping_country"]; $txtShippingState = $shippingAddress["shipping_state"]; } /*--------Multicart 2.0 Ends------------*/ if ($_SESSION['current_zipcode'] != "" && $_SESSION['currentTaxPrice'] > 0) { if (isset($_REQUEST['txtShippingZIP']) && $_REQUEST['txtShippingZIP'] == "") {
if (!$objMember->isNew()) { $objMemberTemplate->setText('BLANK', "(Blank not to change it.)"); } print $objMemberTemplate->get(); } else { $objTemplate->setText('PAGETITLE', 'Viewing ' . $objMember->get('username')); $objBreadcrumbs->add($objMember->get('username'), "index.php?action=members&subaction=view&" . $objMember->getIDPair()); $objMemberTemplate = new clsTemplate('viewuser'); $objMemberTemplate->setText('USERNAME', $objMember->get('username')); $objMemberTemplate->setText('REALNAME', $objMember->get('realname')); $objMemberTemplate->setText('LOCATION', $objMember->get('location')); print $objMemberTemplate->get(); } } if ($strSubAction == 'save') { if (!clsUser::canEdit($objMember, $objUser)) { throw new Exception('exception_accessdenied'); } $objMember->getFromRequest(array('id', 'username', 'password1', 'password2', 'email', 'is_advanced', 'show_empty', 'remember_filter', 'realname', 'location')); if ($objMember->isNew()) { $ret = $objMember->attemptCreate(); if (is_string($ret)) { $objMember->remove('password1'); $objMember->remove('password2'); header("Location: index.php?action=members&subaction=view&error={$ret}&" . $objMember->getQueryString()); } else { $objUser = $ret; $_SESSION['objUser'] = $objUser; clsAlbum::markSeen($objUser); header("Location: index.php?message=register_successful"); }
<?php require_once "Class/clsUser.php"; $location = $_SESSION['dbname']; $clsUser = new clsUser(); $updateAccountOk = false; if (array_key_exists("updateProfile", $_POST)) { $clsUser->updateUserProfile($_POST['fullname'], $_POST['contactno'], $_POST['description']); } else { if (array_key_exists("updateAccount", $_POST)) { $updateAccountOk = $clsUser->updateAccount($_POST['username'], $_POST['password'], $_POST['confirmpassword']); } } $user = $clsUser->getUserInfo(); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>ELECSYS | User</title> <?php include '/Includes/incHead.php'; ?> </head> <body> <!-- Navigation --> <?php include '/Includes/incNav.php'; ?> <!-- End -->
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 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); } }
<?php require_once 'cls/clsAlbum.php'; require_once 'cls/clsGroup.php'; require_once 'cls/clsParameters.php'; require_once 'cls/clsPicture.php'; require_once 'cls/clsTemplate.php'; require_once 'cls/clsThumbnail.php'; $objAlbum = new clsAlbum(); $objAlbum->getFromRequest(); $objAlbum->load(); $objMember = new clsUser(); $objMember->getFromRequest(); $objMember->load(); $objGroup = new clsGroup(); $objGroup->getFromRequest(); $objGroup->load(); $arrSimplePermissions = array(-1 => "Don't change", 0 => "Use same permission as parent", 1 => "Public (anybody can see the album and post comments)", 2 => "Public with rating (same as Public, but users can rate pictures)", 3 => "Public with group posting (same as Public, except group members can post pictures)", 4 => "Private (only group members can see)", 5 => "Private with rating (same as Private, but users can rate pictures)", 6 => "Private with group posting (same as Private, except group members can post pictures)"); if ($strSubAction == '' && $objMember->isNew()) { if (!$objAlbum->canView($objUser)) { throw new Exception('exception_accessdenied'); } /* Do they have access? */ if (!$objAlbum->canView($objUser)) { throw new Exception('exception_accessdenied'); } /* Are they filtering? */ if ($objUser && $objUser->get('remember_filter') && $objUser->get('filter_user')) { header("Location: index.php?action=albums&subaction=useralbums&user_id=" . $objUser->get('filter_user')); } $objBreadcrumbs->add('Albums', 'index.php?action=albums');
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_thievery_text() { global $Host, $opname, $action, $basecost; $objSrcUser =& $GLOBALS["objSrcUser"]; $iSrcId = $objSrcUser->get_userid(); $arrSrcStats = $objSrcUser->get_stats(); //========================================================================== // M: Verify Alliance & Tribe ID from GET or POST //========================================================================== $iTrgAid = $arrSrcStats[ALLIANCE]; if (isset($_GET['kd'])) { $iTrgAid = intval($_GET['kd']); } elseif (isset($_POST['kd'])) { $iTrgAid = intval($_POST['kd']); } if ($iTrgAid < 11) { $iTrgAid = rand(11, 100); } if (isset($_GET['tribe'])) { $_GET['tribe'] = intval($_GET['tribe']); } //========================================================================== // Stop people from avoiding the tribe page so they dont get updated //========================================================================== include_once 'inc/functions/update_ranking.php'; doUpdateRankings($objSrcUser); include_once "inc/functions/races.php"; $arrUnitNames = getUnitVariables($objSrcUser->get_stat(RACE)); $arrUnitNames = $arrUnitNames['output']; set_op_vars(); $land = $objSrcUser->get_build(LAND); $thieves = $objSrcUser->get_army(UNIT5); $tpa = floor($thieves / $land); $credits = floor($objSrcUser->get_thievery(CREDITS)); $op_growth = obj_thief_op_growth($objSrcUser); $hideouts = $objSrcUser->get_build(HIDEOUTS); // frost: age 18 mori hideout/home bonus, updated age 19 (Martel) if ($objSrcUser->get_stat(RACE) == "Mori Hai") { $homes = $objSrcUser->get_build(HOMES); $max_tp = floor((1 + ($hideouts + $homes / 2.5) * 2 / $land) * ($hideouts + $homes / 2.5)); } else { $max_tp = floor((1 + $hideouts * 2 / $land) * $hideouts); } if (!$iTrgAid) { $iTrgAid = $objSrcUser->get_stat(KINGDOM); } echo $topLinks = '<div class="center">' . '<a href="main.php?cat=game&page=mystic">Mystics</a> | ' . '<b>Thievery</b> | ' . '<a href="main.php?cat=game&page=invade">Invasion</a>' . '</div>'; //added templar check - AI if ($objSrcUser->get_stat(RACE) == "Templar") { echo '<div id="textMedium"><p>' . 'Your proud Templar people will not lower themselves to thievery practices.' . '</p></div>'; } else { ?> <div id='textBig'> <p> <img src="<?php echo $Host; ?> thief.gif" style="float: left; margin-right: 10px;" alt="" /> <b>The thief</b> greets you cooly:<br /> <?php if ($arrUnitNames[6] == 'Thief') { $arrUnitNames[6] = 'Thieve'; } ?> Normally <?php echo strtolower($arrUnitNames[6]); ?> s are considered scum and not wanted in a tribe, but in war-times you need every asset available. <?php echo $arrUnitNames[6]; ?> s can be useful in many ways, and the more of them you have on your lands, the safer you will be. </p> <?php echo "<p>" . "Our hideouts can provide a maximum of <b>{$max_tp} thievery points</b>, right now " . "there are <b class=\"indicator\">" . $credits . "</b> left unused. Assuming you find any use for your thieves they will " . "provide you with <b>" . $op_growth . "</b> new thievery points each month. " . "With all your thieves at home we are protected by <b class=\"indicator\">{$tpa} TPA</b> (thieves per acre). " . "</p></div>"; //========================================================================== // M: Thievery Table //========================================================================== echo $strColumnDivs = '<div id="columns">' . '<!-- Start left column -->' . '<div id="leftcolumn">'; // Advisor Link echo $advisorLink = '<br />' . '<div class="tableLinkSmall">' . '<a href="main.php?cat=game&page=advisors&show=actions">The Thief</a>' . '</div>'; ?> <table width="40%" cellpadding="0" cellspacing="0" class="small"> <form action="main.php?cat=game&page=thievery" method="post"> <tr class="header"> <th colspan="2"> Thievery </th> </tr> <tr class="subheader"> <th colspan="2" class="center"> Select Target </th> </tr> <tr class="data"> <th> Alliance: </th> <td> <input maxlength="4" size="3" name="kd" value="<?php echo $iTrgAid; ?> " /> <input type="submit" value="Change" /> </td> </tr> </form> <tr class="data"> <form action="main.php?cat=game&page=thievery2" method="post"> <th> Tribe: </th> <td> <select size="1" name="dplayer"> <option value="<?php echo $objSrcUser->get_userid(); ?> "></option> <?php //========================================================================== // New version of Damadm00's code Martel, July 10, 2006 //========================================================================== include_once 'inc/classes/clsAlliance.php'; $objTrgAlliance = new clsAlliance($iTrgAid); $arrTrgIUsers = $objTrgAlliance->get_userids(); $tableTarget = ''; if (!empty($arrTrgIUsers)) { foreach ($arrTrgIUsers as $iUserId) { $objTmpUser = new clsUser($iUserId); $strTribe = stripslashes($objTmpUser->get_rankings_personal(TRIBE_NAME)); if (isset($_GET['tribe']) && $_GET['tribe'] == $iUserId) { $tableTarget .= sprintf('<option value="%d" selected>%s</option>', $iUserId, $strTribe); } elseif (!isset($_GET['tribe']) || isset($_GET['tribe']) && $_GET['tribe'] != $iUserId) { $tableTarget .= sprintf('<option value="%d">%s</option>', $iUserId, $strTribe); } elseif (isset($_GET['tribe'])) { echo "Trying to exploit bugs/loopholes will get you suspended!"; } } } echo $tableTarget; ?> </select> </td> </tr> <tr class="data"> <td colspan="4" class="right"> <select size="1" name="op"> <?php $op_level = get_op_level($objSrcUser); for ($i = 1; $i <= $op_level; $i++) { if (!empty($opname[$i])) { $cost = get_op_cost($action[$i], $land); echo " <option value=\"{$i}\"> {$opname[$i]} - {$cost}</option>"; } } ?> </select> </td> </tr> </table> <?php echo $strColumnDivs = '</div>' . '<!-- Start right column -->' . '<div id="rightcolumn">' . '<br />' . '<div class="tableLinkSmall">' . '<a href="main.php?cat=game&page=advisors&show=military">The General</a>' . '</div>'; ?> <table class="small" width="60%" cellpadding="0" cellspacing="0"> <tr class="header"> <th colspan="2">Prepare Thieves</th> </tr> <tr class="subheader"> <th>Instruction</th> <td>Select</td> </tr> <tr class="data"> <th>Times to Run Operation:</th> <td> <select size="1" name="amount"> <?php for ($i = 1; $i <= MAX_THIEVE_OPS; $i++) { echo " <option value='{$i}'> {$i} </option>"; } ?> </select> </td> </tr> <tr class="data"> <th> <?php echo $arrUnitNames[6]; ?> s to Send: </th> <td> <input name="amount_sent" size="5" value="1" /> </td> </tr> <tr class="data"> <th>Available:</th> <td> <?php echo number_format($objSrcUser->get_army_home(UNIT5)); ?> </td> </tr> <tr class="data"> <th>Stop on Success:</th> <td> <input type="checkbox" name="stop" value="yes" /> </td> </tr> </table> <br /> <input type="hidden" value="yes" name="SELF_CHECK" /> <div class="center"><input type="submit" value="Send thieves on operation" /></div> </form> <?php echo $strColumnDivs = '</div>' . '</div>'; } }
function include_invade_text() { global $Host; $objSrcUser =& $GLOBALS["objSrcUser"]; $arrSrcStats = $objSrcUser->get_stats(); //========================================================================== // M: Verify Alliance & Tribe ID from GET or POST //========================================================================== $iTrgAid = $arrSrcStats[ALLIANCE]; if (isset($_GET['atkid'])) { $iTrgAid = intval($_GET['atkid']); } elseif (isset($_POST['iTrgAid'])) { $iTrgAid = intval($_POST['iTrgAid']); } if ($iTrgAid < 11) { $iTrgAid = rand(11, 100); } if (isset($_GET['tribe'])) { $_GET['tribe'] = intval($_GET['tribe']); } //========================================================================== // Stop people from avoiding the tribe page so they dont get updated //========================================================================== include_once 'inc/functions/update_ranking.php'; doUpdateRankings($objSrcUser); //========================================================================== // M: Links at top of page //========================================================================== echo $topLinks = '<div class="center">' . '<a href="main.php?cat=game&page=mystic">Mystics</a> | ' . '<a href="main.php?cat=game&page=thievery">Thievery</a> | ' . '<b>Invasion</b>' . '</div>'; //========================================================================== // M: Advisor Welcome Text //========================================================================== $advisorText = '<div id="textBig">' . '<p>' . '<img src="' . $Host . 'fighter.gif" style="float: left; margin-right: 10px;" alt="Fighter" />' . "<b>Your general</b> greets you: <br />" . "From this room we can order our military to attack other tribes. An " . "invasion is a way to expand your domains or take away someone " . "else's. Attacking someone is often considered an \"act of war\" as " . "no tribe appreciates losing their acres to the enemy, so be prepared " . "for retaliations!" . "</p>" . "<p>" . "The way your military fight depends on which strategy you're using. " . "There are several different ways to engage an enemy, either " . "to conquer acres of land or to inflict damage." . "</p>"; if ($arrSrcStats[RACE] == "Oleg Hai") { $advisorText .= "<p> And don't forget, only harpies that has been bought this month (update) will join any invasions.</p>"; } $advisorText .= "</div>"; echo $advisorText; //========================================================================== // M: Invasion Table //========================================================================== echo $strColumnDivs = '<div id="columns">' . '<!-- Start left column -->' . '<div id="leftcolumn">'; // Advisor Link echo $advisorLink = '<br />' . '<div class="tableLinkSmall">' . '<a href="main.php?cat=game&page=advisors&show=military">The General</a>' . '</div>'; $strInvasionTable = '<table width="40%" cellpadding="0" cellspacing="0" class="small">' . '<tr class="header">' . '<th colspan="2">' . "Invasion" . '</th>' . '</tr>' . '<tr class="subheader">' . '<th colspan="2" class="center">' . "Select Target" . '</th>' . '</tr>' . '<tr class="data">' . '<form action="main.php?cat=game&page=invade" method="post">' . '<input type="hidden" name="iTrgAid" value="' . $iTrgAid . '" />' . '<th>' . "Alliance:" . '</th>' . '<td>' . '<input maxlength="4" size="3" name="iTrgAid" value="' . $iTrgAid . '" />' . " " . '<input type="submit" value="Change" />' . '</td>' . '</form>' . '</tr>'; if ($iTrgAid != $arrSrcStats[ALLIANCE] && $iTrgAid > 10) { $strInvasionTable .= '<tr class="data">' . '<form action="main.php?cat=game&page=invade2" method="post">' . '<th>' . "Tribe:" . '</th>' . '<td>' . '<select size="1" name="TrgPlayer">' . '<option value="spacer">' . '</option>'; //====================================================================== // New version of Damadm00's code Martel, July 10, 2006 //====================================================================== include_once 'inc/classes/clsAlliance.php'; $objTrgAlliance = new clsAlliance($iTrgAid); $arrTrgIUsers = $objTrgAlliance->get_userids(); if (!empty($arrTrgIUsers)) { foreach ($arrTrgIUsers as $iUserId) { $objTmpUser = new clsUser($iUserId); $strTribe = stripslashes($objTmpUser->get_rankings_personal(TRIBE_NAME)); if (isset($_GET['tribe']) && $_GET['tribe'] == $iUserId) { $strInvasionTable .= sprintf('<option value="%d" selected>%s</option>', $iUserId, $strTribe); } elseif (!isset($_GET['tribe']) || isset($_GET['tribe']) && $_GET['tribe'] != $iUserId) { $strInvasionTable .= sprintf('<option value="%d">%s</option>', $iUserId, $strTribe); } elseif (isset($_GET['tribe'])) { echo "Trying to exploit bugs/loopholes will get you suspended!"; } } } $strInvasionTable .= '</select>' . '</td>' . '</tr>' . '<tr class="data">' . '<th>' . "Strategy:" . '</th>' . '<td>' . '<select size="1" name="invade_type">' . '<option value="' . ATTACK_STANDARD . '">' . "Standard Attack" . '</option>' . '<option value="' . ATTACK_RAID . '">' . "Raid" . '</option>' . '<option value="' . ATTACK_BARREN . '">' . "Barren Grab" . '</option>' . '<option value="' . ATTACK_HNR . '">' . "Hit 'n' Run" . '</option>' . '<option value="' . ATTACK_BC . '">' . "Blasphemy Crusade" . '</option>' . '</select>' . '</td>' . '</tr>'; } $strInvasionTable .= '</table>'; // M: Show Invasion Table echo $strInvasionTable; echo $strColumnDivs = '</div>' . '<!-- Start right column -->' . '<div id="rightcolumn">' . '<br /><br />'; if ($iTrgAid != $arrSrcStats[ALLIANCE] && $iTrgAid > 10) { $strPrepareTable = '<table cellpadding="0" cellspacing="0" class="small">' . '<tr class="header">' . '<th colspan="3">' . "Prepare Army" . '</th>' . '</tr>' . '<tr class="subheader">' . '<th>' . "Units" . '</th>' . '<th class="right">' . "Owned" . '</th>' . '<th class="right">' . "To Send" . '</th>' . '</tr>'; // M: Get All Units with an offence Value include_once 'inc/functions/races.php'; $arrUnitVars = getUnitVariables($arrSrcStats[RACE]); $arrUnitOffence = $arrUnitVars['offence']; $arrUnitDefence = $arrUnitVars['defence']; $arrUnitVar = $arrUnitVars['variables']; $arrUnitName = $arrUnitVars['output']; $arrArmyHome = $objSrcUser->get_armys_home(); foreach ($arrUnitOffence as $i => $iUnitOffence) { if ($iUnitOffence > 0) { // M: Military Unit Names Grammar $strPlural = 's'; if ($arrUnitName[$i] == 'Swordmen') { $strPlural = ''; } if ($arrUnitName[$i] == 'Pikemen') { $strPlural = ''; } if ($arrUnitName[$i] == 'Crossbowmen') { $strPlural = ''; } if ($arrUnitName[$i] == 'Longbowmen') { $strPlural = ''; } if ($arrUnitName[$i] == 'Thief') { $arrUnitName[$i] = 'Thieve'; } if ($arrUnitName[$i] == 'Priestess') { $strPlural = ''; } if ($arrUnitName[$i] == 'Mummy') { $arrUnitName[$i] = 'Mummie'; } // Oleg Hai Exception (Elites are Mercenaries) if ($arrSrcStats[RACE] == "Oleg Hai" && $i == 5) { $arrArmyHome[$i] = $objSrcUser->get_army_merc(MERC_T3); } $strPrepareTable .= '<tr class="data">' . '<th>' . sprintf('%s%s <span class="militstats">(%d/%d)</span>', $arrUnitName[$i], $strPlural, $arrUnitOffence[$i], $arrUnitDefence[$i]) . '</th>' . '<td>' . $arrArmyHome[$arrUnitVar[$i]] . '</td>' . '<td>' . '<input size="6" maxlength="7" name="arrArmySent[' . $arrUnitVar[$i] . ']" value="0" />' . '</td>' . "</tr>"; } } $strPrepareTable .= '</table>' . '<br />' . '<input type="hidden" name="iTrgAid" value="$iTrgAid" />' . '<div class="center"><input type="submit" value="Order army into battle" /></div>' . '</form>'; } // M: Show Prepare Table if (isset($strPrepareTable)) { echo $strPrepareTable; } echo $strColumnDivs = '</div>' . '</div><div class="clear"><hr /></div>'; }
$_SESSION['PAYMENT_ERROR'] = $result["r_error"]; } } if ($paymentsuccessful) { //-----------------------------Inserting artist starts here --------------------------------------------// if (isset($_SESSION['SESS_insertQry'])) { mysql_query($_SESSION['SESS_insertQry'][0]) or die(mysql_error()); $userid = mysql_insert_id(); $_SESSION['sess_artistid'] = $userid; //Insert social media settings /* $sql_socialmedia = "INSERT INTO ".$tableprefix."seller_social_media (nSellerId,name,title,link,logo) SELECT '".$userid."','name',title,link,logo FROM ".$tableprefix."social_media"; mysql_query($sql_socialmedia) or die(mysql_error());*/ clsUser::setSocialMediaSettingsVendor($userid); $_SESSION["sess_artistname"] = trim($_SESSION['SESS_insertQry'][2]['txtUserName']); $_SESSION["sess_artistid"] = $userid; // Ending Session for User, Affiliates } //------------------------------Ends here--------------------------------------------------------------// $select_Plan = "SELECT plan_Period\n\t\t\t\t\t\t\t\t FROM " . $tableprefix . "sellerPlans\n\t\t\t\t\t\t\t\t WHERE plan_Id = " . trim($_SESSION['membership']['plan_Id']); $result_Plan = mysql_query($select_Plan) or die(mysql_error()); $result_Plan = mysql_fetch_assoc($result_Plan); if ($result_Plan['plan_Period'] == "M") { $noOfDays = 30; } if ($result_Plan['plan_Period'] == "Y") { $noOfDays = 365; } $_SESSION['SES_MEMPLAN'] = $_SESSION['membership']['plan_Id'];
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 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_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; }
} /* This re-loads the user object in case it's changed. */ if ($objUser) { $objUser = new clsUser($objUser->get('id')); } if ($objUser && $objUser->isNew()) { $objUser = null; } if (!preg_match('/^[a-zA-Z2-9_-]*$/', $strAction)) { throw new Exception(ERRORMSG_INVALID); } $objTemplate = new clsTemplate('default'); $objTemplate->setText('SCRIPT', clsDB::initializeJS()); $objTemplate->setText('TITLE', "OSPAP2"); /* Inline CSS for advanced. */ $objTemplate->setText('HEAD', clsUser::getAdvancedStyle($objUser)); if (isset($_REQUEST['error']) && isset($arrMessages[$_REQUEST['error']])) { $objTemplate->setText('ERROR', $arrMessages[$_REQUEST['error']]); } else { if (isset($_REQUEST['message']) && isset($arrMessages[$_REQUEST['message']])) { $objTemplate->setText('MESSAGE', $arrMessages[$_REQUEST['message']]); } } $objTemplate->setScript('MENU', 'menu'); $objTemplate->setScript('LOGO', 'logo'); $objTemplate->setText('COPYRIGHT', "Written by <a href='mailto:ronospap@skullsecurity.org'>Ron</a>. This page and code are public domain. Code is available upon request. No warranty or promises of any kind."); switch ($strAction) { case '': $objTemplate->setScript('CONTENT', 'news'); break; case 'login':
function include_mystic2_text() { include_once "inc/functions/magic.php"; include_once "inc/functions/spells.php"; include_once "inc/functions/news.php"; $strSpellName = strval($_POST["selSpellname"]); $intSpellTimes = intval($_POST["txtAmount"]); $iTrgUserid = intval($_POST["selTarget"]); $minHours = intval($_POST["minHours"]); $blnStopOnSuccess = FALSE; if (isset($_POST["chkStop"]) && $_POST["chkStop"] == "yes") { $blnStopOnSuccess = TRUE; } // Species5618 19-2-2004: added processing of Minimum hours checkbox $blnMinHours = FALSE; if (isset($_POST["chkMin"]) && $_POST["chkMin"] == "yes") { $blnMinHours = TRUE; } $objSrcUser =& $GLOBALS["objSrcUser"]; $arrSrcStats = $objSrcUser->get_stats(); $arrSpells = set_spell_vars($objSrcUser); $strSpellType = $arrSpells[$strSpellName]['type']; // Can't cast damaging spells in protection if ($arrSpells[$strSpellName]['fame'] > 0) { obj_check_protection($objSrcUser, "magic"); } if (empty($iTrgUserid) || $iTrgUserid == $objSrcUser->get_userid()) { if ($strSpellType == SPELL_SELF || $strSpellType == SPELL_ALLIANCE) { $iTrgUserid = $objSrcUser->get_userid(); } else { echo '<div class="center">Please select a target.</div>'; include_game_down(); exit; } } include_once 'inc/functions/update.php'; check_to_update($iTrgUserid); $objTrgUser = new clsUser($iTrgUserid); $arrTrgStats = $objTrgUser->get_stats(); include_once "inc/functions/war.php"; $modifier = war_alli($arrSrcStats[ALLIANCE], $arrTrgStats[ALLIANCE]); if ($modifier < 1 && $strSpellType == SPELL_WAR) { echo '<div class="center">' . 'War only spell, you cannot cast it on this target!' . '</div>'; include_game_down(); exit; } // M: Allow self spells even if target is paused if (($arrTrgStats[KILLED] > 0 || $arrTrgStats[RESET_OPTION] == 'yes') && $strSpellType != SPELL_SELF) { echo $strDiv = '<div id="textMedium"><p>' . 'This tribe is dead or has reset.' . '<br /><br />' . '<a href="main.php?cat=game&page=mystic">' . 'Try Again ?' . '</a>' . '</p></div>'; } elseif ($objTrgUser->isPaused() && $strSpellType != SPELL_SELF) { echo $strDiv = '<div id="textMedium"><p>' . 'This tribe is paused.' . '<br /><br />' . '<a href="main.php?cat=game&page=mystic">' . 'Try Again ?' . '</a>' . '</p></div>'; } else { // Doubleclick-protection. Sets a field in the DB when the script loads, // field will be turned "off" when the thing is done. // Added by Species5618, 10-3-2004 $magic_busy = $objSrcUser->get_spell(CASTING_NOW); if ($magic_busy == BUSY) { echo $strDiv = '<div class="center">' . "Spells are being processed at the moment, please don't " . "doubleclick the button, even though the server might not " . "respond immediately." . '<br /><br />' . '<a href="main.php?cat=game&page=mystic">' . 'Try Again ?' . '</a>' . '</div>'; include_game_down(); exit; } else { $objSrcUser->set_spell(CASTING_NOW, BUSY); make_magic2($objSrcUser, $iTrgUserid, $arrSpells, $strSpellName, $intSpellTimes, $blnStopOnSuccess, $blnMinHours, $minHours); // frost: 'free' casting_now is in inc/functions/magic.php, because // here it's getting ignored } } }