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
|
<?php
htmlHeader();
?>
<body>
<?php
topbar($Links);
if (!$accepted) {
echo "Sign in first";
htmlFooter();
exit;
}
include('./includes/maps.php');
include_once('./includes/sqlEmbedded.php');
function validatename($name) {
if (strlen($name) < 1)
return false;
if ($name != htmlentities($name))
return false;
if (strlen($name) > 14)
return false;
return true;
}
/**
* Returns true if the given user has opted out of emails, false otherwise
*/
function isOptedOutOfEmails($userID) {
$userID = mysql_escape_string($userID);
$sql = "SELECT `isOptedOutOfEmails` FROM `users`
WHERE `ID` = '$userID' AND `isOptedOutOfEmails` = 1
LIMIT 1";
$result = mysql_query($sql) or die(mysql_error());
return (mysql_num_rows($result) >= 1);
}
function setOptedOutOfEmails($userID, $setting) {
$userID = mysql_escape_string($userID);
if ($setting) $setting == '1'; else $setting == '0';
$sql = "UPDATE `users`
SET `isOptedOutOfEmails` = '$setting'
WHERE `ID` = '$userID'
LIMIT 1";
$result = mysql_query($sql) or die(mysql_error());
}
if (isset($_POST['updateSettings']) AND $_POST['updateSettings'] == 'true') {
$userID = $_SESSION['userID'];
if (isset($_POST['displayName'])) {
$inputname = sql_clean($_POST['displayName']);
$inputname = chatFilter($inputname);
if (validatename($inputname)) {
$sql = "UPDATE `users`
SET `displayName` = '$inputname'
WHERE `ID` = '$userID'
";
mysql_query($sql);
$_SESSION['displayName'] = $inputname;
$r .= "<br />Name change success!";
} else {
$r .= "<br />Invalid name";
}
}
if ($_POST['emailOptOut'] == 'true') {
setOptedOutOfEmails($userID, true);
$r .= "<br />You are opted out of emails";
} else {
setOptedOutOfEmails($userID, false);
$r .= "<br />You are accepting emails";
}
DoRedirect("Settings updated! Thank you!");
exit;
}
$checked = '';
if (isOptedOutOfEmails($userID)) {
$checked = 'checked="yes"';
}
$displayName = htmlspecialchars($_SESSION['displayName'], ENT_COMPAT | ENT_HTML5);
?>
<div class="wrapper">
<h2>Control Panel</h2>
<form action="cp" method="post" name="changename">
<input type="hidden" name="updateSettings" value="true">
<fieldset style='width:400px'>
<legend>Settings:</legend>
Display Name: <input type="text" size="20" maxlength="14" value="<?php echo $displayName ?>" name="displayName" class="forminput" />
<br /><br />
<input type="checkbox" name="emailOptOut" value="true" <?php echo $checked ?>>
Opt out of emails? We'll only send you important feature updates! I Promise!
<br /><br />
<input type="submit" value="Update settings" class="forminput" />
</fieldset>
</div>
</form>
<?php
function chatFilter($chat) {
//cuss words
$chat = str_replace("fuck you", "i am moron", $chat);
$chat = str_replace("fuck", "dumb", $chat);
$chat = str_replace("asshole", "dumb", $chat);
$chat = str_replace("damnit", "dumb", $chat);
$chat = str_replace("damn", "dumb", $chat);
$chat = str_replace("cunt", "dumb", $chat);
$chat = str_replace("shit", "dumb", $chat);
$chat = str_replace("bitch", "dumb", $chat);
$chat = str_replace("sucks ass", "is dumb", $chat);
$chat = str_replace("suck ass", "is dumb", $chat);
$chat = str_replace("stfu", "shutup", $chat);
$chat = str_replace("omfg", "omg", $chat);
$chat = str_replace("fuk", "dumb", $chat);
return $chat;
}
htmlFooter();
?>
|