> WHERE isactive='1' ORDER BY honor"), "id"); $row["guildlist"] = ""; $bgcolor = "background-color: #ffffff;"; if ($guilds != false) { foreach($guilds as $a => $b) { if ($userrow["guild"] == 0) { $applylink = "Apply to Join | "; } else { $applylink = ""; } $row["guildlist"] .= "\n"; if ($bgcolor == "background-color: #ffffff;") { $bgcolor = "background-color: #dddddd;"; } else { $bgcolor = "background-color: #ffffff;"; } } } else { $row["guildlist"] .= ""; } $row["guildlist"] .= "
Guild Name & TagHonorFunctions
[".$b["tagline"]."] ".$b["name"]."".$b["honor"]."$applylinkMember List
No Guilds have been created yet.

"; display("Guild Hall", parsetemplate(gettemplate("guild_list"), $row)); } function guildhome() { global $userrow, $controlrow; if ($userrow["guild"] == 0) { err("You are not yet a member of any Guild. Please go back and try again."); } $guild = dorow(doquery("SELECT * FROM <> WHERE id='".$userrow["guild"]."' LIMIT 1")); if ($guild["lastupdate"] <= (mktime() - ($controlrow["guildupdate"] * 3600))) { $guild = guildupdate(); } switch($userrow["guildrank"]) { case 1: $template = "guild_homelow"; break; case 2: $template = "guild_homelow"; break; case 3: $template = "guild_homelow"; break; case 4: $template = "guild_homemid"; break; case 5: $template = "guild_homehigh"; break; default: $template = "guild_homelow"; break; } // Setup Babblebox. $pagerow["babblebox"] = "
Guild Babblebox
\n"; // Setup Bank. $pagerow["bank"] = number_format($guild["bank"]); // Pull memberslist for select box. $members = dorow(doquery("SELECT * FROM <> WHERE guild='".$userrow["guild"]."' ORDER BY guildrank"), "id"); $pagerow["memberselect"] = ""; // Pull applications for selectbox. $apps = dorow(doquery("SELECT * FROM <> WHERE guild='".$userrow["guild"]."' ORDER BY id"), "id"); if ($apps != false) { $pagerow["appselect"] = "
"; } else { $pagerow["appselect"] = "No new applications."; } // Set up everything else. if (trim($guild["news"]) != "") { $pagerow["news"] = nl2br($guild["news"]); } else { $pagerow["news"] = "No news yet."; } $title = "[".$guild["tagline"]."] ".$guild["name"] . " (Honor: ".$guild["honor"].")"; display($title, parsetemplate(gettemplate($template),$pagerow)); } function guildcreate() { global $controlrow, $userrow; // Errors. if ($userrow["gold"] < $controlrow["guildstartup"]) { err("You do not have enough gold to create a Guild. Starting your own Guild requires ".number_format($controlrow["guildstartup"])." gold. Please go back and try again."); } if ($userrow["guild"] != 0) { err("You are already a member of another Guild. You must renounce your current membership before starting your own Guild. Please go back and try again."); } $appquery = doquery("SELECT * FROM <> WHERE charid='".$userrow["id"]."' LIMIT 1"); if (mysql_num_rows($appquery) != 0) { err("You have already applied to join another Guild. Please go back and try again."); } if ($userrow["level"] < $controlrow["guildstartlvl"]) { err("You cannot join a guild until you are at least Level ".$controlrow["guildstartlvl"].". Please continue playing until your character is Level ".$controlrow["guildstartlvl"].", then try again."); } if (isset($_POST["submit"])) { extract($_POST); // Errors. $errors = 0; $errorlist = ""; if (preg_match("/[^A-z\ 0-9_\-]/", $name)==1) { $errors++; $errorlist .= "Guild names can only contain letters, numbers, spaces and hyphens.
"; } // Thanks to "Carlos Pires" from php.net! if (preg_match("/[^A-z\ 0-9_\-]/", $rank1)==1) { $errors++; $errorlist .= "Rank 1 can only contain letters, numbers, spaces and hyphens.
"; } // Thanks to "Carlos Pires" from php.net! if (preg_match("/[^A-z\ 0-9_\-]/", $rank2)==1) { $errors++; $errorlist .= "Rank 2 can only contain letters, numbers, spaces and hyphens.
"; } // Thanks to "Carlos Pires" from php.net! if (preg_match("/[^A-z\ 0-9_\-]/", $rank3)==1) { $errors++; $errorlist .= "Rank 3 can only contain letters, numbers, spaces and hyphens.
"; } // Thanks to "Carlos Pires" from php.net! if (preg_match("/[^A-z\ 0-9_\-]/", $rank4)==1) { $errors++; $errorlist .= "Rank 4 can only contain letters, numbers, spaces and hyphens.
"; } // Thanks to "Carlos Pires" from php.net! if (preg_match("/[^A-z\ 0-9_\-]/", $rank5)==1) { $errors++; $errorlist .= "Rank 5 can only contain letters, numbers, spaces and hyphens.
"; } // Thanks to "Carlos Pires" from php.net! if (preg_match("/[^A-z0-9_\-]/", $tagline)==1) { $errors++; $errorlist .= "Guild taglines must be alphanumeric.
"; } // Thanks to "Carlos Pires" from php.net! if (trim($name) == "") { $errors++; $errorlist .= "Guild name is required.
"; } if (trim($tagline) == "") { $errors++; $errorlist .= "Tagline is required.
"; } if (trim($color1) == "#") { $errors++; $errorlist .= "Tagline color is required.
"; } if (strlen($color1) < 7) { $errors++; $errorlist .= "Tagline color must be 7 characters long.
"; } if (trim($color2) == "#") { $errors++; $errorlist .= "Name color is required.
"; } if (strlen($color2) < 7) { $errors++; $errorlist .= "Name color must be 7 characters long.
"; } if (trim($joincost) == "") { $errors++; $errorlist .= "Cost to join is required.
"; } if (!is_numeric($joincost)) { $errors++; $errorlist .= "Cost to join must be a number.
"; } if (trim($rank1) == "") { $errors++; $errorlist .= "Rank 1 is required.
"; } if (trim($rank2) == "") { $errors++; $errorlist .= "Rank 2 is required.
"; } if (trim($rank3) == "") { $errors++; $errorlist .= "Rank 3 is required.
"; } if (trim($rank4) == "") { $errors++; $errorlist .= "Rank 4 is required.
"; } if (trim($rank5) == "") { $errors++; $errorlist .= "Rank 5 is required.
"; } // Should be fine. Go on and create it. if ($errors == 0) { $querystring = ""; unset($_POST["submit"]); foreach($_POST as $a => $b) { $querystring .= "$a='$b',"; } $querystring .= "id='',isactive='1',founder='".$userrow["id"]."', members='1'"; $query = doquery("INSERT INTO <> SET $querystring"); // Now update the Founder's userrow. $query = doquery("UPDATE <> SET gold=gold-".$controlrow["guildstartup"].", guild='".mysql_insert_id()."',guildrank='5',guildtag='$tagline',tagcolor='$color1',namecolor='$color2' WHERE id='".$userrow["id"]."' LIMIT 1"); // And we're done. display("Create a Guild", "Your guild was successfully created.

