author | Dan |
Sun, 28 Oct 2007 17:46:54 -0400 | |
changeset 211 | 753dabeca1ee |
parent 192 | 9237767a23ae |
child 224 | 6a4573507ff8 |
permissions | -rw-r--r-- |
0 | 1 |
<?php |
2 |
/* |
|
3 |
Plugin Name: User control panel |
|
36
425261984266
Added "page hint" on search page; deprecated "www." on EnanoCMS.org links
Dan
parents:
32
diff
changeset
|
4 |
Plugin URI: http://enanocms.org/ |
0 | 5 |
Description: Provides the page Special:Preferences. |
6 |
Author: Dan Fuhry |
|
192
9237767a23ae
Implemented cron image into Oxygen and St Patty as promised; fixed way-outdated version numbers in plugins
Dan
parents:
175
diff
changeset
|
7 |
Version: 1.0.2 |
36
425261984266
Added "page hint" on search page; deprecated "www." on EnanoCMS.org links
Dan
parents:
32
diff
changeset
|
8 |
Author URI: http://enanocms.org/ |
0 | 9 |
*/ |
10 |
||
11 |
/* |
|
12 |
* Enano - an open-source CMS capable of wiki functions, Drupal-like sidebar blocks, and everything in between |
|
192
9237767a23ae
Implemented cron image into Oxygen and St Patty as promised; fixed way-outdated version numbers in plugins
Dan
parents:
175
diff
changeset
|
13 |
* Version 1.0.2 |
0 | 14 |
* Copyright (C) 2006-2007 Dan Fuhry |
15 |
* |
|
16 |
* This program is Free Software; you can redistribute it and/or modify it under the terms of the GNU General Public License |
|
17 |
* as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. |
|
18 |
* |
|
19 |
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied |
|
20 |
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. |
|
21 |
*/ |
|
22 |
||
23 |
$userprefs_menu = Array(); |
|
24 |
$userprefs_menu_links = Array(); |
|
25 |
function userprefs_menu_add($section, $text, $link) |
|
26 |
{ |
|
27 |
global $userprefs_menu; |
|
28 |
if ( is_array($userprefs_menu[$section]) ) |
|
29 |
{ |
|
30 |
$userprefs_menu[$section][] = Array( |
|
31 |
'text' => $text, |
|
32 |
'link' => $link |
|
33 |
); |
|
34 |
} |
|
35 |
else |
|
36 |
{ |
|
37 |
$userprefs_menu[$section] = Array(Array( |
|
38 |
'text' => $text, |
|
39 |
'link' => $link |
|
40 |
)); |
|
41 |
} |
|
42 |
} |
|
43 |
||
103
a8891e108c95
Several major improvements: Memberlist page added (planned since about beta 2), page group support added for non-JS ACL editor (oops!), and attempting to view a page for which you lack read permissions will get you logged.
Dan
parents:
85
diff
changeset
|
44 |
$plugins->attachHook('compile_template', 'userprefs_jbox_setup($button, $tb, $menubtn);'); |
a8891e108c95
Several major improvements: Memberlist page added (planned since about beta 2), page group support added for non-JS ACL editor (oops!), and attempting to view a page for which you lack read permissions will get you logged.
Dan
parents:
85
diff
changeset
|
45 |
|
a8891e108c95
Several major improvements: Memberlist page added (planned since about beta 2), page group support added for non-JS ACL editor (oops!), and attempting to view a page for which you lack read permissions will get you logged.
Dan
parents:
85
diff
changeset
|
46 |
function userprefs_jbox_setup(&$button, &$tb, &$menubtn) |
a8891e108c95
Several major improvements: Memberlist page added (planned since about beta 2), page group support added for non-JS ACL editor (oops!), and attempting to view a page for which you lack read permissions will get you logged.
Dan
parents:
85
diff
changeset
|
47 |
{ |
a8891e108c95
Several major improvements: Memberlist page added (planned since about beta 2), page group support added for non-JS ACL editor (oops!), and attempting to view a page for which you lack read permissions will get you logged.
Dan
parents:
85
diff
changeset
|
48 |
global $db, $session, $paths, $template, $plugins; // Common objects |
a8891e108c95
Several major improvements: Memberlist page added (planned since about beta 2), page group support added for non-JS ACL editor (oops!), and attempting to view a page for which you lack read permissions will get you logged.
Dan
parents:
85
diff
changeset
|
49 |
|
a8891e108c95
Several major improvements: Memberlist page added (planned since about beta 2), page group support added for non-JS ACL editor (oops!), and attempting to view a page for which you lack read permissions will get you logged.
Dan
parents:
85
diff
changeset
|
50 |
if ( $paths->namespace != 'Special' || $paths->cpage['urlname_nons'] != 'Preferences' ) |
a8891e108c95
Several major improvements: Memberlist page added (planned since about beta 2), page group support added for non-JS ACL editor (oops!), and attempting to view a page for which you lack read permissions will get you logged.
Dan
parents:
85
diff
changeset
|
51 |
return false; |
a8891e108c95
Several major improvements: Memberlist page added (planned since about beta 2), page group support added for non-JS ACL editor (oops!), and attempting to view a page for which you lack read permissions will get you logged.
Dan
parents:
85
diff
changeset
|
52 |
|
a8891e108c95
Several major improvements: Memberlist page added (planned since about beta 2), page group support added for non-JS ACL editor (oops!), and attempting to view a page for which you lack read permissions will get you logged.
Dan
parents:
85
diff
changeset
|
53 |
$tb .= "<ul>$template->toolbar_menu</ul>"; |
a8891e108c95
Several major improvements: Memberlist page added (planned since about beta 2), page group support added for non-JS ACL editor (oops!), and attempting to view a page for which you lack read permissions will get you logged.
Dan
parents:
85
diff
changeset
|
54 |
$template->toolbar_menu = ''; |
a8891e108c95
Several major improvements: Memberlist page added (planned since about beta 2), page group support added for non-JS ACL editor (oops!), and attempting to view a page for which you lack read permissions will get you logged.
Dan
parents:
85
diff
changeset
|
55 |
|
a8891e108c95
Several major improvements: Memberlist page added (planned since about beta 2), page group support added for non-JS ACL editor (oops!), and attempting to view a page for which you lack read permissions will get you logged.
Dan
parents:
85
diff
changeset
|
56 |
$button->assign_vars(array( |
a8891e108c95
Several major improvements: Memberlist page added (planned since about beta 2), page group support added for non-JS ACL editor (oops!), and attempting to view a page for which you lack read permissions will get you logged.
Dan
parents:
85
diff
changeset
|
57 |
'TEXT' => 'list of registered members', |
a8891e108c95
Several major improvements: Memberlist page added (planned since about beta 2), page group support added for non-JS ACL editor (oops!), and attempting to view a page for which you lack read permissions will get you logged.
Dan
parents:
85
diff
changeset
|
58 |
'FLAGS' => '', |
a8891e108c95
Several major improvements: Memberlist page added (planned since about beta 2), page group support added for non-JS ACL editor (oops!), and attempting to view a page for which you lack read permissions will get you logged.
Dan
parents:
85
diff
changeset
|
59 |
'PARENTFLAGS' => '', |
a8891e108c95
Several major improvements: Memberlist page added (planned since about beta 2), page group support added for non-JS ACL editor (oops!), and attempting to view a page for which you lack read permissions will get you logged.
Dan
parents:
85
diff
changeset
|
60 |
'HREF' => makeUrlNS('Special', 'Memberlist') |
a8891e108c95
Several major improvements: Memberlist page added (planned since about beta 2), page group support added for non-JS ACL editor (oops!), and attempting to view a page for which you lack read permissions will get you logged.
Dan
parents:
85
diff
changeset
|
61 |
)); |
a8891e108c95
Several major improvements: Memberlist page added (planned since about beta 2), page group support added for non-JS ACL editor (oops!), and attempting to view a page for which you lack read permissions will get you logged.
Dan
parents:
85
diff
changeset
|
62 |
|
a8891e108c95
Several major improvements: Memberlist page added (planned since about beta 2), page group support added for non-JS ACL editor (oops!), and attempting to view a page for which you lack read permissions will get you logged.
Dan
parents:
85
diff
changeset
|
63 |
$tb .= $button->run(); |
a8891e108c95
Several major improvements: Memberlist page added (planned since about beta 2), page group support added for non-JS ACL editor (oops!), and attempting to view a page for which you lack read permissions will get you logged.
Dan
parents:
85
diff
changeset
|
64 |
} |
a8891e108c95
Several major improvements: Memberlist page added (planned since about beta 2), page group support added for non-JS ACL editor (oops!), and attempting to view a page for which you lack read permissions will get you logged.
Dan
parents:
85
diff
changeset
|
65 |
|
0 | 66 |
function userprefs_menu_html() |
67 |
{ |
|
68 |
global $userprefs_menu; |
|
69 |
global $userprefs_menu_links; |
|
70 |
||
71 |
$html = ''; |
|
72 |
$quot = '"'; |
|
73 |
||
74 |
foreach ( $userprefs_menu as $section => $buttons ) |
|
75 |
{ |
|
76 |
$html .= ( isset($userprefs_menu_links[$section]) ) ? "<a href={$quot}{$userprefs_menu_links[$section]}{$quot}>{$section}</a>\n " : "<a>{$section}</a>\n "; |
|
77 |
$html .= "<ul>\n "; |
|
78 |
foreach ( $buttons as $button ) |
|
79 |
{ |
|
80 |
$html .= " <li><a href={$quot}{$button['link']}{$quot}>{$button['text']}</a></li>\n "; |
|
81 |
} |
|
82 |
$html .= "</ul>\n "; |
|
83 |
} |
|
84 |
||
85 |
return $html; |
|
86 |
} |
|
87 |
||
88 |
function userprefs_show_menu() |
|
89 |
{ |
|
90 |
echo '<div class="menu_nojs"> |
|
91 |
' . userprefs_menu_html() . ' |
|
92 |
<span class="menuclear"></span> |
|
93 |
</div> |
|
94 |
<br /> |
|
95 |
'; |
|
96 |
} |
|
97 |
||
98 |
function userprefs_menu_init() |
|
99 |
{ |
|
100 |
global $db, $session, $paths, $template, $plugins; // Common objects |
|
101 |
global $userprefs_menu_links; |
|
102 |
||
175
1465f48faba0
AJAX login box is now used in userprefs panel; Spry shake effect and general UX on auth fail is smoother now; added ajaxLoginNavTo() JS function
Dan
parents:
140
diff
changeset
|
103 |
userprefs_menu_add('Profile/membership', 'Edit e-mail address and password', makeUrlNS('Special', 'Preferences/EmailPassword') . '" onclick="ajaxLoginNavTo(\'Special\', \'Preferences/EmailPassword\', '.USER_LEVEL_CHPREF.'); return false;'); |
0 | 104 |
userprefs_menu_add('Profile/membership', 'Edit signature', makeUrlNS('Special', 'Preferences/Signature')); |
105 |
userprefs_menu_add('Profile/membership', 'Edit public profile', makeUrlNS('Special', 'Preferences/Profile')); |
|
106 |
userprefs_menu_add('Private messages', 'Inbox', makeUrlNS('Special', 'PrivateMessages/Folder/Inbox')); |
|
107 |
userprefs_menu_add('Private messages', 'Outbox', makeUrlNS('Special', 'PrivateMessages/Folder/Outbox')); |
|
108 |
userprefs_menu_add('Private messages', 'Sent items', makeUrlNS('Special', 'PrivateMessages/Folder/Sent')); |
|
109 |
userprefs_menu_add('Private messages', 'Drafts', makeUrlNS('Special', 'PrivateMessages/Folder/Drafts')); |
|
110 |
userprefs_menu_add('Private messages', 'Archive', makeUrlNS('Special', 'PrivateMessages/Folder/Archive')); |
|
111 |
||
112 |
$userprefs_menu_links['Profile/membership'] = makeUrlNS('Special', 'Preferences'); |
|
113 |
$userprefs_menu_links['Private messages'] = makeUrlNS('Special', 'PrivateMessages'); |
|
114 |
||
115 |
$code = $plugins->setHook('userprefs_jbox'); |
|
116 |
foreach ( $code as $cmd ) |
|
117 |
{ |
|
118 |
eval($cmd); |
|
119 |
} |
|
120 |
} |
|
121 |
||
122 |
$plugins->attachHook('session_started', 'userprefs_menu_init();'); |
|
123 |
||
124 |
function page_Special_Preferences() |
|
125 |
{ |
|
126 |
global $db, $session, $paths, $template, $plugins; // Common objects |
|
127 |
||
128 |
// We need a login to continue |
|
129 |
if ( !$session->user_logged_in ) |
|
130 |
redirect(makeUrlNS('Special', 'Login/' . $paths->page), 'Login required', 'You need to be logged in to access this page. Please wait while you are redirected to the login page.'); |
|
131 |
||
132 |
// User ID - later this will be specified on the URL, but hardcoded for now |
|
133 |
$uid = intval($session->user_id); |
|
134 |
||
135 |
// Instanciate the AES encryptor |
|
136 |
$aes = new AESCrypt(AES_BITS, AES_BLOCKSIZE); |
|
137 |
||
138 |
// Basic user info |
|
139 |
$q = $db->sql_query('SELECT username, password, email, real_name, signature, theme, style FROM '.table_prefix.'users WHERE user_id='.$uid.';'); |
|
140 |
if ( !$q ) |
|
141 |
$db->_die(); |
|
142 |
||
143 |
$row = $db->fetchrow(); |
|
144 |
$db->free_result(); |
|
145 |
||
146 |
$section = $paths->getParam(0); |
|
147 |
if ( !$section ) |
|
148 |
{ |
|
149 |
$section = 'Home'; |
|
150 |
} |
|
151 |
||
152 |
$errors = ''; |
|
153 |
||
154 |
switch ( $section ) |
|
155 |
{ |
|
156 |
case 'EmailPassword': |
|
157 |
// Require elevated privileges (well sortof) |
|
158 |
if ( $session->auth_level < USER_LEVEL_CHPREF ) |
|
159 |
{ |
|
160 |
redirect(makeUrlNS('Special', 'Login/' . $paths->fullpage, 'level=' . USER_LEVEL_CHPREF, true), 'Authentication required', 'You need to re-authenticate to access this page.', 0); |
|
161 |
} |
|
162 |
||
163 |
if ( isset($_POST['submit']) ) |
|
164 |
{ |
|
165 |
$email_changed = false; |
|
166 |
// First do the e-mail address |
|
167 |
if ( strlen($_POST['newemail']) > 0 ) |
|
168 |
{ |
|
169 |
switch('foo') // Same reason as in the password code... |
|
170 |
{ |
|
171 |
case 'foo': |
|
172 |
if ( $_POST['newemail'] != $_POST['newemail_conf'] ) |
|
173 |
{ |
|
174 |
$errors .= '<div class="error-box">The e-mail addresses you entered did not match.</div>'; |
|
175 |
break; |
|
176 |
} |
|
177 |
} |
|
178 |
$q = $db->sql_query('SELECT password FROM '.table_prefix.'users WHERE user_id='.$session->user_id.';'); |
|
179 |
if ( !$q ) |
|
180 |
$db->_die(); |
|
181 |
$row = $db->fetchrow(); |
|
182 |
$db->free_result(); |
|
183 |
$old_pass = $aes->decrypt($row['password'], $session->private_key, ENC_HEX); |
|
184 |
||
185 |
$new_email = $_POST['newemail']; |
|
186 |
||
187 |
$result = $session->update_user($session->user_id, false, $old_pass, false, $new_email); |
|
188 |
if ( $result != 'success' ) |
|
189 |
{ |
|
32
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
31
diff
changeset
|
190 |
$message = '<p>The following errors were encountered while saving your e-mail address:</p>'; |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
31
diff
changeset
|
191 |
$message .= '<ul><li>' . implode("</li>\n<li>", $result) . '</li></ul>'; |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
31
diff
changeset
|
192 |
die_friendly('Error updating e-mail address', $message); |
0 | 193 |
} |
194 |
$email_changed = true; |
|
195 |
} |
|
196 |
// Obtain password |
|
197 |
if ( $_POST['use_crypt'] == 'yes' && !empty($_POST['crypt_data']) ) |
|
198 |
{ |
|
199 |
$key = $session->fetch_public_key($_POST['crypt_key']); |
|
200 |
if ( !$key ) |
|
201 |
die('Can\'t lookup key'); |
|
202 |
$key = hexdecode($key); |
|
203 |
$newpass = $aes->decrypt($_POST['crypt_data'], $key, ENC_HEX); |
|
204 |
// At this point we know if we _want_ to change the password... |
|
205 |
||
206 |
// We can't check the password to see if it matches the confirmation |
|
207 |
// because the confirmation was destroyed during the encryption. I figured |
|
208 |
// this wasn't a big deal because if the encryption worked, then either |
|
209 |
// the Javascript validated it or the user hacked the form. In the latter |
|
210 |
// case, if he's smart enough to hack the encryption code, he's probably |
|
211 |
// smart enough to remember his password. |
|
212 |
||
213 |
if ( strlen($newpass) > 0 ) |
|
214 |
{ |
|
215 |
// Perform checks |
|
216 |
if ( strlen($newpass) < 6 ) |
|
133
af0f6ec48de3
Fully implemented password complexity enforcement; added encryption for passwords on registration form; some baby steps taken towards supporting international usernames - this is not working very well, we might need a hackish fix; TODO: implement password strength meter into installer UI and get international usernames 100% working
Dan
parents:
103
diff
changeset
|
217 |
$errors .= '<div class="error-box" style="margin: 0 0 10px 0;">Password must be at least 6 characters. You hacked my script, darn you!</div>'; |
af0f6ec48de3
Fully implemented password complexity enforcement; added encryption for passwords on registration form; some baby steps taken towards supporting international usernames - this is not working very well, we might need a hackish fix; TODO: implement password strength meter into installer UI and get international usernames 100% working
Dan
parents:
103
diff
changeset
|
218 |
if ( getConfig('pw_strength_enable') == '1' ) |
af0f6ec48de3
Fully implemented password complexity enforcement; added encryption for passwords on registration form; some baby steps taken towards supporting international usernames - this is not working very well, we might need a hackish fix; TODO: implement password strength meter into installer UI and get international usernames 100% working
Dan
parents:
103
diff
changeset
|
219 |
{ |
af0f6ec48de3
Fully implemented password complexity enforcement; added encryption for passwords on registration form; some baby steps taken towards supporting international usernames - this is not working very well, we might need a hackish fix; TODO: implement password strength meter into installer UI and get international usernames 100% working
Dan
parents:
103
diff
changeset
|
220 |
$score_inp = password_score($newpass); |
af0f6ec48de3
Fully implemented password complexity enforcement; added encryption for passwords on registration form; some baby steps taken towards supporting international usernames - this is not working very well, we might need a hackish fix; TODO: implement password strength meter into installer UI and get international usernames 100% working
Dan
parents:
103
diff
changeset
|
221 |
$score_min = intval( getConfig('pw_strength_minimum') ); |
af0f6ec48de3
Fully implemented password complexity enforcement; added encryption for passwords on registration form; some baby steps taken towards supporting international usernames - this is not working very well, we might need a hackish fix; TODO: implement password strength meter into installer UI and get international usernames 100% working
Dan
parents:
103
diff
changeset
|
222 |
if ( $score_inp < $score_min ) |
af0f6ec48de3
Fully implemented password complexity enforcement; added encryption for passwords on registration form; some baby steps taken towards supporting international usernames - this is not working very well, we might need a hackish fix; TODO: implement password strength meter into installer UI and get international usernames 100% working
Dan
parents:
103
diff
changeset
|
223 |
$errors .= '<div class="error-box" style="margin: 0 0 10px 0;">Your password did not meet the complexity score requirement for this site. Your password scored '. $score_inp .', while a score of at least '. $score_min .' is needed.</div>'; |
af0f6ec48de3
Fully implemented password complexity enforcement; added encryption for passwords on registration form; some baby steps taken towards supporting international usernames - this is not working very well, we might need a hackish fix; TODO: implement password strength meter into installer UI and get international usernames 100% working
Dan
parents:
103
diff
changeset
|
224 |
} |
0 | 225 |
// Encrypt new password |
32
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
31
diff
changeset
|
226 |
if ( empty($errors) ) |
0 | 227 |
{ |
32
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
31
diff
changeset
|
228 |
$newpass_enc = $aes->encrypt($newpass, $session->private_key, ENC_HEX); |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
31
diff
changeset
|
229 |
// Perform the swap |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
31
diff
changeset
|
230 |
$q = $db->sql_query('UPDATE '.table_prefix.'users SET password=\'' . $newpass_enc . '\' WHERE user_id=' . $session->user_id . ';'); |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
31
diff
changeset
|
231 |
if ( !$q ) |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
31
diff
changeset
|
232 |
$db->_die(); |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
31
diff
changeset
|
233 |
// Log out and back in |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
31
diff
changeset
|
234 |
$username = $session->username; |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
31
diff
changeset
|
235 |
$session->logout(); |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
31
diff
changeset
|
236 |
if ( $email_changed ) |
0 | 237 |
{ |
32
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
31
diff
changeset
|
238 |
if ( getConfig('account_activation') == 'user' ) |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
31
diff
changeset
|
239 |
{ |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
31
diff
changeset
|
240 |
redirect(makeUrl(getConfig('main_page')), 'Profile changed', 'Your password and e-mail address have been changed. Since e-mail activation is required on this site, you will need to re-activate your account to continue. An e-mail has been sent to the new e-mail address with an activation link. You must click that link in order to log in again.', 19); |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
31
diff
changeset
|
241 |
} |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
31
diff
changeset
|
242 |
else if ( getConfig('account_activation') == 'admin' ) |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
31
diff
changeset
|
243 |
{ |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
31
diff
changeset
|
244 |
redirect(makeUrl(getConfig('main_page')), 'Profile changed', 'Your password and e-mail address have been changed. Since administrative activation is requires on this site, a request has been sent to the administrators to activate your account for you. You will not be able to use your account until it is activated by an administrator.', 19); |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
31
diff
changeset
|
245 |
} |
0 | 246 |
} |
32
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
31
diff
changeset
|
247 |
$session->login_without_crypto($session->username, $newpass); |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
31
diff
changeset
|
248 |
redirect(makeUrlNS('Special', 'Preferences'), 'Password changed', 'Your password has been changed, and you will now be redirected back to the user control panel.', 4); |
0 | 249 |
} |
250 |
} |
|
251 |
} |
|
252 |
else |
|
253 |
{ |
|
254 |
switch('foo') // allow breaking out of our section...i can't wait until PHP6 (goto support!) |
|
255 |
{ |
|
256 |
case 'foo': |
|
257 |
$pass = $_POST['newpass']; |
|
258 |
if ( $pass != $_POST['newpass_conf'] ) |
|
259 |
{ |
|
260 |
$errors .= '<div class="error-box">The passwords you entered did not match</div>'; |
|
261 |
break; |
|
262 |
} |
|
263 |
||
264 |
if ( $email_changed ) |
|
265 |
{ |
|
266 |
if ( getConfig('account_activation') == 'user' ) |
|
267 |
{ |
|
268 |
redirect(makeUrl(getConfig('main_page')), 'Profile changed', 'Your e-mail address has been changed. Since e-mail activation is required on this site, you will need to re-activate your account to continue. An e-mail has been sent to the new e-mail address with an activation link. You must click that link in order to log in again.', 19); |
|
269 |
} |
|
270 |
else if ( getConfig('account_activation') == 'admin' ) |
|
271 |
{ |
|
272 |
redirect(makeUrl(getConfig('main_page')), 'Profile changed', 'Your e-mail address has been changed. Since administrative activation is requires on this site, a request has been sent to the administrators to activate your account for you. You will not be able to use your account until it is activated by an administrator.', 19); |
|
273 |
} |
|
274 |
else |
|
275 |
{ |
|
276 |
redirect(makeUrlNS('Special', 'Preferences'), 'Password changed', 'Your e-mail address has been changed, and you will now be redirected back to the user control panel.', 4); |
|
277 |
} |
|
278 |
} |
|
279 |
||
280 |
return; |
|
281 |
} |
|
282 |
} |
|
283 |
} |
|
284 |
$template->tpl_strings['PAGE_NAME'] = 'Change E-mail Address or Password'; |
|
285 |
break; |
|
286 |
case 'Signature': |
|
287 |
$template->tpl_strings['PAGE_NAME'] = 'Editing signature'; |
|
288 |
break; |
|
289 |
case 'Profile': |
|
290 |
$template->tpl_strings['PAGE_NAME'] = 'Editing public profile'; |
|
291 |
break; |
|
292 |
} |
|
293 |
||
294 |
$template->header(); |
|
295 |
||
296 |
// Output the menu |
|
297 |
// This is not templatized because it conforms to the jBox menu standard. |
|
298 |
||
299 |
userprefs_show_menu(); |
|
300 |
||
301 |
switch ( $section ) |
|
302 |
{ |
|
303 |
case 'Home': |
|
304 |
global $email; |
|
175
1465f48faba0
AJAX login box is now used in userprefs panel; Spry shake effect and general UX on auth fail is smoother now; added ajaxLoginNavTo() JS function
Dan
parents:
140
diff
changeset
|
305 |
$userpage_id = $paths->nslist['User'] . sanitize_page_id($session->username); |
1465f48faba0
AJAX login box is now used in userprefs panel; Spry shake effect and general UX on auth fail is smoother now; added ajaxLoginNavTo() JS function
Dan
parents:
140
diff
changeset
|
306 |
$userpage_exists = ( isPage($userpage_id) ) ? '' : ' class="wikilink-nonexistent"'; |
1465f48faba0
AJAX login box is now used in userprefs panel; Spry shake effect and general UX on auth fail is smoother now; added ajaxLoginNavTo() JS function
Dan
parents:
140
diff
changeset
|
307 |
$user_page = '<a href="' . makeUrlNS('User', sanitize_page_id($session->username)) . '"' . $userpage_exists . '>user page</a> <sup>(<a href="' . makeUrlNS('User', str_replace(' ', '_', $session->username)) . '#do:comments">comments</a>)</sup>'; |
0 | 308 |
$site_admin = $email->encryptEmail(getConfig('contact_email'), '', '', 'administrator'); |
175
1465f48faba0
AJAX login box is now used in userprefs panel; Spry shake effect and general UX on auth fail is smoother now; added ajaxLoginNavTo() JS function
Dan
parents:
140
diff
changeset
|
309 |
$make_one_now = '<a href="' . makeUrlNS('User', sanitize_page_id($session->username)) . '">make one now</a>'; |
0 | 310 |
echo "<h3 style='margin-top: 0;'>$session->username, welcome to your control panel</h3>"; |
311 |
echo "<p>Here you can make changes to your profile, view statistics on yourself on this site, and set your preferences.</p> |
|
175
1465f48faba0
AJAX login box is now used in userprefs panel; Spry shake effect and general UX on auth fail is smoother now; added ajaxLoginNavTo() JS function
Dan
parents:
140
diff
changeset
|
312 |
<p>Your $user_page is your free writing space. You can use it to tell the other members of this site a little bit about yourself. If you haven't already made a user page, why not $make_one_now?</p> |
0 | 313 |
<p>Use the menu at the top to navigate around. If you have any questions, you may contact the $site_admin."; |
314 |
break; |
|
315 |
case 'EmailPassword': |
|
316 |
||
133
af0f6ec48de3
Fully implemented password complexity enforcement; added encryption for passwords on registration form; some baby steps taken towards supporting international usernames - this is not working very well, we might need a hackish fix; TODO: implement password strength meter into installer UI and get international usernames 100% working
Dan
parents:
103
diff
changeset
|
317 |
$errors = trim($errors); |
af0f6ec48de3
Fully implemented password complexity enforcement; added encryption for passwords on registration form; some baby steps taken towards supporting international usernames - this is not working very well, we might need a hackish fix; TODO: implement password strength meter into installer UI and get international usernames 100% working
Dan
parents:
103
diff
changeset
|
318 |
if ( !empty($errors) ) |
af0f6ec48de3
Fully implemented password complexity enforcement; added encryption for passwords on registration form; some baby steps taken towards supporting international usernames - this is not working very well, we might need a hackish fix; TODO: implement password strength meter into installer UI and get international usernames 100% working
Dan
parents:
103
diff
changeset
|
319 |
{ |
af0f6ec48de3
Fully implemented password complexity enforcement; added encryption for passwords on registration form; some baby steps taken towards supporting international usernames - this is not working very well, we might need a hackish fix; TODO: implement password strength meter into installer UI and get international usernames 100% working
Dan
parents:
103
diff
changeset
|
320 |
echo $errors; |
af0f6ec48de3
Fully implemented password complexity enforcement; added encryption for passwords on registration form; some baby steps taken towards supporting international usernames - this is not working very well, we might need a hackish fix; TODO: implement password strength meter into installer UI and get international usernames 100% working
Dan
parents:
103
diff
changeset
|
321 |
} |
af0f6ec48de3
Fully implemented password complexity enforcement; added encryption for passwords on registration form; some baby steps taken towards supporting international usernames - this is not working very well, we might need a hackish fix; TODO: implement password strength meter into installer UI and get international usernames 100% working
Dan
parents:
103
diff
changeset
|
322 |
|
0 | 323 |
echo '<form action="' . makeUrlNS('Special', 'Preferences/EmailPassword') . '" method="post" onsubmit="return runEncryption();" name="empwform" >'; |
324 |
||
325 |
// Password change form |
|
326 |
$pubkey = $session->rijndael_genkey(); |
|
327 |
||
328 |
echo '<fieldset> |
|
329 |
<legend>Change password</legend> |
|
330 |
Type a new password:<br /> |
|
133
af0f6ec48de3
Fully implemented password complexity enforcement; added encryption for passwords on registration form; some baby steps taken towards supporting international usernames - this is not working very well, we might need a hackish fix; TODO: implement password strength meter into installer UI and get international usernames 100% working
Dan
parents:
103
diff
changeset
|
331 |
<input type="password" name="newpass" size="30" tabindex="1" ' . ( getConfig('pw_strength_enable') == '1' ? 'onkeyup="password_score_field(this);" ' : '' ) . '/>' . ( getConfig('pw_strength_enable') == '1' ? '<span class="password-checker" style="font-weight: bold; color: #aaaaaa;"> Loading...</span>' : '' ) . ' |
0 | 332 |
<br /> |
333 |
<br /> |
|
334 |
Type the password again to confirm:<br /> |
|
133
af0f6ec48de3
Fully implemented password complexity enforcement; added encryption for passwords on registration form; some baby steps taken towards supporting international usernames - this is not working very well, we might need a hackish fix; TODO: implement password strength meter into installer UI and get international usernames 100% working
Dan
parents:
103
diff
changeset
|
335 |
<input type="password" name="newpass_conf" size="30" tabindex="2" /> |
af0f6ec48de3
Fully implemented password complexity enforcement; added encryption for passwords on registration form; some baby steps taken towards supporting international usernames - this is not working very well, we might need a hackish fix; TODO: implement password strength meter into installer UI and get international usernames 100% working
Dan
parents:
103
diff
changeset
|
336 |
' . ( getConfig('pw_strength_enable') == '1' ? '<br /><br /><div id="pwmeter"></div> |
af0f6ec48de3
Fully implemented password complexity enforcement; added encryption for passwords on registration form; some baby steps taken towards supporting international usernames - this is not working very well, we might need a hackish fix; TODO: implement password strength meter into installer UI and get international usernames 100% working
Dan
parents:
103
diff
changeset
|
337 |
<small>Your password needs to score at least <b>'.getConfig('pw_strength_minimum').'</b> in order to be accepted.</small>' : '' ) . ' |
0 | 338 |
</fieldset><br /> |
339 |
<fieldset> |
|
340 |
<legend>Change e-mail address</legend> |
|
341 |
New e-mail address:<br /> |
|
133
af0f6ec48de3
Fully implemented password complexity enforcement; added encryption for passwords on registration form; some baby steps taken towards supporting international usernames - this is not working very well, we might need a hackish fix; TODO: implement password strength meter into installer UI and get international usernames 100% working
Dan
parents:
103
diff
changeset
|
342 |
<input type="text" value="' . ( isset($_POST['newemail']) ? htmlspecialchars($_POST['newemail']) : '' ) . '" name="newemail" size="30" tabindex="3" /> |
0 | 343 |
<br /> |
344 |
<br /> |
|
345 |
Confirm e-mail address:<br /> |
|
133
af0f6ec48de3
Fully implemented password complexity enforcement; added encryption for passwords on registration form; some baby steps taken towards supporting international usernames - this is not working very well, we might need a hackish fix; TODO: implement password strength meter into installer UI and get international usernames 100% working
Dan
parents:
103
diff
changeset
|
346 |
<input type="text" value="' . ( isset($_POST['newemail']) ? htmlspecialchars($_POST['newemail']) : '' ) . '" name="newemail_conf" size="30" tabindex="4" /> |
0 | 347 |
</fieldset> |
348 |
<input type="hidden" name="use_crypt" value="no" /> |
|
349 |
<input type="hidden" name="crypt_key" value="' . $pubkey . '" /> |
|
350 |
<input type="hidden" name="crypt_data" value="" /> |
|
351 |
<br /> |
|
352 |
<div style="text-align: right;"><input type="submit" name="submit" value="Save Changes" tabindex="5" /></div>'; |
|
353 |
||
354 |
echo '</form>'; |
|
355 |
||
356 |
// ENCRYPTION CODE |
|
357 |
?> |
|
358 |
<script type="text/javascript"> |
|
133
af0f6ec48de3
Fully implemented password complexity enforcement; added encryption for passwords on registration form; some baby steps taken towards supporting international usernames - this is not working very well, we might need a hackish fix; TODO: implement password strength meter into installer UI and get international usernames 100% working
Dan
parents:
103
diff
changeset
|
359 |
<?php if ( getConfig('pw_strength_enable') == '1' ): ?> |
af0f6ec48de3
Fully implemented password complexity enforcement; added encryption for passwords on registration form; some baby steps taken towards supporting international usernames - this is not working very well, we might need a hackish fix; TODO: implement password strength meter into installer UI and get international usernames 100% working
Dan
parents:
103
diff
changeset
|
360 |
password_score_field(document.forms.empwform.newpass); |
af0f6ec48de3
Fully implemented password complexity enforcement; added encryption for passwords on registration form; some baby steps taken towards supporting international usernames - this is not working very well, we might need a hackish fix; TODO: implement password strength meter into installer UI and get international usernames 100% working
Dan
parents:
103
diff
changeset
|
361 |
<?php endif; ?> |
0 | 362 |
disableJSONExts(); |
363 |
str = ''; |
|
364 |
for(i=0;i<keySizeInBits/4;i++) str+='0'; |
|
365 |
var key = hexToByteArray(str); |
|
366 |
var pt = hexToByteArray(str); |
|
367 |
var ct = rijndaelEncrypt(pt, key, "ECB"); |
|
368 |
var ct = byteArrayToHex(ct); |
|
369 |
switch(keySizeInBits) |
|
370 |
{ |
|
371 |
case 128: |
|
372 |
v = '66e94bd4ef8a2c3b884cfa59ca342b2e'; |
|
373 |
break; |
|
374 |
case 192: |
|
375 |
v = 'aae06992acbf52a3e8f4a96ec9300bd7aae06992acbf52a3e8f4a96ec9300bd7'; |
|
376 |
break; |
|
377 |
case 256: |
|
378 |
v = 'dc95c078a2408989ad48a21492842087dc95c078a2408989ad48a21492842087'; |
|
379 |
break; |
|
380 |
} |
|
381 |
var aes_testpassed = ( ct == v && md5_vm_test() ); |
|
382 |
function runEncryption() |
|
383 |
{ |
|
384 |
var frm = document.forms.empwform; |
|
385 |
if ( frm.newpass.value.length < 1 ) |
|
386 |
return true; |
|
387 |
if(aes_testpassed) |
|
388 |
{ |
|
389 |
frm.use_crypt.value = 'yes'; |
|
390 |
var cryptkey = frm.crypt_key.value; |
|
391 |
frm.crypt_key.value = hex_md5(cryptkey); |
|
392 |
cryptkey = hexToByteArray(cryptkey); |
|
393 |
if(!cryptkey || ( ( typeof cryptkey == 'string' || typeof cryptkey == 'object' ) ) && cryptkey.length != keySizeInBits / 8 ) |
|
394 |
{ |
|
395 |
frm.submit.disabled = true; |
|
396 |
len = ( typeof cryptkey == 'string' || typeof cryptkey == 'object' ) ? '\nLen: '+cryptkey.length : ''; |
|
397 |
alert('The key is messed up\nType: '+typeof(cryptkey)+len); |
|
398 |
} |
|
399 |
} |
|
400 |
pass1 = frm.newpass.value; |
|
401 |
pass2 = frm.newpass_conf.value; |
|
402 |
if ( pass1 != pass2 ) |
|
403 |
{ |
|
404 |
alert('The passwords you entered do not match.'); |
|
405 |
return false; |
|
406 |
} |
|
407 |
if ( pass1.length < 6 && pass1.length > 0 ) |
|
408 |
{ |
|
409 |
alert('The new password must be 6 characters or greater in length.'); |
|
410 |
return false; |
|
411 |
} |
|
412 |
if(aes_testpassed) |
|
413 |
{ |
|
414 |
pass = frm.newpass.value; |
|
415 |
pass = stringToByteArray(pass); |
|
416 |
cryptstring = rijndaelEncrypt(pass, cryptkey, 'ECB'); |
|
417 |
if(!cryptstring) |
|
418 |
{ |
|
419 |
return false; |
|
420 |
} |
|
421 |
cryptstring = byteArrayToHex(cryptstring); |
|
422 |
frm.crypt_data.value = cryptstring; |
|
423 |
frm.newpass.value = ""; |
|
424 |
frm.newpass_conf.value = ""; |
|
425 |
} |
|
426 |
return true; |
|
427 |
} |
|
428 |
</script> |
|
429 |
<?php |
|
430 |
||
431 |
break; |
|
432 |
case 'Signature': |
|
433 |
if ( isset($_POST['new_sig']) ) |
|
434 |
{ |
|
435 |
$sig = $_POST['new_sig']; |
|
436 |
$sig = RenderMan::preprocess_text($sig, true, false); |
|
437 |
$sql_sig = $db->escape($sig); |
|
438 |
$q = $db->sql_query('UPDATE '.table_prefix.'users SET signature=\'' . $sql_sig . '\' WHERE user_id=' . $session->user_id . ';'); |
|
439 |
if ( !$q ) |
|
440 |
$db->_die(); |
|
441 |
$session->signature = $sig; |
|
442 |
echo '<div class="info-box" style="margin: 0 0 10px 0;">Your signature has been saved.</div>'; |
|
443 |
} |
|
444 |
echo '<form action="'.makeUrl($paths->fullpage).'" method="post">'; |
|
74
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
36
diff
changeset
|
445 |
echo $template->tinymce_textarea('new_sig', htmlspecialchars($session->signature)); |
0 | 446 |
echo '<input type="submit" value="Save signature" />'; |
447 |
echo '</form>'; |
|
448 |
break; |
|
449 |
case "Profile": |
|
450 |
if ( isset($_POST['submit']) ) |
|
451 |
{ |
|
452 |
$real_name = htmlspecialchars($_POST['real_name']); |
|
453 |
$real_name = $db->escape($real_name); |
|
31
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
454 |
|
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
455 |
$imaddr_aim = htmlspecialchars($_POST['imaddr_aim']); |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
456 |
$imaddr_aim = $db->escape($imaddr_aim); |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
457 |
|
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
458 |
$imaddr_msn = htmlspecialchars($_POST['imaddr_msn']); |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
459 |
$imaddr_msn = $db->escape($imaddr_msn); |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
460 |
|
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
461 |
$imaddr_yahoo = htmlspecialchars($_POST['imaddr_yahoo']); |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
462 |
$imaddr_yahoo = $db->escape($imaddr_yahoo); |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
463 |
|
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
464 |
$imaddr_xmpp = htmlspecialchars($_POST['imaddr_xmpp']); |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
465 |
$imaddr_xmpp = $db->escape($imaddr_xmpp); |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
466 |
|
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
467 |
$homepage = htmlspecialchars($_POST['homepage']); |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
468 |
$homepage = $db->escape($homepage); |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
469 |
|
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
470 |
$location = htmlspecialchars($_POST['location']); |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
471 |
$location = $db->escape($location); |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
472 |
|
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
473 |
$occupation = htmlspecialchars($_POST['occupation']); |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
474 |
$occupation = $db->escape($occupation); |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
475 |
|
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
476 |
$hobbies = htmlspecialchars($_POST['hobbies']); |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
477 |
$hobbies = $db->escape($hobbies); |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
478 |
|
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
479 |
$email_public = ( isset($_POST['email_public']) ) ? '1' : '0'; |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
480 |
|
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
481 |
$session->real_name = $real_name; |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
482 |
|
32
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
31
diff
changeset
|
483 |
if ( !preg_match('/@([a-z0-9-]+)(\.([a-z0-9-\.]+))?/', $imaddr_msn) && !empty($imaddr_msn) ) |
31
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
484 |
{ |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
485 |
$imaddr_msn = "$imaddr_msn@hotmail.com"; |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
486 |
} |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
487 |
|
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
488 |
if ( substr($homepage, 0, 7) != 'http://' ) |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
489 |
{ |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
490 |
$homepage = "http://$homepage"; |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
491 |
} |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
492 |
|
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
493 |
if ( !preg_match('/^http:\/\/([a-z0-9-.]+)([A-z0-9@#\$%\&:;<>,\.\?=\+\(\)\[\]_\/\\\\]*?)$/i', $homepage) ) |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
494 |
{ |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
495 |
$homepage = ''; |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
496 |
} |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
497 |
|
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
498 |
$session->user_extra['user_aim'] = $imaddr_aim; |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
499 |
$session->user_extra['user_msn'] = $imaddr_msn; |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
500 |
$session->user_extra['user_xmpp'] = $imaddr_xmpp; |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
501 |
$session->user_extra['user_yahoo'] = $imaddr_yahoo; |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
502 |
$session->user_extra['user_homepage'] = $homepage; |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
503 |
$session->user_extra['user_location'] = $location; |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
504 |
$session->user_extra['user_job'] = $occupation; |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
505 |
$session->user_extra['user_hobbies'] = $hobbies; |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
506 |
$session->user_extra['email_public'] = intval($email_public); |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
507 |
|
0 | 508 |
$q = $db->sql_query('UPDATE '.table_prefix."users SET real_name='$real_name' WHERE user_id=$session->user_id;"); |
509 |
if ( !$q ) |
|
510 |
$db->_die(); |
|
511 |
||
31
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
512 |
$q = $db->sql_query('UPDATE '.table_prefix."users_extra SET user_aim='$imaddr_aim',user_yahoo='$imaddr_yahoo',user_msn='$imaddr_msn', |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
513 |
user_xmpp='$imaddr_xmpp',user_homepage='$homepage',user_location='$location',user_job='$occupation', |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
514 |
user_hobbies='$hobbies',email_public=$email_public |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
515 |
WHERE user_id=$session->user_id;"); |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
516 |
|
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
517 |
if ( !$q ) |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
518 |
$db->_die(); |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
519 |
|
0 | 520 |
echo '<div class="info-box" style="margin: 0 0 10px 0;">Your profile has been updated.</div>'; |
521 |
} |
|
522 |
echo '<form action="'.makeUrl($paths->fullpage).'" method="post">'; |
|
523 |
?> |
|
524 |
<div class="tblholder"> |
|
525 |
<table border="0" cellspacing="1" cellpadding="4"> |
|
526 |
<tr> |
|
527 |
<th colspan="2">Your public profile</th> |
|
528 |
</tr> |
|
529 |
<tr> |
|
530 |
<td colspan="2" class="row3">Please note that all of the information you enter here will be <b>publicly viewable.</b> All of the fields on this page are optional and may be left blank if you so desire.</td> |
|
531 |
</tr> |
|
532 |
<tr> |
|
533 |
<td class="row2" style="width: 50%;">Real name:</td> |
|
534 |
<td class="row1" style="width: 50%;"><input type="text" name="real_name" value="<?php echo $session->real_name; ?>" size="30" /></td> |
|
535 |
</tr> |
|
536 |
<tr> |
|
537 |
<td class="row2">Change theme:</td> |
|
538 |
<td class="row1">If you don't like the look of the site, need a visual break, or are just curious, we might have some different themes for you to try out! <a href="<?php echo makeUrlNS('Special', 'ChangeStyle/' . $paths->page); ?>" onclick="ajaxChangeStyle(); return false;">Change my theme...</a></td> |
|
539 |
</tr> |
|
540 |
<tr> |
|
31
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
541 |
<th class="subhead" colspan="2"> |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
542 |
Instant messenger contact information |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
543 |
</th> |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
544 |
<tr> |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
545 |
<td class="row2" style="width: 50%;">AIM handle:</td> |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
546 |
<td class="row1" style="width: 50%;"><input type="text" name="imaddr_aim" value="<?php echo $session->user_extra['user_aim']; ?>" size="30" /></td> |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
547 |
</tr> |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
548 |
<tr> |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
549 |
<td class="row2" style="width: 50%;"><acronym title="Windows™ Live Messenger">WLM</acronym> handle:<br /><small>If you don't specify the domain (@whatever.com), "@hotmail.com" will be assumed.</small></td> |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
550 |
<td class="row1" style="width: 50%;"><input type="text" name="imaddr_msn" value="<?php echo $session->user_extra['user_msn']; ?>" size="30" /></td> |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
551 |
</tr> |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
552 |
<tr> |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
553 |
<td class="row2" style="width: 50%;">Yahoo! IM handle:</td> |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
554 |
<td class="row1" style="width: 50%;"><input type="text" name="imaddr_yahoo" value="<?php echo $session->user_extra['user_yahoo']; ?>" size="30" /></td> |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
555 |
</tr> |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
556 |
<tr> |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
557 |
<td class="row2" style="width: 50%;">Jabber/XMPP handle:</td> |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
558 |
<td class="row1" style="width: 50%;"><input type="text" name="imaddr_xmpp" value="<?php echo $session->user_extra['user_xmpp']; ?>" size="30" /></td> |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
559 |
</tr> |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
560 |
<tr> |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
561 |
<th class="subhead" colspan="2"> |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
562 |
Extra contact information |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
563 |
</th> |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
564 |
</tr> |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
565 |
<tr> |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
566 |
<td class="row2" style="width: 50%;">Your homepage:<br /><small>Please remember the http:// prefix.</small></td> |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
567 |
<td class="row1" style="width: 50%;"><input type="text" name="homepage" value="<?php echo $session->user_extra['user_homepage']; ?>" size="30" /></td> |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
568 |
</tr> |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
569 |
<tr> |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
570 |
<td class="row2" style="width: 50%;">Your location:</td> |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
571 |
<td class="row1" style="width: 50%;"><input type="text" name="location" value="<?php echo $session->user_extra['user_location']; ?>" size="30" /></td> |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
572 |
</tr> |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
573 |
<tr> |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
574 |
<td class="row2" style="width: 50%;">Your job:</td> |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
575 |
<td class="row1" style="width: 50%;"><input type="text" name="occupation" value="<?php echo $session->user_extra['user_job']; ?>" size="30" /></td> |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
576 |
</tr> |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
577 |
<tr> |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
578 |
<td class="row2" style="width: 50%;">Your hobbies:</td> |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
579 |
<td class="row1" style="width: 50%;"><input type="text" name="hobbies" value="<?php echo $session->user_extra['user_hobbies']; ?>" size="30" /></td> |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
580 |
</tr> |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
581 |
<tr> |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
0
diff
changeset
|
582 |
<td class="row2" style="width: 50%;"><label for="chk_email_public">E-mail address is public</label><br /><small>If this is checked, your e-mail address will be displayed on your user page. To protect your address from spambots, your e-mail address will be encrypted.</small></td> |
140
40f7fa5fd061
Revamped the administrator's user CP, big time. The admin module now uses a smart form and enables all profile fields, including users_extra, to be changed. Passwords are encrypted when sent. The whole CP has been split off into a different file to accomodate the large amount of code.
Dan
parents:
133
diff
changeset
|
583 |
<td class="row1" style="width: 50%;"><input type="checkbox" id="chk_email_public" name="email_public" <?php if ($session->user_extra['email_public'] == 1) echo 'checked="checked"'; ?> size="30" /></td> |
0 | 584 |
</tr> |
585 |
<tr> |
|
586 |
<th class="subhead" colspan="2"> |
|
587 |
<input type="submit" name="submit" value="Save profile" /> |
|
588 |
</th> |
|
589 |
</tr> |
|
590 |
</table> |
|
591 |
</div> |
|
592 |
<?php |
|
593 |
echo '</form>'; |
|
594 |
break; |
|
595 |
default: |
|
596 |
$good = false; |
|
597 |
$code = $plugins->setHook('userprefs_body'); |
|
598 |
foreach ( $code as $cmd ) |
|
599 |
{ |
|
600 |
if ( eval($code) ) |
|
601 |
$good = true; |
|
602 |
} |
|
603 |
if ( !$good ) |
|
604 |
{ |
|
605 |
echo '<h3>Invalid module</h3> |
|
606 |
<p>Userprefs module "'.$section.'" not found.</p>'; |
|
607 |
} |
|
608 |
break; |
|
609 |
} |
|
610 |
||
611 |
$template->footer(); |
|
612 |
} |
|
613 |
||
614 |
?> |