initial commit
This commit is contained in:
51
forum/foo.php
Normal file
51
forum/foo.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Please note that files uploaded are placed in /forum/images (even non-image
|
||||
* files) because this function used to only be for images. It has since been
|
||||
* updated to allow for doc files too.
|
||||
*
|
||||
**/
|
||||
|
||||
require $_SERVER['DOCUMENT_ROOT']."/globalFuncs.php";
|
||||
restrictAccess("owner");
|
||||
echo("Change the file /forum/foo.php if you really want to do this");
|
||||
exit();
|
||||
exit();//just to be safe lol
|
||||
conn();
|
||||
|
||||
$lipsum = "Sed facilis libero enim. Omnis molestias ut nihil a ea rem magnam repellat. Dolorum fugit quod quo ipsam qui molestiae aut. Voluptatem doloribus sint natus aut sequi illum quo. Ut est et ut odio et et totam. Et saepe quis maxime rerum et omnis qui. Tenetur sunt ratione iure atque aut blanditiis. Vitae consequuntur esse et qui. Officia sunt eum et distinctio sunt aut rem et. Excepturi nostrum et cum. Id aut delectus id sit. Sed impedit placeat in eos et qui ab. Distinctio doloremque veritatis qui velit voluptas. Velit corporis soluta similique et. Et iure enim quaerat aut qui non porro neque. Laudantium non voluptas illum error sit qui expedita. Deserunt similique officiis blanditiis voluptatibus dicta ea sunt. Deserunt aut reprehenderit ut quia minima facere. Praesentium facere laudantium nisi quasi corrupti accusantium perferendis quidem. Quo dolorem maiores iure officiis aspernatur eos. Quisquam ut excepturi facilis iusto nemo fugiat. Et sequi nostrum asperiores unde cumque perspiciatis aperiam. Pariatur adipisci eum illo quis maxime fugit consequatur. Quo sit fugiat voluptatum. Quia soluta ex ut neque aliquam aperiam. Aperiam ut ad enim. Voluptas ducimus rem fugit. Tempora autem voluptatem cum aliquid. Dolorum iure impedit cumque vel soluta dolores alias. Voluptatem rerum tempora accusantium deserunt nam voluptatem. Voluptas non cum nostrum. Enim possimus vero voluptas rem est voluptatem odit. Ea laudantium odio soluta molestias eligendi aut. Repellendus tempore et consectetur beatae praesentium. Dolorum id quis ad. Est nihil et debitis dolor laborum delectus cum aspernatur. Aliquam voluptates ipsum velit delectus laudantium. Suscipit ratione quia ea hic non veritatis eos neque. Quas quos impedit perferendis sed pariatur quisquam et. Dolores eveniet quas adipisci itaque ipsa veritatis cum nisi.";
|
||||
$tipsum = "Suscipit ratione quia ea hic non veritatis eos neque. Quas quos impedit perferendis sed pariatur quisquam et. Dolores eveniet quas adipisci itaque ipsa veritatis cum nisi";
|
||||
function random_pic(){
|
||||
$files = glob('images/*.*');
|
||||
$file = array_rand($files);
|
||||
return basename($files[$file]).",";
|
||||
}
|
||||
|
||||
for($i=1; $i<=100; $i++){
|
||||
$pid = randID();
|
||||
$uid = $current_user;
|
||||
$sbj = "none";
|
||||
$typ = "other";
|
||||
$ttl = "$i: ".substr($tipsum, 0, rand(0, strlen($tipsum)));
|
||||
$ctt = substr($lipsum, 0, rand(0, strlen($lipsum)));
|
||||
$img = rand(0,19)<=5?random_pic():NULL;
|
||||
|
||||
$stmt = $conn->prepare("INSERT INTO forums (post_id, poster_id, section, type, title, content, image) VALUES (:pid, :uid, :sbj, :typ, :ttl, :ctt, :img)");
|
||||
$stmt->bindParam(":pid", $pid);
|
||||
$stmt->bindParam(":uid", $uid);
|
||||
$stmt->bindParam(":sbj", $sbj);
|
||||
$stmt->bindParam(":typ", $typ);
|
||||
$stmt->bindParam(":ttl", $ttl);
|
||||
$stmt->bindParam(":ctt", $ctt);
|
||||
$stmt->bindParam(":img", $img);
|
||||
$stmt->execute();
|
||||
if(!$stmt){
|
||||
msg("Error fooing posts :(");
|
||||
header("Location: /forum");
|
||||
}
|
||||
|
||||
}
|
||||
msg("Success fooing posts :D");
|
||||
header("Location: /forum")
|
||||
?>
|
||||
BIN
forum/images/7Lb0k3.docx
Normal file
BIN
forum/images/7Lb0k3.docx
Normal file
Binary file not shown.
BIN
forum/images/EeaU8c.docx
Normal file
BIN
forum/images/EeaU8c.docx
Normal file
Binary file not shown.
BIN
forum/images/JkocQZ.docx
Normal file
BIN
forum/images/JkocQZ.docx
Normal file
Binary file not shown.
BIN
forum/images/LvHBpe.docx
Normal file
BIN
forum/images/LvHBpe.docx
Normal file
Binary file not shown.
BIN
forum/images/OFCtQg.docx
Normal file
BIN
forum/images/OFCtQg.docx
Normal file
Binary file not shown.
BIN
forum/images/R1GF5H.docx
Normal file
BIN
forum/images/R1GF5H.docx
Normal file
Binary file not shown.
BIN
forum/images/TOFPvl.docx
Normal file
BIN
forum/images/TOFPvl.docx
Normal file
Binary file not shown.
BIN
forum/images/rQZFd.pdf
Normal file
BIN
forum/images/rQZFd.pdf
Normal file
Binary file not shown.
41
forum/index.php
Normal file
41
forum/index.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
require $_SERVER['DOCUMENT_ROOT']."/globalFuncs.php";
|
||||
conn();
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<?php
|
||||
include "../res/head";
|
||||
?>
|
||||
<body>
|
||||
<?php include "../res/top"; ?>
|
||||
<div id=container>
|
||||
|
||||
<div id=left>
|
||||
<?php
|
||||
$limit = 10;
|
||||
$page = is_numeric($_GET["page"])&&$_GET["page"]>0?$_GET["page"]:1;
|
||||
$start = $limit * ($page - 1);
|
||||
$stmt = $conn->prepare("SELECT * FROM forums ORDER BY date DESC LIMIT $start,$limit");
|
||||
$stmt->execute();
|
||||
foreach($stmt->fetchAll() as $post){
|
||||
makePost($post);
|
||||
}
|
||||
|
||||
//checking if there would be results on the next page
|
||||
$row = $start+$limit;
|
||||
$stmt = $conn->prepare("SELECT * FROM forums ORDER BY date DESC LIMIT $row,1");
|
||||
$stmt->execute();
|
||||
$moreResults = $stmt->rowCount();
|
||||
?>
|
||||
<div id=pages>
|
||||
<?php
|
||||
echo $page!=1?"<div id=prevPage><a href=/forum/?page=".($page-1).">←</a></div>":"<div></div>";
|
||||
echo $moreResults?"<div id=nextPage><a href=/forum/?page=".($page+1).">→</a></div>":"<div></div>";
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
<?php include $_SERVER['DOCUMENT_ROOT']."/res/notifs"; ?>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
216
forum/post/index.php
Normal file
216
forum/post/index.php
Normal file
@@ -0,0 +1,216 @@
|
||||
<?php
|
||||
require $_SERVER['DOCUMENT_ROOT']."/globalFuncs.php";
|
||||
conn();
|
||||
|
||||
//Deleting comments
|
||||
if(isset($_GET["delc"])){
|
||||
$getcstmt = $conn->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"]);
|
||||
}
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<?php
|
||||
$css = '/comments';
|
||||
$css2 = 'post';
|
||||
include "../../res/head";
|
||||
?>
|
||||
<body>
|
||||
<?php
|
||||
include "../../res/top";
|
||||
?>
|
||||
<div class="container card noHover">
|
||||
<div id=post>
|
||||
<div class="forum card noShadow">
|
||||
<div class=info>
|
||||
<p onclick="document.location.href = '/search/?q=<?=$section;?>:+'; return false" class=postType><?=$section." ".$type; ?></p>
|
||||
<p>Posted <?=makeDate($date);?> by <span onclick="document.location.href = '/user/?user=<?=$poster_id;?>'; return false" class=userlink><?=$poster;?></span></p>
|
||||
</div>
|
||||
<div class=title>
|
||||
<h2><?=$title;?></h2>
|
||||
</div>
|
||||
<div class=content>
|
||||
<p>
|
||||
<?=$content;?>
|
||||
<?php
|
||||
if($images != NULL){
|
||||
echo "<input type=checkbox id=hideImgs>
|
||||
<label for=hideImgs id=hide class=noSelect>HIDE ATTACHMENTS</label>
|
||||
<label for=hideImgs id=show class=noSelect>SHOW ATTACHMENTS</label>";
|
||||
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 "<iframe class='postDocPreview toggleView' src=https://docs.google.com/gview?url=http://ib.lukeogburn.com/forum/images/$file&embedded=true></iframe>";
|
||||
//<embed src="file_name.pdf" width="800px" height="2100px" />
|
||||
}else if(in_array($exType, $imgFiles)){
|
||||
echo "<img class='postImage toggleView' src=/forum/images/$file>";
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class=postBottom>
|
||||
<?php
|
||||
if(getUserInfoByName($poster)->id == $current_user){
|
||||
$datediff = time() - strtotime($date);
|
||||
$mins = round($datediff / (60));
|
||||
if($mins <= 5){
|
||||
$editable = " | <a id=editPost href=/post/edit.php?post=".$_GET['post'].">edit</a>";
|
||||
}
|
||||
echo "
|
||||
<p class=postActions><a id=deletePost href=/post/delete.php?post=".$_GET['post'].">delete</a>$editable</p>";
|
||||
}else{
|
||||
echo "<p><a href=?post=".$_GET['post']."&reportPost=true class=postReport>report</a></p>";
|
||||
}
|
||||
?>
|
||||
<i class=material-icons><a class="postSave" href=?post=<?=$_GET['post'];?>&bkmk=<?=$bk?"f":"t";?>><?=$bk?"bookmark":"bookmark_outline";?></a></i>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php include "../../res/comments"; ?>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
126
forum/post/post.css
Normal file
126
forum/post/post.css
Normal file
@@ -0,0 +1,126 @@
|
||||
/* ------------- Global post ------------- */
|
||||
.container{
|
||||
width: 60%;
|
||||
margin: 2% auto 0 auto;
|
||||
color: #333;
|
||||
background-color: white;
|
||||
margin-bottom: 2em;
|
||||
border-radius: 0.2em;
|
||||
padding: 1em 2em;
|
||||
line-height: 1.3em;
|
||||
}
|
||||
.container>*{
|
||||
border-radius: 0.3em;
|
||||
}
|
||||
/* General forum stuff */
|
||||
.forumLink{
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
|
||||
/* ------------- Post ------------- */
|
||||
/* Title, username, time posted */
|
||||
.title>h2{
|
||||
margin: 0.5em 0;
|
||||
line-height: 1.2em;
|
||||
}
|
||||
.info>*{
|
||||
font-size: 0.75em;
|
||||
color: #aaa;
|
||||
margin: 0;
|
||||
display: inline-block;
|
||||
}
|
||||
.userlink:hover, .postType:hover{
|
||||
text-decoration: underline;
|
||||
}
|
||||
.postType{
|
||||
color: #888;
|
||||
font-weight: bold;
|
||||
margin: 0 0.5em 0 0.2em;
|
||||
}
|
||||
/* Text and image */
|
||||
.content>p{
|
||||
margin: 0;
|
||||
}
|
||||
.forum.card{
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
.postImage{
|
||||
margin-top: 1em;
|
||||
width: 100%;
|
||||
border-radius: 0.3em;
|
||||
}
|
||||
.postDocPreview{
|
||||
margin-top: 1em;
|
||||
width: 100%;
|
||||
border-radius: 0.2em;
|
||||
border: 1px solid #999;
|
||||
height: 50vh;
|
||||
}
|
||||
#show:hover, #hide:hover{
|
||||
cursor: pointer;
|
||||
}
|
||||
#hideImgs{
|
||||
display: none;
|
||||
}
|
||||
#hideImgs ~ #hide{
|
||||
display: block;
|
||||
}
|
||||
#hideImgs ~ #show{
|
||||
display: none;
|
||||
}
|
||||
#hideImgs:checked ~ #hide{
|
||||
display: none;
|
||||
}
|
||||
#hideImgs:checked ~ #show{
|
||||
display: block;
|
||||
}
|
||||
#hideImgs ~ label{
|
||||
margin-top: 2em;
|
||||
color: #00d09f;
|
||||
text-align: center;
|
||||
font-size: 0.9em;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
#hideImgs:checked ~ .toggleView{
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* Fixing tag-padding issue
|
||||
.tags>p{
|
||||
padding: 0em 0.5em;
|
||||
}*/
|
||||
/* Reporting and saving */
|
||||
.postBottom{
|
||||
display: block;
|
||||
height: 1.5em;
|
||||
font-size: 1em;
|
||||
padding: 0 1em;
|
||||
display: grid;
|
||||
align-content: center;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
}
|
||||
.postReport, .postActions{
|
||||
margin: 0;
|
||||
font-size: 0.8em;
|
||||
color: #999;
|
||||
}
|
||||
.postReport{
|
||||
color: #922;
|
||||
text-decoration: none;
|
||||
}
|
||||
.postActions>a{
|
||||
color: #888;
|
||||
text-decoration: none;
|
||||
}
|
||||
.postActions>a:hover,.postReport:hover{
|
||||
text-decoration: underline;
|
||||
}
|
||||
.postSave{
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
float: right;
|
||||
}
|
||||
.postSave>*{
|
||||
float: right;
|
||||
}
|
||||
Reference in New Issue
Block a user