'; } 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 ''; echo '
'; echo '
Trade Successful
'; echo '
'; echo '
The trade was successful.
'; 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 ''; echo '
'; echo '
Error
'; 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 '
'; $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 ''; echo '
'; echo '
Trade Declined
'; echo '
'; echo '
'.$user1Name.' has been notified that you have declined the trade.
'; 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 '
'; echo '
Offer
'; echo '
'; echo '
This is the trade '.$user1Name.' has requested. Please look over the details of the trade and choose whether or not you accept or decline. You may also choose to leave '.$user1Name.' a message.
'; echo '
'; echo '
'; echo '

'; } 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 ''; echo ''; echo ''; echo '
'; echo '
Offer
'; 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 ''; if ((($i + 1) % 2 == 0) || ($i + 1 == $max)) echo ''; } echo '
'.$name.'


'; 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 ''; if ((($i + 1) % 2 == 0) || ($i + 1 == $max)) echo ''; } echo '
'.$name.'

'.$type.'
'.$stats.''; 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 ''; if ((($i + 1) % 2 == 0) || ($i + 1 == $max)) echo ''; } } echo '
'.$name.'
'; 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 ''; if ((($i + 1) % 2 == 0) || ($i + 1 == $max)) echo ''; } } echo '
'.$creator.'\'s '.$name.'
'; 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 ''; if ((($i + 1) % 2 == 0) || ($i + 1 == $max)) echo ''; } } echo '
'.$name.'
'; 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 ''; if ((($i + 1) % 2 == 0) || ($i + 1 == $max)) echo ''; } } echo '
'.$name.'
'; 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 ''; if ((($i + 1) % 2 == 0) || ($i + 1 == $max)) echo ''; } } echo '
'.$name.'
'; 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 ''; if ((($i + 1) % 2 == 0) || ($i + 1 == $max)) echo ''; } } echo '
'.$name.'
'; 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 ''; if ((($i + 1) % 2 == 0) || ($i + 1 == $max)) echo ''; } } echo '
'.$name.'
'; 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 ''; if ((($i + 1) % 2 == 0) || ($i + 1 == $max)) echo ''; } } echo '
'.$name.'
'; 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 ''; echo ''; echo ''; echo '
'; echo '
Request
'; 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 '
'; 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 ''; if ((($i + 1) % 2 == 0) || ($i + 1 == $max)) echo ''; } echo '
'.$name.'


'; 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 ''; if ((($i + 1) % 2 == 0) || ($i + 1 == $max)) echo ''; } echo '
'.$name.'

'.$type.'
'.$stats.''; 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 ''; if ((($i + 1) % 2 == 0) || ($i + 1 == $max)) echo ''; } } echo '
'.$name.'
'; 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 ''; if ((($i + 1) % 2 == 0) || ($i + 1 == $max)) echo ''; } } echo '
'.$creator.'\'s '.$name.'
'; 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 ''; if ((($i + 1) % 2 == 0) || ($i + 1 == $max)) echo ''; } } echo '
'.$name.'
'; 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 ''; if ((($i + 1) % 2 == 0) || ($i + 1 == $max)) echo ''; } } echo '
'.$name.'
'; 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 ''; if ((($i + 1) % 2 == 0) || ($i + 1 == $max)) echo ''; } } echo '
'.$name.'
'; 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 ''; if ((($i + 1) % 2 == 0) || ($i + 1 == $max)) echo ''; } } echo '
'.$name.'
'; 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 ''; if ((($i + 1) % 2 == 0) || ($i + 1 == $max)) echo ''; } } echo '
'.$name.'
'; 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 ''; if ((($i + 1) % 2 == 0) || ($i + 1 == $max)) echo ''; } } echo '
'.$name.'
'; echo '

'; } echo '
'; echo '
'; echo ''; echo ''; } } else { echo '
'; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo '
'; echo '
Error
'; echo '
'; echo '
You are not allowed to view this.
'; echo '
'; echo '
'; } } else { echo '
'; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo '
'; echo '
Error
'; echo '
'; echo '
Please select a trade session to view.
'; echo '
Id :

'; echo '
'; echo '
'; echo '
'; } } else { echo '
'; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo '
'; echo '
Error
'; echo '
'; echo '
You must login to view this.
'; echo '
'; echo '
'; } include "index-bottom.php" ?>