Changeset 19 for minimanager/guild.php
- Timestamp:
- Aug 13, 2007, 9:05:34 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
minimanager/guild.php
r5 r19 18 18 global $lang_guild, $lang_global, $output, $mangos_db, $realm_id, $itemperpage; 19 19 20 $ mysql = new MySQL;21 $ mysql->connect($mangos_db[$realm_id]['addr'], $mangos_db[$realm_id]['user'], $mangos_db[$realm_id]['pass'], $mangos_db[$realm_id]['name']);22 23 $start = (isset($_GET['start'])) ? $ mysql->quote_smart($_GET['start']) : 0;24 $order_by = (isset($_GET['order_by'])) ? $ mysql->quote_smart($_GET['order_by']) : "guildid";25 26 $dir = (isset($_GET['dir'])) ? $ mysql->quote_smart($_GET['dir']) : 1;20 $sql = new SQL; 21 $sql->connect($mangos_db[$realm_id]['addr'], $mangos_db[$realm_id]['user'], $mangos_db[$realm_id]['pass'], $mangos_db[$realm_id]['name']); 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 27 $order_dir = ($dir) ? "ASC" : "DESC"; 28 28 $dir = ($dir) ? 0 : 1; 29 29 30 //get total number of items 31 $ query_1 = $mysql->query("SELECT count(*) FROM guild");32 $all_record = $mysql->result($query_1,0); 33 34 $query = $mysql->query("SELECT guildid, name, leaderguid, SUBSTRING_INDEX(MOTD,' ',6), createdate 35 FROM guild ORDER BY $order_by $order_dir LIMIT $start, $itemperpage");36 $this_page = $ mysql->num_rows($query);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 gname,guild.leaderguid AS lguid,SUBSTRING_INDEX(guild.MOTD,' ',6), guild.createdate, 34 (SELECT name FROM `character` 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 37 38 38 //==========================top tage navigaion starts here======================== … … 46 46 <input type=\"text\" size=\"45\" name=\"search_value\" /> 47 47 <select name=\"search_by\"> 48 <option value=\" name\">{$lang_guild['by_name']}</option>48 <option value=\"gname\">{$lang_guild['by_name']}</option> 49 49 <option value=\"leaderguid\">{$lang_guild['by_guild_leader']}</option> 50 50 <option value=\"createdate\">{$lang_guild['by_create_date']}</option> … … 60 60 $output .= "<table class=\"lined\"> 61 61 <tr> 62 <td width=\"5%\" class=\"head\"><a href=\"guild.php?order_by=guildid&start=$start&dir=$dir\" class=\"head_link\">{$lang_guild['id']}</a></td> 63 <td width=\"25%\" class=\"head\"><a href=\"guild.php?order_by=name&start=$start&dir=$dir\" class=\"head_link\">{$lang_guild['guild_name']}</a></td> 64 <td width=\"15%\" class=\"head\"><a href=\"guild.php?order_by=leaderguid&start=$start&dir=$dir\" class=\"head_link\">{$lang_guild['guild_leader']}</a></td> 65 <td width=\"40%\" class=\"head\"><a href=\"guild.php?order_by=MOTD&start=$start&dir=$dir\" class=\"head_link\">{$lang_guild['guild_motd']}</a></td> 66 <td width=\"15%\" class=\"head\"><a href=\"guild.php?order_by=createdate&start=$start&dir=$dir\" class=\"head_link\">{$lang_guild['create_date']}</a></td> 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=\"25%\"><a href=\"guild.php?order_by=gname&start=$start&dir=$dir\">".($order_by=='gname' ? "<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=\"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> 66 <th width=\"35%\">{$lang_guild['guild_motd']}</th> 67 <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> 67 68 </tr>"; 68 69 69 $looping = ($this_page < $itemperpage) ? $this_page : $itemperpage; 70 71 for ($i=1; $i<=$looping; $i++) { 72 $data = $mysql->fetch_row($query); 73 74 $result = $mysql->query("SELECT name FROM `character` WHERE guid ='$data[2]'"); 75 $guild_leader = ($mysql->num_rows($result)) ? $mysql->result($result, 0, 'name') : ""; 76 77 $output .= "<tr> 78 <td>$data[0]</td> 79 <td><a href=\"guild.php?action=view_guild&error=3&id=$data[0]\">$data[1]</a></td> 80 <td><a href=\"char.php?id=$data[2]\">$guild_leader</a></td> 81 <td>$data[3] ...</td> 82 <td class=\"small\">$data[4]</td> 70 while ($data = $sql->fetch_row($query)) { 71 $output .= "<tr> 72 <td>$data[0]</td> 73 <td><a href=\"guild.php?action=view_guild&error=3&id=$data[0]\">$data[1]</a></td> 74 <td>$data[6]</td> 75 <td><a href=\"char.php?id=$data[2]\">$data[5]</a></td> 76 <td>$data[3] ...</td> 77 <td class=\"small\">$data[4]</td> 83 78 </tr>"; 84 79 } … … 87 82 </table></center>"; 88 83 89 $ mysql->close();84 $sql->close(); 90 85 } 91 86 … … 99 94 if(!isset($_GET['search_value']) || !isset($_GET['search_by'])) redirect("guild.php?error=2"); 100 95 101 $ mysql = new MySQL;102 $ mysql->connect($mangos_db[$realm_id]['addr'], $mangos_db[$realm_id]['user'], $mangos_db[$realm_id]['pass'], $mangos_db[$realm_id]['name']);103 104 $search_value = $ mysql->quote_smart($_GET['search_value']);105 $search_by = $ mysql->quote_smart($_GET['search_by']);106 107 if(isset($_GET['order_by'])) $order_by = $ mysql->quote_smart($_GET['order_by']);96 $sql = new SQL; 97 $sql->connect($mangos_db[$realm_id]['addr'], $mangos_db[$realm_id]['user'], $mangos_db[$realm_id]['pass'], $mangos_db[$realm_id]['name']); 98 99 $search_value = $sql->quote_smart($_GET['search_value']); 100 $search_by = $sql->quote_smart($_GET['search_by']); 101 102 if(isset($_GET['order_by'])) $order_by = $sql->quote_smart($_GET['order_by']); 108 103 else $order_by = "guildid"; 109 104 110 $dir = (isset($_GET['dir'])) ? $ mysql->quote_smart($_GET['dir']) : 1;105 $dir = (isset($_GET['dir'])) ? $sql->quote_smart($_GET['dir']) : 1; 111 106 $order_dir = ($dir) ? "ASC" : "DESC"; 112 107 $dir = ($dir) ? 0 : 1; 113 114 if ($search_by == "leaderguid") { 115 $temp = $mysql->query("SELECT guid FROM `character` WHERE name ='$search_value'"); 116 $search_value = $mysql->result($temp, 0, 'guid'); 117 } 118 119 $query = $mysql->query("SELECT guildid, name, leaderguid, SUBSTRING_INDEX(MOTD,' ',6), createdate 120 FROM guild WHERE $search_by LIKE '%$search_value%' ORDER BY $order_by $order_dir LIMIT $sql_search_limit"); 121 $total_found = $mysql->num_rows($query); 108 109 if ($search_by == "leaderguid"){ 110 $temp = $sql->query("SELECT guid FROM `character` WHERE name ='$search_value'"); 111 $search_value = $sql->result($temp, 0, 'guid'); 112 } 113 114 $query = $sql->query("SELECT guild.guildid AS gid, guild.name AS gname,guild.leaderguid AS lguid,SUBSTRING_INDEX(guild.MOTD,' ',6), guild.createdate, 115 (SELECT name FROM `character` WHERE guid = lguid) AS l_name, (SELECT COUNT(*) FROM guild_member WHERE guildid = gid) AS tot_chars 116 FROM guild WHERE $search_by LIKE '%$search_value%' ORDER BY $order_by $order_dir LIMIT $sql_search_limit"); 117 $total_found = $sql->num_rows($query); 122 118 123 119 //==========================top tage navigaion starts here======================== … … 131 127 <input type=\"text\" size=\"30\" name=\"search_value\" /> 132 128 <select name=\"search_by\"> 133 <option value=\" name\">{$lang_guild['by_name']}</option>129 <option value=\"gname\">{$lang_guild['by_name']}</option> 134 130 <option value=\"leaderguid\">{$lang_guild['by_guild_leader']}</option> 135 131 <option value=\"createdate\">{$lang_guild['by_create_date']}</option> … … 143 139 $output .= "<table class=\"lined\"> 144 140 <tr> 145 <td width=\"5%\" class=\"head\"><a href=\"guild.php?action=search&error=4&order_by=guildid&search_by=$search_by&search_value=$search_value&dir=$dir\" class=\"head_link\">{$lang_guild['id']}</a></td> 146 <td width=\"25%\" class=\"head\"><a href=\"guild.php?action=search&error=4&order_by=name&search_by=$search_by&search_value=$search_value&dir=$dir\" class=\"head_link\">{$lang_guild['guild_name']}</a></td> 147 <td width=\"15%\" class=\"head\"><a href=\"guild.php?action=search&error=4&order_by=leaderguid&search_by=$search_by&search_value=$search_value&dir=$dir\" class=\"head_link\">{$lang_guild['guild_leader']}</a></td> 148 <td width=\"40%\" class=\"head\"><a href=\"guild.php?action=search&error=4&order_by=MOTD&search_by=$search_by&search_value=$search_value&dir=$dir\" class=\"head_link\">{$lang_guild['guild_motd']}</a></td> 149 <td width=\"15%\" class=\"head\"><a href=\"guild.php?action=search&error=4&order_by=createdate&search_by=$search_by&search_value=$search_value&dir=$dir\" class=\"head_link\">{$lang_guild['create_date']}</a></td> 141 <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> 142 <th width=\"25%\"><a href=\"guild.php?action=search&error=4&order_by=gname&search_by=$search_by&search_value=$search_value&dir=$dir\">".($order_by=='gname' ? "<img src=\"img/arr_".($dir ? "up" : "dw").".gif\" /> " : "")."{$lang_guild['guild_name']}</a></th> 143 <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> 144 <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> 145 <th width=\"35%\">{$lang_guild['guild_motd']}</th> 146 <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> 150 147 </tr>"; 151 148 152 for ($i=1; $i<=$total_found; $i++){ 153 $data =$mysql->fetch_row($query); 154 155 $result = $mysql->query("SELECT name FROM `character` WHERE guid ='$data[2]'"); 156 $guild_leader = ($mysql->num_rows($result)) ? $mysql->result($result, 0, 'name') : ""; 157 158 $output .= "<tr>"; 159 $output .= "<td>$data[0]</td> 160 <td><a href=\"guild.php?action=view_guild&error=3&id=$data[0]\">$data[1]</a></td> 161 <td><a href=\"char.php?id=$data[2]\">$guild_leader</a></td> 162 <td>$data[3] ...</td> 163 <td class=\"small\">$data[4]</td> 149 while ($data =$sql->fetch_row($query)){ 150 $output .= "<tr> 151 <td>$data[0]</td> 152 <td><a href=\"guild.php?action=view_guild&error=3&id=$data[0]\">$data[1]</a></td> 153 <td>$data[6]</td> 154 <td><a href=\"char.php?id=$data[2]\">$data[5]</a></td> 155 <td>$data[3] ...</td> 156 <td class=\"small\">$data[4]</td> 164 157 </tr>"; 165 158 } … … 170 163 </table></center>"; 171 164 172 $ mysql->close();165 $sql->close(); 173 166 } 174 167 … … 182 175 if(!isset($_GET['id'])) redirect("guild.php?error=1"); 183 176 184 $mysql = new MySQL; 185 $mysql->connect($mangos_db[$realm_id]['addr'], $mangos_db[$realm_id]['user'], $mangos_db[$realm_id]['pass'], $mangos_db[$realm_id]['name']); 186 187 $guild_id = $mysql->quote_smart($_GET['id']); 188 189 $query = $mysql->query("SELECT guildid, name, info, MOTD, createdate FROM guild WHERE guildid = '$guild_id'"); 190 $guild_data = $mysql->fetch_row($query); 191 192 $members = $mysql->query("SELECT guid, rank FROM guild_member WHERE guildid = '$guild_id' ORDER BY rank"); 193 $total_members = $mysql->num_rows($members); 177 $sql = new SQL; 178 $sql->connect($mangos_db[$realm_id]['addr'], $mangos_db[$realm_id]['user'], $mangos_db[$realm_id]['pass'], $mangos_db[$realm_id]['name']); 179 180 $guild_id = $sql->quote_smart($_GET['id']); 181 182 $query = $sql->query("SELECT guildid, name, info, MOTD, createdate FROM guild WHERE guildid = '$guild_id'"); 183 $guild_data = $sql->fetch_row($query); 184 185 $members = $sql->query("SELECT guild_member.guid, guild_member.rank AS mrank, 186 `character`.name, SUBSTRING_INDEX(SUBSTRING_INDEX(`character`.`data`, ' ', 35), ' ', -1) AS level, 187 (SELECT rname FROM guild_rank WHERE guildid ='$guild_id' AND rid = mrank) AS rname 188 FROM guild_member,`character` 189 LEFT JOIN guild_member k1 ON k1.`guid`=`character`.`guid` 190 WHERE guild_member.guildid = '$guild_id' AND guild_member.guid=`character`.guid 191 ORDER BY mrank"); 192 $total_members = $sql->num_rows($members); 194 193 195 194 if (!$guild_data[2]) $guild_data[2] = $lang_global['none']; 196 195 197 $output .= "<center> 196 $output .= "<script type=\"text/javascript\"> 197 answerbox.btn_ok='{$lang_global['yes_low']}'; 198 answerbox.btn_cancel='{$lang_global['no']}'; 199 </script> 200 <center> 198 201 <fieldset style=\"width: 600px;\"> 199 202 <legend>{$lang_guild['guild']}</legend> … … 215 218 </tr> 216 219 <tr> 217 <t d width=\"5%\" class=\"head\">{$lang_guild['remove']}</td>218 <t d width=\"45%\" class=\"head\">{$lang_guild['name']}</td>219 <t d width=\"5%\" class=\"head\">{$lang_guild['level']}</td>220 <t d width=\"45%\" class=\"head\">{$lang_guild['rank']}</td>220 <th width=\"5%\">{$lang_guild['remove']}</th> 221 <th width=\"45%\">{$lang_guild['name']}</th> 222 <th width=\"5%\">{$lang_guild['level']}</th> 223 <th width=\"45%\">{$lang_guild['rank']}</th> 221 224 </tr>"; 222 223 while ($member = $mysql->fetch_row($members)){ 224 $result = $mysql->query("SELECT name,SUBSTRING_INDEX(SUBSTRING_INDEX(`data`, ' ', 35), ' ', -1) FROM `character` WHERE guid ='$member[0]'"); 225 $member_data = $mysql->fetch_row($result); 226 227 if ($member[1]){ 228 $result = $mysql->query("SELECT rname FROM guild_rank WHERE guildid ='$guild_data[0]' AND rid='$member[1]'"); 229 $member_rank = $mysql->result($result, 0, 'rname'); 230 } else $member_rank = $lang_guild['guild_leader']; 231 225 226 while ($member = $sql->fetch_row($members)){ 232 227 $output .= " <tr> 233 <td>< a href=\"guild.php?action=rem_char_from_guild&id=$member[0]&guld_id=$guild_id\"><img src=\"img/x.ico\" class=\"no_border\" alt=\"\" /></a></td>234 <td><a href=\"char.php?id=$member[0]\">$member _data[0]</a></td>235 <td>$member _data[1]</td>236 <td> $member_rank($member[1])</td>228 <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> 229 <td><a href=\"char.php?id=$member[0]\">$member[2]</a></td> 230 <td>$member[3]</td> 231 <td>".($member[4]?$member[4]:$lang_guild['guild_leader'])." ($member[1])</td> 237 232 </tr>"; 238 233 } 239 234 240 235 $output .= "</table><br />"; 241 $ mysql->close();236 $sql->close(); 242 237 243 238 $output .= "<table class=\"hidden\"> … … 296 291 else redirect("guild.php?error=1"); 297 292 298 $ mysql = new MySQL;299 $ mysql->connect($mangos_db[$realm_id]['addr'], $mangos_db[$realm_id]['user'], $mangos_db[$realm_id]['pass'], $mangos_db[$realm_id]['name']);300 301 $char_data = $ mysql->query("SELECT data FROM `character` WHERE guid = '$guid' LIMIT 1");302 $data = $ mysql->result($char_data, 0, 'data');293 $sql = new SQL; 294 $sql->connect($mangos_db[$realm_id]['addr'], $mangos_db[$realm_id]['user'], $mangos_db[$realm_id]['pass'], $mangos_db[$realm_id]['name']); 295 296 $char_data = $sql->query("SELECT data FROM `character` WHERE guid = '$guid' LIMIT 1"); 297 $data = $sql->result($char_data, 0, 'data'); 303 298 $data = explode(' ',$data); 304 299 $data[CHAR_DATA_OFFSET_GUILD_ID] = 0; 305 300 $data[CHAR_DATA_OFFSET_GUILD_RANK] = 0; 306 301 $data = implode(' ',$data); 307 $ mysql->query("UPDATE `character` SET data = '$data' WHERE guid = '$guid'");308 $ mysql->query("DELETE FROM guild_member WHERE guid = '$guid'");309 310 $ mysql->close();302 $sql->query("UPDATE `character` SET data = '$data' WHERE guid = '$guid'"); 303 $sql->query("DELETE FROM guild_member WHERE guid = '$guid'"); 304 305 $sql->close(); 311 306 redirect("guild.php?action=view_guild&id=$guld_id"); 312 307 }
Note:
See TracChangeset
for help on using the changeset viewer.