* */ require_once "src/base.inc.php"; require_once "src/header.inc.php"; const MAX_IMAGE_UPLOADS = 4; echo "
Start by choosing a category from the list below
"; // List Categories foreach (Category::getCategories() as $short => $name) { echo ""; } } function finish_category() { $post = $_SESSION['newpost']; if (isset($_GET['category'])) { $category = Category::getByShortname(addslashes($_GET['category'])); if ($category) { $post->setCategory($category->getId()); return true; } } handle_category(); return false; } function handle_tos() { // Display ToS // TODO: Display ToS Here form_start('post'); echo ""; form_end(); } function finish_tos() { if (isset($_POST['tos']) and $_POST['tos'] == 1) { return true; } else { header('Location: ' . $GLOBALS['CONFIG']['urlroot']); exit; } } function handle_post($error='') { // Display Form form_start('images'); render_form($error); form_end(); } function finish_post() { $post = $_SESSION['newpost']; $required = array( 'title' => 'Title', 'description' => 'Description', 'email' => 'Email Address', 'email2' => 'Confirm Email Address', ); $error = ''; $values = array('title' => '', 'description' => '', 'email' => '', 'email2' => ''); foreach ($required as $field => $desc) { if (!isset($_POST[$field]) or trim($_POST[$field]) == '') { $error .= "$desc is a required field.
"; } else { $values[$field] = trim($_POST[$field]); } } if ($values['email'] != $values['email2']) { $error .= "Email addresses must match.
"; } if ($error == '') { $post->setEmail($values['email']); $post->setName($values['title']); $post->setDescription($values['description']); if ($post->save()) { return true; } else { $error .= 'An internal error has occured.'; } } handle_post($error); return false; } function handle_images() { $post = $_SESSION['newpost']; // Display image form echo "You may upload up to four images with your post.
"; form_start('finish'); for ($i = 1; $i <= MAX_IMAGE_UPLOADS; $i++) { echo ""; } form_end(); } function finish_images() { $post = $_SESSION['newpost']; if (isset($_FILES['images'])) { foreach ($_FILES["images"]["error"] as $key => $error) { if ($error == UPLOAD_ERR_OK) { $post->addImage($_FILES['images']['tmp_name'][$key]); } } } return true; } function handle_finish() { $post = $_SESSION['newpost']; // Send validation email. $post->sendValidation(); // Display confirmation message echo "Your posting is almost complete. You must verify your email address by visiting the link we have emailed you, then your posting will be reviewed by our moderation team.
"; } function form_start($stage) { echo ""; } require_once "src/footer.inc.php"; function render_form($error="") { $title = isset($_POST['title']) ? $_POST['title'] : ''; $description = isset($_POST['description']) ? $_POST['description'] : ''; $email = isset($_POST['email']) ? $_POST['email'] : ''; $email2 = isset($_POST['email2']) ? $_POST['email2'] : ''; if ($error != '') { echo ""; echo "
" . "Your email address will only be visible to our moderators.
"; } ?>