1 | <?php
|
---|
2 | /*
|
---|
3 | * Project Name: MiniManager for Mangos Server
|
---|
4 | * Date: 17.10.2006 inital version (0.0.1a)
|
---|
5 | * Author: Q.SA
|
---|
6 | * Copyright: Q.SA
|
---|
7 | * Email: *****
|
---|
8 | * License: GNU General Public License (GPL)
|
---|
9 | */
|
---|
10 |
|
---|
11 | require_once("header.php");
|
---|
12 | valid_login(1);
|
---|
13 |
|
---|
14 | //########################################################################################################################
|
---|
15 | // SHOW BANNED IP LIST
|
---|
16 | //########################################################################################################################
|
---|
17 | function show_list() {
|
---|
18 | global $lang_global, $lang_baned, $output, $realm_db;
|
---|
19 |
|
---|
20 | $mysql = new MySQL;
|
---|
21 | $link = $mysql->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']);
|
---|
22 |
|
---|
23 | if(isset($_GET['order_by'])) $order_by = $mysql->quote_smart($_GET['order_by']);
|
---|
24 | else $order_by = "ip";
|
---|
25 |
|
---|
26 | $result = $mysql->query("SELECT ip FROM ip_banned ORDER BY $order_by");
|
---|
27 | $total_banned_ips = $mysql->num_rows($result);
|
---|
28 |
|
---|
29 | $output .= "<center>
|
---|
30 | <table class=\"top_hidden\"></td>
|
---|
31 | <tr><td>";
|
---|
32 | makebutton($lang_baned['add_to_banned'], "banned.php?action=add_ip",180);
|
---|
33 | makebutton($lang_global['back'], "javascript:window.history.back()",140);
|
---|
34 | $output .= "</td>
|
---|
35 | <td align=\"right\">{$lang_baned['tot_banned']} : $total_banned_ips</td>
|
---|
36 | </tr></table>";
|
---|
37 | $output .= "<table class=\"lined\">
|
---|
38 | <tr>
|
---|
39 | <td width=\"15%\" class=\"head\"> {$lang_global['delete']} </td>
|
---|
40 | <td width=\"85%\" class=\"head\"><a href=\"banned.php?order_by=ip\" class=\"head_link\">{$lang_baned['ip']}</a></td>
|
---|
41 | </tr>";
|
---|
42 |
|
---|
43 | for ($i=1; $i<=$total_banned_ips; $i++){
|
---|
44 | $ip_ban = $mysql->fetch_row($result);
|
---|
45 | $output .= "<tr>
|
---|
46 | <td><a href=\"banned.php?action=delete_ip&ip=$ip_ban[0]\"><img src=\"img/x.ico\" class=\"no_border\" alt=\"{$lang_global['delete']}\"></a></td>
|
---|
47 | <td>".$ip_ban[0]."</td>
|
---|
48 | </tr>";
|
---|
49 | }
|
---|
50 | $output .= "</table></center><br/>";
|
---|
51 |
|
---|
52 | $mysql->close();
|
---|
53 | }
|
---|
54 |
|
---|
55 |
|
---|
56 | //########################################################################################################################
|
---|
57 | // DELETE IP FROM LIST
|
---|
58 | //########################################################################################################################
|
---|
59 | function delete_ip() {
|
---|
60 | global $lang_global,$lang_baned,$output;
|
---|
61 | if(isset($_GET['ip'])) $ip = addslashes($_GET['ip']);
|
---|
62 | else redirect("banned.php?error=1");
|
---|
63 |
|
---|
64 | $output .= "<center><h1><font class=\"error\">{$lang_global['are_you_sure']}</font></h1><br/>";
|
---|
65 | $output .= "<font class=\"bold\">{$lang_baned['ip']} : '$ip' {$lang_baned['will_be_removed_from_banned']}</font><br/><br/>";
|
---|
66 | $output .= "<table class=\"hidden\">
|
---|
67 | <tr>
|
---|
68 | <td>";
|
---|
69 | makebutton($lang_global['yes'], "banned.php?action=dodelete_ip&ip=$ip",115);
|
---|
70 | makebutton($lang_global['no'], "banned.php",115);
|
---|
71 | $output .= "</td>
|
---|
72 | </tr>
|
---|
73 | </table><br/></center>";
|
---|
74 | }
|
---|
75 |
|
---|
76 |
|
---|
77 | //########################################################################################################################
|
---|
78 | // DO DELETE IP FROM LIST
|
---|
79 | //########################################################################################################################
|
---|
80 | function dodelete_ip() {
|
---|
81 | global $lang_global, $realm_db;
|
---|
82 |
|
---|
83 | $mysql = new MySQL;
|
---|
84 | $link = $mysql->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']);
|
---|
85 |
|
---|
86 | if(isset($_GET['ip'])) $ip = $mysql->quote_smart($_GET['ip']);
|
---|
87 | else redirect("Location: banned.php?error=1");
|
---|
88 |
|
---|
89 | $query = $mysql->query("DELETE FROM ip_banned WHERE ip = '$ip'");
|
---|
90 |
|
---|
91 | if ($mysql->affected_rows() != 0) {
|
---|
92 | $mysql->close();
|
---|
93 | redirect("banned.php?error=3");
|
---|
94 | } else {
|
---|
95 | $mysql->close();
|
---|
96 | redirect("banned.php?error=2");
|
---|
97 | }
|
---|
98 | }
|
---|
99 |
|
---|
100 |
|
---|
101 | //########################################################################################################################
|
---|
102 | // BAN NEW IP
|
---|
103 | //########################################################################################################################
|
---|
104 | function add_ip() {
|
---|
105 | global $lang_global, $lang_baned, $output;
|
---|
106 | $output .= "<center>
|
---|
107 | <fieldset style=\"width: 550px;\">
|
---|
108 | <legend>{$lang_baned['ban_ip_addr']}</legend>
|
---|
109 | <form method=\"GET\" action=\"banned.php\" name=\"form\">
|
---|
110 | <input type=\"hidden\" name=\"action\" value=\"doadd_ip\" />
|
---|
111 | <table class=\"hidden\">
|
---|
112 | <tr>
|
---|
113 | <td><input type=\"text\" name=\"new_ban_ip\" size=\"40\" maxlength=\"16\" value=\"0.0.0.0\" /></td>
|
---|
114 | </tr>
|
---|
115 | <tr>
|
---|
116 | <td>";
|
---|
117 | makebutton($lang_baned['ban_ip_addr'], "javascript:do_submit()",142);
|
---|
118 | makebutton($lang_global['back'], "banned.php",142);
|
---|
119 | $output .= "</td></tr>
|
---|
120 | </table>
|
---|
121 | </form></fieldset><br/><br/></center>";
|
---|
122 | }
|
---|
123 |
|
---|
124 |
|
---|
125 | //########################################################################################################################
|
---|
126 | //DO BAN NEW IP
|
---|
127 | //########################################################################################################################
|
---|
128 | function doadd_ip() {
|
---|
129 | global $lang_global, $realm_db;
|
---|
130 |
|
---|
131 | if( empty($_GET['new_ban_ip'])) redirect("banned.php?error=1");
|
---|
132 |
|
---|
133 | $mysql = new MySQL;
|
---|
134 | $link = $mysql->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']);
|
---|
135 |
|
---|
136 | $new_ban_ip = $mysql->quote_smart($_GET['new_ban_ip']);
|
---|
137 | $result = $mysql->query("INSERT INTO ip_banned VALUES ('$new_ban_ip')");
|
---|
138 |
|
---|
139 | if ($result) {
|
---|
140 | $mysql->close();
|
---|
141 | redirect("banned.php?error=3");
|
---|
142 | }
|
---|
143 | $mysql->close();
|
---|
144 | }
|
---|
145 |
|
---|
146 |
|
---|
147 | //########################################################################################################################
|
---|
148 | // MAIN
|
---|
149 | //########################################################################################################################
|
---|
150 | if(isset($_GET['error'])) $err = $_GET['error'];
|
---|
151 | else $err = NULL;
|
---|
152 |
|
---|
153 | $output .= "<div class=\"top\">";
|
---|
154 | switch ($err) {
|
---|
155 | case 1:
|
---|
156 | $output .= "<h1><font class=\"error\">{$lang_global['empty_fields']}</font></h1>";
|
---|
157 | break;
|
---|
158 | case 2:
|
---|
159 | $output .= "<h1><font class=\"error\">{$lang_baned['err_del_ip']}</font></h1>";
|
---|
160 | break;
|
---|
161 | case 3:
|
---|
162 | $output .= "<h1><font class=\"error\">{$lang_baned['updated']}</font></h1>";
|
---|
163 | break;
|
---|
164 | default: //no error
|
---|
165 | $output .= "<h1>{$lang_baned['banned_ip_list']}</h1>";
|
---|
166 | }
|
---|
167 | $output .= "</div>";
|
---|
168 |
|
---|
169 | if(isset($_GET['action'])) $action = $_GET['action'];
|
---|
170 | else $action = NULL;
|
---|
171 |
|
---|
172 | switch ($action) {
|
---|
173 |
|
---|
174 | case "delete_ip":
|
---|
175 | delete_ip();
|
---|
176 | break;
|
---|
177 | case "dodelete_ip":
|
---|
178 | dodelete_ip();
|
---|
179 | break;
|
---|
180 | case "add_ip":
|
---|
181 | add_ip();
|
---|
182 | break;
|
---|
183 | case "doadd_ip":
|
---|
184 | doadd_ip();
|
---|
185 | break;
|
---|
186 | default:
|
---|
187 | show_list();
|
---|
188 | }
|
---|
189 |
|
---|
190 | require_once("footer.php");
|
---|
191 | ?>
|
---|