-
Notifications
You must be signed in to change notification settings - Fork 11
/
preferences.php
executable file
·266 lines (240 loc) · 7.01 KB
/
preferences.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
<?php
session_start();
require "global_func.php";
if ($_SESSION['loggedin'] == 0)
{
header("Location: login.php");
exit;
}
$userid = $_SESSION['userid'];
require "header.php";
$h = new headers;
$h->startheaders();
include "mysql.php";
global $c;
$is =
mysql_query(
"SELECT u.*,us.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid WHERE u.userid=$userid",
$c) or die(mysql_error());
$ir = mysql_fetch_array($is);
check_level();
$fm = money_formatter($ir['money']);
$cm = money_formatter($ir['crystals'], '');
$lv = date('F j, Y, g:i a', $ir['laston']);
$h->userdata($ir, $lv, $fm, $cm);
$h->menuarea();
switch ($_GET['action'])
{
case 'sexchange2':
do_sex_change();
break;
case 'sexchange':
conf_sex_change();
break;
case 'passchange2':
do_pass_change();
break;
case 'passchange':
pass_change();
break;
case 'namechange2':
do_name_change();
break;
case 'namechange':
name_change();
break;
case 'picchange2':
do_pic_change();
break;
case 'picchange':
pic_change();
break;
case 'profilesig2':
do_profilesig_change();
break;
case 'profilesig':
profilesig_change();
break;
default:
prefs_home();
break;
}
function prefs_home()
{
global $ir, $c, $userid, $h;
print
"<h3>Preferences</h3>
<a href='preferences.php?action=sexchange'>Sex Change</a><br />
<a href='preferences.php?action=passchange'>Password Change</a><br />
<a href='preferences.php?action=namechange'>Name Change</a><br />
<a href='preferences.php?action=picchange'>Display Pic Change</a><br />
<a href='preferences.php?action=profilesig'>Profile Signature Change</a>";
}
function conf_sex_change()
{
global $ir, $c, $userid, $h;
if ($ir['gender'] == "Male")
{
$g = "Female";
}
else
{
$g = "Male";
}
print
"Having the trans-gender costs 20 Crystals.<br />Are you sure you want to become a $g?<br />
<a href='preferences.php?action=sexchange2'>Yes</a> | <a href='preferences.php'>No</a>";
}
function do_sex_change()
{
global $ir, $c, $userid, $h;
if ($ir['crystals'] < 20)
{
print "You don't have enough crystals!";
exit;
}
else if ($ir['gender'] == "Male")
{
$g = "Female";
}
else
{
$g = "Male";
}
mysql_query("UPDATE users SET gender='$g' WHERE userid=$userid", $c);
mysql_query("UPDATE users SET crystals=crystals-20 WHERE userid=$userid",
$c);
mysql_query("UPDATE users SET crystals=0 WHERE crystals<0", $c);
print "Success, you are now $g!<br />
<a href='preferences.php'>Back</a>";
}
function pass_change()
{
global $ir, $c, $userid, $h;
print
"<h3>Password Change</h3><form action='preferences.php?action=passchange2' method='post'>Current Password: <input type='password' name='oldpw' /><br />
New Password: <input type='password' name='newpw' /><br />
Confirm: <input type='password' name='newpw2' /><br />
<input type='submit' value='Change PW' /></form>";
}
function do_pass_change()
{
global $ir, $c, $userid, $h;
$oldpw = stripslashes($_POST['oldpw']);
$newpw = stripslashes($_POST['newpw']);
$newpw2 = stripslashes($_POST['newpw2']);
if (!verify_user_password($oldpw, $ir['userpass']))
{
echo "
The current password you entered was wrong.<br />
<a href='preferences.php?action=passchange'>> Back</a>
";
}
else if ($newpw !== $newpw2)
{
echo "The new passwords you entered did not match!<br />
<a href='preferences.php?action=passchange'>> Back</a>";
}
else
{
// Re-encode password
$new_psw =
mysql_real_escape_string(
encode_password($newpw), $c);
mysql_query(
"UPDATE `users`
SET `userpass` = '{$new_psw}'
WHERE `userid` = {$ir['userid']}", $c);
echo "Password changed!<br />
> <a href='preferences.php'>Go Back</a>";
}
}
function name_change()
{
global $ir, $c, $userid, $h;
print
"<h3>Name Change</h3>
Changing your name now costs \$3000<br />
Please note that you still use the same name to login, this procedure simply changes the name that is displayed. <form action='preferences.php?action=namechange2' method='post'>
New Name: <input type='text' name='newname' /><br />
<input type='submit' value='Change Name' /></form>";
}
function do_name_change()
{
global $ir, $c, $userid, $h;
if ($ir['money'] < 3000)
{
print "You don't have enough money!";
exit;
}
else if ($_POST['newname'] == "")
{
print
"You did not enter a new name.<br />
<a href='preferences.php?action=namechange'>> Back</a>";
}
else
{
$_POST['newname'] =
mysql_real_escape_string(
htmlentities(stripslashes($_POST['newname']),
ENT_QUOTES, 'ISO-8859-1'), $c);
mysql_query(
"UPDATE users SET username='{$_POST['newname']}' WHERE userid=$userid",
$c);
mysql_query("UPDATE users SET money=money-3000 WHERE userid=$userid",
$c);
mysql_query("UPDATE users SET money=0 WHERE money<0", $c);
print "Username changed!";
}
}
function pic_change()
{
global $ir, $c, $userid, $h;
print
"<h3>Pic Change</h3>
Please note that this must be externally hosted, <a href='http://imageshack.us'>ImageShack</a> is our recommendation.<br />
Any images that are not 150x150 will be automatically resized <form action='preferences.php?action=picchange2' method='post'>
New Pic: <input type='text' name='newpic' value='{$ir['display_pic']}' /><br />
<input type='submit' value='Change Pic' /></form>";
}
function do_pic_change()
{
global $ir, $c, $userid, $h;
if (empty($_POST['newpic']))
{
print
"You did not enter a new pic.<br />
<a href='preferences.php?action=picchange'>> Back</a>";
}
else
{
$npic = stripslashes($_POST['newpic']);
$esc_npic =
mysql_real_escape_string(
htmlentities($npic, ENT_QUOTES, 'ISO-8859-1'), $c);
mysql_query(
"UPDATE users SET display_pic='{$esc_npic}' WHERE userid=$userid",
$c);
print "Pic changed!";
}
}
function profilesig_change()
{
global $ir, $c, $userid, $h;
print
"<h3>Profile Signature Change</h3>
Please note that BBCode is supported.<br />
<form action='preferences.php?action=profilesig2' method='post'>
<textarea name='newprofilesig'>{$ir['profile_sig']}</textarea><br />
<input type='submit' value='Change Profile Signature' /></form>";
}
function do_profilesig_change()
{
global $ir, $c, $userid, $h;
$npic = stripslashes($_POST['newprofilesig']);
$esc_npic = mysql_real_escape_string($npic, $c);
mysql_query("UPDATE users SET profile_sig='{$esc_npic}' WHERE userid=$userid", $c);
print "Profile signature changed!";
}
$h->endpage();