Changeset 374 for minimanager/guild.php
- Timestamp:
- Sep 11, 2008, 9:10:27 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
minimanager/guild.php
r307 r374 10 10 11 11 require_once("header.php"); 12 valid_login( 0);12 valid_login($action_permission['read']); 13 13 require_once("scripts/id_tab.php"); 14 14 //######################################################################################################################## … … 16 16 //######################################################################################################################## 17 17 function browse_guilds() { 18 global $lang_guild, $lang_global, $output, $characters_db, $realm_id, $ itemperpage, $realm_db;18 global $lang_guild, $lang_global, $output, $characters_db, $realm_id, $realm_db, $user_id, $user_lvl, $itemperpage, $sql_search_limit, $search_by, $search_value; 19 19 20 20 $sql = new SQL; 21 21 $sql->connect($characters_db[$realm_id]['addr'], $characters_db[$realm_id]['user'], $characters_db[$realm_id]['pass'], $characters_db[$realm_id]['name']); 22 22 23 $start = (isset($_GET['start'])) ? $sql->quote_smart($_GET['start']) : 0; 24 $order_by = (isset($_GET['order_by'])) ? $sql->quote_smart($_GET['order_by']) : "gid"; 25 26 $dir = (isset($_GET['dir'])) ? $sql->quote_smart($_GET['dir']) : 1; 27 $order_dir = ($dir) ? "ASC" : "DESC"; 28 $dir = ($dir) ? 0 : 1; 29 30 $query_1 = $sql->query("SELECT count(*) FROM guild"); 31 $all_record = $sql->result($query_1,0); 32 33 $query = $sql->query("SELECT guild.guildid AS gid, guild.name AS name,guild.leaderguid AS lguid,SUBSTRING_INDEX(guild.MOTD,' ',6), guild.createdate, 34 (SELECT name FROM `characters` WHERE guid = lguid) AS l_name,(SELECT COUNT(*) FROM guild_member WHERE guildid = gid) AS tot_chars 35 FROM guild ORDER BY $order_by $order_dir LIMIT $start, $itemperpage"); 36 $this_page = $sql->num_rows($query); 37 38 //==========================top tage navigaion starts here======================== 39 $output .="<center><table class=\"top_hidden\"> 40 <tr><td> 41 <table class=\"hidden\"> 42 <tr><td> 43 <form action=\"guild.php\" method=\"get\" name=\"form\"> 44 <input type=\"hidden\" name=\"action\" value=\"search\" /> 45 <input type=\"hidden\" name=\"error\" value=\"4\" /> 46 <input type=\"text\" size=\"45\" name=\"search_value\" /> 47 <select name=\"search_by\"> 48 <option value=\"name\">{$lang_guild['by_name']}</option> 49 <option value=\"leaderguid\">{$lang_guild['by_guild_leader']}</option> 50 <option value=\"createdate\">{$lang_guild['by_create_date']}</option> 51 <option value=\"guildid\">{$lang_guild['by_id']}</option> 52 </select></form></td><td>"; 53 makebutton($lang_global['search'], "javascript:do_submit()",80); 54 $output .= "</td></tr></table> 55 <td align=\"right\">"; 56 $output .= generate_pagination("guild.php?action=brows_guilds&order_by=$order_by&dir=".!$dir, $all_record, $itemperpage, $start); 57 $output .= "</td></tr></table>"; 23 //==========================$_GET and SECURE======================== 24 $start = (isset($_GET['start'])) ? $sql->quote_smart($_GET['start']) : 0; 25 if (!preg_match("/^[[:digit:]]{1,5}$/", $start)) $start=0; 26 27 $order_by = (isset($_GET['order_by'])) ? $sql->quote_smart($_GET['order_by']) : "gid"; 28 if (!preg_match("/^[_[:lower:]]{1,10}$/", $order_by)) $order_by="gid"; 29 30 $dir = (isset($_GET['dir'])) ? $sql->quote_smart($_GET['dir']) : 1; 31 if (!preg_match("/^[01]{1}$/", $dir)) $dir=1; 32 33 $order_dir = ($dir) ? "ASC" : "DESC"; 34 $dir = ($dir) ? 0 : 1; 35 //==========================$_GET and SECURE end======================== 36 //==========================MyGuild======================== 37 38 $query_myGuild = $sql->query("SELECT g.guildid as gid, g.name,g.leaderguid AS lguid, (SELECT name from characters where guid = lguid), (SELECT race in (2,5,6,8,10) from characters where guid = lguid) as faction, (select count(*) from characters where guid in (select guid from guild_member where guildid = lguid) and online = 1) as gonline, (select count(*) from guild_member where guildid = gid), SUBSTRING_INDEX(g.MOTD,' ',6), g.createdate, (select account from characters where guid = lguid) FROM guild as g 39 left outer join guild_member as gm on gm.guildid = g.guildid left outer join characters as c on c.guid = gm.guid where c.account = $user_id group by g.guildid order by gid"); 40 41 if ($query_myGuild) 42 { 43 $output .= "<center><fieldset><legend>{$lang_guild['my_guilds']}</legend><table class=\"lined\" align=\"center\"> 44 <tr> 45 <th width=\"5%\">{$lang_guild['id']}</th> 46 <th width=\"25%\">{$lang_guild['guild_name']}</th> 47 <th width=\"15%\">{$lang_guild['guild_leader']}</th> 48 <th width=\"10%\">{$lang_guild['guild_faction']}</th> 49 <th width=\"10%\">{$lang_guild['tot_m_online']}</th> 50 <th width=\"20%\">{$lang_guild['guild_motd']}</th> 51 <th width=\"15%\">{$lang_guild['create_date']}</th> 52 </tr>"; 53 54 $sql->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']); 55 while ($data = $sql->fetch_row($query_myGuild)) { 56 57 $result = $sql->query("SELECT gmlevel FROM account WHERE id ='$data[9]'"); 58 $owner_gmlvl = $sql->result($result, 0, 'gmlevel'); 59 60 $output .= "<tr> 61 <td>$data[0]</td> 62 <td><a href=\"guild.php?action=view_guild&error=3&id=$data[0]\">$data[1]</a></td>"; 63 $output .= ($user_lvl < $owner_gmlvl ) ? "<td>$data[3]</td>" : "<td><a href=\"char.php?id=$data[2]\">$data[3]</a></td>"; 64 $output .= "<td><img src=\"img/".($data[4]==0 ? "alliance" : "horde")."_small.gif\" /></td> 65 <td>$data[5]/$data[6]</td> 66 <td>$data[7] ...</td> 67 <td class=\"small\">$data[8]</td> 68 </tr>"; 69 } 70 $output .= "</table></fieldset></center><br />"; 71 72 $sql->connect($characters_db[$realm_id]['addr'], $characters_db[$realm_id]['user'], $characters_db[$realm_id]['pass'], $characters_db[$realm_id]['name']); 73 } 74 75 //==========================MyGuild end======================== 76 //==========================Browse/Search Guilds CHECK======================== 77 78 if(isset($_GET['search_value']) && isset($_GET['search_by'])) 79 { 80 $search_by = $sql->quote_smart($_GET['search_by']); 81 $search_value = $sql->quote_smart($_GET['search_value']); 82 83 switch($search_by) 84 { 85 case "name": 86 if (preg_match('/^[\t\v\b\f\a\n\r\\\"\'\? <>[](){}_=+-|!@#$%^&*~`.,0123456789\0]{1,30}$/', $search_value)) redirect("guild.php?error=5"); 87 $query = $sql->query("SELECT g.guildid as gid, g.name,g.leaderguid as lguid, (SELECT name from characters where guid = lguid) as lname, c.race in (2,5,6,8,10) as lfaction, (select count(*) from guild_member where guildid = gid) as tot_chars, createdate, c.account as laccount FROM guild as g left outer join characters as c on c.guid = g.leaderguid where g.name like '%$search_value%' ORDER BY $order_by $order_dir LIMIT $start, $itemperpage"); 88 $query_count = $sql->query("SELECT 1 from guild where name like '%$search_value%'"); 89 break; 90 case "leadername" : 91 if (preg_match('/^[\t\v\b\f\a\n\r\\\"\'\? <>[](){}_=+-|!@#$%^&*~`.,0123456789\0]{1,30}$/', $search_value)) redirect("guild.php?error=5"); 92 $query = $sql->query("SELECT g.guildid as gid, g.name,g.leaderguid as lguid, (SELECT name from characters where guid = lguid) as lname, c.race in (2,5,6,8,10) as lfaction, (select count(*) from guild_member where guildid = gid) as tot_chars, createdate, c.account as laccount FROM guild as g left outer join characters as c on c.guid = g.leaderguid where g.leaderguid in (SELECT guid from characters where name like '%$search_value%') ORDER BY $order_by $order_dir LIMIT $start, $itemperpage"); 93 $query_count = $sql->query("SELECT 1 from guild where leaderguid in (select guid from characters where name like '%$search_value%')"); 94 break; 95 case "guildid" : 96 if (!preg_match('/^[[:digit:]]{1,12}$/', $search_value)) redirect("guild.php?error=5"); 97 $query = $sql->query("SELECT g.guildid as gid, g.name,g.leaderguid as lguid, (SELECT name from characters where guid = lguid) as lname, c.race in (2,5,6,8,10) as lfaction, (select count(*) from guild_member where guildid = gid) as tot_chars, createdate, c.account as laccount FROM guild as g left outer join characters as c on c.guid = g.leaderguid where g.guildid = '$search_value' ORDER BY $order_by $order_dir LIMIT $start, $itemperpage"); 98 $query_count = $sql->query("SELECT 1 from guild where guildid = '$search_value'"); 99 break; 100 default : redirect("guild.php?error=2"); 101 } 102 } 103 else 104 { 105 $query = $sql->query("SELECT g.guildid as gid, g.name,g.leaderguid as lguid, (SELECT name from characters where guid = lguid) as lname, c.race in (2,5,6,8,10) as lfaction, (select count(*) from guild_member where guildid = gid) as tot_chars, createdate, c.account as laccount FROM guild as g left outer join characters as c on c.guid = g.leaderguid ORDER BY $order_by $order_dir LIMIT $start, $itemperpage"); 106 $query_count = $sql->query("SELECT 1 from guild"); 107 } 108 109 $all_record = $sql->num_rows($query_count); 110 111 //==========================Browse/Search Guilds CHECK end======================== 112 //==========================Browse/Search Guilds======================== 113 114 $output .="<table class=\"top_hidden\" align=\"center\"><tr><td width =\"140\">"; 115 116 ($search_by && $search_value) ? makebutton($lang_guild['show_guilds'], "guild.php", 150) : $output .= " "; 117 118 $output .= "</td><td align=\"right\"> 119 <form action=\"guild.php\" method=\"get\" name=\"form\"> 120 <input type=\"hidden\" name=\"action\" value=\"browse_guilds\" /> 121 <input type=\"hidden\" name=\"error\" value=\"4\" /> 122 <input type=\"text\" size=\"45\" name=\"search_value\" value=\"{$search_value}\" /> 123 <select name=\"search_by\"> 124 <option value=\"name\"".($search_by == 'name' ? " selected=\"selected\"" : "").">{$lang_guild['by_name']}</option> 125 <option value=\"leadername\"".($search_by == 'leadername' ? " selected=\"selected\"" : "").">{$lang_guild['by_guild_leader']}</option> 126 <option value=\"guildid\"".($search_by == 'guildid' ? " selected=\"selected\"" : "").">{$lang_guild['by_id']}</option> 127 </select> 128 </form></td><td>"; 129 makebutton($lang_global['search'], "javascript:do_submit()",80); 130 131 $output .= "</td></tr><tr> 132 <td colspan=\"3\" align=\"right\">"; 133 134 $output .= generate_pagination("guild.php?action=brows_guilds&order_by=$order_by&".($search_value && $search_by ? "search_by=$search_by&search_value=$search_value&" : "")."dir=".!$dir, $all_record, $itemperpage, $start); 135 136 $output .= "</td></tr></table>"; 137 58 138 //==========================top tage navigaion ENDS here ======================== 59 139 60 $output .= "< table class=\"lined\">140 $output .= "<center><fieldset><legend>{$lang_guild['browse_guilds']}</legend><table class=\"lined\" align=\"center\"> 61 141 <tr> 62 <th width=\"5%\"><a href=\"guild.php?order_by=gid&start=$start&dir=$dir\">".($order_by=='gid' ? "<img src=\"img/arr_".($dir ? "up" : "dw").".gif\" /> " : "")."{$lang_guild['id']}</a></th> 63 <th width=\"23%\"><a href=\"guild.php?order_by=name&start=$start&dir=$dir\">".($order_by=='name' ? "<img src=\"img/arr_".($dir ? "up" : "dw").".gif\" /> " : "")."{$lang_guild['guild_name']}</a></th> 64 <th width=\"5%\"><a href=\"guild.php?order_by=tot_chars&start=$start&dir=$dir\">".($order_by=='tot_chars' ? "<img src=\"img/arr_".($dir ? "up" : "dw").".gif\" /> " : "")."{$lang_guild['tot_members']}</a></th> 65 <th width=\"5%\">Online Members</th> 66 <th width=\"15%\"><a href=\"guild.php?order_by=leaderguid&start=$start&dir=$dir\">".($order_by=='leaderguid' ? "<img src=\"img/arr_".($dir ? "up" : "dw").".gif\" /> " : "")."{$lang_guild['guild_leader']}</a></th> 67 <th width=\"32%\">{$lang_guild['guild_motd']}</th> 68 <th width=\"15%\"><a href=\"guild.php?order_by=createdate&start=$start&dir=$dir\">".($order_by=='createdate' ? "<img src=\"img/arr_".($dir ? "up" : "dw").".gif\" /> " : "")."{$lang_guild['create_date']}</a></th> 142 <th width=\"5%\"><a href=\"guild.php?order_by=gid&start=$start&dir=$dir".( $search_value && $search_by ? "&search_by=$search_by&search_value=$search_value" : "" )."\">".($order_by=='gid' ? "<img src=\"img/arr_".($dir ? "up" : "dw").".gif\" /> " : "")."{$lang_guild['id']}</a></th> 143 <th width=\"30%\"><a href=\"guild.php?order_by=name&start=$start&dir=$dir".( $search_value && $search_by ? "&search_by=$search_by&search_value=$search_value" : "" )."\">".($order_by=='name' ? "<img src=\"img/arr_".($dir ? "up" : "dw").".gif\" /> " : "")."{$lang_guild['guild_name']}</a></th> 144 <th width=\"20%\"><a href=\"guild.php?order_by=lname&start=$start&dir=$dir".( $search_value && $search_by ? "&search_by=$search_by&search_value=$search_value" : "" )."\">".($order_by=='lname' ? "<img src=\"img/arr_".($dir ? "up" : "dw").".gif\" /> " : "")."{$lang_guild['guild_leader']}</a></th> 145 <th width=\"10%\"><a href=\"guild.php?order_by=lfaction&start=$start&dir=$dir".( $search_value && $search_by ? "&search_by=$search_by&search_value=$search_value" : "" )."\">".($order_by=='lfaction' ? "<img src=\"img/arr_".($dir ? "up" : "dw").".gif\" /> " : "")."{$lang_guild['guild_faction']}</a></th> 146 <th width=\"15%\"><a href=\"guild.php?order_by=tot_chars&start=$start&dir=$dir".( $search_value && $search_by ? "&search_by=$search_by&search_value=$search_value" : "" )."\">".($order_by=='tot_chars' ? "<img src=\"img/arr_".($dir ? "up" : "dw").".gif\" /> " : "")."{$lang_guild['tot_members']}</a></th> 147 <th width=\"20%\"><a href=\"guild.php?order_by=createdate&start=$start&dir=$dir".( $search_value && $search_by ? "&search_by=$search_by&search_value=$search_value" : "" )."\">".($order_by=='createdate' ? "<img src=\"img/arr_".($dir ? "up" : "dw").".gif\" /> " : "")."{$lang_guild['create_date']}</a></th> 69 148 </tr>"; 70 149 71 while ($data = $sql->fetch_row($query)) { 72 73 $gonline = $sql->query("SELECT count(*) AS GCNT FROM `guild_member`, `characters`, `guild` WHERE guild.guildid = ".$data[0]." AND guild_member.guildid = guild.guildid AND guild_member.guid = characters.guid AND characters.online = 1;"); 74 $guild_online = $sql->result($gonline,"GCNT"); 75 76 $output .= "<tr> 77 <td>$data[0]</td> 78 <td><a href=\"guild.php?action=view_guild&error=3&id=$data[0]\">$data[1]</a></td> 79 <td>$data[6]</td> 80 <td>$guild_online</td> 81 <td><a href=\"char.php?id=$data[2]\">$data[5]</a></td> 82 <td>$data[3] ...</td> 83 <td class=\"small\">$data[4]</td> 84 </tr>"; 85 } 86 87 $output .= "<tr><td colspan=\"6\" class=\"hidden\" align=\"right\">{$lang_guild['tot_guilds']} : $all_record</td></tr> 88 </table></center>"; 150 $sql->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']); 151 152 while ($data = $sql->fetch_row($query)) { 153 154 $result = $sql->query("SELECT gmlevel FROM account WHERE id ='$data[7]'"); 155 $owner_gmlvl = $sql->result($result, 0, 'gmlevel'); 156 157 $output .= "<tr><td>$data[0]</td>"; 158 $output .= ($user_lvl >= 1) ? "<td><a href=\"guild.php?action=view_guild&error=3&id=$data[0]\">$data[1]</td>" : "<td>$data[1]</td>"; 159 $output .= ($user_lvl < $owner_gmlvl ) ? "<td>$data[3]</td>" : "<td><a href=\"char.php?id=$data[2]\">$data[3]</a></td>"; 160 $output .= "<td><img src=\"img/".($data[4]==0 ? "alliance" : "horde")."_small.gif\" /></td> 161 <td>$data[5]</td> 162 <td class=\"small\">$data[6]</td> 163 </tr>"; 164 } 165 166 $output .= "<tr><td colspan=\"6\" class=\"hidden\" align=\"right\">".generate_pagination("guild.php?action=brows_guilds&order_by=$order_by&".($search_value && $search_by ? "search_by=$search_by&search_value=$search_value&" : "")."dir=".!$dir, $all_record, $itemperpage, $start)."</td></tr> 167 <tr><td colspan=\"6\" class=\"hidden\" align=\"right\">{$lang_guild['tot_guilds']} : $all_record</td></tr> 168 </table></fieldset></center><br />"; 169 170 //==========================Browse/Search Guilds end======================== 89 171 90 172 $sql->close(); … … 92 174 93 175 94 //######################################################################################################################## 95 // SEARCH 96 //######################################################################################################################## 97 function search() { 98 global $lang_guild, $lang_global, $output, $characters_db, $realm_id, $sql_search_limit; 99 100 if(!isset($_GET['search_value']) || !isset($_GET['search_by'])) redirect("guild.php?error=2"); 101 176 function count_days( $a, $b ) { 177 $gd_a = getdate( $a ); 178 $gd_b = getdate( $b ); 179 $a_new = mktime( 12, 0, 0, $gd_a['mon'], $gd_a['mday'], $gd_a['year'] ); 180 $b_new = mktime( 12, 0, 0, $gd_b['mon'], $gd_b['mday'], $gd_b['year'] ); 181 return round( abs( $a_new - $b_new ) / 86400 ); 182 } 183 184 //######################################################################################################################## 185 // VIEW GUILD 186 //######################################################################################################################## 187 function view_guild() { 188 global $lang_guild, $lang_global, $output, $characters_db, $realm_id, $user_lvl, $user_id, $itemperpage, $sql_search_limit, $realm_db; 189 190 if(!isset($_GET['id'])) redirect("guild.php?error=1"); 191 102 192 $sql = new SQL; 103 193 $sql->connect($characters_db[$realm_id]['addr'], $characters_db[$realm_id]['user'], $characters_db[$realm_id]['pass'], $characters_db[$realm_id]['name']); 104 105 $search_value = $sql->quote_smart($_GET['search_value']); 106 $search_by = $sql->quote_smart($_GET['search_by']); 107 108 if(isset($_GET['order_by'])) $order_by = $sql->quote_smart($_GET['order_by']); 109 else $order_by = "guildid"; 110 111 $dir = (isset($_GET['dir'])) ? $sql->quote_smart($_GET['dir']) : 1; 112 $order_dir = ($dir) ? "ASC" : "DESC"; 113 $dir = ($dir) ? 0 : 1; 114 115 if ($search_by == "leaderguid"){ 116 $temp = $sql->query("SELECT guid FROM `characters` WHERE name ='$search_value'"); 117 $search_value = $sql->result($temp, 0, 'guid'); 118 } 119 120 $query = $sql->query("SELECT guild.guildid AS gid, guild.name AS name,guild.leaderguid AS lguid,SUBSTRING_INDEX(guild.MOTD,' ',6), guild.createdate, 121 (SELECT name FROM `characters` WHERE guid = lguid) AS l_name, (SELECT COUNT(*) FROM guild_member WHERE guildid = gid) AS tot_chars 122 FROM guild WHERE $search_by LIKE '%$search_value%' ORDER BY $order_by $order_dir LIMIT $sql_search_limit"); 123 $total_found = $sql->num_rows($query); 124 125 //==========================top tage navigaion starts here======================== 126 $output .="<center><table class=\"top_hidden\"> 127 <tr><td>"; 128 makebutton($lang_guild['guilds'], "guild.php", 120); 129 makebutton($lang_global['back'], "javascript:window.history.back()", 120); 130 $output .= "<form action=\"guild.php\" method=\"get\" name=\"form\"> 131 <input type=\"hidden\" name=\"action\" value=\"search\" /> 132 <input type=\"hidden\" name=\"error\" value=\"4\" /> 133 <input type=\"text\" size=\"30\" name=\"search_value\" /> 134 <select name=\"search_by\"> 135 <option value=\"name\">{$lang_guild['by_name']}</option> 136 <option value=\"leaderguid\">{$lang_guild['by_guild_leader']}</option> 137 <option value=\"createdate\">{$lang_guild['by_create_date']}</option> 138 <option value=\"guildid\">{$lang_guild['by_id']}</option> 139 </select> 140 </form></td><td>"; 141 makebutton($lang_global['search'], "javascript:do_submit()",90); 142 $output .= "</td></tr></table>"; 143 //==========================top tage navigaion ENDS here ======================== 144 145 $output .= "<table class=\"lined\"> 146 <tr> 147 <th width=\"5%\"><a href=\"guild.php?action=search&error=4&order_by=guildid&search_by=$search_by&search_value=$search_value&dir=$dir\">".($order_by=='guildid' ? "<img src=\"img/arr_".($dir ? "up" : "dw").".gif\" /> " : "")."{$lang_guild['id']}</a></th> 148 <th width=\"25%\"><a href=\"guild.php?action=search&error=4&order_by=name&search_by=$search_by&search_value=$search_value&dir=$dir\">".($order_by=='name' ? "<img src=\"img/arr_".($dir ? "up" : "dw").".gif\" /> " : "")."{$lang_guild['guild_name']}</a></th> 149 <th width=\"5%\"><a href=\"guild.php?action=search&error=4&order_by=tot_chars&search_by=$search_by&search_value=$search_value&dir=$dir\">".($order_by=='tot_chars' ? "<img src=\"img/arr_".($dir ? "up" : "dw").".gif\" /> " : "")."{$lang_guild['tot_members']}</a></th> 150 <th width=\"15%\"><a href=\"guild.php?action=search&error=4&order_by=leaderguid&search_by=$search_by&search_value=$search_value&dir=$dir\">".($order_by=='leaderguid' ? "<img src=\"img/arr_".($dir ? "up" : "dw").".gif\" /> " : "")."{$lang_guild['guild_leader']}</a></th> 151 <th width=\"35%\">{$lang_guild['guild_motd']}</th> 152 <th width=\"15%\"><a href=\"guild.php?action=search&error=4&order_by=createdate&search_by=$search_by&search_value=$search_value&dir=$dir\">".($order_by=='createdate' ? "<img src=\"img/arr_".($dir ? "up" : "dw").".gif\" /> " : "")."{$lang_guild['create_date']}</a></th> 153 </tr>"; 154 155 while ($data =$sql->fetch_row($query)){ 156 $output .= "<tr> 157 <td>$data[0]</td> 158 <td><a href=\"guild.php?action=view_guild&error=3&id=$data[0]\">$data[1]</a></td> 159 <td>$data[6]</td> 160 <td><a href=\"char.php?id=$data[2]\">$data[5]</a></td> 161 <td>$data[3] ...</td> 162 <td class=\"small\">$data[4]</td> 163 </tr>"; 164 } 165 166 $output .= "<tr> 167 <td colspan=\"6\" class=\"hidden\" align=\"right\">{$lang_guild['tot_found']} : $total_found {$lang_global['limit']} : $sql_search_limit</td> 168 </tr> 169 </table></center>"; 170 171 $sql->close(); 172 } 173 174 function count_days( $a, $b ) { 175 $gd_a = getdate( $a ); 176 $gd_b = getdate( $b ); 177 $a_new = mktime( 12, 0, 0, $gd_a['mon'], $gd_a['mday'], $gd_a['year'] ); 178 $b_new = mktime( 12, 0, 0, $gd_b['mon'], $gd_b['mday'], $gd_b['year'] ); 179 return round( abs( $a_new - $b_new ) / 86400 ); 180 } 181 182 //######################################################################################################################## 183 // VIEW GUILD 184 //######################################################################################################################## 185 function view_guild() { 186 global $lang_guild, $lang_global, $output, $characters_db, $realm_id, $user_lvl; 187 188 if(!isset($_GET['id'])) redirect("guild.php?error=1"); 189 194 195 $guild_id = $sql->quote_smart($_GET['id']); 196 if(!preg_match("/^[[:digit:]]{1,10}$/", $guild_id)) redirect("guild.php?error=6"); 197 198 199 //==========================SQL INGUILD and GUILDLEADER======================== 200 $q_inguild = $sql->query("select 1 from guild_member where guildid = '$guild_id' and guid in (select guid from characters where account = '$user_id')"); 201 $inguild = $sql->result($q_inguild, 0, '1'); 202 if ( $user_lvl < 1 && !$inguild ) redirect("guild.php?error=1"); 203 204 $q_amIguildleader = $sql->query("select 1 from guild where guildid = '$guild_id' and leaderguid in (select guid from characters where account = '$user_id')"); 205 $amIguildleader = $sql->result($q_amIguildleader, 0, '1'); 206 207 $q_guildmemberCount = $sql->query("SELECT 1 from guild_member where guildid = '$guild_id'"); 208 $guildmemberCount = $sql->num_rows($q_guildmemberCount); 209 210 //==========================SQL INGUILD and GUILDLEADER end======================== 211 212 //==========================$_GET and SECURE======================== 213 $start = (isset($_GET['start'])) ? $sql->quote_smart($_GET['start']) : 0; 214 if (!preg_match("/^[[:digit:]]{1,5}$/", $start)) $start=0; 215 216 $order_by = (isset($_GET['order_by'])) ? $sql->quote_smart($_GET['order_by']) : "mrank"; 217 if (!preg_match("/^[_[:lower:]]{1,10}$/", $order_by)) $order_by="mrank"; 218 219 $dir = (isset($_GET['dir'])) ? $sql->quote_smart($_GET['dir']) : 1; 220 if (!preg_match("/^[01]{1}$/", $dir)) $dir=1; 221 222 $order_dir = ($dir) ? "ASC" : "DESC"; 223 $dir = ($dir) ? 0 : 1; 224 //==========================$_GET and SECURE end======================== 225 226 $query = $sql->query("SELECT guildid, name, info, MOTD, createdate, (select count(*) from guild_member where guildid = '$guild_id') as mtotal, (select count(*) from guild_member where guildid = '$guild_id' and guid in (select guid from characters where online = 1)) as monline FROM guild WHERE guildid = '$guild_id'"); 227 $guild_data = $sql->fetch_row($query); 228 229 230 $output .= "<script type=\"text/javascript\"> 231 answerbox.btn_ok='{$lang_global['yes_low']}'; 232 answerbox.btn_cancel='{$lang_global['no']}'; 233 </script><center> 234 <fieldset> 235 <legend>{$lang_guild['guild']}</legend> 236 <table class=\"hidden\" style=\"width: 100%;\"><tr><td> 237 <table class=\"lined\"> 238 <tr class=\"bold\"><td>$guild_data[1]</td></tr> 239 <tr><td><b>{$lang_guild['create_date']}:</b><br>$guild_data[4]</td></tr>"; 240 241 if ($guild_data[2] != '') $output .= "<tr><td><b>{$lang_guild['info']}:</b><br>$guild_data[2]</td></tr>"; 242 if ($guild_data[3] != '') $output .= "<tr><td><b>{$lang_guild['motd']}:</b><br>$guild_data[3]</td></tr>"; 243 244 $output .="<tr><td><b>{$lang_guild['tot_m_online']}:</b><br>$guild_data[6] / $guild_data[5]</td></tr> 245 </table></td></tr><td> 246 247 <div align=\"right\">".generate_pagination("guild.php?action=view_guild&id=$guild_id&order_by=$order_by&dir=".!$dir, $guildmemberCount, $itemperpage, $start)."</div> 248 249 <tr><td><table class=\"lined\"><tr>"; 250 251 if ($user_lvl >= 4 || $inguild || $amIguildleader) $output .= " <th width=\"3%\">{$lang_guild['remove']}</th>"; 252 253 $output .= " 254 <th width=\"21%\"><a href=\"guild.php?action=view_guild&id=$guild_id&order_by=cname&start=$start&dir=$dir\">".($order_by=='cname' ? "<img src=\"img/arr_".($dir ? "up" : "dw").".gif\" /> " : "")."{$lang_guild['name']}</a></th> 255 <th width=\"3%\"><a href=\"guild.php?action=view_guild&id=$guild_id&order_by=crace&start=$start&dir=$dir\">".($order_by=='crace' ? "<img src=\"img/arr_".($dir ? "up" : "dw").".gif\" /> " : "")."{$lang_guild['race']}</a></th> 256 <th width=\"3%\"><a href=\"guild.php?action=view_guild&id=$guild_id&order_by=class&start=$start&dir=$dir\">".($order_by=='cclass' ? "<img src=\"img/arr_".($dir ? "up" : "dw").".gif\" /> " : "")."{$lang_guild['class']}</a></th> 257 <th width=\"3%\"><a href=\"guild.php?action=view_guild&id=$guild_id&order_by=clevel&start=$start&dir=$dir\">".($order_by=='clevel' ? "<img src=\"img/arr_".($dir ? "up" : "dw").".gif\" /> " : "")."{$lang_guild['level']}</a></th> 258 <th width=\"21%\"><a href=\"guild.php?action=view_guild&id=$guild_id&order_by=mrank&start=$start&dir=$dir\">".($order_by=='mrank' ? "<img src=\"img/arr_".($dir ? "up" : "dw").".gif\" /> " : "")."{$lang_guild['rank']}</a></th> 259 <th width=\"14%\">{$lang_guild['pnote']}</th> 260 <th width=\"14%\">{$lang_guild['offnote']}</th> 261 <th width=\"15%\"><a href=\"guild.php?action=view_guild&id=$guild_id&order_by=clogout&start=$start&dir=$dir\">".($order_by=='clogout' ? "<img src=\"img/arr_".($dir ? "up" : "dw").".gif\" /> " : "")."{$lang_guild['llogin']}</a></th> 262 <th width=\"3%\"><a href=\"guild.php?action=view_guild&id=$guild_id&order_by=conline&start=$start&dir=$dir\">".($order_by=='conline' ? "<img src=\"img/arr_".($dir ? "up" : "dw").".gif\" /> " : "")."{$lang_guild['online']}</a></th> 263 </tr>"; 264 265 $members = $sql->query("SELECT gm.guid as cguid, c.name as cname, c.`race` as crace ,c.`class` as cclass, SUBSTRING_INDEX(SUBSTRING_INDEX(c.`data`, ' ', 35), ' ', -1) AS clevel, gm.rank AS mrank, (SELECT rname FROM guild_rank WHERE guildid ='$guild_id' AND rid = mrank+1) AS rname, gm.Pnote, gm.OFFnote, mid(lpad( hex( CAST(substring_index(substring_index(data,' ',37),' ',-1) as unsigned) ),8,'0'),4,1) as gender, c.`online` as conline, c.`account`, c.`logout_time` as clogout 266 FROM guild_member as gm 267 left outer join characters as c on c.guid = gm.guid 268 WHERE gm.guildid = '$guild_id' 269 ORDER BY $order_by $order_dir LIMIT $start, $itemperpage"); 270 271 $sql->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']); 272 while ($member = $sql->fetch_row($members)){ 273 274 $result = $sql->query("SELECT gmlevel FROM account WHERE id ='$member[11]'"); 275 $owner_gmlvl = $sql->result($result, 0, 'gmlevel'); 276 277 $llogin = count_days($member[12], time()); 278 279 if($member[4] < 10) 280 $lev = '<font color="#FFFFFF">'.$member[4].'</font>'; 281 else if($member[4] < 20) 282 $lev = '<font color="#858585">'.$member[4].'</font>'; 283 else if($member[4] < 30) 284 $lev = '<font color="#339900">'.$member[4].'</font>'; 285 else if($member[4] < 40) 286 $lev = '<font color="#3300CC">'.$member[4].'</font>'; 287 else if($member[4] < 50) 288 $lev = '<font color="#C552FF">'.$member[4].'</font>'; 289 else if($member[4] < 60) 290 $lev = '<font color="#FF8000">'.$member[4].'</font>'; 291 else if($member[4] < 70) 292 $lev = '<font color="#FFF280">'.$member[4].'</font>'; 293 else if($member[4] < 80) 294 $lev = '<font color="#FF0000">'.$member[4].'</font>'; 295 else 296 $lev = '<font color="#000000">'.$member[4].'</font>'; 297 298 if($llogin < 1) 299 $lastlogin = '<font color="#009900">'.$llogin.'</font>'; 300 else if($llogin < 6) 301 $lastlogin = '<font color="#0000CC">'.$llogin.'</font>'; 302 else if($llogin < 16) 303 $lastlogin = '<font color="#FFFF00">'.$llogin.'</font>'; 304 else if($llogin < 16) 305 $lastlogin = '<font color="#FF8000">'.$llogin.'</font>'; 306 else if($llogin < 31) 307 $lastlogin = '<font color="#FF0000">'.$llogin.'</font>'; 308 else if($llogin < 61) 309 $lastlogin = '<font color="#FF00FF">'.$llogin.'</font>'; 310 else 311 $lastlogin = '<font color="#FF0000">'.$llogin.'</font>'; 312 313 $output .= " <tr>"; 314 // gm, gildleader or own account! are allowed to remove from guild 315 $output .= ($user_lvl >= 4 || $amIguildleader || $member[11] == $user_id) ? 316 " <td><img src=\"img/aff_cross.png\" alt=\"\" onclick=\"answerBox('{$lang_global['delete']}: <font color=white>{$member[1]}</font><br />{$lang_global['are_you_sure']}', 'guild.php?action=rem_char_from_guild&id=$member[0]&guld_id=$guild_id');\" style=\"cursor:pointer;\" /></td>" : 317 " <td></td>"; 318 319 320 $output .= ($user_lvl < $owner_gmlvl ) ? "<td>$member[1]</td>" : "<td><a href=\"char.php?id=$member[0]\">$member[1]</a></td>"; 321 $output .= "<td><img src='img/c_icons/{$member[2]}-{$member[9]}.gif' onmousemove='toolTip(\"".get_player_race($member[2])."\",\"item_tooltip\")' onmouseout='toolTip()' /></td> 322 <td><img src='img/c_icons/{$member[3]}.gif' onmousemove='toolTip(\"".get_player_class($member[3])."\",\"item_tooltip\")' onmouseout='toolTip()' /></td> 323 <td>$lev</td> 324 <td>$member[6] ($member[5])</td> 325 <td>$member[7]</td> 326 <td>$member[8]</td> 327 <td>$lastlogin</td> 328 <td>".(($member[10]) ? "<img src=\"img/up.gif\" alt=\"\" />" : "-")."</td> 329 </tr>"; 330 } 331 332 333 $output .= "</table></td></tr></table><br />"; 334 $sql->close(); 335 336 337 $output .= "<table class=\"hidden\"> 338 <tr><td>"; 339 makebutton($lang_guild['show_guilds'], "guild.php", 272); 340 $output .= "</td>"; 341 342 if ($user_lvl >= 4 || $amIguildleader){ 343 344 $output .= "<td>"; 345 makebutton($lang_guild['del_guild'], "guild.php?action=del_guild&id=$guild_id", 272); 346 } 347 348 $output .= "</td></tr></table> 349 </fieldset></center><br />"; 350 } 351 352 //######################################################################################################################## 353 // ARE YOU SURE YOU WOULD LIKE TO OPEN YOUR AIRBAG? 354 //######################################################################################################################## 355 function del_guild() { 356 global $lang_guild, $lang_global, $output, $user_lvl, $user_id, $characters_db, $realm_id; 357 if(isset($_GET['id'])) $id = $_GET['id']; 358 else redirect("guild.php?error=1"); 359 if (!preg_match('/^[[:digit:]]{1,12}$/', $id)) redirect("guild.php?error=5"); 360 190 361 $sql = new SQL; 191 362 $sql->connect($characters_db[$realm_id]['addr'], $characters_db[$realm_id]['user'], $characters_db[$realm_id]['pass'], $characters_db[$realm_id]['name']); 192 363 193 $guild_id = $sql->quote_smart($_GET['id']); 194 195 $query = $sql->query("SELECT guildid, name, info, MOTD, createdate FROM guild WHERE guildid = '$guild_id'"); 196 $guild_data = $sql->fetch_row($query); 197 198 $members = $sql->query("SELECT guild_member.guid, guild_member.rank AS mrank, 199 `characters`.name, SUBSTRING_INDEX(SUBSTRING_INDEX(`characters`.`data`, ' ', 35), ' ', -1) AS level, 200 (SELECT rname FROM guild_rank WHERE guildid ='$guild_id' AND rid = mrank+1) AS rname, 201 guild_member.Pnote, guild_member.OFFnote 202 FROM guild_member,`characters` 203 LEFT JOIN guild_member k1 ON k1.`guid`=`characters`.`guid` 204 WHERE guild_member.guildid = '$guild_id' AND guild_member.guid=`characters`.guid 205 ORDER BY mrank"); 206 207 208 209 $total_members = $sql->num_rows($members); 210 211 if (!$guild_data[2]) $guild_data[2] = $lang_global['none']; 212 213 $output .= "<script type=\"text/javascript\"> 214 answerbox.btn_ok='{$lang_global['yes_low']}'; 215 answerbox.btn_cancel='{$lang_global['no']}'; 216 </script> 217 <center> 218 <fieldset style=\"width: 950px;\"> 219 <legend>{$lang_guild['guild']}</legend> 220 <table class=\"lined\" style=\"width: 910px;\"> 221 <tr class=\"bold\"> 222 <td colspan=\"11\">$guild_data[1]</td> 223 </tr> 224 <tr> 225 <td colspan=\"11\">{$lang_guild['create_date']}: $guild_data[4]</td> 226 </tr> 227 <tr> 228 <td colspan=\"11\">{$lang_guild['info']}: $guild_data[2]</td> 229 </tr> 230 <tr> 231 <td colspan=\"11\">{$lang_guild['motd']}: $guild_data[3]</td> 232 </tr> 233 <tr> 234 <td colspan=\"11\">{$lang_guild['tot_members']}: $total_members</td> 235 </tr> 236 <tr>"; 237 if ($user_lvl > 2){ 238 $output .= " <th width=\"3%\">{$lang_guild['remove']}</th>"; 239 } 240 $output .= " 241 <th width=\"21%\">{$lang_guild['name']}</th> 242 <th width=\"3%\">Race</th> 243 <th width=\"3%\">Class</th> 244 <th width=\"3%\">{$lang_guild['level']}</th> 245 <th width=\"21%\">{$lang_guild['rank']}</th> 246 <th width=\"14%\">Player Note</th> 247 <th width=\"14%\">Office Note</th> 248 <th width=\"15%\">Last Login (Days)</th> 249 <th width=\"3%\">Online</th> 250 </tr>"; 251 252 while ($member = $sql->fetch_row($members)){ 253 254 $query = $sql->query("SELECT `race`,`class`,`online`, `account`, `logout_time`, SUBSTRING_INDEX(SUBSTRING_INDEX(`characters`.`data`, ' ', 35), ' ', -1) AS level, mid(lpad( hex( CAST(substring_index(substring_index(data,' ',".(36+1)."),' ',-1) as unsigned) ),8,'0'),4,1) as gender FROM `characters` WHERE `name` = '$member[2]';"); 255 256 $online = $sql->fetch_row($query); 257 $accid = $online[3]; 258 $llogin = count_days($online[4], time()); 259 260 $level = $online[5]; 261 262 if($level > 0) 263 { 264 $lev = '<font color="#FFFFFF">'.$level.'</font>'; 265 } 266 if($level > 9) 267 { 268 $lev = '<font color="#858585">'.$level.'</font>'; 269 } 270 if($level > 19) 271 { 272 $lev = '<font color="#339900">'.$level.'</font>'; 273 } 274 if($level > 29) 275 { 276 $lev = '<font color="#3300CC">'.$level.'</font>'; 277 } 278 if($level > 39) 279 { 280 $lev = '<font color="#5552FF">'.$level.'</font>'; 281 } 282 if($level > 49) 283 { 284 $lev = '<font color="#FF8000">'.$level.'</font>'; 285 } 286 if($level > 59) 287 { 288 $lev = '<font color="#FF0000">'.$level.'</font>'; 289 } 290 if($level > 69) 291 { 292 $lev = '<font color="#FF00CC">'.$level.'</font>'; 293 } 294 if($level > 70) 295 { 296 $lev = '<font color="#FFF000">'.$level.'</font>'; 297 } 298 299 300 if($llogin < 1) 301 { 302 $lastlogin = '<font color="#009900">'.$llogin.'</font>'; 303 } 304 if($llogin >= 1) 305 { 306 $lastlogin = '<font color="#0000CC">'.$llogin.'</font>'; 307 } 308 if($llogin > 5) 309 { 310 $lastlogin = '<font color="#FFFF00">'.$llogin.'</font>'; 311 } 312 if($llogin > 15) 313 { 314 $lastlogin = '<font color="#FF8000">'.$llogin.'</font>'; 315 } 316 if($llogin > 30) 317 { 318 $lastlogin = '<font color="#FF0000">'.$llogin.'</font>'; 319 } 320 if($llogin > 60) 321 { 322 $lastlogin = '<font color="#FF00FF">'.$llogin.'</font>'; 323 } 324 if($llogin > 90) 325 { 326 $lastlogin = '<font color="#8000FF">'.$llogin.'</font>'; 327 } 328 329 $output .= " <tr>"; 330 if ($user_lvl > 2){ 331 $output .= " <td><img src=\"img/aff_cross.png\" alt=\"\" onclick=\"answerBox('{$lang_global['delete']}: <font color=white>{$member[2]}</font><br />{$lang_global['are_you_sure']}', 'guild.php?action=rem_char_from_guild&id=$member[0]&guld_id=$guild_id');\" style=\"cursor:pointer;\" /></td>"; 332 } 333 $output .= " <td><a href=\"char.php?id=$member[0]\">$member[2]</a></td> 334 <td><img src='img/c_icons/{$online[0]}-{$online[6]}.gif' onmousemove='toolTip(\"".get_player_race($online[0])."\",\"item_tooltip\")' onmouseout='toolTip()' /></td> 335 <td><img src='img/c_icons/{$online[1]}.gif' onmousemove='toolTip(\"".get_player_class($online[1])."\",\"item_tooltip\")' onmouseout='toolTip()' /></td> 336 <td>$lev</td> 337 <td>$member[4] ($member[1])</td> 338 <td>$member[5]</td> 339 <td>$member[6]</td> 340 <td>$lastlogin</td> 341 <td>".(($online[2]) ? "<img src=\"img/up.gif\" alt=\"\" />" : "-")."</td> 342 </tr>"; 343 } 344 345 346 $output .= "</table><br />"; 347 $sql->close(); 348 349 $output .= "<table class=\"hidden\"> 364 $q_amIguildleader = $sql->query("select 1 from guild where guildid = '$id' and leaderguid in (select guid from characters where account = '$user_id')"); 365 $amIguildleader = $sql->result($q_amIguildleader, 0, '1'); 366 367 if ($user_lvl <= 4 && !$amIguildleader) redirect("guild.php?error=6"); 368 369 $output .= "<center><h1><font class=\"error\">{$lang_global['are_you_sure']}</font></h1><br /> 370 <font class=\"bold\">{$lang_guild['guild_id']}: $id {$lang_global['will_be_erased']}</font><br /><br /> 371 <form action=\"cleanup.php?action=docleanup\" method=\"post\" name=\"form\"> 372 <input type=\"hidden\" name=\"type\" value=\"guild\" /> 373 <input type=\"hidden\" name=\"check\" value=\"-$id\" /> 374 <input type=\"hidden\" name=\"override\" value=\"1\" /> 375 <table class=\"hidden\"> 350 376 <tr><td>"; 351 makebutton($lang_guild['guilds'], "guild.php", 272); 352 $output .= "</td> 353 <td>"; 354 if ($user_lvl > 2){ 355 makebutton($lang_guild['del_guild'], "guild.php?action=del_guild&id=$guild_id", 272); 356 $output .= "</td></tr> 357 <tr><td colspan=\"2\">"; 358 makebutton($lang_global['back'], "javascript:window.history.back()",556); 359 $output .= "</td></tr>"; 360 } else { 361 makebutton($lang_global['back'], "javascript:window.history.back()",272); 362 $output .= "</td></tr>"; 363 } 364 365 $output .= "</table> 366 </fieldset></center><br />"; 367 } 368 369 //######################################################################################################################## 370 // ARE YOU SURE YOU WOULD LIKE TO OPEN YOUR AIRBAG? 371 //######################################################################################################################## 372 function del_guild() { 373 global $lang_guild, $lang_global, $output; 374 if(isset($_GET['id'])) $id = $_GET['id']; 375 else redirect("guild.php?error=1"); 376 377 $output .= "<center><h1><font class=\"error\">{$lang_global['are_you_sure']}</font></h1><br /> 378 <font class=\"bold\">{$lang_guild['guild_id']}: $id {$lang_global['will_be_erased']}</font><br /><br /> 379 <form action=\"cleanup.php?action=docleanup\" method=\"post\" name=\"form\"> 380 <input type=\"hidden\" name=\"type\" value=\"guild\" /> 381 <input type=\"hidden\" name=\"check\" value=\"-$id\" /> 382 <table class=\"hidden\"> 383 <tr><td>"; 384 makebutton($lang_global['yes'], "javascript:do_submit()",120); 385 makebutton($lang_global['no'], "guild.php?action=view_guild&id=$id",120); 377 makebutton($lang_global['yes'], "javascript:do_submit()",120); 378 makebutton($lang_global['no'], "guild.php?action=view_guild&id=$id",120); 386 379 $output .= "</td></tr> 387 380 </table> 388 </form></center><br />"; 381 </form></center><br />"; 382 383 $sql->close(); 389 384 } 390 385 … … 393 388 //REMOVE CHAR FROM GUILD 394 389 function rem_char_from_guild(){ 395 global $characters_db, $realm_id, $user_lvl; 396 397 require_once("scripts/defines.php"); 398 399 if(isset($_GET['id'])) $guid = $_GET['id']; 400 else redirect("guild.php?error=1"); 401 if(isset($_GET['guld_id'])) $guld_id = $_GET['guld_id']; 402 else redirect("guild.php?error=1"); 403 404 $sql = new SQL; 405 $sql->connect($characters_db[$realm_id]['addr'], $characters_db[$realm_id]['user'], $characters_db[$realm_id]['pass'], $characters_db[$realm_id]['name']); 406 407 $char_data = $sql->query("SELECT data FROM `characters` WHERE guid = '$guid' LIMIT 1"); 408 $data = $sql->result($char_data, 0, 'data'); 409 $data = explode(' ',$data); 410 $data[CHAR_DATA_OFFSET_GUILD_ID] = 0; 411 $data[CHAR_DATA_OFFSET_GUILD_RANK] = 0; 412 $data = implode(' ',$data); 413 $sql->query("UPDATE `characters` SET data = '$data' WHERE guid = '$guid'"); 414 $sql->query("DELETE FROM guild_member WHERE guid = '$guid'"); 415 416 $sql->close(); 417 redirect("guild.php?action=view_guild&id=$guld_id"); 390 global $characters_db, $realm_id, $user_lvl, $user_id; 391 392 require_once("scripts/defines.php"); 393 394 if(isset($_GET['id'])) $guid = $_GET['id']; 395 else redirect("guild.php?error=1"); 396 if (!preg_match('/^[[:digit:]]{1,12}$/', $guid)) redirect("guild.php?error=5"); 397 if(isset($_GET['guld_id'])) $guld_id = $_GET['guld_id']; 398 else redirect("guild.php?error=1"); 399 if (!preg_match('/^[[:digit:]]{1,12}$/', $guld_id)) redirect("guild.php?error=5"); 400 401 $sql = new SQL; 402 $sql->connect($characters_db[$realm_id]['addr'], $characters_db[$realm_id]['user'], $characters_db[$realm_id]['pass'], $characters_db[$realm_id]['name']); 403 404 $q_amIguildleaderOrSelfRemoval = $sql->query("select 1 from guild as g 405 left outer join guild_member as gm on gm.guildid = g.guildid 406 where g.guildid = '$guld_id' and 407 (g.leaderguid in (select guid from characters where account = '$user_id') or gm.guid in (select guid from characters where account = '$user_id' and guid = '$guid'))"); 408 409 $amIguildleaderOrSelfRemoval = $sql->result($q_amIguildleaderOrSelfRemoval, 0, '1'); 410 411 if ($user_lvl <= 4 && !$amIguildleaderOrSelfRemoval ) redirect("guild.php?error=6"); 412 413 $char_data = $sql->query("SELECT data FROM `characters` WHERE guid = '$guid'"); 414 $data = $sql->result($char_data, 0, 'data'); 415 $data = explode(' ',$data); 416 $data[CHAR_DATA_OFFSET_GUILD_ID] = 0; 417 $data[CHAR_DATA_OFFSET_GUILD_RANK] = 0; 418 $data = implode(' ',$data); 419 $sql->query("UPDATE `characters` SET data = '$data' WHERE guid = '$guid'"); 420 $sql->query("DELETE FROM guild_member WHERE guid = '$guid'"); 421 422 $sql->close(); 423 redirect("guild.php?action=view_guild&id=$guld_id"); 418 424 } 419 425 … … 426 432 switch ($err) { 427 433 case 1: 428 $output .= "<h1><font class=\"error\">{$lang_global['e mpty_fields']}</font></h1>";434 $output .= "<h1><font class=\"error\">{$lang_global['err_empty_fields']}</font></h1>"; 429 435 break; 430 436 case 2: … … 436 442 $output .= "<h1>{$lang_guild['guild_search_result']}:</h1>"; 437 443 break; 444 case 5: 445 $output .= "<h1>{$lang_global['err_invalid_input']}:</h1>"; 446 break; 447 case 6: 448 $output .= "<h1>{$lang_global['err_no_permission']}:</h1>"; 449 break; 438 450 default: //no error 439 451 $output .= "<h1>{$lang_guild['browse_guilds']}</h1>"; … … 447 459 browse_guilds(); 448 460 break; 449 case "search":450 search();451 break;452 461 case "view_guild": 453 462 view_guild();
Note:
See TracChangeset
for help on using the changeset viewer.