prepare("SELECT * FROM comments WHERE id = :cid"); $getcstmt->bindParam(":cid", $_GET["delc"]); $getcstmt->execute(); $comment = $getcstmt->fetch(PDO::FETCH_ASSOC); //Putting comment into "deleted" datebase $mcstmt = $conn->prepare("INSERT INTO deletedComments (post_id, poster_id, date, text, reports) VALUES (:post, :pstr, :date, :text, :rpts)"); $mcstmt->bindParam(":post", $comment["post_id"]); $mcstmt->bindParam(":pstr", $comment["poster_id"]); $mcstmt->bindParam(":date", $comment["date"]); $mcstmt->bindParam(":text", $comment["text"]); $mcstmt->bindParam(":rpts", $comment["reports"]); $mcstmt->execute(); //Removing the comment from the normal database $cstmt = $conn->prepare("DELETE FROM comments WHERE id = :cid"); $cstmt->bindParam(":cid", $_GET["delc"]); $cstmt->execute(); //Giving feedback and redirecting if(!$mcstmt || !$cstmt){ reportError("A comment couldn't be deleted in /forum/post/index.php"); msg("Couldn't delete comment. It has been reported for you"); }else{ msg("Comment deleted"); } header("Location: /forum/post/?post=".$_GET["post"]); } //reporting comment if(isset($_GET["repc"])){ $stmt = $conn->prepare("SELECT * FROM comments WHERE id = :id"); $id = $_GET["repc"]; $stmt->bindParam(":id", $id); $stmt->execute(); $delc = $stmt->fetch(PDO::FETCH_OBJ); $rep = $delc->reports; if(strContains($rep, $current_user)){ $prevRep = true; }else{ $prevRep = false; $rep .= $current_user.","; } $stmt = $conn->prepare("UPDATE comments SET reports = :rep WHERE id = :id"); $id = $_GET["repc"]; $stmt->bindParam(":id", $id); $stmt->bindParam(":rep", $rep); $stmt->execute(); if($stmt){ msg($prevRep==true?"You already reported that comment.":"Comment reported"); header("Location: /forum/post/?post=".$_GET["post"]); }else{ reportError("Error reporting comment in /forum/post/index.php - a"); msg("Error reporting comment. This error has been reported."); header("Location: /forum/post/?post=".$_GET["post"]); } } //Getting and storing the post info to echo later $post = getPostInfo($_GET["post"]); $poster_id = $post->poster_id; $title = $post->title; $content = hyperlink($post->content); $content = decodeUserLink($post->content); $section = $post->section=="none"?"":ucwords(str_replace("_", " ", $post->section)); $type = $post->type=="other"?"":strtolower($post->type); $type = $section==""?ucwords($type):$type; $section = $section==$type?"No topic":$section; $date = $post->date; $images = $post->image; $poster = getUserInfo($poster_id)->name; //Checking if the user has this post bookmarked for un/bookmarking $stmt = $conn->prepare("SELECT * FROM bookmarks WHERE post_id = :pid AND user_id = :uid"); $stmt->bindParam(":pid", $_GET["post"]); $stmt->bindParam(":uid", $current_user); $stmt->execute(); $res = $stmt->fetch(PDO::FETCH_OBJ); $bk = $res->user_id==$current_user?true:false; //Bookmarking the post if(isset($_GET["bkmk"]) && $_GET["bkmk"] =="t" && !$bk){ $stmt = $conn->prepare("INSERT INTO bookmarks (post_id, user_id) VALUES (:pid, :uid)"); $stmt->bindParam(":pid", $_GET["post"]); $stmt->bindParam(":uid", $current_user); $stmt->execute(); if($stmt){ msg("Post saved. You can find it on your account page."); header("Location: /forum/post/?post=".$_GET["post"]); }else{ reportError("Error while saving post in /forum/post/index.php - b"); msg("Error! It has been reported automatically."); header("Location: /forum/post/?post=".$_GET["post"]); } } //Unbookmarking the post if(isset($_GET["bkmk"]) && $_GET["bkmk"] =="f"&&$bk){ $stmt = $conn->prepare("DELETE FROM bookmarks WHERE post_id = :pid AND user_id = :uid"); $stmt->bindParam(":pid", $_GET["post"]); $stmt->bindParam(":uid", $current_user); $stmt->execute(); if($stmt){ msg("Post unsaved."); header("Location: /forum/post/?post=".$_GET["post"]); }else{ reportError("Error unsaving post in /forum/post/index.php - c"); msg("Error! It has already been reported for you."); header("Location: /forum/post/?post=".$_GET["post"]); } } //Checking if the user has this post bookmarked $stmt = $conn->prepare("SELECT * FROM bookmarks WHERE post_id = :pid AND user_id = :uid"); $stmt->bindParam(":pid", $_GET["post"]); $stmt->bindParam(":uid", $current_user); $stmt->execute(); $res = $stmt->fetch(PDO::FETCH_OBJ); $bk = $res->user_id==$current_user?true:false; //Reporting the post if(isset($_GET["reportPost"])){ $post = getPostInfo($_GET["post"]); $current = $post->reports; if(strpos($current, $current_user) === false){ $new = $current.$current_user.","; $stmt = $conn->prepare("UPDATE forums SET reports = :new WHERE post_id = :id"); $stmt->bindParam(":new", $new); $stmt->bindParam(":id", $post->post_id); $stmt->execute(); if($stmt){ msg("Post reported."); header("Location: /forum/post/?post=".$_GET["post"]); }else{ reportError("Error reporting post in /forum/post/index.php - d"); msg("Error reporting post. This error has been reported."); header("Location: /forum/post/?post=".$_GET["post"]); } }else{ msg("You already reported this post."); header("Location: /forum/post/?post=".$_GET["post"]); } } ?>

Posted by

"; foreach(explode(",", substr($images, 0, -1)) as $file){ //substr gets rid of the last comma, explode makes the array $exType = substr($file, strpos($file, '.')+1); $docFiles = ["doc", "docx", "pdf"]; $imgFiles = ["jpg", "jpeg", "png"]; //image stuff if(in_array($exType, $docFiles)){ echo ""; // }else if(in_array($exType, $imgFiles)){ echo ""; } } } ?>

id == $current_user){ $datediff = time() - strtotime($date); $mins = round($datediff / (60)); if($mins <= 5){ $editable = " | edit"; } echo "

delete$editable

"; }else{ echo "

report

"; } ?> &bkmk=>