$params = json_decode(file_get_contents('php://input'), true); $request = $params['r']; // should do safety check (null values, user permissions, etc.) if ($request == 'newPost') { //$post_id, $pinned, $board_id, $title, $content, $user_id echo DBSavePost(-1, $params['pinned'], $params['bName'], $params['title'], $params['content'], $_SESSION['UserID'], $params['addedTags'], $params['deletedTags']); //BY: $_SESSION['added/deletedTags'] to $params['added/deletedTags'] } else { if ($request == 'editPost') { if ($params['pId']) { DBSavePost($params['pId'], $params['pinned'], $params['bName'], $params['title'], $params['content'], $_SESSION['UserID'], $params['addedTags'], $params['deletedTags']); //BY: $_SESSION['added/deletedTags'] to $params['added/deletedTags'] } } else { if ($request == 'deletePost') { DBDeletePost($params['pId'], $_SESSION['UserID']); } else { if ($request == 'newComment') { $parentComment = $params['parentComment']; if ($parentComment == null) { $parentComment = -1; } $parentPost = $params['parentPost']; if ($parentPost == null) { $parentPost = -1; } echo DBSaveComment(-1, $parentPost, $parentComment, $params['content'], $_SESSION['UserID'], 0); } else { if ($request == 'editComment') { echo DBSaveComment($params['cId'], $params['parentPost'], $params['parentComment'], $params['content'], $_SESSION['UserID'], 0); } else {
include_once 'library.php'; // Note we are not using $_POST. // http://victorblog.com/2012/12/20/make-angularjs-http-service-behave-like-jquery-ajax/ $params = json_decode(file_get_contents('php://input'), true); $request = $params['r']; // should do safety check (null values, user permissions, etc.) if ($request == 'newPost') { echo DBNewPost($params['bName'], $params['title'], $params['content']); } else { if ($request == 'editPost') { if ($params['pId']) { DBEditPost($params['pId'], $params['title'], $params['content']); } } else { if ($request == 'deletePost') { DBDeletePost($params['pId']); } else { if ($request == 'newComment') { echo DBNewComment($params['parentPost'], $params['parentComment'], $params['content']); } else { if ($request == 'editComment') { DBEditComment($params['cId'], $params['content']); } else { if ($request == 'deleteComment') { DBDeleteComment($params['cId']); } } } } } }