-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuser.php
217 lines (187 loc) · 8.5 KB
/
user.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
<?php
/*
* user.php
* A routine to view a user account and update personal details
*
* Copyright 2011 caprenter <[email protected]>
*
* This file is part of Setlistr.
*
* Setlistr is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Setlistr is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Setlistr. If not, see <http://www.gnu.org/licenses/>.
*
* Setlistr relies on other free software products. See the README.txt file
* for more details.
*/
require_once('settings.php');
//Initiate the user access script
require_once "phpUserClass/access.class.beta.php";
$user = new flexibleAccess();
//If no-one is logged in redirect to home page.
if ( !$user->is_loaded() ) {
header('Location: index.php');
}
//IS this a DELETE Account request - gulp!
//if so delete it and redirect to home page
if (isset($_POST['user'])) {
$user_id = filter_var($_POST['user'], FILTER_SANITIZE_NUMBER_INT);
if (filter_var($user_id, FILTER_VALIDATE_INT)) {
include("functions/delete_account.php");
}
}
$message ="";
//echo $_POST['username'];
//echo $_POST['email'];
//Process form if submitted to update a users details
if (!empty($_POST['username']) && !empty($_POST['email']) ){
//Sanitize the user inputed data
$email = filter_var($_POST['email'], FILTER_SANITIZE_EMAIL);
//$email = filter_var($email, FILTER_VALIDATE_EMAIL);
if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
$username = filter_var($_POST['username'], FILTER_SANITIZE_STRING);
//$pwd = filter_var($_POST['pwd'], FILTER_SANITIZE_STRING);
if ($user->updateProperty(array('username' => $username)) == 1) {
$message .= "Username updated<br/>";
} else {
$message .= "Failed to update username. ";
$message .= "(This could because the name is already taken) <br/>";
}
if ($user->updateProperty(array('email' => $email)) == 1) {
$message .= "Email updated<br/>";
} else {
$message .= "Failed to update email <br/>";
}
if (!empty($_POST['pwd']) && !empty($_POST['confirm'])) {
$pwd = filter_var($_POST['pwd'], FILTER_SANITIZE_STRING);
$confirm = filter_var($_POST['confirm'], FILTER_SANITIZE_STRING);
//$pass_update = $user->updateProperty(array('password' => $pwd));
//print_r($pass_update);
//echo strlen($pwd );
if ($pwd == $confirm && strlen($pwd) >= 6) {
if ($user->updateProperty(array('password' => $pwd)) == 1) {
$message .= "Password updated<br/>";
} else {
$message .= "Failed to update password <br/>";
}
} else {
if (strlen($pwd) < 6) {
$message .= "Password NOT updated because password is too short.<br/><br/>";
} else {
$message .= "Password NOT updated because they do not match.<br/>";
}
}
}
} else {
$message = "New email address is not valid.<br/><br/>";
}
}
$page = "My Account"; //used for page title in header.php
include('theme/header.php');
$user = new flexibleAccess();
if ( $user->is_loaded() ){
$user_id = $user->get_property("userID");
$username = $user->get_property("username");
$user_api = $user->get_property("apikey");
$email = $user->get_property("email");
}
?>
<!--<div class="list-buttons">
<ul class="inline">
<li><a href="<?php echo $host; ?>">Back</a></li>
</ul>
</div>-->
<div class="workspace">
<div class="active-list">
<h2>Account Settings</h2>
</div>
<!-- <div class="user-column-left">-->
<!--</div>
<div class="user-column-right">-->
<?php
if ($message != NULL) {
echo '<div class="message">' . $message . '</div>';
}
?>
<form action="user.php" method="post" class="login user_edit">
<div class="field-container">
<label for="edit-name">Username: <span class="form-required" title="This field is required.">*</span></label><br/>
<input name="username" id="edit-name" value="<?php echo $username; ?>" class="form-text required" type="text" />
<div class="description">Spaces are allowed; punctuation is not allowed except for periods, hyphens, and underscores.</div>
</div>
<div class="field-container">
<label for="edit-mail">E-mail address: <span class="form-required" title="This field is required.">*</span></label><br/>
<input name="email" id="edit-mail" value="<?php echo $email; ?>" class="form-text required" type="text" />
<div class="description">A valid e-mail address. All e-mails from the system will be sent to this address. The e-mail address is not made public and will only be used if you wish to receive a new password or wish to receive certain news or notifications by e-mail.</div>
</div>
<div class="field-container">
<label for="pwd">Password: </label><br/>
<input name="pwd" id="pwd" class="password" type="password" />
</div>
<div class="field-container">
<label for="confirm">Confirm Password</label><br/>
<input type="password" name="confirm" id="confirm" class="confirm" /> <div class="error-msg"></div>
</div>
<!--
<div class="form-item confirm-parent" id="edit-pass-pass2-wrapper">
<label for="edit-pass-pass2">Confirm password: </label>
<input name="pass[pass2]" id="edit-pass-pass2" maxlength="128" size="25" class="form-text password-confirm" type="password"><span class="password-confirm">Passwords match: <span></span></span>
</div>
<div style="display: none;" class="password-description"></div>
<div class="description">To change the current user password, enter the new password in both fields.</div>
-->
<input type="submit" class="form-submit" value="Update" id="edit-submit" name="op" />
</form>
<!--</div>-->
<div class="user-page-gravatar">
<?php
//gravatar
$url = 'http://www.gravatar.com/avatar/';
//$email = $user->get_property("email");
//$username = $user->get_property("username");
$default = 'monsterid';
$size = 120;
$grav_url = $url.'?gravatar_id=' . md5( strtolower($email) ) . '&default=' . urlencode($default) . '&size=' . $size;
if (@!file_get_contents($grav_url)) {
$grav_url = "./img/missing_gravatar_120.png";
}
echo '<img class="avatar" src="'. $grav_url .'" />';
echo '<div><br/>This is a Gravatar.<br/><a href="http://en.gravatar.com/">Get a Gravatar</a></div>';
//echo $email;
//echo $username;
?>
</div>
<div class="delete-account">
<h3>Your public page</h3>
<p>You have a public page at: </p>
<div class="api_key"><a href="<?php echo $host ?><?php echo $username; ?>"><?php echo $host ?><?php echo $username; ?></a></div>
<p>Any lists that you make public will be listed there.</p>
</div>
<div class="delete-account">
<h3>To delete your account</h3>
<p>By deleting your account we will remove all your account details, and any lists you have created.</p>
<form action="user.php" method="post" id="delete-account">
<input type="hidden" name="user" value="<?php echo $user_id ?>"/>
<input type="submit" class="form-submit" value="Delete Account" id="delete-user-account" name="delete-user-account">
</form>
</div>
<div class="developers">
<h3>Setlistr API Key</h3>
<p>Your API Key allows you to interact with Setlistr from other devices/websites.</p>
<p>Developers can use our <a href="<?php echo $host; ?>api.php">API</a> to exchange data.</p>
<div class="api_key"><?php echo $user_api; ?></div>
</div>
</div><!--end workspace-->
<?php
$password_page = TRUE; //used to initiate the password strength javascript
include('theme/footer.php');
?>