Changeset 19 for minimanager/guild.php


Ignore:
Timestamp:
Aug 13, 2007, 9:05:34 PM (17 years ago)
Author:
george
Message:

Aktualizace MaNGOS Minimanageru na verzi 0.1.4a.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • minimanager/guild.php

    r5 r19  
    1818 global $lang_guild, $lang_global, $output, $mangos_db, $realm_id, $itemperpage;
    1919
    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;
    2727 $order_dir = ($dir) ? "ASC" : "DESC";
    2828 $dir = ($dir) ? 0 : 1;
    2929 
    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);
    3737
    3838//==========================top tage navigaion starts here========================
     
    4646                        <input type=\"text\" size=\"45\" name=\"search_value\" />
    4747                        <select name=\"search_by\">
    48                                 <option value=\"name\">{$lang_guild['by_name']}</option>
     48                                <option value=\"gname\">{$lang_guild['by_name']}</option>
    4949                                <option value=\"leaderguid\">{$lang_guild['by_guild_leader']}</option>
    5050                                <option value=\"createdate\">{$lang_guild['by_create_date']}</option>
     
    6060 $output .= "<table class=\"lined\">
    6161   <tr>
    62         <td width=\"5%\" class=\"head\"><a href=\"guild.php?order_by=guildid&amp;start=$start&amp;dir=$dir\" class=\"head_link\">{$lang_guild['id']}</a></td>
    63         <td width=\"25%\" class=\"head\"><a href=\"guild.php?order_by=name&amp;start=$start&amp;dir=$dir\" class=\"head_link\">{$lang_guild['guild_name']}</a></td>
    64         <td width=\"15%\" class=\"head\"><a href=\"guild.php?order_by=leaderguid&amp;start=$start&amp;dir=$dir\" class=\"head_link\">{$lang_guild['guild_leader']}</a></td>
    65         <td width=\"40%\" class=\"head\"><a href=\"guild.php?order_by=MOTD&amp;start=$start&amp;dir=$dir\" class=\"head_link\">{$lang_guild['guild_motd']}</a></td>
    66         <td width=\"15%\" class=\"head\"><a href=\"guild.php?order_by=createdate&amp;start=$start&amp;dir=$dir\" class=\"head_link\">{$lang_guild['create_date']}</a></td>
     62        <th width=\"5%\"><a href=\"guild.php?order_by=gid&amp;start=$start&amp;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&amp;start=$start&amp;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&amp;start=$start&amp;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&amp;start=$start&amp;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&amp;start=$start&amp;dir=$dir\">".($order_by=='createdate' ? "<img src=\"img/arr_".($dir ? "up" : "dw").".gif\" /> " : "")."{$lang_guild['create_date']}</a></th>
    6768   </tr>";
    6869
    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&amp;error=3&amp;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>
     70while ($data = $sql->fetch_row($query)) {
     71        $output .= "<tr>
     72                         <td>$data[0]</td>
     73                         <td><a href=\"guild.php?action=view_guild&amp;error=3&amp;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>
    8378            </tr>";
    8479}
     
    8782   </table></center>";
    8883
    89  $mysql->close();
     84 $sql->close();
    9085}
    9186
     
    9994 if(!isset($_GET['search_value']) || !isset($_GET['search_by'])) redirect("guild.php?error=2");
    10095
    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']);
    108103        else $order_by = "guildid";
    109104
    110  $dir = (isset($_GET['dir'])) ? $mysql->quote_smart($_GET['dir']) : 1;
     105 $dir = (isset($_GET['dir'])) ? $sql->quote_smart($_GET['dir']) : 1;
    111106 $order_dir = ($dir) ? "ASC" : "DESC";
    112107 $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
     109if ($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);
    122118
    123119//==========================top tage navigaion starts here========================
     
    131127                        <input type=\"text\" size=\"30\" name=\"search_value\" />
    132128                        <select name=\"search_by\">
    133                                 <option value=\"name\">{$lang_guild['by_name']}</option>
     129                                <option value=\"gname\">{$lang_guild['by_name']}</option>
    134130                                <option value=\"leaderguid\">{$lang_guild['by_guild_leader']}</option>
    135131                                <option value=\"createdate\">{$lang_guild['by_create_date']}</option>
     
    143139 $output .= "<table class=\"lined\">
    144140   <tr>
    145         <td width=\"5%\" class=\"head\"><a href=\"guild.php?action=search&amp;error=4&amp;order_by=guildid&amp;search_by=$search_by&amp;search_value=$search_value&amp;dir=$dir\" class=\"head_link\">{$lang_guild['id']}</a></td>
    146         <td width=\"25%\" class=\"head\"><a href=\"guild.php?action=search&amp;error=4&amp;order_by=name&amp;search_by=$search_by&amp;search_value=$search_value&amp;dir=$dir\" class=\"head_link\">{$lang_guild['guild_name']}</a></td>
    147         <td width=\"15%\" class=\"head\"><a href=\"guild.php?action=search&amp;error=4&amp;order_by=leaderguid&amp;search_by=$search_by&amp;search_value=$search_value&amp;dir=$dir\" class=\"head_link\">{$lang_guild['guild_leader']}</a></td>
    148         <td width=\"40%\" class=\"head\"><a href=\"guild.php?action=search&amp;error=4&amp;order_by=MOTD&amp;search_by=$search_by&amp;search_value=$search_value&amp;dir=$dir\" class=\"head_link\">{$lang_guild['guild_motd']}</a></td>
    149         <td width=\"15%\" class=\"head\"><a href=\"guild.php?action=search&amp;error=4&amp;order_by=createdate&amp;search_by=$search_by&amp;search_value=$search_value&amp;dir=$dir\" class=\"head_link\">{$lang_guild['create_date']}</a></td>
     141        <th width=\"5%\"><a href=\"guild.php?action=search&amp;error=4&amp;order_by=guildid&amp;search_by=$search_by&amp;search_value=$search_value&amp;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&amp;error=4&amp;order_by=gname&amp;search_by=$search_by&amp;search_value=$search_value&amp;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&amp;error=4&amp;order_by=tot_chars&amp;search_by=$search_by&amp;search_value=$search_value&amp;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&amp;error=4&amp;order_by=leaderguid&amp;search_by=$search_by&amp;search_value=$search_value&amp;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&amp;error=4&amp;order_by=createdate&amp;search_by=$search_by&amp;search_value=$search_value&amp;dir=$dir\">".($order_by=='createdate' ? "<img src=\"img/arr_".($dir ? "up" : "dw").".gif\" /> " : "")."{$lang_guild['create_date']}</a></th>
    150147   </tr>";
    151148
    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&amp;error=3&amp;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&amp;error=3&amp;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>
    164157            </tr>";
    165158}
     
    170163   </table></center>";
    171164
    172  $mysql->close();
     165 $sql->close();
    173166}
    174167
     
    182175 if(!isset($_GET['id'])) redirect("guild.php?error=1");
    183176
    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);
    194193
    195194 if (!$guild_data[2]) $guild_data[2] = $lang_global['none'];
    196195
    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>
    198201 <fieldset style=\"width: 600px;\">
    199202        <legend>{$lang_guild['guild']}</legend>
     
    215218  </tr>
    216219  <tr>
    217     <td width=\"5%\" class=\"head\">{$lang_guild['remove']}</td>
    218         <td width=\"45%\" class=\"head\">{$lang_guild['name']}</td>
    219         <td width=\"5%\" class=\"head\">{$lang_guild['level']}</td>
    220         <td 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>
    221224  </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)){
    232227        $output .= " <tr>
    233         <td><a href=\"guild.php?action=rem_char_from_guild&amp;id=$member[0]&amp;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&amp;id=$member[0]&amp;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>
    237232        </tr>";
    238233}
    239234
    240235 $output .= "</table><br />";
    241   $mysql->close();
     236  $sql->close();
    242237 
    243238 $output .= "<table class=\"hidden\">
     
    296291                else redirect("guild.php?error=1");
    297292
    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');
    303298        $data = explode(' ',$data);
    304299        $data[CHAR_DATA_OFFSET_GUILD_ID] = 0;
    305300        $data[CHAR_DATA_OFFSET_GUILD_RANK] = 0;
    306301        $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();
    311306        redirect("guild.php?action=view_guild&id=$guld_id");
    312307}
Note: See TracChangeset for help on using the changeset viewer.