Location: PHPKode > projects > photolibrary > popup.comments.read.php
<?PHP
/*
   [Start: Program Information Header]

    Name    : Photolibrary: Comments popup (read)
    Purpose : Read comments on a photo
    Syntax  :

   [End: Program Information Header]

   [Start: Author Information Header]

    Name    : James D. Forrester
    E-mail  : hide@address.com

    Name    : Ed Sanders
    E-mail  : hide@address.com

   [End: Author Information Header]
*/

require('include.initialise.php');

stylesheet('popup.comments');

$page_title = language('comments');

$no_menu = true;
include('include.menu.php');

$mode = getString('mode');
$hash = getString('hash');

if($mode == 'send')
{
  $name     = uncomment($_POST['name']);
  $email    = uncomment($_POST['email']);
  $comment  = uncomment($_POST['comment']);
  $_SESSION['PL_name'] = $name;
  $_SESSION['PL_email'] = $email;
  if(!$hash or !mysql_query("INSERT INTO photocomments (hash, name, email, ip, comment, approved, timestamp) VALUES ('$hash', '$name', '$email', '{$_SERVER['REMOTE_ADDR']}', '$comment', '{$settings['approve_on_post']}', NOW())"))
  {
    header("Location: http://" . $_SERVER['HTTP_HOST']
                               . dirname($_SERVER['PHP_SELF'])
                               . "/popup.comments.write.php?mode=sendfailed");
  }
  else
  {
    update_comments($hash);
    if(!$settings['approve_on_post'])
      format_html('Comment added and awaiting approval.'); //lang
  }
}

format_html('<table cellspacing="0" cellpadding="5" width="100%">');

$query_handle = mysql_query("
  SELECT hash, name, email, comment, approved, UNIX_TIMESTAMP(timestamp) AS timestamp
  FROM photocomments
  WHERE hash='$hash' ".(!$_SESSION['PL_priv'] ? "AND approved" : "")."
  ORDER BY timestamp DESC") or trigger_error(mysql_error(), E_USER_ERROR);
$results = mysql_num_rows($query_handle);
format_html('<tr class="headline"><td class="headTitle">'.language('comments').'</td><td class="headMenu">');
format_html(write_link('popup.comments.read.php', 'Read', 'hash='.$hash).' | '.write_link('popup.comments.write.php', 'Write', 'hash='.$hash));
format_html('</td></tr>');

$i = false;
while($array = mysql_fetch_assoc($query_handle))
{
  extract($array);
  $email = str_replace("@", " at ", $email);
  $fill = ($approved ? 'filled' : 'unassign');
  $comment = str_replace("\n", "<br />", $comment);
  format_html('<tr style="height: 1px;"><td class="'.$fill.' underlined">'.($name ? $name : '<em>Anonymous</em>').($email ? ' <small>('.$email.')</small>' : '').':<br />');
  format_html('&ldquo;'.$comment.'&rdquo;<br /><span class="small" style="float: right;">'.language('posted').': '.date('jS M Y H:i', $timestamp).'</span></td>');
  if(!$i)
  {
    extract(mysql_fetch_assoc(mysql_query("SELECT type, width, height, orientation, hits FROM photos WHERE hash='$hash'")));
    format_html('<td class="filled underlined" align="center" rowspan="10">');
    include('include.thumbnail.php');
    format_html('</td>');
    $i = true;
  }
  format_html('</tr>');

}

format_html('</table>');

include('include.footer.php');
?>
Return current item: photolibrary