Wheatblog PHP Cross Reference Blogging Systems

Source: /view_by_permalink.php - 195 lines - 6795 bytes - Summary - Text - Print

   1  <?php
   2  // File:    view_by_permalink.php
   3  // License: GNU GPL
   4  // Purpose: Presents a post via permalink passed on the URL.  post is show
   5  //     along with comments and a form for caputuring additional comments.  
   6  //
   7  require_once ('settings.php');
   8  $page_title = ':: permalink view';
   9  include_once("$wb_inc_dir/header.php");
  10  
  11      // parse the passed vars into something useful 
  12      // also check for nulls
  13      $the_id = $_GET['the_id'];
  14      $The_id = $db->quote($the_id);
  15  
  16  
  17  
  18      // Session Variables
  19      //
  20      $login    = ( isset($_SESSION['login']) ) ? $_SESSION['login'] : "";
  21      $www      = ( isset($_SESSION['www']) )   ? $_SESSION['www'] : "";
  22      $email    = ( isset($_SESSION['email']) ) ? $_SESSION['email'] : "";
  23  
  24  
  25  
  26      $db->query("SELECT * FROM $tblPosts WHERE id=$The_id
  27          ORDER BY year, month, day limit $front_page_max");
  28  
  29      // output post
  30      echo "<!-- generated by wheatblog: start -->\n\n";
  31  
  32  
  33      $db2 = new DatabaseClass;
  34  
  35      while( $row = $db->fetchArray() )
  36      {
  37          $the_id     = $row['id'];
  38          $the_day    = $row['day'];
  39          $the_month  = $row['month'];
  40          $the_date   = $row['date'];
  41          $the_year   = $row['year'];
  42          $the_locked = $row['locked'];
  43          $the_cat    = $row['category']; $The_cat = $db->quote($the_cat);
  44  
  45          // parse out the category id into its string value
  46          $db2->query("SELECT * FROM $tblCategories where id=$the_cat");
  47  
  48          while( $row2 = $db2->fetchArray() )
  49              $the_category_name = $row2['category'];
  50  
  51          $the_showpref = $row['showpref'];
  52          $the_title    = $row['title'];
  53          $the_body     = $row['body'];
  54  
  55          // Post body
  56          # removed interpolation    
  57          # inserted markup for better formatting control    
  58          
  59          echo '<div class="subcontent">'."\n";
  60          echo '<div class="post-heading">'."\n"; # heading is important, needs to be seperate
  61          echo '<h3 class="post-title">'.$the_title.'</h3>'."\n";
  62          echo '<h4 class="post-date">'.$the_day.', '.$the_month.'.'.$the_date.'.'.$the_year.'</h4>'."\n";
  63          echo '</div>'."\n";  # closes div.post-heading
  64          echo '<div class="post-body">'.$the_body.'</div>'."\n\n";
  65  
  66          // Post category
  67          # removed interpolation
  68         
  69          echo '<div class="post-menu">'."\n".'<ul class="postnav">'."\n"; #links are now unordered list
  70          
  71          echo '<li title="Current Category"><a href="view_by_category.php?the_category='.$the_category.'">'.$the_category_name. '</a></li>'."\n";
  72  
  73          # only difference from  "universal" post display is the ommission of comments
  74          
  75          echo "\n".'</ul>'."\n".'</div>'."\n";  # closes list and div.post-menu
  76          echo '</div>'."\n\n"; # closes div.indent
  77      }
  78  
  79      // ---------------------------
  80      // comments
  81      // ---------------------------
  82  
  83      // set vars to null
  84      $comment_month        = '';
  85      $comment_date         = '';
  86      $comment_year         = '';
  87      $comment_title        = '';
  88      $comment_body         = '';
  89      $comment_author_name  = '';
  90      $comment_author_email = '';
  91      $comment_author_url   = '';   
  92      $the_post_id          = ''; 
  93  
  94      // select comments for this post
  95      $db->query("SELECT * FROM $tblComments where post_id=$The_id
  96          ORDER BY comment_year, comment_month, comment_date");
  97  
  98      // print a comments header
  99      echo '<div class="subcontent"><h3 class="cnt-subhead">Comments</h3></div>';
 100  
 101      while( $row = $db->fetchArray() )
 102      {
 103          $comment_month        = $row['comment_month'];
 104          $comment_date         = $row['comment_date'];
 105          $comment_year         = $row['comment_year'];
 106          $comment_body         = $row['comment_body'];
 107          $comment_author_name  = $row['comment_author_name'];
 108          $comment_author_email = $row['comment_author_email'];
 109          $comment_author_url   = $row['comment_author_url'];
 110  
 111          // print comments
 112          echo '<div class="subcontent-comment">'."\n"; 
 113          echo '<div class="comment-heading">'."\n"; # heading is important, needs to be seperate
 114          echo '<h3 class="comment-auth"><strong>'.$comment_author_name.'</strong> said:</h3>'."\n";
 115          echo '<h4 class="comment-date">'.$the_day.', '.$the_month.'.'.$the_date.'.'.$the_year.'</h4>'."\n";
 116          echo '</div>'."\n";  # closes div.post-heading
 117          echo '<div class="comment-body">'.$comment_body.'</div>'."\n\n";
 118          echo '<div class="comment-menu">'."\n".
 119               '<ul class="postnav">'."\n".
 120               '<li title="Email '.$comment_author_email.'"><a href="mailto:'.$comment_author_email.'">email</a></li>'.'|'."\n".
 121               '<li title="Visit '.$comment_author_name.'\'s Website ('.$comment_author_url.')"><a href="'.$comment_author_url.'">website</a></li>'."\n".
 122               '</ul>' ."\n".
 123               '</div>'."\n".
 124               '</div>'."\n";
 125      }
 126  
 127      // provides demarkation between comments / comment form
 128      //
 129      echo ('
 130          <div class="subcontent-heading"></div>
 131          <!-- generated by wheatblog: stop -->
 132      ');
 133  
 134  
 135  
 136  
 137      // A post is either locked, or not locked.  If locked, just tell the user
 138      // and be done with it.  I wonder if we should include exit in footer.php?
 139      //
 140      if ( $the_locked )
 141      {
 142          echo '<div class="subcontent"><h3 class="cnt-subhead" id="lock">This post is locked. No ' .
 143              'comments are allowed.</h3></div>'."\n";
 144  
 145          include ('includes/footer.php');
 146          exit;
 147      }
 148              
 149  
 150      // New comment dialog header
 151      # JBE - removed interpolation
 152      
 153          // new comment form
 154      # JBE - removed interpolation
 155      
 156      echo '<div class="subcontent">'."\n";
 157      echo '<div class="comment-heading">'.
 158           '<h3 class="post-title">Post a Comment</h3>';
 159      echo '<h4 class="comment-date">'."\n".'Date: ' . date("m") . '/' . date("d") . '/' . date("Y") .'</h4></div>'."\n";
 160      echo '<div class="comment-body">';
 161      echo '<form method="post" action="add_comment.php">'."\n". 
 162           '<input name="comment_month" type="hidden" value="'.date("m").'" />'."\n".
 163           '<input name="comment_date" type="hidden" value="'.date("d").'" />'."\n".
 164           '<input name="comment_year" type="hidden" value="'.date("Y").'" />'."\n". 
 165           '<input name="the_id" type="hidden" value="'.$the_id.'" />'."\n";
 166  
 167          // author
 168          echo 'Name<br />'."\n";
 169          echo '<input name="comment_author_name" ';
 170          echo ( $login != '' ) ? "value=\"$login\" " : '';
 171          echo  'type="text" /><br />'."\n".'Email<br />';
 172  
 173          // email
 174          echo '<input name="comment_author_email" ';
 175          echo ( $email != '' ) ? "value=\"$email\" " : '';
 176          echo 'type="text" /><br />'."\n".'WWW<br />';
 177  
 178          // www
 179          echo '<input name="comment_author_url" ';
 180          echo ( $www != '' ) ? "value=\"$www\" " : '';
 181          echo 'type="text" /><br />'."\n".'Comment<br />';
 182          
 183          // comment and captcha
 184          echo'<textarea name="comment_body" rows="100" cols="50" class="wheatblog_textarea"></textarea><br />'."\n".'<br />'."\n".  
 185      'Please type the number you see in the image below into the box below it.<br />'."\n".
 186          '<img src="captcha.php" /> <br />'."\n".
 187          '<input type="text" name="captcha" /><br />'."\n".
 188          '<input type="submit" value="post comment" /><br />'."\n". 
 189          '</form>'."\n". 
 190          '</div>'."\n\n";
 191          echo '<div class="comment-menu">&nbsp;</div>';
 192          echo '</div>';
 193  
 194  include_once("$wb_inc_dir/footer.php");
 195  ?>

title

Description

title

Description

title

Description

title

title

Body