$user_logged_in = false; //redirect to homepage header("Location: http://localhost/tarboz/"); } //echo "here: ".$_SERVER['REQUEST_METHOD']; if ($user_logged_in) { //$delete_comment_id = ''; //var_dump($_GET); //print_r($_POST); if ($_POST) { $delete_comment_id = isset($_POST['deleteCommentId']) && $_POST['deleteCommentId'] != 'undefined' ? $_POST['deleteCommentId'] : ""; print "post comment id: " . $delete_comment_id . "<br/>\n"; if ($delete_comment_id != "") { $commentManager = new CommentManager(); $comment_to_delete = $commentManager->getCommentById($delete_comment_id); //print "deleted comment id: ". $comment_to_delete->getId()."<br/>\n"; //Delete comment $deleted_coment = $commentManager->DeleteComment($comment_to_delete); if (!$deleted_coment) { echo "Deleting comment #" . $delete_comment_id . " failed."; } else { echo "Deleting comment #" . $delete_comment_id . " succeeded."; } } else { echo "Finding a comment to delete failed."; } } else { echo "Posting a deleted comment failed."; } //end if($_POST) }
break; case ACTION_POST_COMMENT: $content = isset($_POST["content"]) ? $_POST["content"] : false; $entryId = isset($_POST["entry_id"]) ? $_POST["entry_id"] : false; if ($content && $entryId) { CommentManager::PostComment($loggedUser, $content, EntryType::XCLAM, $entryId); } break; case ACTION_EDIT_COMMENT_FORM: $id = $_GET["id"]; $editingComment = CommentManager::GetCommentById($id); $includedPage = "edit_comment"; break; case ACTION_SUBMIT_EDITED_COMMENT: $id = $_POST["id"]; $content = $_POST["content"]; $entryId = $_POST["entry_id"]; CommentManager::UpdateComment($id, $loggedUser, $content, EntryType::XCLAM, $entryId); break; case ACTION_DELETE_COMMENT: if (isset($_GET["id"])) { CommentManager::DeleteComment($_GET["id"]); } break; default: break; } } else { $message = "Please log in before take this action."; } include "pages/xclams/{$includedPage}.php";