You may now return to the game."); } else { // Die gracefully on errors. err("The following error(s) occurred when your account was being made:
$errorlist
Please go back and try again."); } } $row["guildstartup"] = number_format($controlrow["guildstartup"]); display("Create a Guild", parsetemplate(gettemplate("guild_create"), $row)); } function guildedit() { global $userrow; $guild = dorow(doquery("SELECT * FROM <> WHERE id='".$userrow["guild"]."' LIMIT 1")); // Errors. if ($userrow["guildrank"] < 5) { err("You do not have permission to edit the Guild settings. Please go back and try again."); } if (isset($_POST["submit"])) { extract($_POST); // Errors. $errors = 0; $errorlist = ""; if (preg_match("/[^A-z\ 0-9_\-]/", $rank1)==1) { $errors++; $errorlist .= "Rank 1 can only contain letters, numbers, spaces and hyphens.
"; } // Thanks to "Carlos Pires" from php.net! if (preg_match("/[^A-z\ 0-9_\-]/", $rank2)==1) { $errors++; $errorlist .= "Rank 2 can only contain letters, numbers, spaces and hyphens.
"; } // Thanks to "Carlos Pires" from php.net! if (preg_match("/[^A-z\ 0-9_\-]/", $rank3)==1) { $errors++; $errorlist .= "Rank 3 can only contain letters, numbers, spaces and hyphens.
"; } // Thanks to "Carlos Pires" from php.net! if (preg_match("/[^A-z\ 0-9_\-]/", $rank4)==1) { $errors++; $errorlist .= "Rank 4 can only contain letters, numbers, spaces and hyphens.
"; } // Thanks to "Carlos Pires" from php.net! if (preg_match("/[^A-z\ 0-9_\-]/", $rank5)==1) { $errors++; $errorlist .= "Rank 5 can only contain letters, numbers, spaces and hyphens.
"; } // Thanks to "Carlos Pires" from php.net! //if (preg_match("/#[a-fA-F0-9]/", $color1)==1) { $errors++; $errorlist .= "Tagline color does not appear to be a valid HTML color code.
"; } //if (preg_match("/#[a-fA-F0-9]/", $color2)==1) { $errors++; $errorlist .= "Name color does not appear to be a valid HTML color code.
"; } if (trim($color1) == "#") { $errors++; $errorlist .= "Tagline color is required.
"; } if (strlen($color1) != 7) { $errors++; $errorlist .= "Tagline color must be 7 characters long.
"; } if (trim($color2) == "#") { $errors++; $errorlist .= "Name color is required.
"; } if (strlen($color2) != 7) { $errors++; $errorlist .= "Name color must be 7 characters long.
"; } if (trim($joincost) == "") { $errors++; $errorlist .= "Cost to join is required.
"; } if (!is_numeric($joincost)) { $errors++; $errorlist .= "Cost to join must be a number.
"; } if (trim($rank1) == "") { $errors++; $errorlist .= "Rank 1 is required.
"; } if (trim($rank2) == "") { $errors++; $errorlist .= "Rank 2 is required.
"; } if (trim($rank3) == "") { $errors++; $errorlist .= "Rank 3 is required.
"; } if (trim($rank4) == "") { $errors++; $errorlist .= "Rank 4 is required.
"; } if (trim($rank5) == "") { $errors++; $errorlist .= "Rank 5 is required.
"; } // Should be fine. Go on and create it. if ($errors == 0) { $querystring = ""; unset($_POST["submit"]); foreach($_POST as $a => $b) { $querystring .= "$a='$b',"; } $querystring .= "id=id"; $query = doquery("UPDATE <> SET $querystring WHERE id='".$guild["id"]."'"); $updatemem = doquery("UPDATE <> SET namecolor='$color2', tagcolor='$color1' WHERE guild='".$guild["id"]."'"); // And we're done. display("Edit Guild", "Your guild was successfully edited.

