Esempio n. 1
0
$lastCommentArr = null;
try {
    $lastCommentArr = orongo_query("action=fetch&object=comment&max=1&order=comment.id,desc&where=article.id:" . Security::escape($_POST['article']));
} catch (Exception $e) {
    die("500");
}
if (count($lastCommentArr) == 0) {
    errorDie("No new comments!", NO_NEW_COMMENTS);
    exit;
}
foreach ($lastCommentArr as $comment) {
    if ($comment instanceof Comment == false) {
        continue;
    }
    if ($comment->getID() <= $_POST['last_comment_id']) {
        errorDie("No new comments! ", NO_NEW_COMMENTS);
        exit;
    } else {
        $newLCID = $comment->getID();
    }
}
$newComments = null;
try {
    $newComments = orongo_query("action=fetch&object=comment&max=1000000&offset=" . Security::escape($_POST['offset']) . "&order=comment.id,asc&where=article.id:" . Security::escape($_POST['article']));
} catch (Exception $e) {
    die("500");
}
$newComments = array_reverse($newComments);
$html = "";
if (getStyle()->doCommentHTML()) {
    try {
Esempio n. 2
0
/**
 * fetchNotifications AJAX 
 * 
 * @author Jaco Ruit
 */
require '../startOrongo.php';
startOrongo();
define("NOT_LOGGED_IN", 1);
function errorDie($paramError, $paramErrorCode)
{
    $arrayToJs = array();
    $arrayToJs["response"] = $paramError;
    $arrayToJs["response_code"] = $paramErrorCode;
    die(json_encode($arrayToJs));
}
if (getUser() == null) {
    errorDie("Not logged in!", NOT_LOGGED_IN);
}
$arrayToJs = array();
$arrayToJs["notifications"] = array();
$count = 0;
foreach (getUser()->getNotifications() as $notification) {
    if ($notification["notification"] instanceof OrongoNotification == false) {
        continue;
    }
    $arrayToJs["notifications"][$count] = array("title" => $notification["notification"]->getTitle(), "text" => $notification["notification"]->getText(), "time" => $notification["notification"]->getTime(), "image" => $notification["notification"]->getImage());
    OrongoNotifier::deleteNotification($notification["id"]);
    $count++;
}
$arrayToJs["newNotifications"] = $count > 0 ? true : false;
die(json_encode($arrayToJs));
Esempio n. 3
0
define("OK", 31);
function errorDie($paramError, $paramErrorCode)
{
    $arrayToJs = array();
    $arrayToJs["response"] = $paramError;
    $arrayToJs["response_code"] = $paramErrorCode;
    die(json_encode($arrayToJs));
}
if (!isset($_POST['article']) || !is_numeric($_POST['article'])) {
    errorDie("No article!", NO_ARTICLE);
    exit;
}
if (!isset($_POST['content'])) {
    errorDie("Comment has no content!", NO_CONTENT);
    exit;
}
if (strlen($_POST['content']) < 3) {
    errorDie("Content is too short!", TOO_SHORT);
    exit;
}
$user = getUser();
if ($user == null) {
    errorDie("You need to be logged in in order to post comments.", NOT_LOGGED_IN);
    exit;
}
$comment = Comment::createComment(Security::escape($_POST['article']), $user);
$comment->setContent(Security::escape($_POST['content']));
$succesArray = array();
$succesArray["response"] = "Comment posted!";
$succesArray["response_code"] = OK;
die(json_encode($succesArray));