} else { $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)
} //echo "here: ".$_SERVER['REQUEST_METHOD']; if ($user_logged_in) { //$edit_comment_id = ''; //var_dump($_GET); //print_r($_POST); if ($_POST) { $comment_text = isset($_POST['editComment']) && $_POST['editComment'] != 'undefined' ? $_POST['editComment'] : ""; //print "post comment text: ". $comment_text."<br/>\n"; $edit_comment_id = isset($_POST['editCommentId']) && $_POST['editCommentId'] != 'undefined' ? $_POST['editCommentId'] : ""; //print "post comment id: ". $edit_comment_id."<br/>\n"; if ($edit_comment_id != "") { $comment_text = rawurldecode($comment_text); //decode the url $commentManager = new CommentManager(); $edited_comment = $commentManager->getCommentById($edit_comment_id); //print "edited comment id: ". $edited_comment->getId()."<br/>"; //print "edited comment text: ". $edited_comment->getText()."<br/>"; //print "edited comment rating: ". $edited_comment->getRatingId()."<br/>"; //print "edited comment user: "******"<br/>"; //print "edited comment entry id: ". $edited_comment->getEntryId()."<br/>"; //--------handle badword-------------- $bw_handler = new BadwordManager(); $bw_list = $bw_handler->getBadWordList(); //print_r($bw_list); $replacement = $bw_handler->getReplacementList(); //print_r($replacement); $filtered_comment_text = preg_replace($bw_list, $replacement, $comment_text); //echo "edit comment filtered comment: ".$filtered_comment_text; $edited_comment->setText($filtered_comment_text); $updated_comment = $commentManager->updateComment($edited_comment);