Advertisement
fayimora

test

Mar 22nd, 2011
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 6.60 KB | None | 0 0
  1. <?php
  2.     session_start();
  3.     if(!isset($_SESSION['firstName'])){
  4.         $errors[] = "You must login/register to view that page";
  5.         header('Location:index.php');
  6.     }
  7.     if(isset($_GET['logout'])){
  8.         $_SESSION = array();
  9.         if($_COOKIE[session_name()]){
  10.             setcookie(session_name(), '', time()-4200, '/');
  11.         }
  12.         session_destroy();
  13.         header('Location:index.php');
  14.     }
  15. ?>
  16.  
  17. <?php
  18. ob_start();
  19.     function redirect(){
  20.         header('Location:viewBlog.php');
  21.     }
  22.  
  23. ?>
  24.  
  25. <?php
  26.     require('connect.php');
  27.     $getPostID = $_GET['postID'];
  28.     if (isset($getPostID))
  29.     {
  30.         //echo $getPostID;
  31.         if($dbC)
  32.         {
  33.             $query = mysql_query("SELECT * FROM blog_posts WHERE id='$getPostID';");
  34.             $row = mysql_fetch_row($query);
  35.            
  36.             $query2 = mysql_query("SELECT * FROM blog_users WHERE id='$row[1]';");
  37.             $row2 = mysql_fetch_row($query2);
  38.         }  
  39.     }
  40.    
  41.     if(isset($_POST['submit']))
  42.     {
  43.         if(isset($_POST['comment']))
  44.         {
  45.  
  46.             if (empty($_POST['comment'])) {
  47.                 $errors[] = "Please leave a comment!!";
  48.             }
  49.             else
  50.             {
  51.                 $ID = $_SESSION['id'];
  52.                 $q2 = mysql_query("SELECT * FROM blog_users WHERE id='$ID';");
  53.                 $r2 = mysql_fetch_row($q2);
  54.                
  55.                 $theComment = $_POST['comment'];
  56.                 $query4 = mysql_query("INSERT INTO post_comments SET `postId`='$getPostID', `userId`='$r2[0]', `comment`='$theComment';");
  57.             }
  58.         }
  59.     }
  60. ?>
  61.  
  62. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  63. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  64. <html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en">
  65. <head>
  66. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  67. <link type="text/css" rel="stylesheet" href="style.css"/>
  68. <title><?php echo $row[3]; ?></title>
  69. </head>
  70. <body class="page page-id-2 page-template page-template-default">
  71. <div id="wrapper">
  72.  
  73. <div id="page">
  74.     <div class="menu-header">
  75.                             <ul>
  76.                                 <li class="page_item page-item-2 current_page_item"><a href="viewBlog.php" title="Home">HOME</a></li>
  77.                                 <li class="page_item page-item-2 "><a href="about.php" title="ABOUT">ABOUT</a></li>
  78.                                 <?php if($_SESSION['username'] == "fayimora"){ ?>
  79.                                 <li class="page_item page-item-2 "><a href="entry.php" title="ADD ENTRY">ADD ENTRY</a></li>
  80.                                 <?php }?>
  81.                                 <li class="page_item page-item-2 "><a href="postComments.php?logout=1" name="logout" title="LOGOUT">LOGOUT</a></li>
  82.                             </ul>
  83.     </div>
  84.     <div id="header">
  85.             <h1><a href="viewBlog.php">Fayimora&#039;s Blog</a></h1>
  86.  
  87.             <div class="description">WELCOME TO MY BLOG!</div>
  88.  
  89.             <div class="rss">
  90.                 <a href="viewBlog.php" title="RSS"><?php echo "Hello ".$_SESSION['firstName']; ?></a>           </div>
  91.     </div>
  92.  
  93.     <hr />
  94.     <div id="container">
  95.         <div id="sidebar">
  96.  
  97.             <!-- begin widgetized sidebar 1 -->
  98.             <ul>
  99.                 <li id="blog_subscription-3" class="widget widget_blog_subscription"><h2 class="widgettitle"><label for="subscribe-field">Email Subscription</label></h2>
  100.                     <form action="" method="post" accept-charset="utf-8" id="subscribe-blog">
  101.                         <p>Enter your email address to subscribe to this blog and receive notifications of new posts by email.</p>
  102.                         <p><input type="text" name="email" style="width: 95%; padding: 1px 2px" value="" id="subscribe-field"/></p>
  103.  
  104.                         <p><input type="submit" value="Sign me up!" /></p>
  105.                     </form>
  106.                 </li>
  107.                 <li id="archives-3" class="widget widget_archive"> <h2 class="widgettitle">Archives</h2>
  108.                        
  109.                         <ul>    <li><a href='archives.php' title='March 2011'>March 2011</a></li></ul>
  110.                 </li>
  111.             </ul>  
  112.        </div>
  113.    
  114.  
  115.     <div id="content">
  116.     <div class="column">
  117.                 <div class="post" id="post-2">
  118.             <div class="posttitle">
  119.                 <h2 class="pagetitle"><?php echo $row[3]; ?></h2>
  120.                 <small><strong><?php echo "Author: ".$row2[3]." ".$row2[4]."<br/>Date Posted: ".$row[2];?></strong></small>
  121.             </div>
  122.                         <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>
  123.                         <div class="entry">
  124.                             <?php echo $row[4]?>
  125.                         </div>
  126.     <!-- You can start editing here. -->
  127.             <!-- If comments are open, but there are no comments. -->
  128.            
  129.                         <div id="comments"></div>
  130.                         <?php
  131.                             $query3 = mysql_query("SELECT * FROM post_comments WHERE postId='$getPostID' ORDER BY id DESC;");
  132.                             while($row3 = mysql_fetch_row($query3)){
  133.                             //$q = mysql_query("SELECT * FROM blog_users WHERE username=''; ")
  134.                         ?>
  135.                         <hr/>
  136.                         <cite class="fn"> <?php
  137.                                         $q4 = mysql_query("SELECT username FROM blog_users WHERE id='$row3[2]';");
  138.                                         $r4 = mysql_fetch_row($q4);
  139.                                         echo "Posted by: ".$r4[0];
  140.                         ?></cite>
  141.                         <!--em class="comment-awaiting-moderation"></em-->
  142.                         <div class="comment-meta commentmetadata"><?php echo "Date: ".$row3[3]?></div>
  143.                         <p><strong><?php echo $row3[4];?> </strong></p>
  144.                         <?php if($_SESSION['username'] == "fayimora"){?>
  145.                            
  146.                             <br/><a href="<?php echo "postComments.php?delete=$row3[4]"; ?>">DELETE COMMENT!</a>
  147.                         <?php }?>  
  148.                         <hr />
  149.                         <?php }?>
  150.                    
  151.                         <?php
  152.                             if(isset($_GET['delete'])){
  153.                                 $d = $_GET['delete'];
  154.                                
  155.                                 $x = mysql_query("SELECT * FROM post_comments WHERE comment='$d';");
  156.                                 $y = mysql_fetch_row($x);
  157.                                 $z = mysql_query("DELETE FROM post_comments WHERE id='$y[0]';");
  158.                                 redirect();
  159.                             }
  160.                        
  161.                         ?>
  162.                    
  163.                         <div id="respondcon">
  164.                             <div id="respond">
  165.                                         <h3 id="reply-title"><?php if(isset($errors[0])) echo $errors[0];?></h3>
  166.                                        
  167.                                         <form action="<?php echo "postComments.php?postID=$getPostID"?>" method="post" id="commentform">
  168.                                                         <p class="comment-form-comment"><label for="comment">Comment</label></p>
  169.                                                         <textarea id="comment" name="comment" cols="20" rows="6"></textarea>                   
  170.                                                         <p class="form-submit"><input name="submit" type="submit" id="submit" value="Post Comment" /></p>
  171.                                         </form>
  172.                                    
  173.                                    
  174.                             </div><!-- #respond -->
  175.                         </div><!-- #respondcon -->
  176.         </div>
  177.            
  178.     </div>
  179.     </div>
  180.             <hr />
  181.  
  182.             <div id="footer">
  183.  
  184.                
  185.             </div>
  186.  
  187.         </div><!-- #container -->
  188.     </div><!-- #page -->
  189.  
  190.     <div id="footer-bott">
  191.         <a href="mailto:fbfb3@eecs.qmul.ac.uk" rel="generator">Fully designed by Fayimora Femi-Balogun</a>. | Theme:
  192.         <a href="http://theme.wordpress.com/themes/greyzed/">Greyzed</a> by
  193.         <a href="http://theforge.co.zaa/" rel="designer">The Forge Web Creations</a>.  
  194.     </div>
  195.  
  196.     <div class="footerbar"></div>
  197. </div><!-- #wrapper -->
  198.  
  199.  
  200. </body>
  201. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement