-
Notifications
You must be signed in to change notification settings - Fork 7
/
changeusername.php
99 lines (49 loc) · 2.94 KB
/
changeusername.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<?php
session_name("icsession");
session_start();
include('db.php');
$getchar = mysql_query("SELECT * FROM characters WHERE id='".$_SESSION['userid']."'") or die(mysql_error());
$char = mysql_fetch_assoc($getchar);
$display = "";
if($_POST['newUsername'] != NULL || $_POST['newUsername'] != "" && $char['changeusername'] == "1"){
$username = $_POST['newUsername'];
$currentusername = $char['username'];
if(preg_match("/^[a-z0-9_]+$/i", $username))
{
$getuser = mysql_query("SELECT * FROM characters WHERE username='".$username."'");
if(mysql_num_rows($getuser) != "1") //Username does not exist
{
$display .= "Username: <font color=\'#00DD00\'>OK</font><br />";
$guildLeaderCheck = mysql_query("SELECT * FROM guilds WHERE leader='".$char['username']."'");
if(mysql_num_rows($guildLeaderCheck) == "1"){
$updateGuildLeader = mysql_query("UPDATE guilds SET leader='".$username."' WHERE leader='".$char['username']."'");
}
$guildColeaderCheck = mysql_query("SELECT * FROM guilds WHERE coleader='".$char['username']."'");
if(mysql_num_rows($guildColeaderCheck) == "1"){
$updateGuildColeader = mysql_query("UPDATE guilds SET coleader='".$username."' WHERE coleader='".$char['username']."'");
}
$guildCaptianCheck = mysql_query("SELECT * FROM guilds WHERE captian='".$char['username']."'");
if(mysql_num_rows($guildCaptianCheck) == "1"){
$updateGuildCaptian = mysql_query("UPDATE guilds SET captian='".$username."' WHERE captian='".$char['username']."'");
}
$updateInventory = mysql_query("UPDATE inventory SET username='".$username."' WHERE username='".$char['username']."'");
$updateTrade = mysql_query("UPDATE trade SET fromplayer='".$username."' WHERE fromplayer='".$char['username']."'");
$updateUser = mysql_query("UPDATE characters SET changeusername='0', username='".$username."' WHERE id='".$_SESSION['userid']."'");
$updateScavenger = mysql_query("UPDATE scavenger SET username='".$username."' WHERE username='".$currentusername."'");
$updateSecondClass = mysql_query("UPDATE secondclass SET username='".$username."' WHERE username='".$currentusername."'");
$date = time();
$cashmessage = "<b><font color=\'#00DD00\'>".$currentusername." just changed their username to ".$username."!</font></b><br />";
$query = mysql_query("INSERT INTO chatroom (`date`, `userlevel`, `username`, `message`, `to`)VALUES('".$date."', '3', '".$currentusername."', '".$cashmessage."', 'Chatroom')") or die(mysql_error());
}
else
{
$display .= "Username: <font color=\'#DD0000\'>Already Taken</font><br />";
}
}else{
$display .= "Username: <font color=\'#DD0000\'>Illegal Characters</font><br />";
}
}else{
$display .= "Failed even trying to make a change to your username.";
}
print("fillDiv('displayArea','".$display."');");
?>