Changeset 19 for minimanager/banned.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/banned.php

    r5 r19  
    1818 global  $lang_global, $lang_banned, $output, $realm_db, $itemperpage;
    1919
    20  $mysql = new MySQL;
    21  $mysql->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']);
    22 
    23  $start = (isset($_GET['start'])) ? $mysql->quote_smart($_GET['start']) : 0;
    24  $ban_type = (isset($_GET['ban_type'])) ? $mysql->quote_smart($_GET['ban_type']) : "account_banned";
     20 $sql = new SQL;
     21 $sql->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']);
     22
     23 $start = (isset($_GET['start'])) ? $sql->quote_smart($_GET['start']) : 0;
     24 $ban_type = (isset($_GET['ban_type'])) ? $sql->quote_smart($_GET['ban_type']) : "account_banned";
    2525 $key_field = ($ban_type == "account_banned") ? "id" :"ip";
    26  $order_by = (isset($_GET['order_by'])) ? $mysql->quote_smart($_GET['order_by']) : $key_field;
    27 
    28  $dir = (isset($_GET['dir'])) ? $mysql->quote_smart($_GET['dir']) : 1;
     26 $order_by = (isset($_GET['order_by'])) ? $sql->quote_smart($_GET['order_by']) : $key_field;
     27
     28 $dir = (isset($_GET['dir'])) ? $sql->quote_smart($_GET['dir']) : 1;
    2929 $order_dir = ($dir) ? "ASC" : "DESC";
    3030 $dir = ($dir) ? 0 : 1;
    3131       
    32  $query_1 = $mysql->query("SELECT count(*) FROM $ban_type");
    33  $all_record = $mysql->result($query_1,0);
    34 
    35  $result = $mysql->query("SELECT $key_field, bandate, unbandate, bannedby, SUBSTRING_INDEX(banreason,' ',3) FROM $ban_type ORDER BY $order_by $order_dir LIMIT $start, $itemperpage");
    36  $this_page = $mysql->num_rows($result);
     32 $query_1 = $sql->query("SELECT count(*) FROM $ban_type");
     33 $all_record = $sql->result($query_1,0);
     34
     35 $result = $sql->query("SELECT $key_field, bandate, unbandate, bannedby, SUBSTRING_INDEX(banreason,' ',3) FROM $ban_type ORDER BY $order_by $order_dir LIMIT $start, $itemperpage");
     36 $this_page = $sql->num_rows($result);
    3737
    3838  $output .= "<center>
     
    4747     <td align=\"right\">".generate_pagination("banned.php?action=show_list&amp;order_by=$order_by&amp;ban_type=$ban_type&amp;dir=".!$dir, $all_record, $itemperpage, $start)."</td>
    4848         </tr></table>
    49    <table class=\"lined\">
     49  <script type=\"text/javascript\">
     50        answerbox.btn_ok='{$lang_global['yes_low']}';
     51        answerbox.btn_cancel='{$lang_global['no']}';
     52        var del_banned = 'banned.php?action=do_delete_entry&amp;ban_type=$ban_type&amp;$key_field=';
     53 </script>
     54 <table class=\"lined\">
    5055   <tr>
    51         <td width=\"5%\" class=\"head\">{$lang_global['delete']}</td>
    52         <td width=\"19%\" class=\"head\"><a href=\"banned.php?order_by=$key_field&amp;ban_type=$ban_type&amp;dir=$dir\" class=\"head_link\">{$lang_banned['ip_acc']}</a></td>
    53         <td width=\"18%\" class=\"head\"><a href=\"banned.php?order_by=bandate&amp;ban_type=$ban_type&amp;dir=$dir\" class=\"head_link\">{$lang_banned['bandate']}</a></td>
    54         <td width=\"18%\" class=\"head\"><a href=\"banned.php?order_by=unbandate&amp;ban_type=$ban_type&amp;dir=$dir\" class=\"head_link\">{$lang_banned['unbandate']}</a></td>
    55         <td width=\"15%\" class=\"head\"><a href=\"banned.php?order_by=bannedby&amp;ban_type=$ban_type&amp;dir=$dir\" class=\"head_link\">{$lang_banned['bannedby']}</a></td>
    56         <td width=\"25%\" class=\"head\"><a href=\"banned.php?order_by=banreason&amp;ban_type=$ban_type&amp;dir=$dir\" class=\"head_link\">{$lang_banned['banreason']}</a></td>
     56        <th width=\"5%\">{$lang_global['delete_short']}</td>
     57        <th width=\"19%\"><a href=\"banned.php?order_by=$key_field&amp;ban_type=$ban_type&amp;dir=$dir\">".($order_by==$key_field ? "<img src=\"img/arr_".($dir ? "up" : "dw").".gif\" /> " : "")."{$lang_banned['ip_acc']}</a></th>
     58        <th width=\"18%\"><a href=\"banned.php?order_by=bandate&amp;ban_type=$ban_type&amp;dir=$dir\">".($order_by=='bandate' ? "<img src=\"img/arr_".($dir ? "up" : "dw").".gif\" /> " : "")."{$lang_banned['bandate']}</a></th>
     59        <th width=\"18%\"><a href=\"banned.php?order_by=unbandate&amp;ban_type=$ban_type&amp;dir=$dir\">".($order_by=='unbandate' ? "<img src=\"img/arr_".($dir ? "up" : "dw").".gif\" /> " : "")."{$lang_banned['unbandate']}</a></th>
     60        <th width=\"15%\"><a href=\"banned.php?order_by=bannedby&amp;ban_type=$ban_type&amp;dir=$dir\">".($order_by=='bannedby' ? "<img src=\"img/arr_".($dir ? "up" : "dw").".gif\" /> " : "")."{$lang_banned['bannedby']}</a></th>
     61        <th width=\"25%\"><a href=\"banned.php?order_by=banreason&amp;ban_type=$ban_type&amp;dir=$dir\">".($order_by=='banreason' ? "<img src=\"img/arr_".($dir ? "up" : "dw").".gif\" /> " : "")."{$lang_banned['banreason']}</a></th>
    5762  </tr>";
    5863
    59  $looping = ($this_page < $itemperpage) ?  $this_page : $itemperpage;
    60  
    61  for ($i=1; $i <= $looping; $i++){
    62   $ban = $mysql->fetch_row($result);
    63  
     64 while ($ban = $sql->fetch_row($result)){
     65
    6466  if ($ban_type === "account_banned"){
    65         $result1 = $mysql->query("SELECT username FROM account WHERE id ='$ban[0]'");
    66         $owner_acc_name = $mysql->result($result1, 0, 'username');
     67        $result1 = $sql->query("SELECT username FROM account WHERE id ='$ban[0]'");
     68        $owner_acc_name = $sql->result($result1, 0, 'username');
    6769        $name_out = "<a href=\"user.php?action=edit_user&amp;error=11&amp;id=$ban[0]\">$owner_acc_name</a>";
    68   } else $name_out = $ban[0];
    69  
     70  } else {
     71                        $name_out = $ban[0];
     72                        $owner_acc_name = $ban[0];
     73                }
     74 
    7075  $output .= "<tr>
    71                         <td><a href=\"banned.php?action=do_delete_entry&amp;$key_field=$ban[0]&amp;ban_type=$ban_type\"><img src=\"img/x.ico\" class=\"no_border\" alt=\"\" /></a></td>
     76                        <td><img src=\"img/aff_cross.png\" alt=\"\" onclick=\"answerBox('{$lang_global['delete']}: <font color=white>$owner_acc_name</font><br />{$lang_global['are_you_sure']}', del_banned + '$ban[0]');\" style=\"cursor:pointer;\" /></td>
    7277                        <td>$name_out</td>
    7378                        <td>".date('d-m-Y G:i', $ban[1])."</td>
     
    8186         </tr>
    8287 </table></center><br/>";
    83  $mysql->close();
     88 $sql->close();
    8489}
    8590
     
    9196 global $lang_global, $realm_db;
    9297
    93  $mysql = new MySQL;
    94  $mysql->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']);
    95  
    96  if(isset($_GET['ban_type'])) $ban_type = $mysql->quote_smart($_GET['ban_type']);
     98 $sql = new SQL;
     99 $sql->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']);
     100 
     101 if(isset($_GET['ban_type'])) $ban_type = $sql->quote_smart($_GET['ban_type']);
    97102        else redirect("banned.php?error=1");
    98103
    99104 $key_field = ($ban_type == "account_banned") ? "id" : "ip";
    100105
    101  if(isset($_GET[$key_field])) $entry = $mysql->quote_smart($_GET[$key_field]);
     106 if(isset($_GET[$key_field])) $entry = $sql->quote_smart($_GET[$key_field]);
    102107        else redirect("banned.php?error=1");
    103108
    104  $mysql->query("DELETE FROM $ban_type WHERE $key_field = '$entry'");
    105 
    106  if ($mysql->affected_rows()) {
    107         $mysql->close();
     109 $sql->query("DELETE FROM $ban_type WHERE $key_field = '$entry'");
     110
     111 if ($sql->affected_rows()) {
     112        $sql->close();
    108113        redirect("banned.php?error=3&ban_type=$ban_type");
    109114    } else {
    110          $mysql->close();
     115         $sql->close();
    111116         redirect("banned.php?error=2&ban_type=$ban_type");
    112117        }
     
    166171        redirect("banned.php?error=1&action=add_entry");
    167172
    168  $mysql = new MySQL;
    169  $mysql->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']);
    170  
    171  $ban_type = $mysql->quote_smart($_GET['ban_type']);
    172 
    173  $entry = $mysql->quote_smart($_GET['entry']);
     173 $sql = new SQL;
     174 $sql->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']);
     175 
     176 $ban_type = $sql->quote_smart($_GET['ban_type']);
     177
     178 $entry = $sql->quote_smart($_GET['entry']);
    174179 if ($ban_type == "account_banned") {
    175         $result1 = $mysql->query("SELECT id FROM account WHERE username ='$entry'");
    176         if (!$mysql->num_rows($result1)) redirect("banned.php?error=4&action=add_entry");
    177                 else $entry = $mysql->result($result1, 0, 'id');
     180        $result1 = $sql->query("SELECT id FROM account WHERE username ='$entry'");
     181        if (!$sql->num_rows($result1)) redirect("banned.php?error=4&action=add_entry");
     182                else $entry = $sql->result($result1, 0, 'id');
    178183 }
    179184 
    180  $bantime = time() + (3600 * $mysql->quote_smart($_GET['bantime']));
    181  
    182  $banreason = (isset($_GET['banreason']) && ($_POST['banreason'] != '')) ? $mysql->quote_smart($_GET['banreason']) : "none";
     185 $bantime = time() + (3600 * $sql->quote_smart($_GET['bantime']));
     186 
     187 $banreason = (isset($_GET['banreason']) && ($_POST['banreason'] != '')) ? $sql->quote_smart($_GET['banreason']) : "none";
    183188
    184189 if ($ban_type === "account_banned"){
    185         $result = $mysql->query("SELECT count(*) FROM account_banned WHERE id = '$entry'");
    186         if(!$mysql->result($result, 0))
    187                 $mysql->query("INSERT INTO account_banned (id, bandate, unbandate, bannedby, banreason, active)
     190        $result = $sql->query("SELECT count(*) FROM account_banned WHERE id = '$entry'");
     191        if(!$sql->result($result, 0))
     192                $sql->query("INSERT INTO account_banned (id, bandate, unbandate, bannedby, banreason, active)
    188193                                           VALUES ('$entry',".time().",$bantime,'$user_name','$banreason', 1)");
    189194
    190195 } else {
    191                 $mysql->query("INSERT INTO ip_banned (ip, bandate, unbandate, bannedby, banreason)
     196                $sql->query("INSERT INTO ip_banned (ip, bandate, unbandate, bannedby, banreason)
    192197                                                VALUES ('$entry',".time().",$bantime,'$user_name','$banreason')");
    193198                }
    194199                       
    195  if ($mysql->affected_rows()) {
    196         $mysql->close();
     200 if ($sql->affected_rows()) {
     201        $sql->close();
    197202        redirect("banned.php?error=3&ban_type=$ban_type");
    198203        } else {
    199                 $mysql->close();
     204                $sql->close();
    200205                redirect("banned.php?error=2&ban_type=$ban_type");
    201206         }
    202  $mysql->close();
     207 $sql->close();
    203208}
    204209
Note: See TracChangeset for help on using the changeset viewer.