65 |
65 |
66 function userprefs_menu_html() |
66 function userprefs_menu_html() |
67 { |
67 { |
68 global $userprefs_menu; |
68 global $userprefs_menu; |
69 global $userprefs_menu_links; |
69 global $userprefs_menu_links; |
|
70 global $lang; |
70 |
71 |
71 $html = ''; |
72 $html = ''; |
72 $quot = '"'; |
73 $quot = '"'; |
73 |
74 |
74 foreach ( $userprefs_menu as $section => $buttons ) |
75 foreach ( $userprefs_menu as $section => $buttons ) |
75 { |
76 { |
76 $html .= ( isset($userprefs_menu_links[$section]) ) ? "<a href={$quot}{$userprefs_menu_links[$section]}{$quot}>{$section}</a>\n " : "<a>{$section}</a>\n "; |
77 $section_name = $section; |
|
78 if ( preg_match('/^[a-z]+_[a-z_]+$/', $section) ) |
|
79 { |
|
80 $section_name = $lang->get($section_name); |
|
81 } |
|
82 $html .= ( isset($userprefs_menu_links[$section]) ) ? "<a href={$quot}{$userprefs_menu_links[$section]}{$quot}>{$section_name}</a>\n " : "<a>{$section_name}</a>\n "; |
77 $html .= "<ul>\n "; |
83 $html .= "<ul>\n "; |
78 foreach ( $buttons as $button ) |
84 foreach ( $buttons as $button ) |
79 { |
85 { |
80 $html .= " <li><a href={$quot}{$button['link']}{$quot}>{$button['text']}</a></li>\n "; |
86 $buttontext = $button['text']; |
|
87 if ( preg_match('/^[a-z]+_[a-z_]+$/', $buttontext) ) |
|
88 { |
|
89 $buttontext = $lang->get($buttontext); |
|
90 } |
|
91 $html .= " <li><a href={$quot}{$button['link']}{$quot}>{$buttontext}</a></li>\n "; |
81 } |
92 } |
82 $html .= "</ul>\n "; |
93 $html .= "</ul>\n "; |
83 } |
94 } |
84 |
95 |
85 return $html; |
96 return $html; |
98 function userprefs_menu_init() |
109 function userprefs_menu_init() |
99 { |
110 { |
100 global $db, $session, $paths, $template, $plugins; // Common objects |
111 global $db, $session, $paths, $template, $plugins; // Common objects |
101 global $userprefs_menu_links; |
112 global $userprefs_menu_links; |
102 |
113 |
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;'); |
114 userprefs_menu_add('usercp_sec_profile', 'usercp_sec_profile_emailpassword', makeUrlNS('Special', 'Preferences/EmailPassword') . '" onclick="ajaxLoginNavTo(\'Special\', \'Preferences/EmailPassword\', '.USER_LEVEL_CHPREF.'); return false;'); |
104 userprefs_menu_add('Profile/membership', 'Edit signature', makeUrlNS('Special', 'Preferences/Signature')); |
115 userprefs_menu_add('usercp_sec_profile', 'usercp_sec_profile_signature', makeUrlNS('Special', 'Preferences/Signature')); |
105 userprefs_menu_add('Profile/membership', 'Edit public profile', makeUrlNS('Special', 'Preferences/Profile')); |
116 userprefs_menu_add('usercp_sec_profile', 'usercp_sec_profile_publicinfo', makeUrlNS('Special', 'Preferences/Profile')); |
106 userprefs_menu_add('Profile/membership', 'Group memberships', makeUrlNS('Special', 'Usergroups')); |
117 userprefs_menu_add('usercp_sec_profile', 'usercp_sec_profile_usergroups', makeUrlNS('Special', 'Usergroups')); |
107 if ( getConfig('avatar_enable') == '1' ) |
118 if ( getConfig('avatar_enable') == '1' ) |
108 { |
119 { |
109 userprefs_menu_add('Profile/membership', 'Avatar settings', makeUrlNS('Special', 'Preferences/Avatar')); |
120 userprefs_menu_add('usercp_sec_profile', 'usercp_sec_profile_avatar', makeUrlNS('Special', 'Preferences/Avatar')); |
110 } |
121 } |
111 userprefs_menu_add('Private messages', 'Inbox', makeUrlNS('Special', 'PrivateMessages/Folder/Inbox')); |
122 userprefs_menu_add('usercp_sec_pm', 'usercp_sec_pm_inbox', makeUrlNS('Special', 'PrivateMessages/Folder/Inbox')); |
112 userprefs_menu_add('Private messages', 'Outbox', makeUrlNS('Special', 'PrivateMessages/Folder/Outbox')); |
123 userprefs_menu_add('usercp_sec_pm', 'usercp_sec_pm_outbox', makeUrlNS('Special', 'PrivateMessages/Folder/Outbox')); |
113 userprefs_menu_add('Private messages', 'Sent items', makeUrlNS('Special', 'PrivateMessages/Folder/Sent')); |
124 userprefs_menu_add('usercp_sec_pm', 'usercp_sec_pm_sent', makeUrlNS('Special', 'PrivateMessages/Folder/Sent')); |
114 userprefs_menu_add('Private messages', 'Drafts', makeUrlNS('Special', 'PrivateMessages/Folder/Drafts')); |
125 userprefs_menu_add('usercp_sec_pm', 'usercp_sec_pm_drafts', makeUrlNS('Special', 'PrivateMessages/Folder/Drafts')); |
115 userprefs_menu_add('Private messages', 'Archive', makeUrlNS('Special', 'PrivateMessages/Folder/Archive')); |
126 userprefs_menu_add('usercp_sec_pm', 'usercp_sec_pm_archive', makeUrlNS('Special', 'PrivateMessages/Folder/Archive')); |
|
127 |
116 /* |
128 /* |
|
129 // Reserved for Enano's Next Big Innovation.(TM) |
117 userprefs_menu_add('Private messages', 'Inbox', makeUrlNS('Special', 'Private_Messages#folder:inbox')); |
130 userprefs_menu_add('Private messages', 'Inbox', makeUrlNS('Special', 'Private_Messages#folder:inbox')); |
118 userprefs_menu_add('Private messages', 'Starred', makeUrlNS('Special', 'Private_Messages#folder:starred')); |
131 userprefs_menu_add('Private messages', 'Starred', makeUrlNS('Special', 'Private_Messages#folder:starred')); |
119 userprefs_menu_add('Private messages', 'Sent items', makeUrlNS('Special', 'Private_Messages#folder:sent')); |
132 userprefs_menu_add('Private messages', 'Sent items', makeUrlNS('Special', 'Private_Messages#folder:sent')); |
120 userprefs_menu_add('Private messages', 'Drafts', makeUrlNS('Special', 'Private_Messages#folder:drafts')); |
133 userprefs_menu_add('Private messages', 'Drafts', makeUrlNS('Special', 'Private_Messages#folder:drafts')); |
121 userprefs_menu_add('Private messages', 'Archive', makeUrlNS('Special', 'Private_Messages#folder:archive')); |
134 userprefs_menu_add('Private messages', 'Archive', makeUrlNS('Special', 'Private_Messages#folder:archive')); |
199 $new_email = $_POST['newemail']; |
212 $new_email = $_POST['newemail']; |
200 |
213 |
201 $result = $session->update_user($session->user_id, false, $old_pass, false, $new_email); |
214 $result = $session->update_user($session->user_id, false, $old_pass, false, $new_email); |
202 if ( $result != 'success' ) |
215 if ( $result != 'success' ) |
203 { |
216 { |
204 $message = '<p>The following errors were encountered while saving your e-mail address:</p>'; |
217 $message = '<p>' . $lang->get('usercp_emailpassword_err_list') . '</p>'; |
205 $message .= '<ul><li>' . implode("</li>\n<li>", $result) . '</li></ul>'; |
218 $message .= '<ul><li>' . implode("</li>\n<li>", $result) . '</li></ul>'; |
206 die_friendly('Error updating e-mail address', $message); |
219 die_friendly($lang->get('usercp_emailpassword_err_title'), $message); |
207 } |
220 } |
208 $email_changed = true; |
221 $email_changed = true; |
209 } |
222 } |
210 // Obtain password |
223 // Obtain password |
211 if ( $_POST['use_crypt'] == 'yes' && !empty($_POST['crypt_data']) ) |
224 if ( $_POST['use_crypt'] == 'yes' && !empty($_POST['crypt_data']) ) |
225 // smart enough to remember his password. |
238 // smart enough to remember his password. |
226 |
239 |
227 if ( strlen($newpass) > 0 ) |
240 if ( strlen($newpass) > 0 ) |
228 { |
241 { |
229 if ( defined('ENANO_DEMO_MODE') ) |
242 if ( defined('ENANO_DEMO_MODE') ) |
230 $errors .= '<div class="error-box" style="margin: 0 0 10px 0;">You can\'t change your password in demo mode.</div>'; |
243 $errors .= '<div class="error-box" style="margin: 0 0 10px 0;">' . $lang->get('usercp_emailpassword_err_demo') . '</div>'; |
231 // Perform checks |
244 // Perform checks |
232 if ( strlen($newpass) < 6 ) |
245 if ( strlen($newpass) < 6 ) |
233 $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>'; |
246 $errors .= '<div class="error-box" style="margin: 0 0 10px 0;">' . $lang->get('usercp_emailpassword_err_password_too_short') . '</div>'; |
234 if ( getConfig('pw_strength_enable') == '1' ) |
247 if ( getConfig('pw_strength_enable') == '1' ) |
235 { |
248 { |
236 $score_inp = password_score($newpass); |
249 $score_inp = password_score($newpass); |
237 $score_min = intval( getConfig('pw_strength_minimum') ); |
|
238 if ( $score_inp < $score_min ) |
250 if ( $score_inp < $score_min ) |
239 $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>'; |
251 $errors .= '<div class="error-box" style="margin: 0 0 10px 0;">' . $lang->get('usercp_emailpassword_err_password_too_weak', array('score' => $score_inp)) . '</div>'; |
240 } |
252 } |
241 // Encrypt new password |
253 // Encrypt new password |
242 if ( empty($errors) ) |
254 if ( empty($errors) ) |
243 { |
255 { |
244 $newpass_enc = $aes->encrypt($newpass, $session->private_key, ENC_HEX); |
256 $newpass_enc = $aes->encrypt($newpass, $session->private_key, ENC_HEX); |
251 $session->logout(); |
263 $session->logout(); |
252 if ( $email_changed ) |
264 if ( $email_changed ) |
253 { |
265 { |
254 if ( getConfig('account_activation') == 'user' ) |
266 if ( getConfig('account_activation') == 'user' ) |
255 { |
267 { |
256 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); |
268 redirect(makeUrl(getConfig('main_page')), $lang->get('usercp_emailpassword_msg_profile_success'), $lang->get('usercp_emailpassword_msg_need_activ_user'), 20); |
257 } |
269 } |
258 else if ( getConfig('account_activation') == 'admin' ) |
270 else if ( getConfig('account_activation') == 'admin' ) |
259 { |
271 { |
260 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); |
272 redirect(makeUrl(getConfig('main_page')), $lang->get('usercp_emailpassword_msg_profile_success'), $lang->get('usercp_emailpassword_msg_need_activ_admin'), 20); |
261 } |
273 } |
262 } |
274 } |
263 $session->login_without_crypto($session->username, $newpass); |
275 $session->login_without_crypto($session->username, $newpass); |
264 redirect(makeUrlNS('Special', 'Preferences'), 'Password changed', 'Your password has been changed, and you will now be redirected back to the user control panel.', 4); |
276 redirect(makeUrlNS('Special', 'Preferences'), $lang->get('usercp_emailpassword_msg_pass_success'), $lang->get('usercp_emailpassword_msg_password_changed'), 5); |
265 } |
277 } |
266 } |
278 } |
267 } |
279 } |
268 else |
280 else |
269 { |
281 { |
271 { |
283 { |
272 case 'foo': |
284 case 'foo': |
273 $pass = $_POST['newpass']; |
285 $pass = $_POST['newpass']; |
274 if ( $pass != $_POST['newpass_conf'] ) |
286 if ( $pass != $_POST['newpass_conf'] ) |
275 { |
287 { |
276 $errors .= '<div class="error-box">The passwords you entered did not match</div>'; |
288 $errors .= '<div class="error-box">' . $lang->get('usercp_emailpassword_err_password_no_match') . '</div>'; |
277 break; |
289 break; |
278 } |
290 } |
279 |
291 |
|
292 $session->logout(); |
280 if ( $email_changed ) |
293 if ( $email_changed ) |
281 { |
294 { |
282 if ( getConfig('account_activation') == 'user' ) |
295 if ( getConfig('account_activation') == 'user' ) |
283 { |
296 { |
284 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); |
297 redirect(makeUrl(getConfig('main_page')), $lang->get('usercp_emailpassword_msg_profile_success'), $lang->get('usercp_emailpassword_msg_need_activ_user'), 20); |
285 } |
298 } |
286 else if ( getConfig('account_activation') == 'admin' ) |
299 else if ( getConfig('account_activation') == 'admin' ) |
287 { |
300 { |
288 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); |
301 redirect(makeUrl(getConfig('main_page')), $lang->get('usercp_emailpassword_msg_profile_success'), $lang->get('usercp_emailpassword_msg_need_activ_admin'), 20); |
289 } |
302 } |
290 else |
303 } |
291 { |
304 else |
292 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); |
305 { |
293 } |
306 $session->login_without_crypto($session->username, $newpass); |
|
307 redirect(makeUrlNS('Special', 'Preferences'), $lang->get('usercp_emailpassword_msg_pass_success'), $lang->get('usercp_emailpassword_msg_password_changed'), 5); |
294 } |
308 } |
295 |
309 |
296 return; |
310 return; |
297 } |
311 } |
298 } |
312 } |
299 } |
313 } |
300 $template->tpl_strings['PAGE_NAME'] = 'Change E-mail Address or Password'; |
314 $template->tpl_strings['PAGE_NAME'] = $lang->get('usercp_emailpassword_title'); |
301 break; |
315 break; |
302 case 'Signature': |
316 case 'Signature': |
303 $template->tpl_strings['PAGE_NAME'] = 'Editing signature'; |
317 $template->tpl_strings['PAGE_NAME'] = $lang->get('usercp_signature_title'); |
304 break; |
318 break; |
305 case 'Profile': |
319 case 'Profile': |
306 $template->tpl_strings['PAGE_NAME'] = 'Editing public profile'; |
320 $template->tpl_strings['PAGE_NAME'] = $lang->get('usercp_publicinfo_title'); |
307 break; |
321 break; |
308 } |
322 } |
309 |
323 |
310 $template->header(); |
324 $template->header(); |
311 |
325 |
318 { |
332 { |
319 case 'Home': |
333 case 'Home': |
320 global $email; |
334 global $email; |
321 $userpage_id = $paths->nslist['User'] . sanitize_page_id($session->username); |
335 $userpage_id = $paths->nslist['User'] . sanitize_page_id($session->username); |
322 $userpage_exists = ( isPage($userpage_id) ) ? '' : ' class="wikilink-nonexistent"'; |
336 $userpage_exists = ( isPage($userpage_id) ) ? '' : ' class="wikilink-nonexistent"'; |
323 $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>'; |
337 $user_page = makeUrlNS('User', sanitize_page_id($session->username)); |
324 $site_admin = $email->encryptEmail(getConfig('contact_email'), '', '', 'administrator'); |
338 $site_admin = $email->encryptEmail(getConfig('contact_email'), '', '', $lang->get('usercp_intro_para3_admin_link')); |
325 $make_one_now = '<a href="' . makeUrlNS('User', sanitize_page_id($session->username)) . '">make one now</a>'; |
339 |
326 echo "<h3 style='margin-top: 0;'>$session->username, welcome to your control panel</h3>"; |
340 echo '<h3 style="margin-top: 0;">' . $lang->get('usercp_intro_heading_main', array('username' => $session->username)) . '</h3>'; |
327 echo "<p>Here you can make changes to your profile, view statistics on yourself on this site, and set your preferences.</p> |
341 |
328 <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> |
342 echo '<p>' . $lang->get('usercp_intro_para1') . '</p> |
329 <p>Use the menu at the top to navigate around. If you have any questions, you may contact the $site_admin."; |
343 <p>' . $lang->get('usercp_intro_para2', array('userpage_link' => $user_page)) . '</p> |
|
344 <p>' . $lang->get('usercp_intro_para3', array('admin_contact_link' => $site_admin)) . '</p>'; |
330 break; |
345 break; |
331 case 'EmailPassword': |
346 case 'EmailPassword': |
332 |
347 |
333 $errors = trim($errors); |
348 $errors = trim($errors); |
334 if ( !empty($errors) ) |
349 if ( !empty($errors) ) |
340 |
355 |
341 // Password change form |
356 // Password change form |
342 $pubkey = $session->rijndael_genkey(); |
357 $pubkey = $session->rijndael_genkey(); |
343 |
358 |
344 echo '<fieldset> |
359 echo '<fieldset> |
345 <legend>Change password</legend> |
360 <legend>' . $lang->get('usercp_emailpassword_grp_chpasswd') . '</legend> |
346 Type a new password:<br /> |
361 ' . $lang->get('usercp_emailpassword_field_newpass') . '<br /> |
347 <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>' : '' ) . ' |
362 <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>' : '' ) . ' |
348 <br /> |
363 <br /> |
349 <br /> |
364 <br /> |
350 Type the password again to confirm:<br /> |
365 ' . $lang->get('usercp_emailpassword_field_newpass_confirm') . '<br /> |
351 <input type="password" name="newpass_conf" size="30" tabindex="2" /> |
366 <input type="password" name="newpass_conf" size="30" tabindex="2" /> |
352 ' . ( getConfig('pw_strength_enable') == '1' ? '<br /><br /><div id="pwmeter"></div> |
367 ' . ( getConfig('pw_strength_enable') == '1' ? '<br /><br /><div id="pwmeter"></div> |
353 <small>Your password needs to score at least <b>'.getConfig('pw_strength_minimum').'</b> in order to be accepted.</small>' : '' ) . ' |
368 <small>' . $lang->get('usercp_emailpassword_msg_password_min_score') . '</small>' : '' ) . ' |
354 </fieldset><br /> |
369 </fieldset><br /> |
355 <fieldset> |
370 <fieldset> |
356 <legend>Change e-mail address</legend> |
371 <legend>' . $lang->get('usercp_emailpassword_grp_chemail') . '</legend> |
357 New e-mail address:<br /> |
372 ' . $lang->get('usercp_emailpassword_field_newemail') . '<br /> |
358 <input type="text" value="' . ( isset($_POST['newemail']) ? htmlspecialchars($_POST['newemail']) : '' ) . '" name="newemail" size="30" tabindex="3" /> |
373 <input type="text" value="' . ( isset($_POST['newemail']) ? htmlspecialchars($_POST['newemail']) : '' ) . '" name="newemail" size="30" tabindex="3" /> |
359 <br /> |
374 <br /> |
360 <br /> |
375 <br /> |
361 Confirm e-mail address:<br /> |
376 ' . $lang->get('usercp_emailpassword_field_newemail_confirm') . '<br /> |
362 <input type="text" value="' . ( isset($_POST['newemail']) ? htmlspecialchars($_POST['newemail']) : '' ) . '" name="newemail_conf" size="30" tabindex="4" /> |
377 <input type="text" value="' . ( isset($_POST['newemail']) ? htmlspecialchars($_POST['newemail']) : '' ) . '" name="newemail_conf" size="30" tabindex="4" /> |
363 </fieldset> |
378 </fieldset> |
364 <input type="hidden" name="use_crypt" value="no" /> |
379 <input type="hidden" name="use_crypt" value="no" /> |
365 <input type="hidden" name="crypt_key" value="' . $pubkey . '" /> |
380 <input type="hidden" name="crypt_key" value="' . $pubkey . '" /> |
366 <input type="hidden" name="crypt_data" value="" /> |
381 <input type="hidden" name="crypt_data" value="" /> |
367 <br /> |
382 <br /> |
368 <div style="text-align: right;"><input type="submit" name="submit" value="Save Changes" tabindex="5" /></div>'; |
383 <div style="text-align: right;"><input type="submit" name="submit" value="' . $lang->get('etc_save_changes') . '" tabindex="5" /></div>'; |
369 |
384 |
370 echo '</form>'; |
385 echo '</form>'; |
371 |
386 |
372 // ENCRYPTION CODE |
387 // ENCRYPTION CODE |
373 ?> |
388 ?> |