Esempio n. 1
0
<?php

require_once __DIR__ . '/../includes/helpers.php';
require_once __DIR__ . '/../loader.php';
if (empty($_GET['id']) and empty($_GET['slug'])) {
    redirect_to("index.php");
}
if (isset($_GET['id'])) {
    $p = Pics::getPic($_GET['id']);
} else {
    $p = Pics::getBySlug($_GET['slug']);
}
$c = Comment::findComments($p->id);
if (!$p) {
    redirect_to("index.php");
}
if (isset($_POST['submit'])) {
    if (CSRF::check($_POST['token'])) {
        $author = htmlspecialchars($_POST['author']);
        $body = htmlspecialchars($_POST['body']);
        $comment = Comment::make($p->id, $author, $body);
        if ($comment) {
            $comment->create();
            $msg = opmsg("Comment posted successfully and awaiting moderation!", "success");
        } else {
            $msg = opmsg("Failed", "danger");
        }
    } else {
        $msg = opmsg("Failed", "danger");
    }
} else {