Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- if(!isset($_SESSION['firstName'])){
- $errors[] = "You must login/register to view that page";
- header('Location:index.php');
- }
- if(isset($_GET['logout'])){
- $_SESSION = array();
- if($_COOKIE[session_name()]){
- setcookie(session_name(), '', time()-4200, '/');
- }
- session_destroy();
- header('Location:index.php');
- }
- ?>
- <?php
- ob_start();
- function redirect(){
- header('Location:viewBlog.php');
- }
- ?>
- <?php
- require('connect.php');
- $getPostID = $_GET['postID'];
- if (isset($getPostID))
- {
- //echo $getPostID;
- if($dbC)
- {
- $query = mysql_query("SELECT * FROM blog_posts WHERE id='$getPostID';");
- $row = mysql_fetch_row($query);
- $query2 = mysql_query("SELECT * FROM blog_users WHERE id='$row[1]';");
- $row2 = mysql_fetch_row($query2);
- }
- }
- if(isset($_POST['submit']))
- {
- if(isset($_POST['comment']))
- {
- if (empty($_POST['comment'])) {
- $errors[] = "Please leave a comment!!";
- }
- else
- {
- $ID = $_SESSION['id'];
- $q2 = mysql_query("SELECT * FROM blog_users WHERE id='$ID';");
- $r2 = mysql_fetch_row($q2);
- $theComment = $_POST['comment'];
- $query4 = mysql_query("INSERT INTO post_comments SET `postId`='$getPostID', `userId`='$r2[0]', `comment`='$theComment';");
- }
- }
- }
- ?>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
- <link type="text/css" rel="stylesheet" href="style.css"/>
- <title><?php echo $row[3]; ?></title>
- </head>
- <body class="page page-id-2 page-template page-template-default">
- <div id="wrapper">
- <div id="page">
- <div class="menu-header">
- <ul>
- <li class="page_item page-item-2 current_page_item"><a href="viewBlog.php" title="Home">HOME</a></li>
- <li class="page_item page-item-2 "><a href="about.php" title="ABOUT">ABOUT</a></li>
- <?php if($_SESSION['username'] == "fayimora"){ ?>
- <li class="page_item page-item-2 "><a href="entry.php" title="ADD ENTRY">ADD ENTRY</a></li>
- <?php }?>
- <li class="page_item page-item-2 "><a href="postComments.php?logout=1" name="logout" title="LOGOUT">LOGOUT</a></li>
- </ul>
- </div>
- <div id="header">
- <h1><a href="viewBlog.php">Fayimora's Blog</a></h1>
- <div class="description">WELCOME TO MY BLOG!</div>
- <div class="rss">
- <a href="viewBlog.php" title="RSS"><?php echo "Hello ".$_SESSION['firstName']; ?></a> </div>
- </div>
- <hr />
- <div id="container">
- <div id="sidebar">
- <!-- begin widgetized sidebar 1 -->
- <ul>
- <li id="blog_subscription-3" class="widget widget_blog_subscription"><h2 class="widgettitle"><label for="subscribe-field">Email Subscription</label></h2>
- <form action="" method="post" accept-charset="utf-8" id="subscribe-blog">
- <p>Enter your email address to subscribe to this blog and receive notifications of new posts by email.</p>
- <p><input type="text" name="email" style="width: 95%; padding: 1px 2px" value="" id="subscribe-field"/></p>
- <p><input type="submit" value="Sign me up!" /></p>
- </form>
- </li>
- <li id="archives-3" class="widget widget_archive"> <h2 class="widgettitle">Archives</h2>
- <ul> <li><a href='archives.php' title='March 2011'>March 2011</a></li></ul>
- </li>
- </ul>
- </div>
- <div id="content">
- <div class="column">
- <div class="post" id="post-2">
- <div class="posttitle">
- <h2 class="pagetitle"><?php echo $row[3]; ?></h2>
- <small><strong><?php echo "Author: ".$row2[3]." ".$row2[4]."<br/>Date Posted: ".$row[2];?></strong></small>
- </div>
- <div class="postcomments"><a href=" <?php echo "postComments.php?postID=$row[0]" ?> " title="Comments"><?php $c = mysql_query("SELECT * FROM post_comments WHERE postId='$row[0]' ;"); $num=mysql_num_rows($c); echo $num; ?></a></div>
- <div class="entry">
- <?php echo $row[4]?>
- </div>
- <!-- You can start editing here. -->
- <!-- If comments are open, but there are no comments. -->
- <div id="comments"></div>
- <?php
- $query3 = mysql_query("SELECT * FROM post_comments WHERE postId='$getPostID' ORDER BY id DESC;");
- while($row3 = mysql_fetch_row($query3)){
- //$q = mysql_query("SELECT * FROM blog_users WHERE username=''; ")
- ?>
- <hr/>
- <cite class="fn"> <?php
- $q4 = mysql_query("SELECT username FROM blog_users WHERE id='$row3[2]';");
- $r4 = mysql_fetch_row($q4);
- echo "Posted by: ".$r4[0];
- ?></cite>
- <!--em class="comment-awaiting-moderation"></em-->
- <div class="comment-meta commentmetadata"><?php echo "Date: ".$row3[3]?></div>
- <p><strong><?php echo $row3[4];?> </strong></p>
- <?php if($_SESSION['username'] == "fayimora"){?>
- <br/><a href="<?php echo "postComments.php?delete=$row3[4]"; ?>">DELETE COMMENT!</a>
- <?php }?>
- <hr />
- <?php }?>
- <?php
- if(isset($_GET['delete'])){
- $d = $_GET['delete'];
- $x = mysql_query("SELECT * FROM post_comments WHERE comment='$d';");
- $y = mysql_fetch_row($x);
- $z = mysql_query("DELETE FROM post_comments WHERE id='$y[0]';");
- redirect();
- }
- ?>
- <div id="respondcon">
- <div id="respond">
- <h3 id="reply-title"><?php if(isset($errors[0])) echo $errors[0];?></h3>
- <form action="<?php echo "postComments.php?postID=$getPostID"?>" method="post" id="commentform">
- <p class="comment-form-comment"><label for="comment">Comment</label></p>
- <textarea id="comment" name="comment" cols="20" rows="6"></textarea>
- <p class="form-submit"><input name="submit" type="submit" id="submit" value="Post Comment" /></p>
- </form>
- </div><!-- #respond -->
- </div><!-- #respondcon -->
- </div>
- </div>
- </div>
- <hr />
- <div id="footer">
- </div>
- </div><!-- #container -->
- </div><!-- #page -->
- <div id="footer-bott">
- <a href="mailto:fbfb3@eecs.qmul.ac.uk" rel="generator">Fully designed by Fayimora Femi-Balogun</a>. | Theme:
- <a href="http://theme.wordpress.com/themes/greyzed/">Greyzed</a> by
- <a href="http://theforge.co.zaa/" rel="designer">The Forge Web Creations</a>.
- </div>
- <div class="footerbar"></div>
- </div><!-- #wrapper -->
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement