* */ require_once('../../src/base.inc.php'); // Verify User is admin if (!isset($_SESSION['currentUser']) or !$_SESSION['currentUser']->isAdmin()) { header('Location: ' . buildUrl('moderate/')); exit; } $error = ''; // Get the current user object. $page = new Page(); if (isset($_GET['id']) and is_numeric($_GET['id'])) { $page = Page::getById($_GET['id']); } // Save changes? if ($_SERVER['REQUEST_METHOD'] == 'POST') { // Title if (isset($_POST['title']) and trim($_POST['title']) != '') { $page->setTitle($_POST['title']); } else { $error .= '

Title is a required field.

'; } // URL if (isset($_POST['url']) and trim($_POST['url']) != '') { $page->setURL($_POST['url']); } else { $error .= '

URL is a required field.

'; } // Content if (isset($_POST['content']) and trim($_POST['content']) != '') { $page->setContent($_POST['content']); } else { $error .= '

Content is a required field.

'; } // Save if ($error == '') { if ($page->save()) { // Return to pages list header("Location: index.php"); } else { $error .= '

An error has occured.

'; } } } require_once('../src/header.inc.php'); echo "

Edit Page

"; if ($error != '') { echo "
$error
"; } $url = "editor.php"; if (isset($_GET['id'])) { $url .= '?id=' . $_GET['id']; } echo "
"; ?>

Cancel