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 v2(GPL)
|
---|
9 | */
|
---|
10 |
|
---|
11 | require_once("header.php");
|
---|
12 | valid_login(3);
|
---|
13 |
|
---|
14 | //#################################################################################################################
|
---|
15 | // print cleanup options
|
---|
16 | //#################################################################################################################
|
---|
17 | function cleanup(){
|
---|
18 | global $lang_cleanup,$lang_global,$output;
|
---|
19 |
|
---|
20 | $output .= "<center>
|
---|
21 | <fieldset style=\"width: 740px;\">
|
---|
22 | <legend>{$lang_cleanup['cleanup_options']}</legend>
|
---|
23 | <table class=\"hidden\">
|
---|
24 | <tr><td>
|
---|
25 | <form action=\"cleanup.php\" method=\"get\" name=\"form\">
|
---|
26 | <input type=\"hidden\" name=\"action\" value=\"run_cleanup\" />
|
---|
27 | <select name=\"cleanup_by\">
|
---|
28 | <optgroup label=\"{$lang_cleanup['clean_chars']}\">
|
---|
29 | <option value=\"char_lvl\">{$lang_cleanup['char_level']}</option>
|
---|
30 | <option value=\"totaltime\">{$lang_cleanup['tot_play_time']}</option>
|
---|
31 | </optgroup>
|
---|
32 | <optgroup label=\"{$lang_cleanup['clean_acc']}\">
|
---|
33 | <option value=\"last_login\">{$lang_cleanup['last_login_time']}</option>
|
---|
34 | <option value=\"failed_login\">{$lang_cleanup['failed_logins']}</option>
|
---|
35 | <option value=\"banned\">{$lang_cleanup['banned']}</option>
|
---|
36 | <option value=\"locked\">{$lang_cleanup['locked']}</option>
|
---|
37 | <option value=\"num_of_char_in_acc\">{$lang_cleanup['chars_in_acc']}</option>
|
---|
38 | </optgroup>
|
---|
39 | <optgroup label=\"{$lang_cleanup['clean_guilds']}\">
|
---|
40 | <option value=\"num_of_char_in_guild\">{$lang_cleanup['chars_in_guild']}</option>
|
---|
41 | </optgroup>
|
---|
42 | </select>
|
---|
43 | <select name=\"cleanup_sign\">
|
---|
44 | <option value=\"=\">=</option>
|
---|
45 | <option value=\"<\"><</option>
|
---|
46 | <option value=\"<=\"><=</option>
|
---|
47 | <option value=\">\">></option>
|
---|
48 | <option value=\">=\">>=</option>
|
---|
49 | <option value=\"!=\">!=</option>
|
---|
50 | </select>
|
---|
51 | <input type=\"text\" size=\"25\" maxlength=\"40\" name=\"cleanup_value\" />
|
---|
52 | </td><td>";
|
---|
53 | makebutton($lang_cleanup['run_cleanup'], "javascript:do_submit()",100);
|
---|
54 | makebutton($lang_global['back'], "javascript:window.history.back()",100);
|
---|
55 | $output .= "</td></tr>
|
---|
56 | </table><br /></fieldset><br /><br /></center>";
|
---|
57 | }
|
---|
58 |
|
---|
59 |
|
---|
60 | //########################################################################################################
|
---|
61 | // make and list list of all acc/chars
|
---|
62 | //########################################################################################################
|
---|
63 | function run_cleanup(){
|
---|
64 | global $lang_cleanup, $lang_global, $output, $realm_db, $mangos_db, $realm_id, $user_lvl;
|
---|
65 |
|
---|
66 | if( empty($_GET['cleanup_by']) || empty($_GET['cleanup_sign']) ) redirect("cleanup.php?error=1");
|
---|
67 |
|
---|
68 | $mysql = new MySQL;
|
---|
69 | $mysql->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass']);
|
---|
70 |
|
---|
71 | $cleanup_by = $mysql->quote_smart($_GET['cleanup_by']);
|
---|
72 | $cleanup_sign = $mysql->quote_smart($_GET['cleanup_sign']);
|
---|
73 | $cleanup_value = $mysql->quote_smart($_GET['cleanup_value']);
|
---|
74 |
|
---|
75 | switch ($cleanup_by) {
|
---|
76 | // clean by lvl
|
---|
77 | case "char_lvl":
|
---|
78 | $mysql->connect($mangos_db[$realm_id]['addr'], $mangos_db[$realm_id]['user'], $mangos_db[$realm_id]['pass'], $mangos_db[$realm_id]['name']);
|
---|
79 |
|
---|
80 | $result = $mysql->query("SELECT guid FROM `character` WHERE SUBSTRING_INDEX(SUBSTRING_INDEX(`data`, ' ', 35), ' ', -1) $cleanup_sign $cleanup_value");
|
---|
81 | $total_chars = $mysql->num_rows($result);
|
---|
82 |
|
---|
83 | $output .= "<center>";
|
---|
84 | if ($total_chars){
|
---|
85 | $output .= "<h1><font class=\"error\">{$lang_global['are_you_sure']}</font></h1><br />";
|
---|
86 | $output .= "<form action=\"cleanup.php?action=docleanup\" method=\"post\" name=\"form\">
|
---|
87 | <input type=\"hidden\" name=\"type\" value=\"char\" />
|
---|
88 | <font class=\"bold\">{$lang_cleanup['chars_id']}: ";
|
---|
89 |
|
---|
90 | $pass_array = "";
|
---|
91 |
|
---|
92 | while($char = $mysql->fetch_row($result)){
|
---|
93 | $output .= "<a href=\"char.php?id=$char[0]\" target=\"_blank\">$char[0], </a>";
|
---|
94 | $pass_array .= "-$char[0]";
|
---|
95 | }
|
---|
96 | $output .= "<input type=\"hidden\" name=\"check\" value=\"$pass_array\" />";
|
---|
97 | $output .= "<br />{$lang_cleanup['tot_of']} $total_chars {$lang_global['will_be_erased']}</font><br /><br />";
|
---|
98 | $output .= "<table class=\"hidden\">
|
---|
99 | <tr><td>";
|
---|
100 | makebutton($lang_global['yes'], "javascript:do_submit()",120);
|
---|
101 | makebutton($lang_global['no'], "cleanup.php",120);
|
---|
102 | $output .= "</td></tr>
|
---|
103 | </table>
|
---|
104 | </form>";
|
---|
105 | } else {
|
---|
106 | $output .= "<h1><font class=\"error\">{$lang_global['err_no_records_found']}</font></h1><br />";
|
---|
107 | $output .= "<table class=\"hidden\">
|
---|
108 | <tr><td>";
|
---|
109 | makebutton($lang_global['go_back'], "cleanup.php",120);
|
---|
110 | $output .= "</td></tr>
|
---|
111 | </table>";
|
---|
112 | }
|
---|
113 | $output .= "</center><br />";
|
---|
114 | break;
|
---|
115 |
|
---|
116 |
|
---|
117 | //last loggin
|
---|
118 | case "last_login":
|
---|
119 | $mysql->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']);
|
---|
120 |
|
---|
121 | $result = $mysql->query("SELECT id FROM account WHERE last_login $cleanup_sign '$cleanup_value' AND gmlevel < $user_lvl");
|
---|
122 | $total_accounts = $mysql->num_rows($result);
|
---|
123 |
|
---|
124 | $output .= "<center>";
|
---|
125 | if ($total_accounts){
|
---|
126 | $output .= "<h1><font class=\"error\">{$lang_global['are_you_sure']}</font></h1><br />";
|
---|
127 | $output .= "<form action=\"cleanup.php?action=docleanup\" method=\"post\" name=\"form\">
|
---|
128 | <input type=\"hidden\" name=\"type\" value=\"acc\" />
|
---|
129 | <font class=\"bold\">{$lang_cleanup['acc_ids']}: ";
|
---|
130 |
|
---|
131 | $pass_array = "";
|
---|
132 |
|
---|
133 | while($acc = $mysql->fetch_row($result)){
|
---|
134 | $output .= "<a href=\"user.php?action=edit_user&id=$acc[0]\" target=\"_blank\">$acc[0], </a>";
|
---|
135 | $pass_array .= "-$acc[0]";
|
---|
136 | }
|
---|
137 | $output .= "<input type=\"hidden\" name=\"check\" value=\"$pass_array\" />";
|
---|
138 | $output .= "<br />{$lang_cleanup['tot_of']} $total_accounts {$lang_global['will_be_erased']}</font><br /><br />";
|
---|
139 | $output .= "<table class=\"hidden\">
|
---|
140 | <tr><td>";
|
---|
141 | makebutton($lang_global['yes'], "javascript:do_submit()",120);
|
---|
142 | makebutton($lang_global['no'], "cleanup.php",120);
|
---|
143 | $output .= "</td></tr>
|
---|
144 | </table>
|
---|
145 | </form>";
|
---|
146 | } else {
|
---|
147 | $output .= "<h1><font class=\"error\">{$lang_global['err_no_records_found']}</font></h1><br />";
|
---|
148 | $output .= "<table class=\"hidden\">
|
---|
149 | <tr><td>";
|
---|
150 | makebutton($lang_global['go_back'], "cleanup.php",120);
|
---|
151 | $output .= "</td></tr>
|
---|
152 | </table>";
|
---|
153 | }
|
---|
154 | $output .= "</center><br />";
|
---|
155 | break;
|
---|
156 |
|
---|
157 |
|
---|
158 | //failed loggin attempts
|
---|
159 | case "failed_login":
|
---|
160 | $mysql->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']);
|
---|
161 |
|
---|
162 | $result = $mysql->query("SELECT id FROM account WHERE failed_logins $cleanup_sign $cleanup_value AND gmlevel < $user_lvl");
|
---|
163 | $total_accounts = $mysql->num_rows($result);
|
---|
164 |
|
---|
165 | $output .= "<center>";
|
---|
166 | if ($total_accounts){
|
---|
167 | $output .= "<h1><font class=\"error\">{$lang_global['are_you_sure']}</font></h1><br />";
|
---|
168 | $output .= "<form action=\"cleanup.php?action=docleanup\" method=\"post\" name=\"form\">
|
---|
169 | <input type=\"hidden\" name=\"type\" value=\"acc\" />
|
---|
170 | <font class=\"bold\">{$lang_cleanup['acc_ids']}: ";
|
---|
171 |
|
---|
172 | $pass_array = "";
|
---|
173 |
|
---|
174 | while($acc = $mysql->fetch_row($result)){
|
---|
175 | $output .= "<a href=\"user.php?action=edit_user&id=$acc[0]\" target=\"_blank\">$acc[0], </a>";
|
---|
176 | $pass_array .= "-$acc[0]";
|
---|
177 | }
|
---|
178 |
|
---|
179 | $output .= "<input type=\"hidden\" name=\"check\" value=\"$pass_array\" />";
|
---|
180 | $output .= "<br />{$lang_cleanup['tot_of']} $total_accounts {$lang_global['will_be_erased']}</font><br /><br />";
|
---|
181 | $output .= "<table class=\"hidden\">
|
---|
182 | <tr><td>";
|
---|
183 | makebutton($lang_global['yes'], "javascript:do_submit()",120);
|
---|
184 | makebutton($lang_global['no'], "cleanup.php",120);
|
---|
185 | $output .= "</td></tr>
|
---|
186 | </table>
|
---|
187 | </form>";
|
---|
188 | } else {
|
---|
189 | $output .= "<h1><font class=\"error\">{$lang_global['err_no_records_found']}</font></h1><br />";
|
---|
190 | $output .= "<table class=\"hidden\">
|
---|
191 | <tr><td>";
|
---|
192 | makebutton($lang_global['go_back'], "cleanup.php",120);
|
---|
193 | $output .= "</td></tr>
|
---|
194 | </table>";
|
---|
195 | }
|
---|
196 | $output .= "</center><br />";
|
---|
197 | break;
|
---|
198 |
|
---|
199 |
|
---|
200 | //clean banned accounts
|
---|
201 | case "banned":
|
---|
202 | $mysql->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']);
|
---|
203 |
|
---|
204 | $result = $mysql->query("SELECT id FROM account_banned");
|
---|
205 | $total_accounts = $mysql->num_rows($result);
|
---|
206 |
|
---|
207 | $output .= "<center>";
|
---|
208 | if ($total_accounts){
|
---|
209 | $output .= "<h1><font class=\"error\">{$lang_global['are_you_sure']}</font></h1><br />";
|
---|
210 | $output .= "<form action=\"cleanup.php?action=docleanup\" method=\"post\" name=\"form\">
|
---|
211 | <input type=\"hidden\" name=\"type\" value=\"acc\" />
|
---|
212 | <font class=\"bold\">{$lang_cleanup['acc_ids']}: ";
|
---|
213 |
|
---|
214 | $pass_array = "";
|
---|
215 |
|
---|
216 | while($acc = $mysql->fetch_row($result)){
|
---|
217 | $output .= "<a href=\"user.php?action=edit_user&id=$acc[0]\" target=\"_blank\">$acc[0], </a>";
|
---|
218 | $pass_array .= "-$acc[0]";
|
---|
219 | }
|
---|
220 |
|
---|
221 | $output .= "<input type=\"hidden\" name=\"check\" value=\"$pass_array\" />";
|
---|
222 | $output .= "<br />{$lang_cleanup['tot_of']} $total_accounts {$lang_global['will_be_erased']}</font><br /><br />";
|
---|
223 | $output .= " <table class=\"hidden\">
|
---|
224 | <tr><td>";
|
---|
225 | makebutton($lang_global['yes'], "javascript:do_submit()",120);
|
---|
226 | makebutton($lang_global['no'], "cleanup.php",120);
|
---|
227 | $output .= "</td></tr>
|
---|
228 | </table>
|
---|
229 | </form>";
|
---|
230 | } else {
|
---|
231 | $output .= "<h1><font class=\"error\">{$lang_global['err_no_records_found']}</font></h1><br />";
|
---|
232 | $output .= "<table class=\"hidden\">
|
---|
233 | <tr><td>";
|
---|
234 | makebutton($lang_global['go_back'], "cleanup.php",120);
|
---|
235 | $output .= "</td></tr>
|
---|
236 | </table>";
|
---|
237 | }
|
---|
238 | $output .= "</center><br />";
|
---|
239 | break;
|
---|
240 |
|
---|
241 | //clean chars with given total time played
|
---|
242 | case "totaltime":
|
---|
243 | $mysql->connect($mangos_db[$realm_id]['addr'], $mangos_db[$realm_id]['user'], $mangos_db[$realm_id]['pass'], $mangos_db[$realm_id]['name']);
|
---|
244 |
|
---|
245 | $result = $mysql->query("SELECT guid FROM `character` WHERE totaltime $cleanup_sign $cleanup_value");
|
---|
246 | $total_chars = $mysql->num_rows($result);
|
---|
247 |
|
---|
248 | $output .= "<center>";
|
---|
249 | if ($total_chars){
|
---|
250 | $output .= "<h1><font class=\"error\">{$lang_global['are_you_sure']}</font></h1><br />";
|
---|
251 | $output .= "<form action=\"cleanup.php?action=docleanup\" method=\"post\" name=\"form\">
|
---|
252 | <input type=\"hidden\" name=\"type\" value=\"char\" />
|
---|
253 | <font class=\"bold\">{$lang_cleanup['chars_id']}: ";
|
---|
254 |
|
---|
255 | $pass_array = "";
|
---|
256 |
|
---|
257 | while($char = $mysql->fetch_row($result)){
|
---|
258 | $output .= "<a href=\"char.php?id=$char[0]\" target=\"_blank\">$char[0], </a>";
|
---|
259 | $pass_array .= "-$char[0]";
|
---|
260 | }
|
---|
261 |
|
---|
262 | $output .= "<input type=\"hidden\" name=\"check\" value=\"$pass_array\" />";
|
---|
263 | $output .= "<br />{$lang_cleanup['tot_of']} $total_chars {$lang_global['will_be_erased']}</font><br /><br />";
|
---|
264 | $output .= " <table class=\"hidden\">
|
---|
265 | <tr><td>";
|
---|
266 | makebutton($lang_global['yes'], "javascript:do_submit()",120);
|
---|
267 | makebutton($lang_global['no'], "cleanup.php",120);
|
---|
268 | $output .= "</td></tr>
|
---|
269 | </table>
|
---|
270 | </form>";
|
---|
271 | } else {
|
---|
272 | $output .= "<h1><font class=\"error\">{$lang_global['err_no_records_found']}</font></h1><br />";
|
---|
273 | $output .= "<table class=\"hidden\">
|
---|
274 | <tr><td>";
|
---|
275 | makebutton($lang_global['go_back'], "cleanup.php",120);
|
---|
276 | $output .= "</td></tr>
|
---|
277 | </table>";
|
---|
278 | }
|
---|
279 | $output .= "</center><br />";
|
---|
280 | break;
|
---|
281 |
|
---|
282 |
|
---|
283 | //clean locked acc
|
---|
284 | case "locked":
|
---|
285 | $mysql->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']);
|
---|
286 |
|
---|
287 | $result = $mysql->query("SELECT id FROM account WHERE locked $cleanup_sign $cleanup_value AND gmlevel < $user_lvl");
|
---|
288 | $total_accounts = $mysql->num_rows($result);
|
---|
289 |
|
---|
290 | $output .= "<center>";
|
---|
291 | if ($total_accounts){
|
---|
292 | $output .= "<h1><font class=\"error\">{$lang_global['are_you_sure']}</font></h1><br />";
|
---|
293 | $output .= "<form action=\"cleanup.php?action=docleanup\" method=\"post\" name=\"form\">
|
---|
294 | <input type=\"hidden\" name=\"type\" value=\"acc\" />
|
---|
295 | <font class=\"bold\">{$lang_cleanup['acc_ids']}: ";
|
---|
296 |
|
---|
297 | $pass_array = "";
|
---|
298 |
|
---|
299 | while($acc = $mysql->fetch_row($result)){
|
---|
300 | $output .= "<a href=\"user.php?action=edit_user&id=$acc[0]\" target=\"_blank\">$acc[0], </a>";
|
---|
301 | $pass_array .= "-$acc[0]";
|
---|
302 | }
|
---|
303 |
|
---|
304 | $output .= "<input type=\"hidden\" name=\"check\" value=\"$pass_array\" />";
|
---|
305 | $output .= "<br />{$lang_cleanup['tot_of']} $total_accounts {$lang_global['will_be_erased']}</font><br /><br />";
|
---|
306 | $output .= "<table class=\"hidden\">
|
---|
307 | <tr><td>";
|
---|
308 | makebutton($lang_global['yes'], "javascript:do_submit()",120);
|
---|
309 | makebutton($lang_global['no'], "cleanup.php",120);
|
---|
310 | $output .= "</td></tr>
|
---|
311 | </table>
|
---|
312 | </form>";
|
---|
313 | } else {
|
---|
314 | $output .= "<h1><font class=\"error\">{$lang_global['err_no_records_found']}</font></h1><br />";
|
---|
315 | $output .= "<table class=\"hidden\">
|
---|
316 | <tr><td>";
|
---|
317 | makebutton($lang_global['go_back'], "cleanup.php",120);
|
---|
318 | $output .= "</td></tr>
|
---|
319 | </table>";
|
---|
320 | }
|
---|
321 | $output .= "</center><br />";
|
---|
322 | break;
|
---|
323 |
|
---|
324 |
|
---|
325 | //accounts without chars or specified number of chars
|
---|
326 | case "num_of_char_in_acc":
|
---|
327 | $mysql->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']);
|
---|
328 |
|
---|
329 | $result = $mysql->query("SELECT id FROM account WHERE gmlevel < $user_lvl");
|
---|
330 |
|
---|
331 | $acc_output_array = array();
|
---|
332 |
|
---|
333 | while($acc = $mysql->fetch_row($result)){
|
---|
334 | $total_chars_in_acc = 0;
|
---|
335 | foreach ($mangos_db as $db){
|
---|
336 | $mysql->connect($db['addr'], $db['user'], $db['pass'], $db['name']);
|
---|
337 |
|
---|
338 | $query = $mysql->query("SELECT count(*) FROM `character` WHERE account = '$acc[0]'");
|
---|
339 | $total_chars_in_acc = $total_chars_in_acc + $mysql->result($query, 0);
|
---|
340 | }
|
---|
341 |
|
---|
342 | switch ($cleanup_sign){
|
---|
343 | case "=":
|
---|
344 | if($total_chars_in_acc == $cleanup_value) array_push($acc_output_array, $acc[0]);
|
---|
345 | break;
|
---|
346 | case "<":
|
---|
347 | if($total_chars_in_acc < $cleanup_value) array_push($acc_output_array, $acc[0]);
|
---|
348 | break;
|
---|
349 | case "<=":
|
---|
350 | if($total_chars_in_acc <= $cleanup_value) array_push($acc_output_array, $acc[0]);
|
---|
351 | break;
|
---|
352 | case ">":
|
---|
353 | if($total_chars_in_acc > $cleanup_value) array_push($acc_output_array, $acc[0]);
|
---|
354 | break;
|
---|
355 | case ">=":
|
---|
356 | if($total_chars_in_acc >= $cleanup_value) array_push($acc_output_array, $acc[0]);
|
---|
357 | break;
|
---|
358 | case "!=":
|
---|
359 | if($total_chars_in_acc <> $cleanup_value) array_push($acc_output_array, $acc[0]);
|
---|
360 | break;
|
---|
361 | default:
|
---|
362 | redirect("cleanup.php?error=1");
|
---|
363 | }
|
---|
364 | }
|
---|
365 |
|
---|
366 | $output .= "<center>";
|
---|
367 | if ($acc_output_array){
|
---|
368 | $output .= "<h1><font class=\"error\">{$lang_global['are_you_sure']}</font></h1><br />";
|
---|
369 | $output .= "<form action=\"cleanup.php?action=docleanup\" method=\"post\" name=\"form\">
|
---|
370 | <input type=\"hidden\" name=\"type\" value=\"acc\" />
|
---|
371 | <font class=\"bold\">{$lang_cleanup['acc_ids']}: ";
|
---|
372 |
|
---|
373 | $pass_array = "";
|
---|
374 |
|
---|
375 | for ($i = 0; $i < count($acc_output_array); $i++){
|
---|
376 | $output .= "<a href=\"user.php?action=edit_user&id=$acc_output_array[$i]\" target=\"_blank\">$acc_output_array[$i], </a>";
|
---|
377 | $pass_array .= "-$acc_output_array[$i]";
|
---|
378 | }
|
---|
379 |
|
---|
380 | $output .= "<input type=\"hidden\" name=\"check\" value=\"$pass_array\" />";
|
---|
381 | $output .= "<br />{$lang_cleanup['tot_of']} ".count($acc_output_array)." {$lang_global['will_be_erased']}</font><br /><br />";
|
---|
382 | $output .= " <table class=\"hidden\">
|
---|
383 | <tr><td>";
|
---|
384 | makebutton($lang_global['yes'], "javascript:do_submit()",120);
|
---|
385 | makebutton($lang_global['no'], "cleanup.php",120);
|
---|
386 | $output .= "</td></tr>
|
---|
387 | </table>
|
---|
388 | </form>";
|
---|
389 | } else {
|
---|
390 | $output .= "<h1><font class=\"error\">{$lang_global['err_no_records_found']}</font></h1><br />";
|
---|
391 | $output .= "<table class=\"hidden\">
|
---|
392 | <tr><td>";
|
---|
393 | makebutton($lang_global['go_back'], "cleanup.php",120);
|
---|
394 | $output .= "</td></tr>
|
---|
395 | </table>";
|
---|
396 | }
|
---|
397 | $output .= "</center><br />";
|
---|
398 | break;
|
---|
399 |
|
---|
400 |
|
---|
401 | //guild without chars or specified number of chars
|
---|
402 | case "num_of_char_in_guild":
|
---|
403 | $mysql->connect($mangos_db[$realm_id]['addr'], $mangos_db[$realm_id]['user'], $mangos_db[$realm_id]['pass'], $mangos_db[$realm_id]['name']);
|
---|
404 |
|
---|
405 | $result = $mysql->query("SELECT guildid FROM guild");
|
---|
406 |
|
---|
407 | $guild_output_array = array();
|
---|
408 |
|
---|
409 | while($guild = $mysql->fetch_row($result)){
|
---|
410 | $query = $mysql->query("SELECT count(*) FROM guild_member WHERE guildid = '$guild[0]'");
|
---|
411 | $total_chars_in_guild = $mysql->result($query, 0);
|
---|
412 |
|
---|
413 | switch ($cleanup_sign){
|
---|
414 | case "=":
|
---|
415 | if($total_chars_in_guild == $cleanup_value) array_push($guild_output_array, $guild[0]);
|
---|
416 | break;
|
---|
417 | case "<":
|
---|
418 | if($total_chars_in_guild < $cleanup_value) array_push($guild_output_array, $guild[0]);
|
---|
419 | break;
|
---|
420 | case "<=":
|
---|
421 | if($total_chars_in_guild <= $cleanup_value) array_push($guild_output_array, $guild[0]);
|
---|
422 | break;
|
---|
423 | case ">":
|
---|
424 | if($total_chars_in_guild > $cleanup_value) array_push($guild_output_array, $guild[0]);
|
---|
425 | break;
|
---|
426 | case ">=":
|
---|
427 | if($total_chars_in_guild >= $cleanup_value) array_push($guild_output_array, $guild[0]);
|
---|
428 | break;
|
---|
429 | case "!=":
|
---|
430 | if($total_chars_in_guild <> $cleanup_value) array_push($guild_output_array, $guild[0]);
|
---|
431 | break;
|
---|
432 | default:
|
---|
433 | redirect("cleanup.php?error=1");
|
---|
434 | }
|
---|
435 | }
|
---|
436 |
|
---|
437 | $output .= "<center>";
|
---|
438 | if ($guild_output_array){
|
---|
439 | $output .= "<h1><font class=\"error\">{$lang_global['are_you_sure']}</font></h1><br />";
|
---|
440 | $output .= "<form action=\"cleanup.php?action=docleanup\" method=\"post\" name=\"form\">
|
---|
441 | <input type=\"hidden\" name=\"type\" value=\"guild\" />
|
---|
442 | <font class=\"bold\">{$lang_cleanup['guilds_id']}: ";
|
---|
443 |
|
---|
444 | $pass_array = "";
|
---|
445 |
|
---|
446 | for ($i=0; $i < count($guild_output_array); $i++){
|
---|
447 | $output .= "<a href=\"guild.php?action=view_guild&error=3&id=$guild_output_array[$i]\" target=\"_blank\">$guild_output_array[$i], </a>";
|
---|
448 | $pass_array .= "-$guild_output_array[$i]";
|
---|
449 | }
|
---|
450 |
|
---|
451 | $output .= "<input type=\"hidden\" name=\"check\" value=\"$pass_array\" />";
|
---|
452 | $output .= "<br />{$lang_cleanup['tot_of']} ".count($guild_output_array)." {$lang_global['will_be_erased']}</font><br /><br />";
|
---|
453 | $output .= " <table class=\"hidden\">
|
---|
454 | <tr><td>";
|
---|
455 | makebutton($lang_global['yes'], "javascript:do_submit()",120);
|
---|
456 | makebutton($lang_global['no'], "cleanup.php",120);
|
---|
457 | $output .= "</td></tr>
|
---|
458 | </table>
|
---|
459 | </form>";
|
---|
460 | } else {
|
---|
461 | $output .= "<h1><font class=\"error\">{$lang_global['err_no_records_found']}</font></h1><br />";
|
---|
462 | $output .= "<table class=\"hidden\">
|
---|
463 | <tr><td>";
|
---|
464 | makebutton($lang_global['go_back'], "cleanup.php",120);
|
---|
465 | $output .= "</td></tr>
|
---|
466 | </table>";
|
---|
467 | }
|
---|
468 | $output .= "</center><br />";
|
---|
469 | break;
|
---|
470 |
|
---|
471 | default:
|
---|
472 | redirect("Location: cleanup.php?error=1");
|
---|
473 | }
|
---|
474 |
|
---|
475 | $mysql->close();
|
---|
476 | }
|
---|
477 |
|
---|
478 |
|
---|
479 | //################################################################################################
|
---|
480 | // DO CLAENUP
|
---|
481 | //################################################################################################
|
---|
482 | function docleanup(){
|
---|
483 | global $lang_cleanup, $lang_global, $output, $realm_db, $mangos_db, $realm_id, $user_lvl,
|
---|
484 | $tab_del_user_mangos, $tab_del_user_realmd;
|
---|
485 |
|
---|
486 | if (!isset($_POST['type']) || $_POST['type'] === '') redirect("cleanup.php?error=1");
|
---|
487 |
|
---|
488 | $mysql = new MySQL;
|
---|
489 | $mysql->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass']);
|
---|
490 |
|
---|
491 | $type = $mysql->quote_smart($_POST['type']);
|
---|
492 | if(isset($_POST['check']) && $_POST['check'] != '') {
|
---|
493 | $check = $mysql->quote_smart($_POST['check']);
|
---|
494 | $check = explode('-',$check);
|
---|
495 | } else redirect("cleanup.php?error=1");
|
---|
496 |
|
---|
497 | $deleted_acc = 0;
|
---|
498 | $deleted_chars = 0;
|
---|
499 | $deleted_gulds = 0;
|
---|
500 |
|
---|
501 | require_once("./scripts/del_lib.php");
|
---|
502 |
|
---|
503 | switch ($type){
|
---|
504 | //we deliting account array
|
---|
505 | case "acc":
|
---|
506 | for ($i = 1; $i < count($check); $i++) {
|
---|
507 | if ($check[$i] != "" ) {
|
---|
508 | list($flag,$del_char) = del_acc($check[$i]);
|
---|
509 | if ($flag) {
|
---|
510 | $deleted_acc++;
|
---|
511 | $deleted_chars += $del_char;
|
---|
512 | }
|
---|
513 | }
|
---|
514 | }
|
---|
515 | break;
|
---|
516 |
|
---|
517 | //we deleting charrecter array
|
---|
518 | case "char":
|
---|
519 | for ($i = 1; $i < count($check); $i++) {
|
---|
520 | if ($check[$i] != "" ) {
|
---|
521 | if (del_char($check[$i], $realm_id)) $deleted_chars++;
|
---|
522 | }
|
---|
523 | }
|
---|
524 | break;
|
---|
525 |
|
---|
526 | //cleaning guilds
|
---|
527 | case "guild":
|
---|
528 |
|
---|
529 | for ($i = 1; $i < count($check); $i++) {
|
---|
530 | if ($check[$i] != "" ) {
|
---|
531 | if (del_guild($check[$i], $realm_id)) $deleted_gulds++;
|
---|
532 | }
|
---|
533 | }
|
---|
534 | break;
|
---|
535 |
|
---|
536 | default:
|
---|
537 | redirect("cleanup.php?error=1");
|
---|
538 | }
|
---|
539 |
|
---|
540 | $mysql->close();
|
---|
541 |
|
---|
542 | $output .= "<center>";
|
---|
543 | if ($type == "guild") {
|
---|
544 | if (!$deleted_gulds) $output .= "<h1><font class=\"error\">{$lang_cleanup['no_guilds_del']}</font></h1>";
|
---|
545 | else $output .= "<h1><font class=\"error\">{$lang_cleanup['total']} <font color=blue>$deleted_gulds</font> {$lang_cleanup['guilds_deleted']}</font></h1>";
|
---|
546 | } else {
|
---|
547 | if (($deleted_acc+$deleted_chars) == 0) $output .= "<h1><font class=\"error\">{$lang_cleanup['no_acc_chars_deleted']}</font></h1>";
|
---|
548 | else {
|
---|
549 | $output .= "<h1><font class=\"error\">{$lang_cleanup['total']} <font color=blue>$deleted_acc</font> {$lang_cleanup['accs_deleted']}</font></h1><br />";
|
---|
550 | $output .= "<h1><font class=\"error\">{$lang_cleanup['total']} <font color=blue>$deleted_chars</font> {$lang_cleanup['chars_deleted']}</font></h1>";
|
---|
551 | }
|
---|
552 | }
|
---|
553 | $output .= "<br /><br />";
|
---|
554 | $output .= "<table class=\"hidden\">
|
---|
555 | <tr><td>";
|
---|
556 | makebutton($lang_cleanup['back_cleaning'], "cleanup.php", 200);
|
---|
557 | $output .= "</td></tr>
|
---|
558 | </table><br /></center>";
|
---|
559 | }
|
---|
560 |
|
---|
561 |
|
---|
562 |
|
---|
563 | //########################################################################################################################
|
---|
564 | // MAIN
|
---|
565 | //########################################################################################################################
|
---|
566 | $err = (isset($_GET['error'])) ? $_GET['error'] : NULL;
|
---|
567 |
|
---|
568 | $output .= "<div class=\"top\">";
|
---|
569 | switch ($err) {
|
---|
570 | case 1:
|
---|
571 | $output .= "<h1><font class=\"error\">{$lang_global['empty_fields']}</font></h1>";
|
---|
572 | break;
|
---|
573 | default: //no error
|
---|
574 | $output .= "<h1>{$lang_cleanup['clean_db']}</h1>";
|
---|
575 | }
|
---|
576 | $output .= "</div>";
|
---|
577 |
|
---|
578 | $action = (isset($_GET['action'])) ? $_GET['action'] : NULL;
|
---|
579 |
|
---|
580 | switch ($action) {
|
---|
581 | case "run_cleanup":
|
---|
582 | run_cleanup();
|
---|
583 | break;
|
---|
584 | case "docleanup":
|
---|
585 | docleanup();
|
---|
586 | break;
|
---|
587 | default:
|
---|
588 | cleanup();
|
---|
589 | }
|
---|
590 |
|
---|
591 | require_once("footer.php");
|
---|
592 | ?>
|
---|