You may now return to town or to your Guild Hall."); } else { // Die gracefully on errors. err("The following error(s) occurred when your account was being made:
$errorlist
Please go back and try again."); } } display("Edit Guild", parsetemplate(gettemplate("guild_edit"), $guild)); } function guildapp() { global $userrow; $id = $_GET["id"]; if (!is_numeric($id)) { err("Invalid input. Please go back and try again."); } $guild = dorow(doquery("SELECT * FROM <> WHERE id='$id' LIMIT 1")); if ($guild == false) { err("Invalid input. Please go back and try again."); } // Errors. if ($userrow["gold"] < $guild["joincost"]) { err("You do not have enough gold to join this Guild. Joining this Guild requires ".number_format($guild["joincost"])." gold. Please go back and try again."); } if ($userrow["guild"] != 0) { err("You are already a member of another Guild. You must renounce your current membership before joining this Guild. Please go back and try again."); } $appquery = doquery("SELECT * FROM <> WHERE charid='".$userrow["id"]."' LIMIT 1"); if (mysql_num_rows($appquery) != 0) { err("You have already applied to join another Guild. Please go back and try again."); } if ($userrow["level"] < $controlrow["guildjoinlvl"]) { err("You cannot join a guild until you are at least Level ".$controlrow["guildjoinlvl"].". Please continue playing until your character is Level ".$controlrow["guildjoinlvl"].", then try again."); } if (isset($_POST["yes"])) { $query = doquery("INSERT INTO <> SET id='',guild='$id',charid='".$userrow["id"]."',charname='".$userrow["charname"]."'"); $update = doquery("UPDATE <> SET bank=bank+".$guild["joincost"]." WHERE id='".$guild["id"]."' LIMIT 1"); $updatemem = doquery("UPDATE <> SET gold=gold-".$guild["joincost"]." WHERE id='".$userrow["id"]."' LIMIT 1"); $send = doquery("INSERT INTO <> SET id='', postdate=NOW(), senderid='0', sendername='".$guild["name"]."', recipientid='".$guild["founder"]."', recipientname='Guild Leader', status='0', title='New Guild Application', message='Someone has applied to join your Guild.

