Changeset 19 for minimanager/banned.php
- Timestamp:
- Aug 13, 2007, 9:05:34 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
minimanager/banned.php
r5 r19 18 18 global $lang_global, $lang_banned, $output, $realm_db, $itemperpage; 19 19 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"; 25 25 $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; 29 29 $order_dir = ($dir) ? "ASC" : "DESC"; 30 30 $dir = ($dir) ? 0 : 1; 31 31 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); 37 37 38 38 $output .= "<center> … … 47 47 <td align=\"right\">".generate_pagination("banned.php?action=show_list&order_by=$order_by&ban_type=$ban_type&dir=".!$dir, $all_record, $itemperpage, $start)."</td> 48 48 </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&ban_type=$ban_type&$key_field='; 53 </script> 54 <table class=\"lined\"> 50 55 <tr> 51 <t d width=\"5%\" class=\"head\">{$lang_global['delete']}</td>52 <t d width=\"19%\" class=\"head\"><a href=\"banned.php?order_by=$key_field&ban_type=$ban_type&dir=$dir\" class=\"head_link\">{$lang_banned['ip_acc']}</a></td>53 <t d width=\"18%\" class=\"head\"><a href=\"banned.php?order_by=bandate&ban_type=$ban_type&dir=$dir\" class=\"head_link\">{$lang_banned['bandate']}</a></td>54 <t d width=\"18%\" class=\"head\"><a href=\"banned.php?order_by=unbandate&ban_type=$ban_type&dir=$dir\" class=\"head_link\">{$lang_banned['unbandate']}</a></td>55 <t d width=\"15%\" class=\"head\"><a href=\"banned.php?order_by=bannedby&ban_type=$ban_type&dir=$dir\" class=\"head_link\">{$lang_banned['bannedby']}</a></td>56 <t d width=\"25%\" class=\"head\"><a href=\"banned.php?order_by=banreason&ban_type=$ban_type&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&ban_type=$ban_type&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&ban_type=$ban_type&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&ban_type=$ban_type&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&ban_type=$ban_type&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&ban_type=$ban_type&dir=$dir\">".($order_by=='banreason' ? "<img src=\"img/arr_".($dir ? "up" : "dw").".gif\" /> " : "")."{$lang_banned['banreason']}</a></th> 57 62 </tr>"; 58 63 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 64 66 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'); 67 69 $name_out = "<a href=\"user.php?action=edit_user&error=11&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 70 75 $output .= "<tr> 71 <td>< a href=\"banned.php?action=do_delete_entry&$key_field=$ban[0]&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> 72 77 <td>$name_out</td> 73 78 <td>".date('d-m-Y G:i', $ban[1])."</td> … … 81 86 </tr> 82 87 </table></center><br/>"; 83 $ mysql->close();88 $sql->close(); 84 89 } 85 90 … … 91 96 global $lang_global, $realm_db; 92 97 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']); 97 102 else redirect("banned.php?error=1"); 98 103 99 104 $key_field = ($ban_type == "account_banned") ? "id" : "ip"; 100 105 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]); 102 107 else redirect("banned.php?error=1"); 103 108 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(); 108 113 redirect("banned.php?error=3&ban_type=$ban_type"); 109 114 } else { 110 $ mysql->close();115 $sql->close(); 111 116 redirect("banned.php?error=2&ban_type=$ban_type"); 112 117 } … … 166 171 redirect("banned.php?error=1&action=add_entry"); 167 172 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']); 174 179 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'); 178 183 } 179 184 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"; 183 188 184 189 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) 188 193 VALUES ('$entry',".time().",$bantime,'$user_name','$banreason', 1)"); 189 194 190 195 } 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) 192 197 VALUES ('$entry',".time().",$bantime,'$user_name','$banreason')"); 193 198 } 194 199 195 if ($ mysql->affected_rows()) {196 $ mysql->close();200 if ($sql->affected_rows()) { 201 $sql->close(); 197 202 redirect("banned.php?error=3&ban_type=$ban_type"); 198 203 } else { 199 $ mysql->close();204 $sql->close(); 200 205 redirect("banned.php?error=2&ban_type=$ban_type"); 201 206 } 202 $ mysql->close();207 $sql->close(); 203 208 } 204 209
Note:
See TracChangeset
for help on using the changeset viewer.