The following files exists in this folder. Click to view.
blogwatcher.php103 lines ASCII Unix (LF) 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
<?php
include("check_session.php");
require_once('databaseconnection.php');
$sql = "SELECT `content`, `url`, `type`, `order` FROM contentarea WHERE postId = :postId";
$stm = $pdo->prepare($sql);
$stm->execute(['postId' => $_GET["mess"]]);
$dbOutput = $stm->fetchAll(PDO::FETCH_ASSOC);
$sql = "SELECT `headline`, `date`, `author`, `blogName`, `authorId`, `blogId` FROM post WHERE postId = :postId";
$stm = $pdo->prepare($sql);
$stm->execute(['postId' => $_GET["mess"]]);
$postInfo = $stm->fetch(PDO::FETCH_ASSOC);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?php echo"{$dbOutput[0]["content"]}";?></title>
<link rel="stylesheet" href="/spectre/spectre-master/dist/spectre.css">
<script src="https://kit.fontawesome.com/0b0c9a8dc7.js" crossorigin="anonymous"></script>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Special+Gothic+Expanded+One&family=Special+Gothic:wght@400..700&display=swap" rel="stylesheet">
<style>
#navTop{
font-family: "Special Gothic Expanded One", Helvetica;
}
</style>
</head>
<body style="text-align:center;">
<header class="navbar">
<section class="navbar-section">
<a href="settings.php" class="btn btn-link">Settings</a>
<a href="home.php" class="btn btn-link">Home</a>
</section>
<section class="navbar-center">
<h3 id="navTop">PHiNTERNET</h3>
</section>
<section class="navbar-section">
<a href="newpost.php" class="btn btn-link">Create Post</a>
<a href="profile.php?mess=<?php echo"{$_SESSION["userId"]}"?>" class="btn btn-link">Profile</a>
</section>
</header>
<h1><?php $headlineOutput=htmlspecialchars($dbOutput[0]["content"]); echo"{$headlineOutput}";?></h1>
<?php
for($i=1; $i < count($dbOutput); $i++){
switch ($dbOutput[$i]["type"]){
case "text":
$outputText=htmlspecialchars($dbOutput[$i]["content"]);
echo"<p>{$outputText}</p>";
break;
case "img":
$outputImg=htmlspecialchars($dbOutput[$i]["content"]);
echo"<img style=\"max-width: 50%;\" src=\"{$dbOutput[$i]["url"]}\" alt=\"{$outputImg}\"><br>";
break;
case "header":
$outputHeader=htmlspecialchars($dbOutput[$i]["content"]);
echo"<h3>{$outputHeader}</h3>";
break;
case "link":
$outputLink=htmlspecialchars($dbOutput[$i]["content"]);
echo"<a href=\"{$dbOutput[$i]["url"]}\" class=\"h4\">{$outputLink}</a><br>";
break;
}
}
$outputName=htmlspecialchars($postInfo["author"]);
$outputBlogName=htmlspecialchars($postInfo["blogName"]);
$outputPostName=htmlspecialchars($postInfo["headline"]);
echo"<hr><p><a href=\"profile.php?mess={$postInfo["authorId"]}\">{$outputName}</a>/<a href=\"blogpostdisplay.php?mess={$postInfo["blogId"]}\">{$outputBlogName}</a>/<a href=\"#\">{$outputPostName}</a></p>";
echo"<h4>Author: {$outputName}</h4><p>Date published: {$postInfo["date"]}</p><hr>";
?>
<h2>Comments</h2>
<form method="post" action="commentUpload.php?mess=<?php echo"{$_GET["mess"]}";?>">
<textarea rows="4" cols="60" placeholder="Leave a comment" name="comment" required></textarea><br>
<input type="submit" value="Post" class="btn btn-primary">
</form>
<br>
<?php
$sql = "SELECT `date`, `userId`, `commentorName`, `content` FROM `comment` WHERE postId = :postId";
$stm = $pdo->prepare($sql);
$stm->execute(['postId' => $_GET["mess"]]);
$commentInfo = $stm->fetchAll(PDO::FETCH_ASSOC);
if(isset($commentInfo[0]["content"]) and $commentInfo[0]["content"] != NULL){
for($i=0; $i <= count($commentInfo)-1; $i++){
$commentOutput=htmlspecialchars($commentInfo[$i]["content"]);
$commentorOutput=htmlspecialchars($commentInfo[$i]["commentorName"]);
echo"<p>Comment by <a href=\"profile.php?mess={$commentInfo[$i]["userId"]}\">$commentorOutput:</a><br><textarea readonly rows=\"4\" cols=\"60\">{$commentOutput}</textarea><br>{$commentInfo[$i]["date"]}</p>";
}
}
?>
</body>
</html>