0
+ − 1
<?php
+ − 2
/*
+ − 3
Plugin Name: User control panel
36
+ − 4
Plugin URI: http://enanocms.org/
0
+ − 5
Description: Provides the page Special:Preferences.
+ − 6
Author: Dan Fuhry
+ − 7
Version: 1.0
36
+ − 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
+ − 13
* Version 1.0 release candidate 2
+ − 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
+ − 44
function userprefs_menu_html()
+ − 45
{
+ − 46
global $userprefs_menu;
+ − 47
global $userprefs_menu_links;
+ − 48
+ − 49
$html = '';
+ − 50
$quot = '"';
+ − 51
+ − 52
foreach ( $userprefs_menu as $section => $buttons )
+ − 53
{
+ − 54
$html .= ( isset($userprefs_menu_links[$section]) ) ? "<a href={$quot}{$userprefs_menu_links[$section]}{$quot}>{$section}</a>\n " : "<a>{$section}</a>\n ";
+ − 55
$html .= "<ul>\n ";
+ − 56
foreach ( $buttons as $button )
+ − 57
{
+ − 58
$html .= " <li><a href={$quot}{$button['link']}{$quot}>{$button['text']}</a></li>\n ";
+ − 59
}
+ − 60
$html .= "</ul>\n ";
+ − 61
}
+ − 62
+ − 63
return $html;
+ − 64
}
+ − 65
+ − 66
function userprefs_show_menu()
+ − 67
{
+ − 68
echo '<div class="menu_nojs">
+ − 69
' . userprefs_menu_html() . '
+ − 70
<span class="menuclear"></span>
+ − 71
</div>
+ − 72
<br />
+ − 73
';
+ − 74
}
+ − 75
+ − 76
function userprefs_menu_init()
+ − 77
{
+ − 78
global $db, $session, $paths, $template, $plugins; // Common objects
+ − 79
global $userprefs_menu_links;
+ − 80
+ − 81
userprefs_menu_add('Profile/membership', 'Edit e-mail address and password', makeUrlNS('Special', 'Preferences/EmailPassword'));
+ − 82
userprefs_menu_add('Profile/membership', 'Edit signature', makeUrlNS('Special', 'Preferences/Signature'));
+ − 83
userprefs_menu_add('Profile/membership', 'Edit public profile', makeUrlNS('Special', 'Preferences/Profile'));
+ − 84
userprefs_menu_add('Private messages', 'Inbox', makeUrlNS('Special', 'PrivateMessages/Folder/Inbox'));
+ − 85
userprefs_menu_add('Private messages', 'Outbox', makeUrlNS('Special', 'PrivateMessages/Folder/Outbox'));
+ − 86
userprefs_menu_add('Private messages', 'Sent items', makeUrlNS('Special', 'PrivateMessages/Folder/Sent'));
+ − 87
userprefs_menu_add('Private messages', 'Drafts', makeUrlNS('Special', 'PrivateMessages/Folder/Drafts'));
+ − 88
userprefs_menu_add('Private messages', 'Archive', makeUrlNS('Special', 'PrivateMessages/Folder/Archive'));
+ − 89
+ − 90
$userprefs_menu_links['Profile/membership'] = makeUrlNS('Special', 'Preferences');
+ − 91
$userprefs_menu_links['Private messages'] = makeUrlNS('Special', 'PrivateMessages');
+ − 92
+ − 93
$code = $plugins->setHook('userprefs_jbox');
+ − 94
foreach ( $code as $cmd )
+ − 95
{
+ − 96
eval($cmd);
+ − 97
}
+ − 98
}
+ − 99
+ − 100
$plugins->attachHook('session_started', 'userprefs_menu_init();');
+ − 101
+ − 102
function page_Special_Preferences()
+ − 103
{
+ − 104
global $db, $session, $paths, $template, $plugins; // Common objects
+ − 105
+ − 106
// We need a login to continue
+ − 107
if ( !$session->user_logged_in )
+ − 108
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.');
+ − 109
+ − 110
// User ID - later this will be specified on the URL, but hardcoded for now
+ − 111
$uid = intval($session->user_id);
+ − 112
+ − 113
// Instanciate the AES encryptor
+ − 114
$aes = new AESCrypt(AES_BITS, AES_BLOCKSIZE);
+ − 115
+ − 116
// Basic user info
+ − 117
$q = $db->sql_query('SELECT username, password, email, real_name, signature, theme, style FROM '.table_prefix.'users WHERE user_id='.$uid.';');
+ − 118
if ( !$q )
+ − 119
$db->_die();
+ − 120
+ − 121
$row = $db->fetchrow();
+ − 122
$db->free_result();
+ − 123
+ − 124
$section = $paths->getParam(0);
+ − 125
if ( !$section )
+ − 126
{
+ − 127
$section = 'Home';
+ − 128
}
+ − 129
+ − 130
$errors = '';
+ − 131
+ − 132
switch ( $section )
+ − 133
{
+ − 134
case 'EmailPassword':
+ − 135
// Require elevated privileges (well sortof)
+ − 136
if ( $session->auth_level < USER_LEVEL_CHPREF )
+ − 137
{
+ − 138
redirect(makeUrlNS('Special', 'Login/' . $paths->fullpage, 'level=' . USER_LEVEL_CHPREF, true), 'Authentication required', 'You need to re-authenticate to access this page.', 0);
+ − 139
}
+ − 140
+ − 141
if ( isset($_POST['submit']) )
+ − 142
{
+ − 143
$email_changed = false;
+ − 144
// First do the e-mail address
+ − 145
if ( strlen($_POST['newemail']) > 0 )
+ − 146
{
+ − 147
switch('foo') // Same reason as in the password code...
+ − 148
{
+ − 149
case 'foo':
+ − 150
if ( $_POST['newemail'] != $_POST['newemail_conf'] )
+ − 151
{
+ − 152
$errors .= '<div class="error-box">The e-mail addresses you entered did not match.</div>';
+ − 153
break;
+ − 154
}
+ − 155
}
+ − 156
$q = $db->sql_query('SELECT password FROM '.table_prefix.'users WHERE user_id='.$session->user_id.';');
+ − 157
if ( !$q )
+ − 158
$db->_die();
+ − 159
$row = $db->fetchrow();
+ − 160
$db->free_result();
+ − 161
$old_pass = $aes->decrypt($row['password'], $session->private_key, ENC_HEX);
+ − 162
+ − 163
$new_email = $_POST['newemail'];
+ − 164
+ − 165
$result = $session->update_user($session->user_id, false, $old_pass, false, $new_email);
+ − 166
if ( $result != 'success' )
+ − 167
{
32
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
diff
changeset
+ − 168
$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
diff
changeset
+ − 169
$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
diff
changeset
+ − 170
die_friendly('Error updating e-mail address', $message);
0
+ − 171
}
+ − 172
$email_changed = true;
+ − 173
}
+ − 174
// Obtain password
+ − 175
if ( $_POST['use_crypt'] == 'yes' && !empty($_POST['crypt_data']) )
+ − 176
{
+ − 177
$key = $session->fetch_public_key($_POST['crypt_key']);
+ − 178
if ( !$key )
+ − 179
die('Can\'t lookup key');
+ − 180
$key = hexdecode($key);
+ − 181
$newpass = $aes->decrypt($_POST['crypt_data'], $key, ENC_HEX);
+ − 182
// At this point we know if we _want_ to change the password...
+ − 183
+ − 184
// We can't check the password to see if it matches the confirmation
+ − 185
// because the confirmation was destroyed during the encryption. I figured
+ − 186
// this wasn't a big deal because if the encryption worked, then either
+ − 187
// the Javascript validated it or the user hacked the form. In the latter
+ − 188
// case, if he's smart enough to hack the encryption code, he's probably
+ − 189
// smart enough to remember his password.
+ − 190
+ − 191
if ( strlen($newpass) > 0 )
+ − 192
{
+ − 193
// Perform checks
+ − 194
if ( strlen($newpass) < 6 )
+ − 195
$errors .= '<div class="error-box">Password must be at least 6 characters. You hacked my script, darn you!</div>';
+ − 196
// 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
diff
changeset
+ − 197
if ( empty($errors) )
0
+ − 198
{
32
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
diff
changeset
+ − 199
$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
diff
changeset
+ − 200
// 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
diff
changeset
+ − 201
$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
diff
changeset
+ − 202
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
diff
changeset
+ − 203
$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
diff
changeset
+ − 204
// 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
diff
changeset
+ − 205
$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
diff
changeset
+ − 206
$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
diff
changeset
+ − 207
if ( $email_changed )
0
+ − 208
{
32
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
diff
changeset
+ − 209
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
diff
changeset
+ − 210
{
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
diff
changeset
+ − 211
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
diff
changeset
+ − 212
}
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
diff
changeset
+ − 213
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
diff
changeset
+ − 214
{
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
diff
changeset
+ − 215
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
diff
changeset
+ − 216
}
0
+ − 217
}
32
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
diff
changeset
+ − 218
$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
diff
changeset
+ − 219
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
+ − 220
}
+ − 221
}
+ − 222
}
+ − 223
else
+ − 224
{
+ − 225
switch('foo') // allow breaking out of our section...i can't wait until PHP6 (goto support!)
+ − 226
{
+ − 227
case 'foo':
+ − 228
$pass = $_POST['newpass'];
+ − 229
if ( $pass != $_POST['newpass_conf'] )
+ − 230
{
+ − 231
$errors .= '<div class="error-box">The passwords you entered did not match</div>';
+ − 232
break;
+ − 233
}
+ − 234
+ − 235
if ( $email_changed )
+ − 236
{
+ − 237
if ( getConfig('account_activation') == 'user' )
+ − 238
{
+ − 239
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);
+ − 240
}
+ − 241
else if ( getConfig('account_activation') == 'admin' )
+ − 242
{
+ − 243
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);
+ − 244
}
+ − 245
else
+ − 246
{
+ − 247
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);
+ − 248
}
+ − 249
}
+ − 250
+ − 251
return;
+ − 252
}
+ − 253
}
+ − 254
}
+ − 255
$template->tpl_strings['PAGE_NAME'] = 'Change E-mail Address or Password';
+ − 256
break;
+ − 257
case 'Signature':
+ − 258
$template->tpl_strings['PAGE_NAME'] = 'Editing signature';
+ − 259
break;
+ − 260
case 'Profile':
+ − 261
$template->tpl_strings['PAGE_NAME'] = 'Editing public profile';
+ − 262
break;
+ − 263
}
+ − 264
+ − 265
$template->header();
+ − 266
+ − 267
// Output the menu
+ − 268
// This is not templatized because it conforms to the jBox menu standard.
+ − 269
+ − 270
userprefs_show_menu();
+ − 271
+ − 272
switch ( $section )
+ − 273
{
+ − 274
case 'Home':
+ − 275
global $email;
+ − 276
$user_page = '<a href="' . makeUrlNS('User', str_replace(' ', '_', $session->username)) . '">user page</a> <sup>(<a href="' . makeUrlNS('User', str_replace(' ', '_', $session->username)) . '#do:comments">comments</a>)</sup>';
+ − 277
$site_admin = $email->encryptEmail(getConfig('contact_email'), '', '', 'administrator');
+ − 278
echo "<h3 style='margin-top: 0;'>$session->username, welcome to your control panel</h3>";
+ − 279
echo "<p>Here you can make changes to your profile, view statistics on yourself on this site, and set your preferences.</p>
+ − 280
<p>If you have not already done so, you are encouraged to make a $user_page and tell the other members of this site a little about yourself.</p>
+ − 281
<p>Use the menu at the top to navigate around. If you have any questions, you may contact the $site_admin.";
+ − 282
break;
+ − 283
case 'EmailPassword':
+ − 284
+ − 285
echo '<form action="' . makeUrlNS('Special', 'Preferences/EmailPassword') . '" method="post" onsubmit="return runEncryption();" name="empwform" >';
+ − 286
+ − 287
// Password change form
+ − 288
$pubkey = $session->rijndael_genkey();
+ − 289
+ − 290
echo '<fieldset>
+ − 291
<legend>Change password</legend>
+ − 292
Type a new password:<br />
+ − 293
<input type="password" name="newpass" size="30" tabindex="1" />
+ − 294
<br />
+ − 295
<br />
+ − 296
Type the password again to confirm:<br />
+ − 297
<input type="password" name="newpass_conf" size="30" tabindex="2" />
+ − 298
</fieldset><br />
+ − 299
<fieldset>
+ − 300
<legend>Change e-mail address</legend>
+ − 301
New e-mail address:<br />
+ − 302
<input type="text" name="newemail" size="30" tabindex="3" />
+ − 303
<br />
+ − 304
<br />
+ − 305
Confirm e-mail address:<br />
+ − 306
<input type="text" name="newemail_conf" size="30" tabindex="4" />
+ − 307
</fieldset>
+ − 308
<input type="hidden" name="use_crypt" value="no" />
+ − 309
<input type="hidden" name="crypt_key" value="' . $pubkey . '" />
+ − 310
<input type="hidden" name="crypt_data" value="" />
+ − 311
<br />
+ − 312
<div style="text-align: right;"><input type="submit" name="submit" value="Save Changes" tabindex="5" /></div>';
+ − 313
+ − 314
echo '</form>';
+ − 315
+ − 316
// ENCRYPTION CODE
+ − 317
?>
+ − 318
<script type="text/javascript">
+ − 319
disableJSONExts();
+ − 320
str = '';
+ − 321
for(i=0;i<keySizeInBits/4;i++) str+='0';
+ − 322
var key = hexToByteArray(str);
+ − 323
var pt = hexToByteArray(str);
+ − 324
var ct = rijndaelEncrypt(pt, key, "ECB");
+ − 325
var ct = byteArrayToHex(ct);
+ − 326
switch(keySizeInBits)
+ − 327
{
+ − 328
case 128:
+ − 329
v = '66e94bd4ef8a2c3b884cfa59ca342b2e';
+ − 330
break;
+ − 331
case 192:
+ − 332
v = 'aae06992acbf52a3e8f4a96ec9300bd7aae06992acbf52a3e8f4a96ec9300bd7';
+ − 333
break;
+ − 334
case 256:
+ − 335
v = 'dc95c078a2408989ad48a21492842087dc95c078a2408989ad48a21492842087';
+ − 336
break;
+ − 337
}
+ − 338
var aes_testpassed = ( ct == v && md5_vm_test() );
+ − 339
function runEncryption()
+ − 340
{
+ − 341
var frm = document.forms.empwform;
+ − 342
if ( frm.newpass.value.length < 1 )
+ − 343
return true;
+ − 344
if(aes_testpassed)
+ − 345
{
+ − 346
frm.use_crypt.value = 'yes';
+ − 347
var cryptkey = frm.crypt_key.value;
+ − 348
frm.crypt_key.value = hex_md5(cryptkey);
+ − 349
cryptkey = hexToByteArray(cryptkey);
+ − 350
if(!cryptkey || ( ( typeof cryptkey == 'string' || typeof cryptkey == 'object' ) ) && cryptkey.length != keySizeInBits / 8 )
+ − 351
{
+ − 352
frm.submit.disabled = true;
+ − 353
len = ( typeof cryptkey == 'string' || typeof cryptkey == 'object' ) ? '\nLen: '+cryptkey.length : '';
+ − 354
alert('The key is messed up\nType: '+typeof(cryptkey)+len);
+ − 355
}
+ − 356
}
+ − 357
pass1 = frm.newpass.value;
+ − 358
pass2 = frm.newpass_conf.value;
+ − 359
if ( pass1 != pass2 )
+ − 360
{
+ − 361
alert('The passwords you entered do not match.');
+ − 362
return false;
+ − 363
}
+ − 364
if ( pass1.length < 6 && pass1.length > 0 )
+ − 365
{
+ − 366
alert('The new password must be 6 characters or greater in length.');
+ − 367
return false;
+ − 368
}
+ − 369
if(aes_testpassed)
+ − 370
{
+ − 371
pass = frm.newpass.value;
+ − 372
pass = stringToByteArray(pass);
+ − 373
cryptstring = rijndaelEncrypt(pass, cryptkey, 'ECB');
+ − 374
if(!cryptstring)
+ − 375
{
+ − 376
return false;
+ − 377
}
+ − 378
cryptstring = byteArrayToHex(cryptstring);
+ − 379
frm.crypt_data.value = cryptstring;
+ − 380
frm.newpass.value = "";
+ − 381
frm.newpass_conf.value = "";
+ − 382
}
+ − 383
return true;
+ − 384
}
+ − 385
</script>
+ − 386
<?php
+ − 387
+ − 388
break;
+ − 389
case 'Signature':
+ − 390
if ( isset($_POST['new_sig']) )
+ − 391
{
+ − 392
$sig = $_POST['new_sig'];
+ − 393
$sig = RenderMan::preprocess_text($sig, true, false);
+ − 394
$sql_sig = $db->escape($sig);
+ − 395
$q = $db->sql_query('UPDATE '.table_prefix.'users SET signature=\'' . $sql_sig . '\' WHERE user_id=' . $session->user_id . ';');
+ − 396
if ( !$q )
+ − 397
$db->_die();
+ − 398
$session->signature = $sig;
+ − 399
echo '<div class="info-box" style="margin: 0 0 10px 0;">Your signature has been saved.</div>';
+ − 400
}
+ − 401
echo '<form action="'.makeUrl($paths->fullpage).'" method="post">';
+ − 402
echo $template->tinymce_textarea('new_sig', $session->signature);
+ − 403
echo '<input type="submit" value="Save signature" />';
+ − 404
echo '</form>';
+ − 405
break;
+ − 406
case "Profile":
+ − 407
if ( isset($_POST['submit']) )
+ − 408
{
+ − 409
$real_name = htmlspecialchars($_POST['real_name']);
+ − 410
$real_name = $db->escape($real_name);
31
+ − 411
+ − 412
$imaddr_aim = htmlspecialchars($_POST['imaddr_aim']);
+ − 413
$imaddr_aim = $db->escape($imaddr_aim);
+ − 414
+ − 415
$imaddr_msn = htmlspecialchars($_POST['imaddr_msn']);
+ − 416
$imaddr_msn = $db->escape($imaddr_msn);
+ − 417
+ − 418
$imaddr_yahoo = htmlspecialchars($_POST['imaddr_yahoo']);
+ − 419
$imaddr_yahoo = $db->escape($imaddr_yahoo);
+ − 420
+ − 421
$imaddr_xmpp = htmlspecialchars($_POST['imaddr_xmpp']);
+ − 422
$imaddr_xmpp = $db->escape($imaddr_xmpp);
+ − 423
+ − 424
$homepage = htmlspecialchars($_POST['homepage']);
+ − 425
$homepage = $db->escape($homepage);
+ − 426
+ − 427
$location = htmlspecialchars($_POST['location']);
+ − 428
$location = $db->escape($location);
+ − 429
+ − 430
$occupation = htmlspecialchars($_POST['occupation']);
+ − 431
$occupation = $db->escape($occupation);
+ − 432
+ − 433
$hobbies = htmlspecialchars($_POST['hobbies']);
+ − 434
$hobbies = $db->escape($hobbies);
+ − 435
+ − 436
$email_public = ( isset($_POST['email_public']) ) ? '1' : '0';
+ − 437
+ − 438
$session->real_name = $real_name;
+ − 439
32
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
diff
changeset
+ − 440
if ( !preg_match('/@([a-z0-9-]+)(\.([a-z0-9-\.]+))?/', $imaddr_msn) && !empty($imaddr_msn) )
31
+ − 441
{
+ − 442
$imaddr_msn = "$imaddr_msn@hotmail.com";
+ − 443
}
+ − 444
+ − 445
if ( substr($homepage, 0, 7) != 'http://' )
+ − 446
{
+ − 447
$homepage = "http://$homepage";
+ − 448
}
+ − 449
+ − 450
if ( !preg_match('/^http:\/\/([a-z0-9-.]+)([A-z0-9@#\$%\&:;<>,\.\?=\+\(\)\[\]_\/\\\\]*?)$/i', $homepage) )
+ − 451
{
+ − 452
$homepage = '';
+ − 453
}
+ − 454
+ − 455
$session->user_extra['user_aim'] = $imaddr_aim;
+ − 456
$session->user_extra['user_msn'] = $imaddr_msn;
+ − 457
$session->user_extra['user_xmpp'] = $imaddr_xmpp;
+ − 458
$session->user_extra['user_yahoo'] = $imaddr_yahoo;
+ − 459
$session->user_extra['user_homepage'] = $homepage;
+ − 460
$session->user_extra['user_location'] = $location;
+ − 461
$session->user_extra['user_job'] = $occupation;
+ − 462
$session->user_extra['user_hobbies'] = $hobbies;
+ − 463
$session->user_extra['email_public'] = intval($email_public);
+ − 464
0
+ − 465
$q = $db->sql_query('UPDATE '.table_prefix."users SET real_name='$real_name' WHERE user_id=$session->user_id;");
+ − 466
if ( !$q )
+ − 467
$db->_die();
+ − 468
31
+ − 469
$q = $db->sql_query('UPDATE '.table_prefix."users_extra SET user_aim='$imaddr_aim',user_yahoo='$imaddr_yahoo',user_msn='$imaddr_msn',
+ − 470
user_xmpp='$imaddr_xmpp',user_homepage='$homepage',user_location='$location',user_job='$occupation',
+ − 471
user_hobbies='$hobbies',email_public=$email_public
+ − 472
WHERE user_id=$session->user_id;");
+ − 473
+ − 474
if ( !$q )
+ − 475
$db->_die();
+ − 476
0
+ − 477
echo '<div class="info-box" style="margin: 0 0 10px 0;">Your profile has been updated.</div>';
+ − 478
}
+ − 479
echo '<form action="'.makeUrl($paths->fullpage).'" method="post">';
+ − 480
?>
+ − 481
<div class="tblholder">
+ − 482
<table border="0" cellspacing="1" cellpadding="4">
+ − 483
<tr>
+ − 484
<th colspan="2">Your public profile</th>
+ − 485
</tr>
+ − 486
<tr>
+ − 487
<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>
+ − 488
</tr>
+ − 489
<tr>
+ − 490
<td class="row2" style="width: 50%;">Real name:</td>
+ − 491
<td class="row1" style="width: 50%;"><input type="text" name="real_name" value="<?php echo $session->real_name; ?>" size="30" /></td>
+ − 492
</tr>
+ − 493
<tr>
+ − 494
<td class="row2">Change theme:</td>
+ − 495
<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>
+ − 496
</tr>
+ − 497
<tr>
31
+ − 498
<th class="subhead" colspan="2">
+ − 499
Instant messenger contact information
+ − 500
</th>
+ − 501
<tr>
+ − 502
<td class="row2" style="width: 50%;">AIM handle:</td>
+ − 503
<td class="row1" style="width: 50%;"><input type="text" name="imaddr_aim" value="<?php echo $session->user_extra['user_aim']; ?>" size="30" /></td>
+ − 504
</tr>
+ − 505
<tr>
+ − 506
<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>
+ − 507
<td class="row1" style="width: 50%;"><input type="text" name="imaddr_msn" value="<?php echo $session->user_extra['user_msn']; ?>" size="30" /></td>
+ − 508
</tr>
+ − 509
<tr>
+ − 510
<td class="row2" style="width: 50%;">Yahoo! IM handle:</td>
+ − 511
<td class="row1" style="width: 50%;"><input type="text" name="imaddr_yahoo" value="<?php echo $session->user_extra['user_yahoo']; ?>" size="30" /></td>
+ − 512
</tr>
+ − 513
<tr>
+ − 514
<td class="row2" style="width: 50%;">Jabber/XMPP handle:</td>
+ − 515
<td class="row1" style="width: 50%;"><input type="text" name="imaddr_xmpp" value="<?php echo $session->user_extra['user_xmpp']; ?>" size="30" /></td>
+ − 516
</tr>
+ − 517
<tr>
+ − 518
<th class="subhead" colspan="2">
+ − 519
Extra contact information
+ − 520
</th>
+ − 521
</tr>
+ − 522
<tr>
+ − 523
<td class="row2" style="width: 50%;">Your homepage:<br /><small>Please remember the http:// prefix.</small></td>
+ − 524
<td class="row1" style="width: 50%;"><input type="text" name="homepage" value="<?php echo $session->user_extra['user_homepage']; ?>" size="30" /></td>
+ − 525
</tr>
+ − 526
<tr>
+ − 527
<td class="row2" style="width: 50%;">Your location:</td>
+ − 528
<td class="row1" style="width: 50%;"><input type="text" name="location" value="<?php echo $session->user_extra['user_location']; ?>" size="30" /></td>
+ − 529
</tr>
+ − 530
<tr>
+ − 531
<td class="row2" style="width: 50%;">Your job:</td>
+ − 532
<td class="row1" style="width: 50%;"><input type="text" name="occupation" value="<?php echo $session->user_extra['user_job']; ?>" size="30" /></td>
+ − 533
</tr>
+ − 534
<tr>
+ − 535
<td class="row2" style="width: 50%;">Your hobbies:</td>
+ − 536
<td class="row1" style="width: 50%;"><input type="text" name="hobbies" value="<?php echo $session->user_extra['user_hobbies']; ?>" size="30" /></td>
+ − 537
</tr>
+ − 538
<tr>
+ − 539
<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>
+ − 540
<td class="row1" style="width: 50%;"><input type="checkbox" id="chk_email_public" name="email_public" value="<?php if ($session->user_extra['email_public'] == 1) echo 'checked="checked"'; ?>" size="30" /></td>
0
+ − 541
</tr>
+ − 542
<tr>
+ − 543
<th class="subhead" colspan="2">
+ − 544
<input type="submit" name="submit" value="Save profile" />
+ − 545
</th>
+ − 546
</tr>
+ − 547
</table>
+ − 548
</div>
+ − 549
<?php
+ − 550
echo '</form>';
+ − 551
break;
+ − 552
default:
+ − 553
$good = false;
+ − 554
$code = $plugins->setHook('userprefs_body');
+ − 555
foreach ( $code as $cmd )
+ − 556
{
+ − 557
if ( eval($code) )
+ − 558
$good = true;
+ − 559
}
+ − 560
if ( !$good )
+ − 561
{
+ − 562
echo '<h3>Invalid module</h3>
+ − 563
<p>Userprefs module "'.$section.'" not found.</p>';
+ − 564
}
+ − 565
break;
+ − 566
}
+ − 567
+ − 568
$template->footer();
+ − 569
}
+ − 570
+ − 571
?>