<?php $forums = new Forums(); $user = new User(); if (!$forums->getCat(escape($cat))) { Redirect::to('/404'); // TODO MAKE 404 } if (!$user->isLoggedIn()) { Session::flash('error', 'It seems you are not logged in!'); Redirect::to(path . 'index.php'); } if (Input::exists()) { if (Input::get('Submit')) { if (Token::check(Input::get('token'))) { $val = new Validation(); $validate = $val->check($_POST, array('title' => array('required' => true), 'content' => array('required' => true))); if ($validate->passed()) { try { $forums->createPost(array('post_title' => escape(Input::get('title')), 'cat_id' => escape($cat), 'post_cont' => Input::get('content'), 'post_date' => date('Y-m-d- H:i:s'), 'post_user' => $user->data()->id)); $db = DB::getInstance(); $post = $db->get('post', array('1', '=', '1'))->count(); $post = $post; session::flash('complete', 'You posted your post!'); Redirect::to("/forums/view/" . escape($cat) . "/" . $post); } catch (Exception $e) { die($e->getMessage()); } } else { } } else {
?> </head> <body> <?php require 'inc/templates/nav.php'; ?> <div class="container"> <div class="col-md-3"> <?php include 'pages/admin/nav.php'; ?> </div> <div class="col-md-9"> <form method="post" action=""> <div class="form-group"> <input class="form-control" name="title" type="text" placeholder="Title" value="<?php echo $forums->getCat(Input::get('c'))[0]->name; ?> "> </div> <div class="form-group"> <select name="cat_par"> <option <?php if (!$forums->getCat(Input::get('c'))[0]->parent) { ?> selected="selected"<?php } ?> value="NULL">No parent</option> <?php foreach ($forums->getCatParent() as $cat) { ?>
echo '<div class="alert alert-info">You need to <a class="alert-link" href="/login">login</a> or <a class="alert-link" href="/register">sign up</a> to get the full features of this page</div>'; } ?> <div class="jumbotron"> <h1><?php Setting::show('title'); ?> </h1><br/> <h3><?php Setting::show('motd'); ?> </h3> </div> <div class="col-md-9"> <?php if (!$forums->getCat()) { echo '<div class="alert alert-info">There is no categoies at this time please contact an administrator!</div>'; } else { foreach ($forums->listParentCat() as $parent) { echo "<div class='panel panel-primary'><div class='panel-heading'>{$parent['name']}</div><div class='panel-body'>"; foreach ($forums->listChildCat($parent['id']) as $child) { echo "<a href='/forums/cat/{$child['id']}'>{$child['name']}</a><br/>"; } echo "</div></div>"; } } ?> </div> </div> <?php include 'inc/templates/foot.php';