Do not reply to this message!', gold='0'"); display("Join a Guild", "Thank you for applying to this Guild. If the Guild Leader approves your application, you will be notified via the Post Office.

You may now return to the game."); } elseif (isset($_POST["no"])) { die(header("Location: index.php?do=guilds")); } else { $guild["joincost"] = number_format($guild["joincost"]); $guild["statement"] = nl2br($guild["statement"]); display("Join a Guild", parsetemplate(gettemplate("guild_apply"), $guild)); } } function guildmembers() { $id = $_GET["id"]; if (!is_numeric($id)) { err("Invalid input. Please go back and try again."); } $guild = dorow(doquery("SELECT * FROM <> WHERE id='$id' LIMIT 1")); if ($guild == false) { err("Invalid input. Please go back and try again."); } $guildmembers = dorow(doquery("SELECT * FROM <> WHERE guild='$id' ORDER BY guildrank DESC"), "id"); $row["guildmembers"] = "\n"; $bgcolor = "background-color: #ffffff;"; if ($guildmembers != false) { foreach ($guildmembers as $a => $b) { $row["guildmembers"] .= "\n"; if ($bgcolor == "background-color: #ffffff;") { $bgcolor = "background-color: #dddddd;"; } else { $bgcolor = "background-color: #ffffff;"; } } } else { $row["guildmembers"] .= ""; } $row["guildmembers"] .= "
NameRank
[".$guild["tagline"]."]".$b["charname"]."".$guild["rank".$b["guildrank"]]."
This Guild has no members yet.

"; $row["name"] = $guild["name"]; display("Guild Hall", parsetemplate(gettemplate("guild_members"), $row)); } function guildbank() { global $userrow; extract($_POST); $guild = dorow(doquery("SELECT * FROM <> WHERE id='".$userrow["guild"]."' LIMIT 1")); if (isset($_POST["out"])) { $member = dorow(doquery("SELECT * FROM <> WHERE id='$charid' LIMIT 1")); // Errors. if ($userrow["guildrank"] < 4) { err("You do not have permission to distribute Guild funds. Please go back and try again."); } if (!is_numeric($charid)) { err("Invalid input. Please go back and try again."); } if (!is_numeric($gold)) { err("Invalid input. Please go back and try again."); } if ($gold < 0) { err("You can't send a negative amount of gold. Please go back and try again."); } if ($gold > $guild["bank"]) { err("Your Guild does not have that much gold in the bank. Please go back and try again."); } if ($member == false) { err("Invalid input. Please go back and try again."); } if ($member["guild"] != $userrow["guild"]) { err("That player is not in your Guild. Please go back and try again."); } if ($member["id"] == $userrow["id"]) { err("You cannot send Guild money to yourself. Please go back and try again."); } // Do stuff. $send = doquery("INSERT INTO <> SET id='', postdate=NOW(), senderid='0', sendername='".$guild["name"]."', recipientid='$charid', recipientname='".$member["charname"]."', status='0', title='Money from your Guild', message='Your Guild has sent you money from the Guild Bank.

Do not reply to this message!', gold='$gold'"); $update = doquery("UPDATE <> SET bank=bank-$gold WHERE id='".$userrow["guild"]."' LIMIT 1"); display("Post Office", gettemplate("mailbox_sent")); } elseif (isset($_POST["in"])) { // Errors. if (!is_numeric($_POST["golddeposit"])) { err("Invalid action. Please go back and try again."); } if ($_POST["golddeposit"] < 1) { err("Deposit amount must be greater than 0."); } if ($_POST["golddeposit"] > $userrow["gold"]) { err("You do not have that much money in your pocket."); } // Do stuff. $update = doquery("UPDATE <> SET bank=bank+".$_POST["golddeposit"]." WHERE id='".$userrow["guild"]."' LIMIT 1"); $updatemem = doquery("UPDATE <> SET gold=gold-".$_POST["golddeposit"]." WHERE id='".$userrow["id"]."' LIMIT 1"); display("Guild Bank", "Thank you for depositing money to the Guild Bank.

