# HG changeset patch # User Dan # Date 1198818207 18000 # Node ID 491518997ae5e6a9a59b51c00b044934896ed097 # Parent bfa2e9c23f0346108183e6acf2781a785441dd2b Made CAPTCHA for guests' page editing work with the non-AJAX interface diff -r bfa2e9c23f03 -r 491518997ae5 index.php --- a/index.php Thu Dec 27 23:32:11 2007 -0500 +++ b/index.php Fri Dec 28 00:03:27 2007 -0500 @@ -130,13 +130,32 @@ } if(isset($_POST['_save'])) { - $e = PageUtils::savepage($paths->page_id, $paths->namespace, $_POST['page_text'], $_POST['edit_summary'], isset($_POST['minor'])); - if ( $e == 'good' ) + $captcha_valid = true; + if ( !$session->user_logged_in && getConfig('guest_edit_require_captcha') == '1' ) { - redirect(makeUrl($paths->page), $lang->get('editor_msg_save_success_title'), $lang->get('editor_msg_save_success_body'), 3); + $captcha_valid = false; + if ( isset($_POST['captcha_id']) && isset($_POST['captcha_code']) ) + { + $hash_correct = strtolower($session->get_captcha($_POST['captcha_id'])); + $hash_input = strtolower($_POST['captcha_code']); + if ( $hash_input === $hash_correct ) + $captcha_valid = true; + } + } + if ( $captcha_valid ) + { + $e = PageUtils::savepage($paths->page_id, $paths->namespace, $_POST['page_text'], $_POST['edit_summary'], isset($_POST['minor'])); + if ( $e == 'good' ) + { + redirect(makeUrl($paths->page), $lang->get('editor_msg_save_success_title'), $lang->get('editor_msg_save_success_body'), 3); + } } } $template->header(); + if ( isset($captcha_valid) ) + { + echo '
'; + } if(isset($_POST['_preview'])) { $text = $_POST['page_text']; @@ -153,8 +172,21 @@';
+ echo '' . $lang->get('editor_lbl_field_captcha') . ' ' + . ' ' + . $lang->get('editor_msg_captcha_pleaseenter') . ' ' + . $lang->get('editor_msg_captcha_blind'); + echo ' | ';
+ $hash = $session->make_captcha();
+ echo ' '; + echo ''; + echo $lang->get('editor_lbl_field_captcha_code') . ' '; + echo ' |