require "constants.php";
$title = "Anathema Online";
include "index-top.php";
?>
$town = $_GET['town'];
$conditions = "WHERE id='$town'";
$townName = getInfo(name,towns,$conditions);
$leader = getInfo(leader,towns,"WHERE id='$town'");
$leaderName = getInfo(username,users,"WHERE id='$leader'");
if ($townName) {
if ($_POST['mode'] == "claim") {
if (numRowsConditions(users,"WHERE guard='$town' and town='$town' and status='conscious'") > 0) $failure = "There are conscious guards in this town.";
if ((getInfo(town,users,"WHERE id='$leader'") == $town) && (getInfo(status,users,"WHERE id='$leader'") == "conscious")) $failure = "The baron is in town and is conscious.";
$result = getRows(lords,"WHERE town='$town'");
while ($row = mysql_fetch_array($result)) {
$lord = $row['name'];
if ((getInfo(town,users,"WHERE id='$lord'") == $town) && (getInfo(status,users,"WHERE id='$lord'") == "conscious")) $failure = "There is at least one conscious lord still in the town.";
$knights = explode('.',$row['knights']);
$max = count($knights);
for ($i = 0;$i < $max;$i++) {
$knight = $knights[$i];
if ((getInfo(town,users,"WHERE id='$knight'") == $town) && (getInfo(status,users,"WHERE id='$knight'") == "conscious")) $failure = "There is at least one conscious knight still in the town.";
}
}
if (rank($user) < 40) $failure = "You are not a lord.";
if (getInfo(town,users,"WHERE id='$userId'") != $town) $failure = "You are not in this town.";
if (!$failure) {
$query = "UPDATE towns SET leader='$userId' WHERE id='$town'";
mysql_query($query);
sendMessage($leaderName,"Your Town","Your town has been taken over by $user_name.","God");
echo '
';
echo '';
echo '';
echo '';
echo '
';
echo '';
echo '';
echo '';
echo '| ';
echo 'You have claimed this town for yourself.';
echo ' | ';
echo '
';
echo '';
echo '
';
echo '
';
} else {
echo '';
echo '';
echo '';
echo '';
echo '
';
echo '';
echo '';
echo '';
echo '| ';
echo ''.$failure.'';
echo ' | ';
echo '
';
echo '';
echo '
';
echo '
';
}
}
echo '';
echo '';
echo '';
echo '';
echo '';
echo '
';
echo '';
echo '';
echo '';
echo '| ';
$conditions = "WHERE id='$town'";
$description = getInfo(description,towns,$conditions);
echo $description;
echo ' | ';
echo '
';
$numdistricts = numRowsConditions(districts,"WHERE town='$town'");
if ($numdistricts <= 1) {
if (numRowsConditions(places,"WHERE town='$town' and abandoned='abandoned'") > 0) echo '| View Archives for Abandoned Buildings |
';
}
echo '';
echo '
';
if ((getInfo(town,users,"WHERE id='$userId'") == $town) && ((numRowsConditions(users,"WHERE guard='$town' and town='$town' and status='conscious'") <= 0) && ((getInfo(town,users,"WHERE id='$leader'") != $town) || (getInfo(status,users,"WHERE id='$leader'") != "conscious"))) && (rank($userId) >= 30) && (getInfo(town,lords,"WHERE name='$userId'") != $town) && (!getInfo(developed,towns,"WHERE id='$town'"))) echo '
';
$userTown = getInfo(town,users,"WHERE username='$user_name'");
/*
if ($userTown != $town) {
if ((!getInfo(locked,towns,"WHERE id='$town'")) && (!getInfo(locked,towns,"WHERE id='$userTown'"))) echo '
';
}
*/
echo '
';
if ($numdistricts <= 1) {
if (numRowsConditions(places,"WHERE town='$town' and abandoned='' and (type!='28' and type!='29' and type!='21' and type!='23' and type!='37')") > 0) {
echo '';
echo '';
echo '';
echo '';
if (!getInfo(developed,towns,"WHERE id='$town'")) {
echo '';
echo '';
echo '';
echo '';
echo '';
}
echo '';
echo '
';
$time = time() - (3600 * 24 * 7);
$max = numRows(places);
$result = getRows(places,"WHERE town='$town' and abandoned='' and hidden='' and (type!='28' and type!='29' and type!='21' and type!='23' and type!='37') ORDER BY list_order DESC, id ASC");
while ($row = mysql_fetch_array($result)) {
unset($font);
$name = stripslashes($row['name']);
if (!$name) $name = "----";
$id = $row['id'];
echo '';
echo '| ';
$counter = numRowsConditions(rooms,"WHERE place='$id' and hidden=''");
$fire = getInfo(id,fires,"WHERE place='$id'");
if ($fire) $font = ' color="#f97400"';
if ($counter == 1) {
$conditions = "WHERE place='$id'";
$room = getInfo(id,rooms,$conditions);
echo ''.$name.'';
} else echo ''.$name.'';
unset($fire);
unset($font);
echo ' | ';
if (!getInfo(developed,towns,"WHERE id='$town'")) {
$owner = $row['owner'];
$owner = getInfo(username,users,"WHERE id='$owner'");
echo '';
if ($owner != "God") echo $owner;
echo ' | ';
echo '';
$type = $row['type'];
$type = getInfo(type,buildings,"WHERE id='$type'");
$type = capitalize($type);
echo $type;
echo ' | ';
echo '';
echo $counter;
echo ' | ';
echo '';
echo getInfo(burn,places,"WHERE id='$id'");
echo ' | ';
echo '';
echo getInfo(health,places,"WHERE id='$id'");
echo ' | ';
}
$counter = numRowsConditions(users,"WHERE location='$id' and status != 'dead' and logged >='$time'");
echo '';
echo $counter;
echo ' | ';
echo '
';
}
echo '';
echo '
';
echo '
';
}
if (numRowsConditions(places,"WHERE town='$town' and abandoned='' and type='28'") > 0) {
echo '';
echo '';
echo '';
echo '';
if (!getInfo(developed,towns,"WHERE id='$town'")) {
echo '';
echo '';
echo '';
echo '';
echo '';
}
echo '';
echo '
';
$time = time() - (3600 * 24 * 7);
$max = numRows(places);
$result = getRows(places,"WHERE town='$town' and abandoned='' and hidden='' and type='28' ORDER BY id ASC");
while ($row = mysql_fetch_array($result)) {
unset($font);
$name = stripslashes($row['name']);
if (!$name) $name = "----";
$id = $row['id'];
echo '';
echo '| ';
$counter = numRowsConditions(rooms,"WHERE place='$id' and hidden=''");
$fire = getInfo(id,fires,"WHERE place='$id'");
if ($fire) $font = ' color="#f97400"';
if ($counter == 1) {
$conditions = "WHERE place='$id'";
$room = getInfo(id,rooms,$conditions);
echo ''.$name.'';
} else echo ''.$name.'';
unset($fire);
unset($font);
echo ' | ';
if (!getInfo(developed,towns,"WHERE id='$town'")) {
$owner = $row['owner'];
$owner = getInfo(username,users,"WHERE id='$owner'");
echo '';
if ($owner != "God") echo $owner;
echo ' | ';
echo '';
$type = $row['type'];
$type = getInfo(type,buildings,"WHERE id='$type'");
$type = capitalize($type);
echo $type;
echo ' | ';
echo '';
echo $counter;
echo ' | ';
echo '';
echo getInfo(burn,places,"WHERE id='$id'");
echo ' | ';
echo '';
echo getInfo(health,places,"WHERE id='$id'");
echo ' | ';
}
$counter = numRowsConditions(users,"WHERE location='$id' and status != 'dead' and logged >='$time'");
echo '';
echo $counter;
echo ' | ';
echo '
';
}
echo '';
echo '
';
echo '
';
}
if (numRowsConditions(places,"WHERE town='$town' and abandoned='' and (type='29' or type='21' or type='23' or type='37')") > 0) {
echo '';
echo '';
echo '';
echo '';
if (!getInfo(developed,towns,"WHERE id='$town'")) {
echo '';
echo '';
echo '';
echo '';
echo '';
}
echo '';
echo '
';
$time = time() - (3600 * 24 * 7);
$max = numRows(places);
$result = getRows(places,"WHERE town='$town' and abandoned='' and (type='29' or type='21' or type='23' or type='37') ORDER BY id ASC");
while ($row = mysql_fetch_array($result)) {
unset($font);
$name = stripslashes($row['name']);
if (!$name) $name = "----";
$id = $row['id'];
echo '';
echo '| ';
$counter = numRowsConditions(rooms,"WHERE place='$id' and hidden=''");
$fire = getInfo(id,fires,"WHERE place='$id'");
if ($fire) $font = ' color="#f97400"';
if ($counter == 1) {
$conditions = "WHERE place='$id'";
$room = getInfo(entrance,places,"WHERE id='$id'");
if (!$room) $room = getInfo(id,rooms,$conditions);
echo ''.$name.'';
} else echo ''.$name.'';
unset($fire);
unset($font);
echo ' | ';
if (!getInfo(developed,towns,"WHERE id='$town'")) {
$owner = $row['owner'];
$owner = getInfo(username,users,"WHERE id='$owner'");
echo '';
if ($owner != "God") echo $owner;
echo ' | ';
echo '';
$type = $row['type'];
$type = getInfo(type,buildings,"WHERE id='$type'");
$type = capitalize($type);
echo $type;
echo ' | ';
echo '';
echo $counter;
echo ' | ';
echo '';
echo getInfo(burn,places,"WHERE id='$id'");
echo ' | ';
echo '';
echo getInfo(health,places,"WHERE id='$id'");
echo ' | ';
}
$counter = numRowsConditions(users,"WHERE location='$id' and status != 'dead' and logged >='$time'");
echo '';
echo $counter;
echo ' | ';
echo '
';
}
echo '';
echo '
';
echo '
';
}
} else {
echo '';
echo '';
echo '';
echo '';
echo '';
echo '';
echo '';
echo '
';
$result = getRows(districts,"WHERE town='$town' ORDER BY outskirts ASC");
while ($row = mysql_fetch_array($result)) {
unset($font);
$name = stripslashes($row['name']);
if (!$name) $name = "----";
$district = $row['id'];
echo '';
echo '| ';
echo ''.$name.'';
echo ' | ';
$owner = $row['owner'];
$owner = getInfo(username,users,"WHERE id='$owner'");
echo '';
if ($owner != "God") echo $owner;
echo ' | ';
$counter = numRowsConditions(places,"WHERE district='$district' and abandoned=''");
echo '';
echo $counter;
echo ' | ';
echo '
';
}
echo '';
echo '
';
echo '
';
}
$district = getInfo(id,districts,"WHERE town='$town'");
if (!getInfo(developed,towns,"WHERE id='$town'")) echo '
';
if (numRowsConditions(districts,"WHERE town='$town'") <= 1) echo '
';
echo '';
} else {
echo '';
echo '';
echo '';
echo '';
echo '';
echo '
';
echo '';
echo '';
echo '';
echo '| ';
echo 'This town does not exist.';
echo ' | ';
echo '
';
echo '';
echo '
';
echo '';
}
?>
include "index-bottom.php"
?>