diff -r c72b545f1304 -r 67bd3121a12e plugins/SpecialUserFuncs.php --- a/plugins/SpecialUserFuncs.php Wed Dec 26 00:37:26 2007 -0500 +++ b/plugins/SpecialUserFuncs.php Thu Dec 27 22:09:33 2007 -0500 @@ -374,6 +374,14 @@ $level = ( isset($data['level']) ) ? intval($data['level']) : USER_LEVEL_MEMBER; $result = $session->login_with_crypto($data['username'], $data['crypt_data'], $data['crypt_key'], $data['challenge'], $level, $captcha_hash, $captcha_code); $session->start(); + + // Run the session_started hook to establish special pages + $code = $plugins->setHook('session_started'); + foreach ( $code as $cmd ) + { + eval($cmd); + } + if ( $result['success'] ) { $response = Array( @@ -412,6 +420,14 @@ $result = $session->login_without_crypto($_POST['username'], $_POST['pass'], false, intval($_POST['auth_level']), $captcha_hash, $captcha_code); } $session->start(); + + // Run the session_started hook to establish special pages + $code = $plugins->setHook('session_started'); + foreach ( $code as $cmd ) + { + eval($cmd); + } + $paths->init(); if($result['success']) { @@ -959,89 +975,172 @@ $template->footer(); } -/* -If you want the old preferences page back, be my guest. -function page_Special_Preferences() { - global $db, $session, $paths, $template, $plugins; // Common objects - $template->header(); - if(isset($_POST['submit'])) { - $data = $session->update_user($session->user_id, $_POST['username'], $_POST['current_pass'], $_POST['new_pass'], $_POST['email'], $_POST['real_name'], $_POST['sig']); - if($data == 'success') echo '

Information

Your profile has been updated. Return to the index page.

'; - else echo $data; - } else { - echo ' -

Edit your profile

-
- - - - - - - - - -
Username:
Current Password:
You only need to enter your current password if you are changing your e-mail address or changing your password.
New Password:
E-mail:
Real Name:
Signature:
Your signature appears
below your comment posts.
-
-
- '; - } - $template->footer(); -} -*/ - function page_Special_Contributions() { global $db, $session, $paths, $template, $plugins; // Common objects + global $lang; + + // This is a vast improvement over the old Special:Contributions in 1.0.x. + $template->header(); $user = $paths->getParam(); - if(!$user && isset($_GET['user'])) + if ( !$user && isset($_GET['user']) ) { $user = $_GET['user']; } - elseif(!$user && !isset($_GET['user'])) + else if ( !$user && !isset($_GET['user']) ) { - echo 'No user selected!'; + echo '

' . $lang->get('userfuncs_contribs_err_no_user') . '