You may now return to Town or to your Guild Hall."); } } function guildpromote() { global $userrow; extract($_POST); $guild = dorow(doquery("SELECT * FROM <> WHERE id='".$userrow["guild"]."' LIMIT 1")); $member = dorow(doquery("SELECT * FROM <> WHERE id='$charid' LIMIT 1")); if (isset($_POST["promote"])) { // Errors. if ($userrow["guildrank"] < 4) { err("You do not have permission to promote members. Please go back and try again."); } if ($userrow["guildrank"] == 4 && $member["guildrank"] >= 3) { err("You do not have permission to promote this member any higher. Please go back and try again."); } if ($member["guildrank"] == 5) { err("This member cannot be promoted any higher. Please go back and try again."); } if ($member == false) { err("Invalid input. Please go back and try again."); } if ($member["guild"] != $userrow["guild"]) { err("That player is not in your Guild. Please go back and try again."); } // Do stuff. $update = doquery("UPDATE <> SET guildrank=guildrank+1 WHERE id='$charid' LIMIT 1"); } elseif (isset($_POST["demote"])) { // Errors. if ($userrow["guildrank"] < 4) { err("You do not have permission to demote members. Please go back and try again."); } if ($userrow["guildrank"] == 4 && $member["guildrank"] > 3) { err("You do not have permission to demote this member. Please go back and try again."); } if ($userrow["id"] == $member["id"]) { err("You cannot demote yourself. Please go back and try again."); } if ($member == false) { err("Invalid input. Please go back and try again."); } if ($member["guild"] != $userrow["guild"]) { err("That player is not in your Guild. Please go back and try again."); } if ($member["guildrank"] == 1) { guildremove(); } // Do stuff. $update = doquery("UPDATE <> SET guildrank=guildrank-1 WHERE id='$charid' LIMIT 1"); } display("Guild Ranks", "Thank you for promoting/demoting this user.

You may now return to Town or to your Guild Hall."); } function guildapprove() { global $userrow; extract($_POST); $guild = dorow(doquery("SELECT * FROM <> WHERE id='".$userrow["guild"]."' LIMIT 1")); $member = dorow(doquery("SELECT * FROM <> WHERE id='$charid' LIMIT 1")); $app = dorow(doquery("SELECT * FROM <> WHERE guild='".$userrow["guild"]."' AND charid='$charid' LIMIT 1")); // Errors. if ($userrow["guildrank"] < 4) { err("You do not have permission to approve new members. Please go back and try again."); } if ($app == false) { err("Invalid input. Please go back and try again."); } // Do stuff. if (isset($_POST["approve"])) { $updatemem = doquery("UPDATE <> SET guild='".$userrow["guild"]."', guildrank='1', guildtag='".$guild["tagline"]."', tagcolor='".$guild["color1"]."', namecolor='".$guild["color2"]."' WHERE id='".$app["charid"]."' LIMIT 1"); $updateguild = doquery("UPDATE <> SET members=members+1 WHERE id='".$userrow["guild"]."' LIMIT 1"); $deleteapp = doquery("DELETE FROM <> WHERE guild='".$userrow["guild"]."' AND charid='$charid' LIMIT 1"); $send = doquery("INSERT INTO <> SET id='', postdate=NOW(), senderid='0', sendername='".$guild["name"]."', recipientid='$charid', recipientname='".$member["charname"]."', status='0', title='Guild Approval', message='The Guild has approved you for membership, and you are now a member of ".$guild["name"].". Congratulations!

Do not reply to this message!', gold='0'"); guildupdate(); display("Approve Members", "Thank you for approving this user.

You may now return to Town or to your Guild Hall."); } else { $deleteapp = doquery("DELETE FROM <> WHERE guild='".$userrow["guild"]."' AND charid='$charid' LIMIT 1"); $send = doquery("INSERT INTO <> SET id='', postdate=NOW(), senderid='0', sendername='".$guild["name"]."', recipientid='$charid', recipientname='".$member["charname"]."', status='0', title='Guild Denial', message='The Guild has denied your application for membership. Sorry.

Do not reply to this message!', gold='0'"); display("Approve Members", "Thank you for denying this user.

You may now return to Town or to your Guild Hall."); } } function guildremove() { global $userrow; extract($_POST); $guild = dorow(doquery("SELECT * FROM <> WHERE id='".$userrow["guild"]."' LIMIT 1")); $member = dorow(doquery("SELECT * FROM <> WHERE id='$charid' LIMIT 1")); if (isset($_POST["yes"])) { $update = doquery("UPDATE <> SET members=members-1 WHERE id='".$guild["id"]."' LIMIT 1"); $updatemem = doquery("UPDATE <> SET guild='0', guildrank='0', guildtag='', tagcolor='', namecolor='' WHERE id='$charid' LIMIT 1"); $send = doquery("INSERT INTO <> SET id='', postdate=NOW(), senderid='0', sendername='".$guild["name"]."', recipientid='$charid', recipientname='".$member["charname"]."', status='0', title='Guild Removal', message='The Guild has removed you from their membership. Sorry.

