exit; } $postID = $_POST['postID']; $comment = $_POST['comment']; //If comment is empty, show error if (trim($comment) == '') { echo MSG_COMMENT_EMPTY; exit; } //if Post Id was not set, show error if (!$postID) { echo MSG_INVALID_REQUEST; exit; } //Check the post id is correct if (!BuckysPost::checkPostID($postID)) { echo MSG_POST_NOT_EXIST; exit; } $post = BuckysPost::getPostById($postID); if ($post['visibility'] == 0 && $userID != $post['poster'] && !BuckysFriend::isFriend($userID, $post['poster'])) { //Only Friends can leave comments to private post echo MSG_INVALID_REQUEST; exit; } //If error, show it if (!($commentID = BuckysComment::saveComments($userID, $postID, $comment))) { echo $db->getLastError(); exit; } else { //Show Results