* */ require_once "src/base.inc.php"; require_once "src/header.inc.php"; echo "

Submit Post

"; // Process submission if (isset($_POST['category'])) { $required = array( 'title' => 'Title', 'description' => 'Description', 'category' => 'Category', 'email' => 'Email Address', 'email2' => 'Confirm Email Address', ); $error = ''; $values = array(); 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 ($_POST['tos'] != '1') { $error .= "

You must accept the terms of service.

"; } $category = Category::getByShortname(addslashes($values['category'])); if (!$category) { $error .= "

Invalid category.

"; } if ($error == '') { $post = new Post(); $post->setEmail($values['email']); $post->setCategory($category->getId()); $post->setName($values['title']); $post->setDescription($values['description']); // TODO: Set the source of the post. if ($post->save()) { $post->sendValidation(); // TODO: Revise wording. echo "

Your posting is awaiting email verification

"; } else { $error .= "An internal error has occured."; } } else { render_form($error); } } else { render_form(); } require_once "src/footer.inc.php"; function render_form($error="") { global $values; if ($error != '') { echo "
$error
"; } echo "
"; echo "

"; echo "

"; echo "

"; echo "

"; echo "

"; // TODO: Link to terms of service. echo "

"; // TODO: Allow picture uploads. echo "

"; } ?>