'; $template->footer(); return; } $user = $db->escape($user); + $q = 'SELECT log_type, time_id, action, date_string, page_id, namespace, author, edit_summary, minor_edit, page_id, namespace, ( action = \'edit\' ) AS is_edit FROM '.table_prefix.'logs WHERE author=\''.$user.'\' AND log_type=\'page\' ORDER BY is_edit DESC, time_id DESC;'; + $q = $db->sql_query($q); + if ( !$q ) + $db->_die('SpecialUserFuncs selecting contribution data'); - $q = 'SELECT time_id,date_string,page_id,namespace,author,edit_summary,minor_edit,page_id,namespace FROM '.table_prefix.'logs WHERE author=\''.$user.'\' AND action=\'edit\' ORDER BY time_id DESC;'; - if(!$db->sql_query($q)) $db->_die('The history data for the page "'.$paths->cpage['name'].'" could not be selected.'); - echo 'History of edits and actions

Edits:

'; - if($db->numrows() < 1) echo 'No history entries in this category.'; - while($r = $db->fetchrow()) + echo '

' . $lang->get('userfuncs_contribs_heading_edits') . '

'; + + $cnt_edits = 0; + $cnt_other = 0; + $current = 'cnt_edits'; + $cls = 'row2'; + + while ( $row = $db->fetchrow($q) ) { - $title = get_page_title($r['page_id'], $r['namespace']); - echo ''.$r['date_string'].' (revert to) '.htmlspecialchars($title).': '.$r['edit_summary']; - if($r['minor_edit']) echo ' - minor edit'; - echo '
'; - } - $db->free_result(); - echo '

Other changes:

'; - $q = 'SELECT log_type,time_id,action,date_string,page_id,namespace,author,edit_summary,minor_edit,page_id,namespace FROM '.table_prefix.'logs WHERE author=\''.$user.'\' AND action!=\'edit\' ORDER BY time_id DESC;'; - if(!$db->sql_query($q)) $db->_die('The history data for the page "'.$paths->cpage['name'].'" could not be selected.'); - if($db->numrows() < 1) echo 'No history entries in this category.'; - while($r = $db->fetchrow()) - { - if ( $r['log_type'] == 'page' ) + if ( $current == 'cnt_edits' && $row['is_edit'] != 1 ) + { + // No longer processing page edits - split the table + if ( $cnt_edits == 0 ) + { + echo '

' . $lang->get('userfuncs_contribs_msg_no_edits') . '

'; + } + else + { + echo ''; + echo '

' . $lang->get('userfuncs_contribs_heading_other') . '

'; + } + $current = 'cnt_other'; + $cls = 'row2'; + } + if ( $$current == 0 ) + { + echo '
+ '; + echo ' + '; + echo ' '; + if ( $current == 'cnt_edits' ) + { + echo ' '; + } + echo ' '; + if ( $current == 'cnt_other' ) + { + echo ' + + '; + } + echo ' + '; + } + ++$$current; + $cls = ( $cls == 'row1' ) ? 'row2' : 'row1'; + + echo ''; + + // date & time + echo ' '; + + // page & link to said page + echo ' '; + + switch ( $row['action'] ) { - $title = get_page_title($r['page_id'], $r['namespace']); - echo '(rollback) '.$r['date_string'].''.htmlspecialchars($title).': '; - if ( $r['action'] == 'prot' ) echo 'Protected page; reason: '.$r['edit_summary']; - else if ( $r['action'] == 'unprot' ) echo 'Unprotected page; reason: '.$r['edit_summary']; - else if ( $r['action'] == 'rename' ) echo 'Renamed page; old title was: '.htmlspecialchars($r['edit_summary']); - else if ( $r['action'] == 'create' ) echo 'Created page'; - else if ( $r['action'] == 'delete' ) echo 'Deleted page'; - if ( $r['minor_edit'] ) echo ' - minor edit'; - echo '
'; + case 'edit': + if ( $row['edit_summary'] == 'Automatic backup created when logs were purged' ) + { + $row['edit_summary'] = $lang->get('history_summary_clearlogs'); + } + else if ( empty($row['edit_summary']) ) + { + $row['edit_summary'] = '' . $lang->get('history_summary_none_given') . ''; + } + echo ' '; + if ( $row['minor_edit'] == 1 ) + { + echo ''; + } + else + { + echo ''; + } + break; + case 'prot': + echo ' '; + echo ' '; + echo ' '; + break; + case 'unprot': + echo ' '; + echo ' '; + echo ' '; + break; + case 'semiprot': + echo ' '; + echo ' '; + echo ' '; + break; + case 'rename': + echo ' '; + echo ' '; + echo ' '; + break; + case 'create': + echo ' '; + echo ' '; + echo ' '; + break; + case 'delete': + echo ' '; + echo ' '; + echo ' '; + break; + case 'reupload': + echo ' '; + echo ' '; + echo ' '; + break; } - else if($r['log_type']=='security') + + // actions column + echo ' '; + + if ( $current == 'cnt_other' && $cnt_edits + $cnt_other >= $db->numrows($q) ) + { + echo '
' . $lang->get('history_col_datetime') . '' . $lang->get('history_col_page') . '' . $lang->get('history_col_summary') . '' . $lang->get('history_col_minor') . '' . $lang->get('history_col_action_taken') . '' . $lang->get('history_col_extra') . '' . $lang->get('history_col_actions') . '
' . date('d M Y h:i a', $row['time_id']) . '' . get_page_title_ns($row['page_id'], $row['namespace']) . ' ' . $row['edit_summary'] . 'M' . $lang->get('history_log_protect') . '' . $lang->get('history_extra_reason') . ' ' . $row['edit_summary'] . '' . $lang->get('history_log_unprotect') . '' . $lang->get('history_extra_reason') . ' ' . $row['edit_summary'] . '' . $lang->get('history_log_semiprotect') . '' . $lang->get('history_extra_reason') . ' ' . $row['edit_summary'] . '' . $lang->get('history_log_rename') . '' . $lang->get('history_extra_oldtitle') . ' ' . htmlspecialchars($row['edit_summary']) . '' . $lang->get('history_log_create') . '' . $lang->get('history_log_delete') . '' . $lang->get('history_extra_reason') . ' ' . $row['edit_summary'] . '' . $lang->get('history_log_uploadnew') . '' . $lang->get('history_extra_reason') . ' ' . $row['edit_summary'] . ''; + if ( $row['is_edit'] == 1 ) { - // Not implemented, and when it is, it won't be public + echo ' ' . $lang->get('history_action_view') . ' | '; + echo ' ' . $lang->get('history_action_restore') . ''; + } + else + { + echo ' ' . $lang->get('history_action_revert') . ''; + } + echo '
'; } } + + if ( $current == 'cnt_edits' ) + { + // no "other" edits, close the table + echo ''; + echo '

' . $lang->get('userfuncs_contribs_heading_other') . '

'; + echo '

' . $lang->get('userfuncs_contribs_msg_no_other') . '

'; + } + $db->free_result(); $template->footer(); } @@ -1049,7 +1148,12 @@ function page_Special_ChangeStyle() { global $db, $session, $paths, $template, $plugins; // Common objects - if(!$session->user_logged_in) die_friendly('Access denied', '

You must be logged in to change your style. Spoofer.

'); + global $lang; + + if ( !$session->user_logged_in ) + { + die_friendly('Access denied', '

You must be logged in to change your style. Spoofer.

'); + } if(isset($_POST['theme']) && isset($_POST['style']) && isset($_POST['return_to'])) { if ( !preg_match('/^([a-z0-9_-]+)$/i', $_POST['theme']) ) @@ -1058,51 +1162,64 @@ die('Hacking attempt'); $d = ENANO_ROOT . '/themes/' . $_POST['theme']; $f = ENANO_ROOT . '/themes/' . $_POST['theme'] . '/css/' . $_POST['style'] . '.css'; - if(!file_exists($d) || !is_dir($d)) die('The directory "'.$d.'" does not exist.'); - if(!file_exists($f)) die('The file "'.$f.'" does not exist.'); + if ( !file_exists($d) || !is_dir($d) ) + { + die('The directory "'.$d.'" does not exist.'); + } + if ( !file_exists($f) ) + { + die('The file "'.$f.'" does not exist.'); + } $d = $db->escape($_POST['theme']); $f = $db->escape($_POST['style']); $q = 'UPDATE '.table_prefix.'users SET theme=\''.$d.'\',style=\''.$f.'\' WHERE username=\''.$session->username.'\''; - if(!$db->sql_query($q)) + if ( !$db->sql_query($q) ) { $db->_die('Your theme/style preferences were not updated.'); } else { - redirect(makeUrl($_POST['return_to']), '', '', 0); + redirect(makeUrl($_POST['return_to']), $lang->get('userfuncs_changetheme_success_title'), $lang->get('userfuncs_changetheme_success_body'), 3); } } else { $template->header(); $ret = ( isset($_POST['return_to']) ) ? $_POST['return_to'] : $paths->getParam(0); - if(!$ret) $ret = getConfig('main_page'); + if ( !$ret ) + { + $ret = getConfig('main_page'); + } ?>
- -

Please select a new theme:

+ +

get('userfuncs_changetheme_heading_theme'); ?>

-

+

-

Please select a stylesheet:

+

get('userfuncs_changetheme_heading_style'); ?>

-

+

getParam(0); - if(!$user) die_friendly('Account activation error', '

This page can only be accessed using links sent to users via e-mail.

'); + if ( !$user ) + { + die_friendly($lang->get('userfuncs_activate_err_badlink_title'), '

' . $lang->get('userfuncs_activate_err_badlink_body') . '

'); + } $key = $paths->getParam(1); - if(!$key) die_friendly('Account activation error', '

This page can only be accessed using links sent to users via e-mail.

'); + if ( !$key ) + { + die_friendly($lang->get('userfuncs_activate_err_badlink_title'), '

' . $lang->get('userfuncs_activate_err_badlink_body') . '

'); + } $s = $session->activate_account(str_replace('_', ' ', $user), $key); - if($s > 0) die_friendly('Activation successful', '

Your account is now active. Thank you for registering.

'); - else die_friendly('Activation failed', '

The activation key was probably incorrect.

'); + if ( $s > 0 ) + { + die_friendly($lang->get('userfuncs_activate_success_title'), '

' . $lang->get('userfuncs_activate_success_body') . '

'); + } + else + { + die_friendly($lang->get('userfuncs_activate_err_badlink_title'), '

' . $lang->get('userfuncs_activate_err_bad_key') . '

'); + } } function page_Special_Captcha() @@ -1196,6 +1327,8 @@ function page_Special_PasswordReset() { global $db, $session, $paths, $template, $plugins; // Common objects + global $lang; + $template->header(); if($paths->getParam(0) == 'stage2') { @@ -1226,7 +1359,7 @@ if ( ( intval($row['temp_password_time']) + ( 3600 * 24 ) ) < time() ) { - echo '

Your temporary password has expired. Please request another one.

'; + echo '

' . $lang->get('userfuncs_passreset_err_pass_expired', array('reset_url' => makeUrlNS('Special', 'PasswordReset'))) . '

'; $template->footer(); return false; } @@ -1239,7 +1372,7 @@ $crypt_key = $session->fetch_public_key($_POST['crypt_key']); if(!$crypt_key) { - echo 'ERROR: Couldn\'t look up public key for decryption.'; + echo $lang->get('user_err_key_not_found'); $template->footer(); return false; } @@ -1247,7 +1380,7 @@ $data = $aes->decrypt($_POST['crypt_data'], $crypt_key, ENC_HEX); if(strlen($data) < 6) { - echo 'ERROR: Your password must be six characters or greater in length.'; + echo $lang->get('userfuncs_passreset_err_too_short'); $template->footer(); return false; } @@ -1258,13 +1391,13 @@ $conf = $_POST['pass_confirm']; if($data != $conf) { - echo 'ERROR: The passwords you entered do not match.'; + echo $lang->get('userfuncs_passreset_err_no_match'); $template->footer(); return false; } if(strlen($data) < 6) { - echo 'ERROR: Your password must be six characters or greater in length.'; + echo $lang->get('userfuncs_passreset_err_too_short'); $template->footer(); return false; } @@ -1282,7 +1415,7 @@ if ( $inp_score < $min_score ) { $url = makeUrl($paths->fullpage); - echo "

ERROR: Your password did not pass the complexity score requirement. You need $min_score points to pass; your password received a score of $inp_score. Go back

"; + echo "

" . $lang->get('userfuncs_passreset_err_failed_score', array('inp_score' => $inp_score, 'url' => $url)) . "

"; $template->footer(); return false; } @@ -1293,7 +1426,7 @@ if($q) { $session->login_without_crypto($row['username'], $data); - echo '

Your password has been reset. Return to the main page.

'; + echo '

' . $lang->get('userfuncs_passreset_stage2_success', array('url_mainpage' => makeUrl(getConfig('main_page')))) . '

'; } else { @@ -1308,24 +1441,24 @@ $pubkey = $session->rijndael_genkey(); $evt_get_score = ( getConfig('pw_strength_enable') == '1' ) ? 'onkeyup="password_score_field(this);" ' : ''; - $pw_meter = ( getConfig('pw_strength_enable') == '1' ) ? 'Password strength rating:
' : ''; - $pw_blurb = ( getConfig('pw_strength_enable') == '1' && intval(getConfig('pw_strength_minimum')) > -10 ) ? '
Your password needs to have a score of at least '.getConfig('pw_strength_minimum').'.' : ''; + $pw_meter = ( getConfig('pw_strength_enable') == '1' ) ? '' . $lang->get('userfuncs_passreset_stage2_lbl_strength') . '
' : ''; + $pw_blurb = ( getConfig('pw_strength_enable') == '1' && intval(getConfig('pw_strength_minimum')) > -10 ) ? '
' . $lang->get('userfuncs_passreset_stage2_blurb_strength') . '' : ''; ?>

- - - + + + -
Reset password
Password:/>
Confirm:
get('userfuncs_passreset_stage2_th'); ?>
get('userfuncs_passreset_stage2_lbl_password'); ?> />
get('userfuncs_passreset_stage2_lbl_confirm'); ?>
+ - +
@@ -1375,12 +1508,12 @@ pass2 = frm.pass_confirm.value; if ( pass1 != pass2 ) { - alert('The passwords you entered do not match.'); + alert($lang.get('userfuncs_passreset_err_no_match')); return false; } if ( pass1.length < 6 ) { - alert('The new password must be 6 characters or greater in length.'); + alert($lang.get('userfuncs_passreset_err_too_short')); return false; } if(testpassed) @@ -1409,20 +1542,20 @@ { if($session->mail_password_reset($_POST['username'])) { - echo '

An e-mail has been sent to the e-mail address on file for your username with a new password in it. Please check your e-mail for further instructions.

'; + echo '

' . $lang->get('userfuncs_passreset_stage1_success') . '

'; } else { - echo '

Error occured, your new password was not sent.

'; + echo '

' . $lang->get('userfuncs_passreset_stage1_error') . '

'; } $template->footer(); return true; } - echo '

Don\'t worry, it happens to the best of us.

-

To reset your password, just enter your username below, and a new password will be e-mailed to you.

+ echo '

' . $lang->get('userfuncs_passreset_blurb_line1') . '

+

' . $lang->get('userfuncs_passreset_blurb_line2') . '

-

Username: '.$template->username_field('username').'

-

+

' . $lang->get('userfuncs_passreset_lbl_username') . ' '.$template->username_field('username').'

+

'; $template->footer(); } @@ -1430,6 +1563,8 @@ function page_Special_Memberlist() { global $db, $session, $paths, $template, $plugins; // Common objects + global $lang; + $template->header(); $startletters = 'abcdefghijklmnopqrstuvwxyz';