diff -r 1e40b33f2e3e -r c949e82b8f49 index.php --- a/index.php Mon Apr 13 12:32:36 2009 -0400 +++ b/index.php Mon Apr 13 14:43:28 2009 -0400 @@ -329,39 +329,92 @@ $template->footer(); break; case 'protect': - if (!isset($_REQUEST['level'])) die_friendly('Invalid request', '
No protection level specified
'); - require_once(ENANO_ROOT.'/includes/pageutils.php'); - if(!empty($_POST['reason'])) + if ( isset($_POST['level']) && isset($_POST['reason']) ) { - if(!preg_match('#^([0-2]*){1}$#', $_POST['level'])) die_friendly('Error protecting page', 'Request validation failed
'); - PageUtils::protect($paths->page_id, $paths->namespace, intval($_POST['level']), $_POST['reason']); + $level = intval($_POST['level']); + if ( !in_array($level, array(PROTECT_FULL, PROTECT_SEMI, PROTECT_NONE)) ) + { + $errors[] = 'bad level'; + } + $reason = trim($_POST['reason']); + if ( empty($reason) ) + { + $errors[] = $lang->get('onpage_protect_err_need_reason'); + } - die_friendly($lang->get('page_protect_lbl_success_title'), '' . $lang->get('page_protect_lbl_success_body', array( 'page_link' => makeUrl($paths->page) )) . '
'); + $page = new PageProcessor($paths->page_id, $paths->namespace); + $result = $page->protect_page($level, $reason); + if ( $result['success'] ) + { + redirect(makeUrl($paths->page), $lang->get('page_protect_lbl_success_title'), $lang->get('page_protect_lbl_success_body', array('page_link' => makeUrl($paths->page, false, true))), 3); + } + else + { + $errors[] = $lang->get('page_err_' . $result['error']); + } } $template->header(); ?> footer();