Changeset 307 for minimanager/user.php
- Timestamp:
- Mar 13, 2008, 8:18:42 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
minimanager/user.php
r306 r307 8 8 * License: GNU General Public License v2(GPL) 9 9 */ 10 10 11 11 require_once("header.php"); 12 12 valid_login(1); … … 21 21 $sql = new SQL; 22 22 $sql->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']); 23 23 24 24 $start = (isset($_GET['start'])) ? $sql->quote_smart($_GET['start']) : 0; 25 25 $order_by = (isset($_GET['order_by'])) ? $sql->quote_smart($_GET['order_by']) : "id"; 26 26 27 27 $dir = (isset($_GET['dir'])) ? $sql->quote_smart($_GET['dir']) : 1; 28 28 $order_dir = ($dir) ? "ASC" : "DESC"; 29 29 $dir = ($dir) ? 0 : 1; 30 30 31 31 //get total number of items 32 32 $query_1 = $sql->query("SELECT count(*) FROM account"); 33 33 $all_record = $sql->result($query_1,0); 34 34 35 $query = $sql->query("SELECT id,username,gmlevel,email,joindate,last_ip,failed_logins,locked,last_login,online 35 $query = $sql->query("SELECT id,username,gmlevel,email,joindate,last_ip,failed_logins,locked,last_login,online 36 36 FROM account ORDER BY $order_by $order_dir LIMIT $start, $itemperpage"); 37 37 $this_page = $sql->num_rows($query); … … 40 40 $output .="<script type=\"text/javascript\" src=\"js/check.js\"></script> 41 41 <center><table class=\"top_hidden\"> 42 <tr><td>"; 42 <tr><td>"; 43 43 makebutton($lang_user['add_acc'], "user.php?action=add_new", 124); 44 44 makebutton($lang_user['cleanup'], "cleanup.php", 122); … … 142 142 $sql = new SQL; 143 143 $sql->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']); 144 144 145 145 $search_value = $sql->quote_smart($_GET['search_value']); 146 146 $search_by = $sql->quote_smart($_GET['search_by']); … … 150 150 $order_dir = ($dir) ? "ASC" : "DESC"; 151 151 $dir = ($dir) ? 0 : 1; 152 152 153 153 switch ($search_by){ 154 154 155 155 case "greater_gmlevel": 156 156 $sql_query = "SELECT id,username,gmlevel,email,joindate,last_ip,failed_logins,locked,last_login,online 157 157 FROM account WHERE gmlevel > $search_value ORDER BY $order_by $order_dir LIMIT $sql_search_limit"; 158 158 break; 159 159 160 160 case "banned": 161 161 $sql_query = "SELECT id,username,gmlevel,email,joindate,last_ip,failed_logins,locked,last_login,online … … 165 165 $sql_query .= " ORDER BY $order_by $order_dir LIMIT $sql_search_limit"; 166 166 break; 167 167 168 168 case "failed_logins": 169 169 $sql_query = "SELECT id,username,gmlevel,email,joindate,last_ip,failed_logins,locked,last_login,online 170 170 FROM account WHERE failed_logins > $search_value ORDER BY $order_by $order_dir LIMIT $sql_search_limit"; 171 171 break; 172 172 173 173 default: 174 174 $sql_query = "SELECT id,username,gmlevel,email,joindate,last_ip,failed_logins,locked,last_login,online … … 213 213 <input type=\"hidden\" name=\"backup_op\" value=\"0\"/> 214 214 <table class=\"lined\"> 215 <tr> 215 <tr> 216 216 <th width=\"1%\"><input name=\"allbox\" type=\"checkbox\" value=\"Check All\" onclick=\"CheckAll(document.form1);\" /></th> 217 217 <th width=\"5%\"><a href=\"user.php?action=search&error=3&search_value=$search_value&search_by=$search_by&order_by=id&dir=$dir\">".($order_by=='id' ? "<img src=\"img/arr_".($dir ? "up" : "dw").".gif\" /> " : "")."{$lang_user['id']}</a></th> … … 260 260 </table> 261 261 </form><br /></center>"; 262 262 263 263 $sql->close(); 264 264 } … … 289 289 $sql = new SQL; 290 290 $sql->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']); 291 291 292 292 for ($i=0; $i<count($check); $i++){ 293 293 $username = $sql->result($sql->query("SELECT username FROM `account` WHERE id = {$check[$i]}"),0); … … 317 317 $sql = new SQL; 318 318 $sql->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']); 319 319 320 320 if(isset($_GET['check'])) $check = $sql->quote_smart($_GET['check']); 321 321 else redirect("user.php?error=1"); … … 324 324 $deleted_chars = 0; 325 325 require_once("scripts/del_lib.php"); 326 326 327 327 for ($i=0; $i<count($check); $i++) { 328 328 if ($check[$i] != "" ) { … … 336 336 $sql->close(); 337 337 $output .= "<center>"; 338 if ($deleted_acc == 0) $output .= "<h1><font class=\"error\">{$lang_user['no_acc_deleted']}</font></h1>"; 338 if ($deleted_acc == 0) $output .= "<h1><font class=\"error\">{$lang_user['no_acc_deleted']}</font></h1>"; 339 339 else { 340 340 $output .= "<h1><font class=\"error\">{$lang_user['total']} <font color=blue>$deleted_acc</font> {$lang_user['acc_deleted']}</font><br /></h1>"; … … 358 358 $sql = new SQL; 359 359 $sql->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']); 360 360 361 361 if(isset($_GET['check'])) $check = $sql->quote_smart($_GET['check']); 362 362 else redirect("user.php?error=1"); … … 383 383 $num_fields = $sql->num_fields($acc_query); 384 384 $numrow = $sql->num_rows($acc_query); 385 385 386 386 $result = "-- Dumping data for $value[0] ".date("m.d.y_H.i.s")."\n"; 387 387 $result .= "LOCK TABLES $value[0] WRITE;\n"; 388 388 $result .= "DELETE FROM $value[0] WHERE $value[1] = $acc[0];\n"; 389 389 390 390 if ($numrow){ 391 391 $result .= "INSERT INTO $value[0] ("; 392 392 393 393 for($count = 0; $count < $num_fields; $count++) { 394 394 $result .= "`".$sql->field_name($acc_query,$count)."`"; 395 395 if ($count < ($num_fields-1)) $result .= ","; 396 } 396 } 397 397 $result .= ") VALUES \n"; 398 398 … … 408 408 }else $result .= "''"; 409 409 if ($j<($num_fields-1)) $result .= ","; 410 } 410 } 411 411 if ($i < ($numrow-1)) $result .= "),\n"; 412 } 412 } 413 413 $result .= ");\n"; 414 414 } … … 418 418 } 419 419 fclose($fp); 420 420 421 421 foreach ($characters_db as $db){ 422 422 $file_name_new = $acc[0]."_{$db['name']}.sql"; … … 424 424 fwrite($fp, "CREATE DATABASE /*!32312 IF NOT EXISTS*/ {$db['name']};\n")or die (error($lang_backup['file_write_err'])); 425 425 fwrite($fp, "USE {$db['name']};\n\n")or die (error($lang_backup['file_write_err'])); 426 426 427 427 $sql->connect($db['addr'], $db['user'], $db['pass'], $db['name']); 428 $all_char_query = $sql->query("SELECT guid,name FROM `character ` WHERE account = $acc[0]");429 428 $all_char_query = $sql->query("SELECT guid,name FROM `characters` WHERE account = $acc[0]"); 429 430 430 while ($char = $sql->fetch_array($all_char_query)){ 431 431 fwrite($fp, "-- Dumping data for character $char[1]\n")or die (error($lang_backup['file_write_err'])); … … 434 434 $num_fields = $sql->num_fields($char_query); 435 435 $numrow = $sql->num_rows($char_query); 436 436 437 437 $result = "LOCK TABLES $value[0] WRITE;\n"; 438 438 $result .= "DELETE FROM $value[0] WHERE $value[1] = $char[0];\n"; … … 440 440 if ($numrow){ 441 441 $result .= "INSERT INTO $value[0] ("; 442 442 443 443 for($count = 0; $count < $num_fields; $count++) { 444 444 $result .= "`".$sql->field_name($char_query,$count)."`"; 445 445 if ($count < ($num_fields-1)) $result .= ","; 446 } 446 } 447 447 $result .= ") VALUES \n"; 448 448 … … 458 458 }else $result .= "''"; 459 459 if ($j<($num_fields-1)) $result .= ","; 460 } 460 } 461 461 if ($i < ($numrow-1)) $result .= "),\n"; 462 } 462 } 463 463 $result .= ");\n"; 464 464 … … 474 474 } 475 475 $sql->close(); 476 476 477 477 redirect("user.php?error=15"); 478 478 } … … 499 499 } 500 500 </script> 501 501 502 502 <fieldset style=\"width: 550px;\"> 503 503 <legend>{$lang_user['create_new_acc']}</legend> … … 582 582 $tbc = (isset($_GET['new_tbc'])) ? $sql->quote_smart($_GET['new_tbc']) : 0; 583 583 584 $result = $sql->query("INSERT INTO account (username, I,gmlevel,email, joindate,last_ip,failed_logins,locked,last_login,online,tbc)585 VALUES ('$new_user','$pass',0 ,'$new_mail', current_date() ,'$last_ip',0, $locked ,NULL, 0, $tbc)");584 $result = $sql->query("INSERT INTO account (username,sha_pass_hash,gmlevel,email, joindate,last_ip,failed_logins,locked,last_login,online,tbc) 585 VALUES ('$new_user','$pass',0 ,'$new_mail',now() ,'$last_ip',0, $locked ,NULL, 0, $tbc)"); 586 586 $sql->close(); 587 587 … … 596 596 function edit_user() { 597 597 global $lang_global, $lang_user, $output, $realm_db, $characters_db, $realm_id, $user_lvl, $user_name, $gm_level_arr; 598 598 599 599 if (empty($_GET['id'])) redirect("user.php?error=10"); 600 600 601 601 $sql = new SQL; 602 602 $sql->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']); 603 603 604 604 $id = $sql->quote_smart($_GET['id']); 605 605 606 606 $result = $sql->query("SELECT id,username,gmlevel,email,joindate,last_ip,failed_logins,locked,last_login,online,tbc FROM account WHERE id = '$id'"); 607 607 $data = $sql->fetch_row($result); 608 608 609 609 if ($sql->num_rows($result)){ 610 610 //restricting accsess to lower gmlvl … … 717 717 718 718 $sql->connect($characters_db[$realm_id]['addr'], $characters_db[$realm_id]['user'], $characters_db[$realm_id]['pass'], $characters_db[$realm_id]['name']); 719 $query = $sql->query("SELECT count(*) FROM `character ` WHERE account = $id");719 $query = $sql->query("SELECT count(*) FROM `characters` WHERE account = $id"); 720 720 $chars_on_realm = $sql->result($query, 0); 721 721 … … 731 731 //if there is any chars to display 732 732 if ($chars_on_realm){ 733 $char_array = $sql->query("SELECT guid,name,race,class,SUBSTRING_INDEX(SUBSTRING_INDEX(`data`, ' ', 35), ' ', -1) FROM `character ` WHERE account = $id");733 $char_array = $sql->query("SELECT guid,name,race,class,SUBSTRING_INDEX(SUBSTRING_INDEX(`data`, ' ', 35), ' ', -1) FROM `characters` WHERE account = $id"); 734 734 while ($char = $sql->fetch_array($char_array)){ 735 $output .= "<tr> 735 $output .= "<tr> 736 736 <td> '---></td> 737 737 <td><a href=\"char.php?id=$char[0]\">$char[1] - ".get_player_race($char[2])." ".get_player_class($char[3])." | lvl $char[4]</a></td> … … 762 762 if( (!isset($_POST['id']) || $_POST['id'] === '') || (!isset($_POST['username']) || $_POST['username'] === '') || (!isset($_POST['pass']) || $_POST['pass'] === '') ) 763 763 redirect("user.php?action=edit_user&&id={$_POST['id']}&error=1"); 764 764 765 765 $sql = new SQL; 766 766 $sql->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']); … … 770 770 $pass = $sql->quote_smart($_POST['pass']); 771 771 $user_pass_change = ($pass != sha1(strtoupper($username).":******")) ? "username='$username',sha_pass_hash='$pass'," : ""; 772 772 773 773 $mail = (isset($_POST['mail']) && $_POST['mail'] != '') ? $sql->quote_smart($_POST['mail']) : ""; 774 774 $failed = (isset($_POST['failed'])) ? $sql->quote_smart($_POST['failed']) : 0; … … 808 808 if(!$sql->result($result, 0)) 809 809 $sql->query("INSERT INTO account_banned (id, bandate, unbandate, bannedby, banreason, active) 810 VALUES ($id, ".time().",".(time()+(365*24*3600)).",'$user_name','none', 1)"); 810 VALUES ($id, ".time().",".(time()+(365*24*3600)).",'$user_name','none', 1)"); 811 811 } 812 812 … … 840 840 $output .= "<h1>{$lang_user['acc_created']}</h1>"; 841 841 break; 842 case 6: 842 case 6: 843 843 $output .= "<h1><font class=\"error\">{$lang_user['nonidentical_passes']}</font></h1>"; 844 844 break; … … 881 881 882 882 switch ($action) { 883 case "browse_users": 883 case "browse_users": 884 884 browse_users(); 885 885 break; 886 case "search": 886 case "search": 887 887 search(); 888 888 break; 889 case "add_new": 889 case "add_new": 890 890 add_new(); 891 891 break; 892 case "doadd_new": 892 case "doadd_new": 893 893 doadd_new(); 894 894 break; 895 case "edit_user": 895 case "edit_user": 896 896 edit_user(); 897 897 break; 898 case "doedit_user": 898 case "doedit_user": 899 899 doedit_user(); 900 900 break; 901 case "del_user": 901 case "del_user": 902 902 del_user(); 903 903 break; 904 case "dodel_user": 904 case "dodel_user": 905 905 dodel_user(); 906 906 break; 907 case "backup_user": 907 case "backup_user": 908 908 backup_user(); 909 909 break;
Note:
See TracChangeset
for help on using the changeset viewer.