Do not reply to this message!', gold='0'"); guildupdate(); display("Remove Members", "Thank you for removing this user.

You may now return to Town or to your Guild Hall."); } elseif (isset($_POST["no"])) { die(header("Location: index.php?do=guildhome")); } $pagerow["charid"] = $charid; $pagerow["charname"] = $member["charname"]; display("Remove Member", parsetemplate(gettemplate("guild_remove"), $pagerow)); } function guildnews() { global $userrow; $guild = dorow(doquery("SELECT * FROM <> WHERE id='".$userrow["guild"]."' LIMIT 1")); // Errors. if ($userrow["guildrank"] < 5) { err("You do not have permission to edit Guild news. Please go back and try again."); } if (isset($_POST["submit"])) { $query = doquery("UPDATE <> SET news='".$_POST["news"]."' WHERE id='".$userrow["guild"]."' LIMIT 1"); display("Guild News", "Thank you for updating your Guild News.

You may now return to Town or to your Guild Hall."); } if (trim($guild["news"]) == "") { $guild["news"] = "No news yet."; } display("Guild News", parsetemplate(gettemplate("guild_news"), $guild)); } function guilddisband() { global $userrow; $guild = dorow(doquery("SELECT * FROM <> WHERE id='".$userrow["guild"]."' LIMIT 1")); // Errors. if ($userrow["id"] != $guild["founder"]) { err("You do not have permission to disband the Guild. Please go back and try again."); } if (isset($_POST["yes"])) { $guildmembers = dorow(doquery("SELECT * FROM <> WHERE guild='".$guild["id"]."'"), "id"); foreach ($guildmembers as $a => $b) { $send = doquery("INSERT INTO <> SET id='', postdate=NOW(), senderid='0', sendername='".$guild["name"]."', recipientid='".$b["id"]."', recipientname='".$b["charname"]."', status='0', title='Guild Disbanded', message='Your Guild leader has chosen to disband the guild. Your member status has been reset, and you can now apply to join another guild if you wish.

Do not reply to this message!', gold='0'"); } $updatemem = doquery("UPDATE <> SET guild='0', guildrank='0', guildtag='', tagcolor='', namecolor='' WHERE guild='".$guild["id"]."'"); $delete = doquery("DELETE FROM <> WHERE id='".$guild["id"]."'"); $deletebb = doquery("DELETE FROM <> WHERE guild='".$guild["id"]."'"); display("Disband Guild", "Thank you for disbanding your Guild.

You may now return to Town."); } elseif (isset($_POST["no"])) { die(header("Location: index.php?do=guildhome")); } display("Disband Guild", gettemplate("guild_disband")); } function guildleave() { global $userrow; $guild = dorow(doquery("SELECT * FROM {{table}} WHERE id='".$userrow["guild"]."' LIMIT 1", "guilds")); if (isset($_POST["yes"])) { $updatemem = doquery("UPDATE <> SET guild='0', guildrank='0', guildtag='', tagcolor='', namecolor='' WHERE id='".$userrow["id"]."'"); $update = doquery("UPDATE <> SET members=members-1 WHERE id='".$userrow["guild"]."' LIMIT 1"); guildupdate(); display("Leave Guild", "Thank you for leaving your Guild.

You may now return to Town."); } elseif (isset($_POST["no"])) { die(header("Location: index.php?do=guildhome")); } display("Leave Guild", gettemplate("guild_leave")); } function guildupdate() { global $userrow; $guild = dorow(doquery("SELECT * FROM <> WHERE id='".$userrow["guild"]."' LIMIT 1")); $users = dorow(doquery("SELECT * FROM <> WHERE guild='".$userrow["guild"]."'"), "id"); $honor = $guild["members"]; $totalexp = 0; foreach ($users as $a => $b) { $totalexp += $b["experience"]; $honor += ($b["pvpwins"] * 2); $honor -= $b["pvplosses"]; } $honor += floor(sqrt($totalexp)); $lastupdate = mktime(); $update = doquery("UPDATE <> SET honor='$honor',lastupdate='$lastupdate' WHERE id='".$userrow["guild"]."' LIMIT 1"); // Now update the array and send back to main guild function. $guild["honor"] = $honor; $guild["lastupdate"] = $lastupdate; return ($guild); } ?>