Exemple #1
0
<?php

$forums = new Forums();
$user = new User();
if ($cat && $post_id) {
    if (!$forums->getPost(escape($cat), escape($post_id))) {
        Redirect::to('/404');
        // TODO MAKE 404
    }
} else {
    Redirect::to('/404');
    //TODO: MAKE 404
}
if (!$user->isLoggedIn()) {
    Session::flash('error', 'It seems you are not logged in!');
    Redirect::to('/');
}
$db = DB::getInstance();
$q = $db->get('post', array('id', '=', escape($post_id)))->first();
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->createReply(array('title' => escape(Input::get('title')), 'post_id' => escape($post_id), 'content' => Input::get('content'), 'date' => date('Y-m-d- H:i:s'), 'user_id' => $user->data()->id));
                    Notifaction::createMessage($user->data()->username . ' posted a reply on your page', $forums->getPost2($post_id)->post_user);
                    session::flash('complete', 'You posted your reply!');
                    Redirect::to('/forums/view/' . $cat . '/' . $post_id);
                } catch (Exception $e) {
Exemple #2
0
<?php

$user = new User();
$forums = new Forums();
if (!$cat && !$post_id) {
    session::flash('error', 'There was no valid page! You have been taken back to the homepage!');
    Redirect::to('/');
}
$post = $forums->getPost($cat, $post_id);
$post = $post[0];
$author = new User($post->post_user);
?>
<html>
	<head>
		<?php 
include 'inc/templates/head.php';
?>
	</head>
	<body>
		<?php 
include 'inc/templates/nav.php';
?>
		<?php 
if (Session::exists('error')) {
    ?>
			<div class="alert alert-danger"><?php 
    echo Session::flash('error');
    ?>
</div>
		<?php 
}
Exemple #3
0
				<?php 
if ($cat) {
    if ($cat != null) {
        echo "<h1>Posts</h1><a href=\"/forums/create/{$cat}\">Create Post</a>";
        ?>
				<table class='table table-striped table-hover'>
					<thead>
						<tr>
							<th>ID #</th>
							<th>Name</th>
							<th>User</th>
						</tr>
					</thead>
					<tbody>
						<?php 
        foreach ($forums->getPost(escape($cat)) as $post) {
            $author = new User($post->post_user);
            ?>
						<tr>
							<td><?php 
            echo $post->id;
            ?>
</td>
							<td><?php 
            echo $post->post_title;
            ?>
</td>
							<td><?php 
            echo $author->data()->username;
            ?>
</td>
Exemple #4
0
				<?php 
if (Input::exists('get')) {
    if (Input::get('cat') != null) {
        echo "<h1>Posts</h1><a href=\"/forums/create/\">Create Post</a>";
        ?>
				<table class='table table-striped table-hover'>
					<thead>
						<tr>
							<th>ID #</th>
							<th>Name</th>
							<th>User</th>
						</tr>
					</thead>
					<tbody>
						<?php 
        foreach ($forums->getPost(escape(Input::get('cat'))) as $post) {
            $author = new User($post->post_user);
            ?>
						<tr>
							<td><?php 
            echo $post->id;
            ?>
</td>
							<td><?php 
            echo $post->post_title;
            ?>
</td>
							<td><?php 
            echo $author->data()->username;
            ?>
</td>