<?php

/*++++++++++++++++++++++++++++++++++++++++

  Script: Maian Gallery v2.0
  Written by: David Ian Bennett
  E-Mail: support@maianscriptworld.co.uk
  Website: http://www.maianscriptworld.co.uk

  ++++++++++++++++++++++++++++++++++++++++
  
  This File: comments.php
  Description: View Comments

  ++++++++++++++++++++++++++++++++++++++++*/

// Make sure that this file is being called from parent file
if (!defined('INCLUDE_FILES')) {
  accessDenied($msg_script18,$msg_script19);
  exit;
}

$q_comments = mysql_query("SELECT *,DATE_FORMAT(addDate,'".$SETTINGS->mysql_date."') AS cdate
                           FROM ".$database['prefix']."comments 
                           WHERE imageID = '".(isset($_POST['imgid']) ? $_POST['imgid'] : $_GET['comments'])."'
                           AND is_active = '1'
                           ORDER BY id DESC
                           LIMIT $limitvalue,$limit
                           ") or die(mysql_error());

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $msg_charset; ?>">
<title><?php echo $msg_manage11; ?></title>
<link href="css/css.css" rel="stylesheet" type="text/css">
<style type="text/css">
body {
  margin:0;
  padding:0;
}
</style>
<script type="text/javascript" src="js/js_code.js"></script>
</head>

<body>
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tr>
    <td align="left" style="padding:5px;background-color:#1EB5DD;color:#FFFFFF">
    <?php
    
    if (mysql_num_rows($q_comments)>0)
    {
    while ($COMMENT = mysql_fetch_object($q_comments))
    {
    ?>
    <!-- Show comments -->
    <div style="margin-bottom:5px">
    <div>
    <table width="100%" cellspacing="0" cellpadding="0">
    <tr>
      <td align="left" class="popCell" width="85%">
      <?php echo str_replace(array('{name}','{date}'),array(cleanData($COMMENT->name),$COMMENT->cdate),$msg_comments13); ?>
      </td>
      <td align="center" class="popCell" width="15%" style="border-left:0;font-weight:normal">
      [<a href="javascript:toggle_box('com_<?php echo $COMMENT->id; ?>')" title="<?php echo $msg_script16; ?>" style="color:#FFFFFF"><?php echo $msg_script16; ?></a>] [<a href="index.php?cmd=comments&amp;return=cat_images&amp;comments=<?php echo (isset($_POST['imgid']) ? $_POST['imgid'] : $_GET['comments']); ?>&amp;del=<?php echo $COMMENT->id; ?>" onclick="return delete_confirm('<?php echo $msg_javascript37; ?>')" title="<?php echo $msg_comments15; ?>" style="color:#FFFFFF">X</a>]
      </td>
    </tr>
    <tr>
      <td align="left" colspan="2" style="border-bottom:1px solid #083253;border-right:1px solid #083253;border-left:1px solid #083253;padding:5px;background-color:#1EB5DD">
      <?php echo cleanData(nl2br($COMMENT->comments),COMMENTS_TEXT_WRAP); ?>
      </td>
    </tr>
    <tr>
      <td align="left" colspan="2" style="text-align:right;font-style:italic;border-bottom:1px solid #083253;border-right:1px solid #083253;color:#083253;border-left:1px solid #083253;padding:5px;background-color:#1EB5DD">
      IP: <?php echo $COMMENT->ip_address; ?>
      </td>
    </tr>
    </table>
    </div>
    <!-- End show comments -->
    
    <!-- Show edit comments -->
    <div id="com_<?php echo $COMMENT->id; ?>" style="margin-top:5px;display:none">
    <form method="post" action="index.php?cmd=comments">
    <input type="hidden" name="edit_comment" value="1">
    <input type="hidden" name="imgid" value="<?php echo $COMMENT->imageID; ?>">
    <input type="hidden" name="comid" value="<?php echo $COMMENT->id; ?>">
    <table width="100%" cellspacing="0" cellpadding="0">
    <tr>
      <td align="center" colspan="2" style="border:1px solid #FFFFFF;padding:5px;background-color:#0F5B96">
      <table width="100%" cellspacing="0" cellpadding="0">
      <tr>
        <td width="30%" align="left" style="padding:5px" valign="top">
        <span style="display:block;margin-bottom:4px;font-weight:bold"><?php echo $msg_addimg7; ?>:</span>
        <input class="formbox" type="text" name="name" maxlength="25" size="25" value="<?php echo cleanData($COMMENT->name); ?>" style="width:90%"><br><br>
        <span style="display:block;margin-bottom:4px;font-weight:bold"><?php echo $msg_settings4; ?>:</span>
        <input class="formbox" type="text" name="email" maxlength="25" size="25" value="<?php echo $COMMENT->email; ?>" style="width:90%"><br>
        </td>
        <td width="70%" align="left" style="padding:5px"><textarea name="comments" rows="8" cols="40" style="width:98%"><?php echo cleanData($COMMENT->comments); ?></textarea></td>
      </tr>
      </table><br>
      <input type="submit" class="formbutton" value="<?php echo $msg_comments12; ?>" title="<?php echo $msg_comments12; ?>">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" class="editbutton" value="<?php echo $msg_script28; ?>" title="<?php echo $msg_script28; ?>" onclick="javascript:toggle_box('com_<?php echo $COMMENT->id; ?>')">
    </td>
    </tr>
    </table>
    </form>
    </div>
    <!-- End show edit comments -->
    
    </div>
    <?php
    }
    
    echo admin_page_numbers(rowCount('comments',' WHERE imageID = \''.(isset($_POST['imgid']) ? $_POST['imgid'] : $_GET['comments']).'\' AND is_active = \'1\' AND is_approved = \'0\''),$limit,$page);
    
    } else {
    ?>
    <table width="100%" cellspacing="0" cellpadding="0">
    <tr>
      <td align="center" style="border:1px solid #36393D;padding:5px;background-color:#0F5B96">
      [ <?php echo $msg_comments14; ?> ]
    </td>
    </tr>
    </table>
    <?php
    }
    ?>
    </td>
</tr>
</table>    
</body>
</html>
