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 '
' . $lang->get('editor_err_captcha_wrong') . '
'; + } if(isset($_POST['_preview'])) { $text = $_POST['page_text']; @@ -153,8 +172,21 @@

'; - if($paths->wiki_mode) - echo $lang->get('editor_lbl_edit_summary') . '

'; + echo $lang->get('editor_lbl_edit_summary') . '

'; + if ( !$session->user_logged_in && getConfig('guest_edit_require_captcha') == '1' ) + { + echo '
'; + 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 '
'; + } echo '