Example #1
0
    $Comments->setPostId($vars['post']);
    $Archive->BuildData();
    $Comments->BuildData();
    //
    if ($_POST['post_submit'] == "true") {
        if (!isset($_SESSION['userid']) && isal_num($_SESSION['userid'])) {
            $error[] = "User ID Session variable is missing";
        }
        if (!isset($vars['post']) && isal_num($vars['post'])) {
            $error[] = "Post ID GET variable is missing";
        }
        if (strlen($_POST['comment']) < 10) {
            $error[] = "Comment must be longer than 10 characters long";
        }
        if (!count($error)) {
            $var = array("user_id" => $_SESSION['userid'], "post_id" => $_POST['post'], "comment" => $_POST['comment']);
            $Comments->Insert($var);
            $status = "success";
        } else {
            $status = "failed";
        }
    } else {
        $status = "unknown";
    }
    $smarty->assign(array("page_name" => "News&nbsp;:&nbsp;Comment", "load" => "news/comments.tpl", "filename" => $Archive->getFilename(), "archive_index" => $Archive->getIndex(), "records" => $Archive->getRecords(), "comments" => $Comments->getRecords(), "page_list" => $Comments->getCountDisplay(), "sql_queries" => array_merge($Archive->getSQLQueries(), $Comments->getSQLQueries()), "status" => $status, "errors" => $error));
    $smarty->display('public/body/index.tpl');
    echo "<!-- page rendered in approx {$timer->Stop()} -->";
} catch (Exception $e) {
    $smarty->assign(array("exception" => $e->getMessage()));
    $smarty->display('public/body/error.tpl');
}