require "constants.php";
$title = "Anathema Online";
include "index-top.php";
if ($logged_in) {
$id = $_GET['id'];
$mode = $_POST['accept'];
if ($id) {
$conditions = "WHERE id='$id'";
$user1 = getInfo(user1,trades,$conditions);
$trade_money = getInfo(user1_money,trades,$conditions);
$trade_slaves = getInfo(user1_slaves,trades,$conditions);
$trade_places = getInfo(user1_buildings,trades,$conditions);
$trade_offer = getInfo(user1_items,trades,$conditions);
$trade_places = explode('.',$trade_places);
$max = count($trade_places);
for ($i = 0;$i < $max;$i++) {
$place = $trade_places[$i];
$place = getInfo(name,places,"WHERE id='$place'");
$trade_places[$i] = $place;
}
$trade_places = implode('.',$trade_places);
$trade_offer = explode('.',$trade_offer);
$max = count($trade_offer);
for ($i = 0;$i < $max;$i++) {
$item = $trade_offer[$i];
$conditions = "WHERE id='$item'";
$type = getInfo(type,user_items,$conditions);
if (($type == "food") || ($type == "drink") || ($type == "alcohol")) $trade_foods[] = $item;
if (($type == "clothing") || ($type == "weapon") || ($type == "armour")) $trade_clothes[] = $item;
if ($type == "other") $trade_other[] = $item;
if ($type == "relic") $trade_relics[] = $item;
if ($type == "resource") $trade_resources[] = $item;
if ($type == "crate") $trade_crates[] = $item;
if ($type == "material") $trade_materials[] = $item;
if ($type == "key") $trade_keys[] = $item;
if ($type == "door") $trade_doors[] = $item;
if ($type == "arrows") $trade_arrows[] = $item;
}
$conditions = "WHERE id='$id'";
$user2 = getInfo(user2,trades,$conditions);
$req_money = getInfo(user2_money,trades,$conditions);
$req_slaves = getInfo(user2_slaves,trades,$conditions);
$req_places = getInfo(user2_buildings,trades,$conditions);
$req_offer = getInfo(user2_items,trades,$conditions);
$req_places = explode('.',$req_places);
$max = count($req_places);
for ($i = 0;$i < $max;$i++) {
$place = $req_places[$i];
$place = getInfo(name,places,"WHERE id='$place'");
$req_places[$i] = $place;
}
$req_places = implode('.',$req_places);
$req_offer = explode('.',$req_offer);
$max = count($req_offer);
for ($i = 0;$i < $max;$i++) {
$item = $req_offer[$i];
$conditions = "WHERE id='$item'";
$type = getInfo(type,user_items,$conditions);
if (($type == "food") || ($type == "drink") || ($type == "alcohol")) $req_foods[] = $item;
if (($type == "clothing") || ($type == "weapon") || ($type == "armour")) $req_clothes[] = $item;
if ($type == "other") $req_other[] = $item;
if ($type == "relic") $req_relics[] = $item;
if ($type == "resource") $req_resources[] = $item;
if ($type == "crate") $req_crates[] = $item;
if ($type == "material") $req_materials[] = $item;
if ($type == "key") $req_keys[] = $item;
if ($type == "door") $req_doors[] = $item;
if ($type == "arrows") $req_arrows[] = $item;
}
if (($user2 == $userId) || ($user1 == $userId) || (admin($user_name))) {
if ($mode) {
if ($user2 == $userId) {
if ($mode == "Accept") {
$conditions = "WHERE id='$id'";
$user1 = getInfo(user1,trades,$conditions);
$user1_offer = getInfo(user1_items,trades,$conditions);
$user1_money = getInfo(user1_money,trades,$conditions);
$user1_slaves = getInfo(user1_slaves,trades,$conditions);
$user1_places = getInfo(user1_buildings,trades,$conditions);
$user2_offer = getInfo(user2_items,trades,$conditions);
$user2_money = getInfo(user2_money,trades,$conditions);
$user2_slaves = getInfo(user2_slaves,trades,$conditions);
$user2_places = getInfo(user2_buildings,trades,$conditions);
$user1_inventory = getInfo(inventory,users,"WHERE id='$user1'");
$user2_inventory = getInfo(inventory,users,"WHERE id='$user2'");
$user1Money = getInfo(money,users,"WHERE id='$user1'");
$user2Money = getInfo(money,users,"WHERE id='$user2'");
if ($user2_offer) {
$items = explode('.',$user2_offer);
$inventory = $user2_inventory;
$max = count($items);
$inventory = explode('.',$inventory);
for ($i = 0;$i < $max;$i++) {
$item = $items[$i];
if (!inArray($item,$inventory)) {
$error = "yes";
}
else {
$inventory = implode('.',$inventory);
$inventory = removeElement($item,$inventory,'.');
$inventory = explode('.',$inventory);
}
}
$inventory = implode('.',$inventory);
$user2_inventory = $inventory;
$query0 = "UPDATE users SET inventory='$user2_inventory' WHERE id='$user2'";
if ($user1_inventory) $user1_inventory .= '.'.$user2_offer;
else $user1_inventory = $user2_offer;
$query1 = "UPDATE users SET inventory='$user1_inventory' WHERE id='$user1'";
}
if ($user1_offer) {
$user2_inventory .= '.'.$user1_offer;
$query2 = "UPDATE users SET inventory='$user2_inventory' WHERE id='$user2'";
}
if ($user2_money) {
if ($user2Money - $user2_money < 0) $error = "yes";
else {
$user2moneyFinal = $user2Money - $user2_money;
$user1moneyFinal = $user1Money + $user2_money;
$user2Money = $user2moneyFinal;
$user1Money = $user1moneyFinal;
$query3a = "UPDATE users SET money='$user2moneyFinal' WHERE id='$user2'";
$query3b = "UPDATE users SET money='$user1moneyFinal' WHERE id='$user1'";
}
echo 'Error Money : '.$error.'
';
}
if ($user1_money) {
$user2moneyFinal = $user2Money + $user1_money;
$user2Money = $user2moneyFinal;
$query4 = "UPDATE users SET money='$user2moneyFinal' WHERE id='$user2'";
}
if ($user1_slaves) {
$user1_slaves = explode('.',$user1_slaves);
$max = count($user1_slaves);
for ($i = 0;$i < $max;$i++) {
$slave = $user1_slaves[$i];
if ((getInfo(master,users,"WHERE id='$slave'") == $user1) || ($slave == $user1) || (getInfo(NPC,users,"WHERE id='$slave'") == $user1)) {
#building
$max = numRows(places);
for ($i = 1;$i <= $max;$i++) {
$owner = getInfo(owner,places,"WHERE id='$i'");
$type = getInfo(type,places,"WHERE id='$i'");
$type = getInfo(label,buildings,"WHERE id='$type'");
if (($owner == $slave) && (($type == "ship") || ($type == "caravan"))) $slave1Buildings[] = $i;
}
#town
$max = numRows(towns);
for ($i = 1;$i <= $max;$i++) {
$leader = getInfo(leader,towns,"WHERE id='$i'");
if ($leader == $slave) $slave1Towns[] = $i;
}
#kingdom
$max = numRows(kingdoms);
for ($i = 1;$i <= $max;$i++) {
$leader = getInfo(leader,kingdoms,"WHERE id='$i'");
if ($leader == $slave) $slave1Kingdoms[] = $i;
}
}
else $error = "yes";
}
}
if ($user2_slaves) {
$user2_slaves = explode('.',$user2_slaves);
$max = count($user2_slaves);
for ($i = 0;$i < $max;$i++) {
$slave = $user2_slaves[$i];
if ((getInfo(master,users,"WHERE id='$slave'") == $user2) || ($slave == $user2) || (getInfo(NPC,users,"WHERE id='$slave'") == $user2)) {
if (getInfo(master,users,"WHERE id='$slave'") == $user2) $query6a = "UPDATE users SET master='$user1' WHERE id='$slave'";
if (getInfo(NPC,users,"WHERE id='$slave'") == $user2) $query6b = "UPDATE users SET NPC='$user1' WHERE id='$slave'";
#building
$max = numRows(places);
for ($i = 1;$i <= $max;$i++) {
$owner = getInfo(owner,places,"WHERE id='$i'");
$type = getInfo(type,places,"WHERE id='$i'");
$type = getInfo(label,buildings,"WHERE id='$type'");
if (($owner == $slave) && (($type == "ship") || ($type == "caravan"))) $slave2Buildings[] = $i;
}
#town
$max = numRows(towns);
for ($i = 1;$i <= $max;$i++) {
$leader = getInfo(leader,towns,"WHERE id='$i'");
if ($leader == $slave) $slave2Towns[] = $i;
}
#kingdom
$max = numRows(kingdoms);
for ($i = 1;$i <= $max;$i++) {
$leader = getInfo(leader,kingdoms,"WHERE id='$i'");
if ($leader == $slave) $slave2Kingdoms[] = $i;
}
}
else $error = "yes";
}
}
if ($user1_places) {
$user1_places = explode('.',$user1_places);
$max = count($user1_places);
for ($i = 0;$i < $max;$i++) {
$place = $user1_places[$i];
if (getInfo(owner,places,"WHERE id='$place'") != $user1) $error = "yes";
}
}
if ($user2_places) {
$user2_places = explode('.',$user2_places);
$max = count($user1_places);
for ($i = 0;$i < $max;$i++) {
$place = $user2_places[$i];
if (getInfo(owner,places,"WHERE id='$place'") != $user2) $error = "yes";
}
}
if (!$error) {
if ($query0) mysql_query($query0);
if ($query1) mysql_query($query1);
if ($query2) mysql_query($query2);
if ($query3a) mysql_query($query3a);
if ($query3b) mysql_query($query3b);
if ($query4) mysql_query($query4);
if ($user1_places) {
$max = count($user1_places);
for ($i = 0;$i < $max;$i++) {
$place = $user1_places[$i];
if (getInfo(owner,places,"WHERE id='$place'") == $user1) {
$query = "UPDATE places SET owner='$user2' WHERE id='$place'";
mysql_query($query);
}
}
}
if ($user2_places) {
$max = count($user2_places);
for ($i = 0;$i < $max;$i++) {
$place = $user2_places[$i];
if (getInfo(owner,places,"WHERE id='$place'") == $user2) {
$query8 = "UPDATE places SET owner='$user1' WHERE id='$place'";
mysql_query($query8);
}
}
}
if ($user1_slaves) {
$max = count($user1_slaves);
for ($i = 0;$i < $max;$i++) {
$slave = $user1_slaves[$i];
echo $slave;
if ((getInfo(master,users,"WHERE id='$slave'") == $user1) || ($slave == $user1) || (getInfo(NPC,users,"WHERE id='$slave'") == $user1)) {
$query = "UPDATE users SET master='$user2' WHERE id='$slave'";
mysql_query($query);
if (getInfo(NPC,users,"WHERE id='$slave'") == $user1) {
$query = "UPDATE users SET NPC='$user2' WHERE id='$slave'";
mysql_query($query);
}
}
}
}
if ($user2_slaves) {
$max = count($user2_slaves);
for ($i = 0;$i < $max;$i++) {
$slave = $user2_slaves[$i];
if ((getInfo(master,users,"WHERE id='$slave'") == $user2) || ($slave == $user2) || (getInfo(NPC,users,"WHERE id='$slave'") == $user2)) {
$query = "UPDATE users SET master='$user1' WHERE id='$slave'";
mysql_query($query);
if (getInfo(NPC,users,"WHERE id='$slave'") == $user2) {
$query = "UPDATE users SET NPC='$user1' WHERE id='$slave'";
mysql_query($query);
}
}
}
}
$max = count($slave1Buildings);
for ($i = 0;$i < $max;$i++) {
$building = $slave1Buildings[$i];
$type = getInfo(type,places,"WHERE id='$building'");
$type = getInfo(label,buildings,"WHERE id='$type'");
if (($type == "ship") || ($type == "caravan")) {
$query = "UPDATE places SET owner='$user2' WHERE id='$building'";
mysql_query($query);
}
}
$max = count($slave2Buildings);
for ($i = 0;$i < $max;$i++) {
$building = $slave2Buildings[$i];
$type = getInfo(type,places,"WHERE id='$building'");
$type = getInfo(label,buildings,"WHERE id='$type'");
if (($type == "ship") || ($type == "caravan")) {
$query = "UPDATE places SET owner='$user1' WHERE id='$building'";
mysql_query($query);
}
}
$max = count($slave1Towns);
for ($i = 0;$i < $max;$i++) {
$nationality1 = getInfo(nationality,users,"WHERE id='$user1'");
$town = $slave1Towns[$i];
$query = "UPDATE towns SET leader='$user1' WHERE id='$town'";
mysql_query($query);
$query = "UPDATE towns SET kingdom='$nationality1' WHERE id='$town'";
mysql_query($query);
}
$max = count($slave2Towns);
for ($i = 0;$i < $max;$i++) {
$nationality2 = getInfo(nationality,users,"WHERE id='$user2'");
$town = $slave2Towns[$i];
$query = "UPDATE towns SET leader='$user2' WHERE id='$town'";
mysql_query($query);
$query = "UPDATE towns SET kingdom='$nationality2' WHERE id='$town'";
mysql_query($query);
}
$max = count($slave1Kingdoms);
for ($i = 0;$i < $max;$i++) {
$kingdom = $slave1Kingdoms[$i];
$query = "UPDATE kingdoms SET leader='$user1' WHERE id='$kingdom'";
mysql_query($query);
}
$max = count($slave2Kingdoms);
for ($i = 0;$i < $max;$i++) {
$kingdom = $slave2Kingdoms[$i];
$query = "UPDATE kingdoms SET leader='$user2' WHERE id='$kingdom'";
mysql_query($query);
}
$query = "DELETE from trades WHERE id='$id'";
mysql_query($query);
echo '
';
echo '';
echo '';
echo '';
echo '
';
echo '';
echo '';
echo '| ';
echo 'The trade was successful.';
echo ' |
';
echo '';
echo '
';
$user2Name = getInfo(username,users,"WHERE id='$user2'");
$user1Name = getInfo(username,users,"WHERE id='$user1'");
$message = $_POST['message'];
if ($message) $message = "The trade with ".$user2Name." was successful. ".$user2Name." left you the following message :
".$message;
else $message = "The trade with ".$user2Name." was successful.";
sendMessage($user1Name,"Trade Successful",$message,"God");
} else {
$conditions = "WHERE id='$id'";
$user1 = getInfo(user1,trades,$conditions);
$user1Name = getInfo(username,users,"WHERE id='$user1'");
$user2Name = getInfo(username,users,"WHERE id='$user2'");
$user1_money = getInfo(user1_money,trades,$conditions);
$money = getInfo(money,users,"WHERE id='$user1'");
$user1_items = getInfo(user1_items,trades,$conditions);
$inventory = getInfo(inventory,users,"WHERE id='$user1'");
$money += $user1_money;
$inventory .= '.'.$user1_items;
$query = "UPDATE users SET money='$money' WHERE id='$user1'";
mysql_query($query);
$query = "UPDATE users SET inventory='$inventory' WHERE id='$user1'";
mysql_query($query);
echo '';
echo '';
echo '';
echo '';
echo '
';
echo '';
echo '';
echo '| ';
echo 'An error occurred. A likely cause would be that you or '.$user1Name.' are not in possession of certain items you wish to trade. Please make sure you have these items and try again.';
echo ' |
';
echo '';
echo '
';
$query = "DELETE from trades WHERE id='$id'";
mysql_query($query);
$message = "The trade with ".$user2Name." failed, because you or ".$user2Name." are not currently in possession of certain items you wish to exchange. Please make sure you are in possession of all items and try again.";
sendMessage($user1Name,"Trade Failed",$message,"God");
}
}
if ($mode == "Decline") {
$conditions = "WHERE id='$id'";
$user1 = getInfo(user1,trades,$conditions);
$user2 = getInfo(user2,trades,$conditions);
$user1_money = getInfo(user1_money,trades,$conditions);
$money = getInfo(money,users,"WHERE id='$user1'");
$user1_items = getInfo(user1_items,trades,$conditions);
$inventory = getInfo(inventory,users,"WHERE id='$user1'");
$money += $user1_money;
$inventory .= '.'.$user1_items;
$user1Name = getInfo(username,users,"WHERE id='$user1'");
$user2Name = getInfo(username,users,"WHERE id='$user2'");
$query = "UPDATE users SET money='$money' WHERE id='$user1'";
mysql_query($query);
$query = "UPDATE users SET inventory='$inventory' WHERE id='$user1'";
mysql_query($query);
echo '';
echo '';
echo '';
echo '';
echo '
';
echo '';
echo '';
echo '| ';
echo ''.$user1Name.' has been notified that you have declined the trade.';
echo ' |
';
echo '';
echo '
';
$query = "DELETE from trades WHERE id='$id'";
mysql_query($query);
$message = $_POST['message'];
if ($message) $message = $user2Name." declined the trade and left the following message :
".$message;
else $message = $user2Name." declined the trade.";
sendMessage($user1Name,"Trade Declined",$message,"God");
}
}
} else {
$user1Name = getInfo(username,users,"WHERE id='$user1'");
$user2Name = getInfo(username,users,"WHERE id='$user2'");
if ($user2 == $userId) {
echo '
';
}
echo '';
echo '';
echo '';
echo '';
echo '';
echo '';
echo ' ';
echo '';
echo '';
echo '';
$trade_slaves = explode('.',$trade_slaves);
$max = count($trade_slaves);
for ($i = 0;$i < $max;$i++) {
$slave = $trade_slaves[$i];
$trade_slaves[$i] = getInfo(username,users,"WHERE id='$slave'");
}
$trade_slaves = implode('.',$trade_slaves);
echo '';
if ($trade_money) echo ' Money : '.$trade_money;
if ($trade_slaves) echo ' Slaves : '.implode(', ',explode('.',$trade_slaves));
if ($trade_places) echo ' Buildings/Land : '.implode(', ',explode('.',$trade_places));
echo ' | ';
echo ' ';
echo '';
echo ' ';
echo '';
echo '';
echo '';
echo '';
echo '';
echo '';
if ($trade_clothes) {
echo '';
$max = count($trade_clothes);
for ($i = 0;$i < $max;$i++) {
$item = $trade_clothes[$i];
$conditions = "WHERE id='$item'";
$name = getInfo(name,user_items,$conditions);
$item = getInfo(item,user_items,$conditions);
$image = displayClothing($item);
$item = $trade_clothes[$i];
if ($i % 2 == 0) echo '';
echo ''.$name.'
 ';
echo ' | ';
if ((($i + 1) % 2 == 0) || ($i + 1 == $max)) echo ' | ';
}
echo ' ';
}
if ($trade_foods) {
$max = count($trade_foods);
echo '';
for ($i = 0;$i < $max;$i++) {
$item = $trade_foods[$i];
$conditions = "WHERE id='$item'";
$name = getInfo(name,user_items,$conditions);
$type = getInfo(type,user_items,$conditions);
$stat = getInfo("stat",user_items,$conditions);
if ($type == "food") {
$stats = '+'.$stat.' health';
$type = "Food";
}
if ($type == "drink") {
$stats = '+'.$stat.' mana';
$type = "Drink";
}
if ($type == "alcohol") {
$stats = '+'.$stat.' health +'.$stat.' intoxication';
$type = "Alcohol";
}
if ($i % 2 == 0) echo '';
echo ''.$name.' '.$type.' '.$stats.'';
echo ' | ';
if ((($i + 1) % 2 == 0) || ($i + 1 == $max)) echo ' | ';
}
echo ' ';
}
if ($trade_other) {
echo '';
if ($trade_other) {
$max = count($trade_other);
for ($i = 0;$i < $max;$i++) {
$item = $trade_other[$i];
$conditions = "WHERE id='$item'";
$name = getInfo(name,user_items,$conditions);
if ($i % 2 == 0) echo '';
echo '| '.$name.'';
echo ' | ';
if ((($i + 1) % 2 == 0) || ($i + 1 == $max)) echo ' | ';
}
}
echo ' ';
}
if ($trade_relics) {
echo '';
if ($trade_relics) {
$max = count($trade_relics);
for ($i = 0;$i < $max;$i++) {
$item = $trade_relics[$i];
$conditions = "WHERE id='$item'";
$item = getInfo(item,user_items,$conditions);
$conditions = "WHERE id='$item'";
$creator = getInfo(creator,items,$conditions);
$name = getInfo(name,items,$conditions);
$item = $trade_relics[$i];
if ($i % 2 == 0) echo '';
echo '| '.$creator.'\'s '.$name.'';
echo ' | ';
if ((($i + 1) % 2 == 0) || ($i + 1 == $max)) echo ' | ';
}
}
echo ' ';
}
if ($trade_crates) {
echo '';
if ($trade_crates) {
$max = count($trade_crates);
for ($i = 0;$i < $max;$i++) {
$item = $trade_crates[$i];
$conditions = "WHERE id='$item'";
$name = getInfo(name,user_items,$conditions);
if ($i % 2 == 0) echo '';
echo '| '.$name.'';
echo ' | ';
if ((($i + 1) % 2 == 0) || ($i + 1 == $max)) echo ' | ';
}
}
echo ' ';
}
if ($trade_arrows) {
echo '';
if ($trade_arrows) {
$max = count($trade_arrows);
for ($i = 0;$i < $max;$i++) {
$item = $trade_arrows[$i];
$conditions = "WHERE id='$item'";
$name = getInfo(name,user_items,$conditions);
if ($i % 2 == 0) echo '';
echo '| '.$name.'';
echo ' | ';
if ((($i + 1) % 2 == 0) || ($i + 1 == $max)) echo ' | ';
}
}
echo ' ';
}
if ($trade_resources) {
echo '';
if ($trade_resources) {
$max = count($trade_resources);
for ($i = 0;$i < $max;$i++) {
$item = $trade_resources[$i];
$conditions = "WHERE id='$item'";
$name = getInfo(name,user_items,$conditions);
if ($i % 2 == 0) echo '';
echo '| '.$name.'';
echo ' | ';
if ((($i + 1) % 2 == 0) || ($i + 1 == $max)) echo ' | ';
}
}
echo ' ';
}
if ($trade_materials) {
echo '';
if ($trade_materials) {
$max = count($trade_materials);
for ($i = 0;$i < $max;$i++) {
$item = $trade_materials[$i];
$conditions = "WHERE id='$item'";
$name = getInfo(name,user_items,$conditions);
if ($i % 2 == 0) echo '';
echo '| '.$name.'';
echo ' | ';
if ((($i + 1) % 2 == 0) || ($i + 1 == $max)) echo ' | ';
}
}
echo ' ';
}
if ($trade_keys) {
echo '';
if ($trade_keys) {
$max = count($trade_keys);
for ($i = 0;$i < $max;$i++) {
$item = $trade_keys[$i];
$conditions = "WHERE id='$item'";
$name = getInfo(name,user_items,$conditions);
if ($i % 2 == 0) echo '';
echo '| '.$name.'';
echo ' | ';
if ((($i + 1) % 2 == 0) || ($i + 1 == $max)) echo ' | ';
}
}
echo ' ';
}
if ($trade_doors) {
echo '';
if ($trade_doors) {
$max = count($trade_doors);
for ($i = 0;$i < $max;$i++) {
$item = $trade_doors[$i];
$conditions = "WHERE id='$item'";
$name = getInfo(name,user_items,$conditions);
if ($i % 2 == 0) echo '';
echo '| '.$name.'';
echo ' | ';
if ((($i + 1) % 2 == 0) || ($i + 1 == $max)) echo ' | ';
}
}
echo ' ';
}
echo ' | ';
echo ' ';
echo '';
echo ' ';
echo '';
echo ' | | ';
echo '';
echo '';
echo '';
echo '';
echo '';
echo '';
echo ' ';
echo '';
echo '';
echo '';
$req_slaves = explode('.',$req_slaves);
$max = count($req_slaves);
for ($i = 0;$i < $max;$i++) {
$slave = $req_slaves[$i];
$req_slaves[$i] = getInfo(username,users,"WHERE id='$slave'");
}
$req_slaves = implode('.',$req_slaves);
echo '';
if ($req_money) echo ' Money : '.$req_money;
if ($req_slaves) echo ' Slaves : '.implode(', ',explode('.',$req_slaves));
if ($req_places) echo ' Buildings/Land : '.implode(', ',explode('.',$req_places));
echo ' | ';
echo ' ';
echo '';
echo ' ';
echo '';
echo '';
echo '';
echo '';
echo '';
echo '';
if ($req_clothes) {
echo '';
$max = count($req_clothes);
for ($i = 0;$i < $max;$i++) {
$item = $req_clothes[$i];
$conditions = "WHERE id='$item'";
$name = getInfo(name,user_items,$conditions);
$item = getInfo(item,user_items,$conditions);
$image = displayClothing($item);
$item = $req_clothes[$i];
if ($i % 2 == 0) echo '';
echo ''.$name.'
 ';
echo ' | ';
if ((($i + 1) % 2 == 0) || ($i + 1 == $max)) echo ' | ';
}
echo ' ';
}
if ($req_foods) {
$max = count($req_foods);
echo '';
for ($i = 0;$i < $max;$i++) {
$item = $req_foods[$i];
$conditions = "WHERE id='$item'";
$name = getInfo(name,user_items,$conditions);
$type = getInfo(type,user_items,$conditions);
$stat = getInfo("stat",user_items,$conditions);
if ($type == "food") {
$stats = '+'.$stat.' health';
$type = "Food";
}
if ($type == "drink") {
$stats = '+'.$stat.' mana';
$type = "Drink";
}
if ($type == "alcohol") {
$stats = '+'.$stat.' health +'.$stat.' intoxication';
$type = "Alcohol";
}
if ($i % 2 == 0) echo '';
echo ''.$name.' '.$type.' '.$stats.'';
echo ' | ';
if ((($i + 1) % 2 == 0) || ($i + 1 == $max)) echo ' | ';
}
echo ' ';
}
if ($req_other) {
echo '';
if ($req_other) {
$max = count($req_other);
for ($i = 0;$i < $max;$i++) {
$item = $req_other[$i];
$conditions = "WHERE id='$item'";
$name = getInfo(name,user_items,$conditions);
$price = getInfo(price,user_items,$conditions);
if ($i % 2 == 0) echo '';
echo '| '.$name.'';
echo ' | ';
if ((($i + 1) % 2 == 0) || ($i + 1 == $max)) echo ' | ';
}
}
echo ' ';
}
if ($req_relics) {
echo '';
if ($req_relics) {
$max = count($req_relics);
for ($i = 0;$i < $max;$i++) {
$item = $req_relics[$i];
$conditions = "WHERE id='$item'";
$item = getInfo(item,user_items,$conditions);
$conditions = "WHERE id='$item'";
$creator = getInfo(creator,items,$conditions);
$name = getInfo(name,items,$conditions);
$item = $req_relics[$i];
if ($i % 2 == 0) echo '';
echo '| '.$creator.'\'s '.$name.'';
echo ' | ';
if ((($i + 1) % 2 == 0) || ($i + 1 == $max)) echo ' | ';
}
}
echo ' ';
}
if ($req_arrows) {
echo '';
if ($req_arrows) {
$max = count($req_arrows);
for ($i = 0;$i < $max;$i++) {
$item = $req_arrows[$i];
$conditions = "WHERE id='$item'";
$name = getInfo(name,user_items,$conditions);
if ($i % 2 == 0) echo '';
echo '| '.$name.'';
echo ' | ';
if ((($i + 1) % 2 == 0) || ($i + 1 == $max)) echo ' | ';
}
}
echo ' ';
}
if ($req_resources) {
echo '';
if ($req_resources) {
$max = count($req_resources);
for ($i = 0;$i < $max;$i++) {
$item = $req_resources[$i];
$conditions = "WHERE id='$item'";
$name = getInfo(name,user_items,$conditions);
if ($i % 2 == 0) echo '';
echo '| '.$name.'';
echo ' | ';
if ((($i + 1) % 2 == 0) || ($i + 1 == $max)) echo ' | ';
}
}
echo ' ';
}
if ($req_materials) {
echo '';
if ($req_materials) {
$max = count($req_materials);
for ($i = 0;$i < $max;$i++) {
$item = $req_materials[$i];
$conditions = "WHERE id='$item'";
$name = getInfo(name,user_items,$conditions);
if ($i % 2 == 0) echo '';
echo '| '.$name.'';
echo ' | ';
if ((($i + 1) % 2 == 0) || ($i + 1 == $max)) echo ' | ';
}
}
echo ' ';
}
if ($req_keys) {
echo '';
if ($req_keys) {
$max = count($req_keys);
for ($i = 0;$i < $max;$i++) {
$item = $req_keys[$i];
$conditions = "WHERE id='$item'";
$name = getInfo(name,user_items,$conditions);
if ($i % 2 == 0) echo '';
echo '| '.$name.'';
echo ' | ';
if ((($i + 1) % 2 == 0) || ($i + 1 == $max)) echo ' | ';
}
}
echo ' ';
}
if ($req_doors) {
echo '';
if ($req_doors) {
$max = count($req_doors);
for ($i = 0;$i < $max;$i++) {
$item = $req_doors[$i];
$conditions = "WHERE id='$item'";
$name = getInfo(name,user_items,$conditions);
if ($i % 2 == 0) echo '';
echo '| '.$name.'';
echo ' | ';
if ((($i + 1) % 2 == 0) || ($i + 1 == $max)) echo ' | ';
}
}
echo ' ';
}
if ($req_crates) {
echo '';
if ($req_crates) {
$max = count($req_crates);
for ($i = 0;$i < $max;$i++) {
$item = $req_crates[$i];
$conditions = "WHERE id='$item'";
$name = getInfo(name,user_items,$conditions);
if ($i % 2 == 0) echo '';
echo '| '.$name.'';
echo ' | ';
if ((($i + 1) % 2 == 0) || ($i + 1 == $max)) echo ' | ';
}
}
echo ' ';
}
echo ' | ';
echo ' ';
echo ' ';
echo ' |
|
';
echo '';
echo '';
}
} else {
echo '';
echo '';
echo '';
echo '';
echo '';
echo '
';
echo '';
echo '';
echo '';
echo '| ';
echo 'You are not allowed to view this.';
echo ' | ';
echo '
';
echo '';
echo '
';
echo '';
}
} else {
echo '';
echo '';
echo '';
}
} else {
echo '';
echo '';
echo '';
echo '';
echo '';
echo '
';
echo '';
echo '';
echo '';
echo '| ';
echo 'You must login to view this.';
echo ' | ';
echo '
';
echo '';
echo '
';
echo '';
}
include "index-bottom.php"
?>