<link rel="stylesheet" href="/styles/main.css" type="text/css" media="screen" /> </head> <body> <?php require_once dirname(__FILE__) . '/include/visible_header.php'; if ($message) { echo '<b>' . $message . '</b>'; } elseif ($_POST['attack_id']) { echo '<b>Troop movements started!</b>'; } if (!$tocity) { echo '<h2>Select a City to Attack/Move to</h2><ul>'; if ($fromcity) { $close_upper_bound = intval($fromcity->getValue('id')) + 25000; $dbcities = mysql_query("SELECT user_id,city_id FROM server_cities WHERE server_id=" . $server->getID() . " AND city_id < {$close_upper_bound} ORDER BY city_id DESC LIMIT 50", $db) or die(mysql_error()); } else { $dbcities = mysql_query("SELECT user_id,city_id FROM server_cities WHERE server_id=" . $server->getID() . " ORDER BY user_id LIMIT 50", $db) or die(mysql_error()); } //end if-else fromcity while ($city = mysql_fetch_assoc($dbcities)) { $user = new user($city['user_id'], $server); $city = new city($city['city_id']); echo '<li>'; echo '<a href="/server/' . $server->getID() . '/attack/' . $city->getValue('id') . '+' . $cities[1] . '">'; if ($city->getValue('name')) { echo htmlentities($city->getValue('name')) . ' / '; } echo 'Location: ' . str_pad($city->getValue('id'), 6, '0', STR_PAD_LEFT); echo '</a>'; echo ' / Population: ' . $city->getValue('population') . ' / Defense: ' . (intval($city->getValue('defense')) + 1) . ' / User: <a href="/server/' . $server->getID() . '/user/' . $user->getValue('userid') . '">' . htmlentities($user->getValue('nickname')) . '</a>';
require_once dirname(__FILE__) . '/include/user.php'; require_once dirname(__FILE__) . '/include/server.php'; require_once dirname(__FILE__) . '/include/cron.php'; if (!$server) { $server = new server($_REQUEST['server_id']); } if (!$current_user) { $current_user = new user($LOGIN_DATA['user_id'], $server); } echo "<h3>Cities</h3><ul>"; foreach ($current_user->getValue('cities') as $city) { echo '<li>'; echo ' ' . str_pad($city->getValue('population'), 3, '0', STR_PAD_LEFT) . ' <img src="/images/group.png" alt="Population" title="Population" />'; echo ' ' . str_pad(intval($city->getValue('defense')) + 1, 2, '0', STR_PAD_LEFT) . ' <img src="/images/shield.png" alt="Defense" title="Defense" />'; echo ' ' . str_pad(intval($city->unit_count()), 3, '0', STR_PAD_LEFT) . ' <img src="/images/car.png" alt="Units" title="Units" />'; echo ' <a href="/server/' . $server->getID() . '/city/' . $city->getValue('id') . '">'; echo ' @ ' . str_pad($city->getValue('id'), 6, '0', STR_PAD_LEFT); if ($city->getValue('name')) { echo ' / ' . htmlentities($city->getValue('name')); } echo '</a>'; $attack = mysql_query("SELECT user_id,unit_count,eta FROM server_unit_transaction WHERE server_id=" . $server->getID() . " AND destination=" . $city->getValue('id') . " AND user_id!=" . $current_user->getValue('userid') . " AND eta < " . (time() + 60 * 5) . " ORDER BY eta DESC LIMIT 1", $db) or die(mysql_error()); $attack = mysql_fetch_assoc($attack); if ($attack) { $attack_user = new user($attack['user_id'], $server); $nickname = $attack_user->getValue('nickname') ? $attack_user->getValue('nickname') : 'User #' . $attack_user->getValue('userid'); echo ' <br /><i>' . $attack['unit_count'] . ' units attacking from <a href="/server/' . $server->getID() . '/user/' . $attack_user->getValue('userid') . '">' . $nickname . '</a> in ' . round(($attack['eta'] - time()) / 60, 2) . " minutes.</i>"; } //end if attack echo "</li>"; }
require_once dirname(__FILE__) . '/include/processCookie.php'; require_once dirname(__FILE__) . '/include/cron.php'; require_once dirname(__FILE__) . '/include/connectDB.php'; require_once dirname(__FILE__) . '/include/user.php'; require_once dirname(__FILE__) . '/include/server.php'; require_once dirname(__FILE__) . '/include/city.php'; if (!$server) { $server = new server($_REQUEST['server_id']); } if (!$current_user) { $current_user = new user($LOGIN_DATA['user_id'], $server); } ?> <h3>Troop Movements</h3> <ul> <?php $transactions = mysql_query("SELECT unit_count,eta,destination,user_id FROM server_unit_transaction WHERE server_id=" . $server->getID() . " AND user_id=" . $current_user->getValue('userid') . " ORDER BY eta ASC", $db) or die(mysql_query()); while ($transaction = mysql_fetch_assoc($transactions)) { $city = new city($transaction['destination']); $dest = $city->getValue('name') ? htmlentities($city->getValue('name')) : 'City at ' . str_pad($city->getValue('id'), 6, '0', STR_PAD_LEFT); $is_attack = $city->getValue('user')->getValue('userid') != $transaction['user_id']; $time_left = round(($transaction['eta'] - time()) / 60, 2); if ($time_left > 0) { echo "\t\t\t" . '<li>' . ($is_attack ? 'Attacking ' : 'Moving to ') . $dest . ' with ' . $transaction['unit_count'] . ' troops in ' . $time_left . ' minutes </li>' . "\n"; } } //end while unit ?> </ul>
<script type="text/javascript"> //<![CDATA[ var day_left_id = ''; function update_day_left() { var block = document.getElementById('day-left'); block.innerHTML = Math.round((block.innerHTML - (1/60))*100)/100; if(block.innerHTML < 0) block.innerHTML = 0; day_left_id = setTimeout("update_day_left()", 1100); }//end function update_day_left day_left_id = setTimeout("update_day_left()", 1100); var statistics_id = ''; function update_statistics() { new Ajax.Updater('statistics', '/statistics.php?server_id=<?php echo $server->getID(); ?> '); new Ajax.Updater('server-message', '/server-message.php?server_id=<?php echo $server->getID(); ?> '); statistics_id = setTimeout("update_statistics()", 1000*8); }//end function update_day_left statistics_id = setTimeout("update_statistics()", 1000*8) //]]> </script> <?php $week = $server->getPreviousWeek(); $time_left = ceil(abs(time() - $server->getWeekLength() - $week) / $server->getDayLength());
$mod = 'near'; case 'city': case 'ls': $data = trim(preg_replace('/^city[\\s]+/i', '', $data)); $data = trim(preg_replace('/^near[\\s]+/i', '', $data)); if (!$data || $data == 'cities') { $reply = 'On ' . $server->getName() . ' your cities : '; foreach ($user->getValue('cities') as $city) { $reply .= $city->getValue('name') . '@' . $city->getValue('id') . ' '; } } else { if ($mod == 'near') { foreach ($user->getValue('cities') as $city) { if ($city->getValue('id') == $data || @preg_match('/^' . $data . '$/i', $city->getValue('name'))) { $close_upper_bound = intval($city->getValue('id')) + 30000; $dbcities = mysql_query("SELECT city_id FROM server_cities WHERE server_id=" . $server->getID() . " AND city_id < {$close_upper_bound} ORDER BY city_id DESC LIMIT 10", $db) or die(mysql_error()); $reply = 'On ' . $server->getName() . ' near ' . $city->getValue('name') . '@' . $city->getValue('id') . ' : '; while ($icity = mysql_fetch_assoc($dbcities)) { $cityo = new city($icity['city_id']); $reply .= $cityo->getValue('name') . '@' . $cityo->getValue('id') . ' '; } break; } } } else { foreach ($user->getValue('cities') as $city) { if ($city->getValue('id') == $data || @preg_match('/^' . $data . '$/i', $city->getValue('name'))) { $reply = $city->getValue('name') . '@' . $city->getValue('id') . ' Population: ' . $city->getValue('population') . ' / Defense: ' . ($city->getValue('defense') + 1) . ' / Units: ' . $city->unit_count(); break; } }
echo $server->getName(); ?> Leaders</title> <?php $xhtmlSite->metaType(); ?> <link rel="stylesheet" href="/styles/main.css" type="text/css" media="screen" /> <link rel="stylesheet" href="/styles/login.css" type="text/css" media="screen" /> <link rel="shortcut icon" href="/favicon.ico" /> </head> <body> <?php require dirname(__FILE__) . '/include/visible_header.php'; echo '<h3>Round Leaders</h3><ol style="list-style-type:none;padding:0px;">'; $close_players = mysql_query("SELECT user_id FROM server_data WHERE server_id=" . $server->getID() . " AND `key`='gold' ORDER BY value DESC LIMIT 50", $db) or die(mysql_error()); $leaders = array(); while ($player = mysql_fetch_assoc($close_players)) { $player_data = new user($player['user_id'], $server); $leaders[$player_data->calculateScore()] = $player_data; } //end while close_players krsort($leaders); foreach ($leaders as $score => $leader) { echo '<li>'; echo $leader->online_icon() . ' '; $nickname = $leader->getValue('nickname') ? $leader->getValue('nickname') : 'User #' . $leader->getValue('userid'); echo '<a href="/server/' . $server->getID() . '/user/' . $leader->getValue('userid') . '">' . htmlentities($nickname) . '</a>'; echo ' (Score: ' . $score . ')'; echo '</li>'; }
<div><?php echo $this_user->getValue('gold'); ?> Gold</div> <div><?php echo $this_user->getValue('city_count'); ?> Cities</div> <h2 style="clear:both;">Cities</h2> <ul> <?php foreach ($this_user->getValue('cities') as $city) { echo '<li>'; $can_access = $city->getValue('user_' . $LOGIN_DATA['user_id'] . '_access'); $can_access = $can_access === true || intval($can_access) > time(); echo '<a href="/server/' . $server->getID() . '/city/' . $city->getValue('id') . '">'; if ($city->getValue('name')) { echo htmlentities($city->getValue('name')) . ' / '; } echo ' Location: ' . str_pad($city->getValue('id'), 6, '0', STR_PAD_LEFT); echo '</a>'; echo ' / Population: ' . $city->getValue('population'); echo ' / Defense: ' . (intval($city->getValue('defense')) + 1); echo ' - <a href="/server/' . $server->getID() . '/attack/' . $city->getValue('id') . '">attack/move</a>'; echo '</li>'; } //end foreach city ?> </ul> <?php }
<title>The Project - <?php echo $server->getName(); ?> Attack History</title> <?php $xhtmlSite->metaType(); ?> <link rel="stylesheet" href="/styles/main.css" type="text/css" media="screen" /> <link rel="shortcut icon" href="/favicon.ico" /> </head> <body> <?php require dirname(__FILE__) . '/include/visible_header.php'; echo '<h3>Recent Attacks</h3><ol style="list-style-type:none;padding:0px;">'; $attacks = mysql_query("SELECT destination,user_id,results,time FROM server_attack_results WHERE server_id=" . $server->getID() . " ORDER BY time DESC LIMIT 50", $db) or die(mysql_error()); while ($attack = mysql_fetch_assoc($attacks)) { $user = new user($attack['user_id'], $server); $dest = new city($attack['destination']); $class = $attack['results'] < 0 ? 'won' : 'lost'; echo '<li class="' . $class . '">'; echo ceil((time() - $attack['time']) / 60) . ' minutes ago: '; echo '<a href="/server/' . $server->getID() . '/user/' . $user->getValue('userid') . '">' . ($user->getValue('nickname') ? htmlentities($user->getValue('nickname')) : 'User #' . $user->getValue('userid')) . '</a>'; echo ' attacked '; echo $dest->getValue('name') . ' (Location: ' . $dest->getValue('id') . ')'; echo ' and '; echo $class; echo ' by ' . abs($attack['results']); echo '</li>'; } //end while attacks
if (!$this_city) { $this_city = new city($_REQUEST['city_id']); } if (!$can_access) { $can_access = $this_city->getValue('user_' . $LOGIN_DATA['user_id'] . '_access'); if ($can_access !== true && intval($can_access) > time()) { $can_access_time = ceil(($can_access - time()) / 60); } $can_access = $can_access === true || intval($can_access) > time(); } //end if ! can_access if ($can_access) { if (!$server) { $server = new server($_REQUEST['server_id']); } $units = mysql_query("SELECT unit_id,name,description,cost FROM units WHERE server_id=" . $server->getID(), $db) or die(mysql_query()); while ($unit = mysql_fetch_assoc($units)) { $unit_options .= "\t\t\t" . '<option value="' . $unit['unit_id'] . '">' . htmlentities($unit['name']) . ' (' . $unit['cost'] . ' Gold)</option>' . "\n"; $unit_list .= "\t\t\t<li>"; $unit_list .= htmlentities($unit['name']); $unit_list .= ' (' . intval($this_city->getValue('unit_' . $unit['unit_id'])) . ')'; if ($unit['description']) { $unit_list .= ' - ' . htmlentities($unit['description']); } $unit_list .= "</li>\n"; } //end while unit echo '<h3>Units (' . $this_city->unit_count() . ')</h3>'; echo '<ul>'; echo $unit_list; echo '</ul>';
if (!$this_city) { $this_city = new city($_REQUEST['city_id']); } if (!$can_access) { $can_access = $this_city->getValue('user_' . $LOGIN_DATA['user_id'] . '_access'); if ($can_access !== true && intval($can_access) > time()) { $can_access_time = ceil(($can_access - time()) / 60); } $can_access = $can_access === true || intval($can_access) > time(); } //end if ! can_access if ($can_access) { if (!$server) { $server = new server($_REQUEST['server_id']); } $buildings = mysql_query("SELECT building_id,name,description,cost FROM buildings WHERE server_id=" . $server->getID(), $db) or die(mysql_query()); while ($building = mysql_fetch_assoc($buildings)) { $building_list .= "\t\t\t" . '<li>'; $building_list .= htmlentities($building['name']); $building_list .= ' (' . intval($this_city->getValue($building['building_id'])) . ')'; if ($building['description']) { $building_list .= ' - ' . htmlentities($building['description']); } $building_list .= '</li>' . "\n"; $building_options .= "\t\t\t" . '<option value="' . $building['building_id'] . '">' . htmlentities($building['name']) . ' (' . $building['cost'] . ' Gold)</option>' . "\n"; } //end while building echo '<h3>Buildings</h3>'; echo '<ul>'; echo $building_list; echo '</ul>';
$is_owner = $LOGIN_DATA['user_id'] == $this_city->getValue('user')->getValue('userid'); $can_edit = $this_city->getValue('user_' . $LOGIN_DATA['user_id'] . '_edit'); $can_edit = $can_edit === true || intval($can_edit) > time(); if ($can_edit !== true && intval($can_edit) > time()) { $can_edit_time = ceil(($can_edit - time()) / 60); } $can_access = $this_city->getValue('user_' . $LOGIN_DATA['user_id'] . '_access'); if ($can_access !== true && intval($can_access) > time()) { $can_access_time = ceil(($can_access - time()) / 60); } $can_access = $can_access === true || intval($can_access) > time(); if ($can_access) { if (!$server) { $server = new server($_REQUEST['server_id']); } $units = mysql_query("SELECT unit_id,name,cost FROM units WHERE server_id=" . $server->getID(), $db) or die(mysql_query()); while ($unit = mysql_fetch_assoc($units)) { $transactions = mysql_query("SELECT unit_count,eta FROM server_unit_transaction WHERE server_id=" . $server->getID() . " AND unit_id=" . $unit['unit_id'] . " AND user_id=" . $this_city->getValue('user')->getValue('userid') . " AND destination=" . $this_city->getValue('id') . " ORDER BY eta DESC", $db) or die(mysql_query()); while ($transaction = mysql_fetch_assoc($transactions)) { $time_left = round(($transaction['eta'] - time()) / 60, 2); if ($time_left < 0) { $time_left = 0; } $unit_transaction_list .= "\t\t\t" . '<li>' . htmlentities($unit['name']) . ' (' . $transaction['unit_count'] . ') in ' . $time_left . ' minutes</li>' . "\n"; } //end while unit } //end while unit $buildings = mysql_query("SELECT building_id,name,cost FROM buildings WHERE server_id=" . $server->getID(), $db) or die(mysql_query()); while ($building = mysql_fetch_assoc($buildings)) { $transactions = mysql_query("SELECT eta FROM server_building_transaction WHERE server_id=" . $server->getID() . " AND building_id=" . $building['building_id'] . " AND user_id=" . $this_city->getValue('user')->getValue('userid') . " AND city_id=" . $this_city->getValue('id') . " ORDER BY eta DESC", $db) or die(mysql_query());
die('Please log in.'); } $_REQUEST['user_id'] = $LOGIN_DATA['user_id']; } $_REQUEST['user_id'] = intval($_REQUEST['user_id']); $_REQUEST['server_id'] = intval($_REQUEST['server_id']); if (!$server && $_REQUEST['server_id']) { $server = new server($_REQUEST['server_id']); } if ($_REQUEST['format'] == 'rss') { echo '<?xml version="1.0" encoding="utf-8" ?>' . "\n"; echo '<rss version="2.0">' . "\n"; echo '</rss>'; } else { echo '<h3>Recent Attacks</h3><ul>'; $attacks = mysql_query("SELECT destination,results,time FROM server_attack_results WHERE user_id=" . $_REQUEST['user_id'] . ($server ? " AND server_id=" . $server->getID() : '') . " ORDER BY time DESC LIMIT 5", $db) or die(mysql_error()); while ($attack = mysql_fetch_assoc($attacks)) { $dest = new city($attack['destination']); $class = $attack['results'] < 0 ? 'won' : 'lost'; echo '<li class="' . $class . '">'; echo ceil((time() - $attack['time']) / 60) . ' minutes ago: '; echo ' You attacked '; echo '<a href="/server/' . $dest->getValue('server')->getID() . '/city/' . $dest->getValue('id') . '">'; echo $dest->getValue('name') . ' (Location: ' . $dest->getValue('id') . ')'; echo '</a>'; echo ' and '; echo $class; echo ' by ' . abs($attack['results']); echo '</li>'; } //end while attacks