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 '
Your profile has been updated. Return to the index page.
'; - else echo $data; - } else { - 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' . $lang->get('userfuncs_contribs_msg_no_edits') . '
'; + } + else + { + echo ''; + echo '' . $lang->get('history_col_datetime') . ' | '; + echo '' . $lang->get('history_col_page') . ' | '; + if ( $current == 'cnt_edits' ) + { + echo '' . $lang->get('history_col_summary') . ' | '; + } + echo '' . $lang->get('history_col_minor') . ' | '; + if ( $current == 'cnt_other' ) + { + echo '' . $lang->get('history_col_action_taken') . ' | +' . $lang->get('history_col_extra') . ' | + '; + } + echo '' . $lang->get('history_col_actions') . ' | +||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
' . date('d M Y h:i a', $row['time_id']) . ' | '; + + // page & link to said page + echo '' . get_page_title_ns($row['page_id'], $row['namespace']) . ' | '; + + 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 '' . $row['edit_summary'] . ' | '; + if ( $row['minor_edit'] == 1 ) + { + echo 'M | '; + } + else + { + echo ''; + } + break; + case 'prot': + echo ' | '; + echo ' | ' . $lang->get('history_log_protect') . ' | '; + echo '' . $lang->get('history_extra_reason') . ' ' . $row['edit_summary'] . ' | '; + break; + case 'unprot': + echo ''; + echo ' | ' . $lang->get('history_log_unprotect') . ' | '; + echo '' . $lang->get('history_extra_reason') . ' ' . $row['edit_summary'] . ' | '; + break; + case 'semiprot': + echo ''; + echo ' | ' . $lang->get('history_log_semiprotect') . ' | '; + echo '' . $lang->get('history_extra_reason') . ' ' . $row['edit_summary'] . ' | '; + break; + case 'rename': + echo ''; + echo ' | ' . $lang->get('history_log_rename') . ' | '; + echo '' . $lang->get('history_extra_oldtitle') . ' ' . htmlspecialchars($row['edit_summary']) . ' | '; + break; + case 'create': + echo ''; + echo ' | ' . $lang->get('history_log_create') . ' | '; + echo ''; + break; + case 'delete': + echo ' | '; + echo ' | ' . $lang->get('history_log_delete') . ' | '; + echo '' . $lang->get('history_extra_reason') . ' ' . $row['edit_summary'] . ' | '; + break; + case 'reupload': + echo ''; + echo ' | ' . $lang->get('history_log_uploadnew') . ' | '; + echo '' . $lang->get('history_extra_reason') . ' ' . $row['edit_summary'] . ' | '; + break; } - else if($r['log_type']=='security') + + // actions column + echo ''; + 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_other' && $cnt_edits + $cnt_other >= $db->numrows($q) ) + { + 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'); + } ?> 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' ) ? '