<?php

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

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

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

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

// Make sure that this file is being called from parent file
if(!defined('INCLUDE_FILES')) {
	include('index.html');
	exit;
}

$q_comments = mysql_query("SELECT *,DATE_FORMAT(addDate,'".$SETTINGS->formatdate."') AS cdate
                           FROM ".$database['prefix']."comments 
                           WHERE eventid = '{$_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 $charset; ?>">
<title><?php echo $viewcomms; ?></title>
<link href="css/stylesheet.css" rel="stylesheet" type="text/css">
<style type="text/css">
body {margin:0px auto}
</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:#D4C792">
    <?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" style="margin-bottom:3px">
    <tr>
      <td align="left" class="popCell" width="85%">
      <?php echo str_replace(array('{name}','{date}'),array(cleanData($COMMENT->name),$COMMENT->cdate),$viewcomms2); ?>
      </td>
      <td align="center" class="popCell" width="15%" style="font-weight:normal;border-left:0;text-align:center">
      [<a href="javascript:toggle_box('com_<?php echo $COMMENT->id; ?>')" title="<?php echo $script7; ?>"><?php echo $script7; ?></a>] [<a href="index.php?cmd=comments&amp;comments=<?php echo $_GET['comments']; ?>&amp;del=<?php echo $COMMENT->id; ?>" onclick="return delete_confirm('<?php echo $msg_javascript; ?>')" title="<?php echo $viewcomms3; ?>">X</a>]
      </td>
    </tr>
    </table>
    <table width="100%" cellspacing="0" cellpadding="0">
    <tr>
      <td align="left" style="border:1px solid #788091;padding:5px;background-color:#FFFFFF">
      <?php echo cleanData(nl2br($COMMENT->comments),COMMENTS_TEXT_WRAP); ?>
      </td>
    </tr>
    <tr>
      <td style="text-align:right;border:1px solid #788091;border-top:0;padding:5px;background-color:#FFFFFF">
      <b>IP</b>: <?php echo $COMMENT->ip; ?>
      </td>
    </tr>
    </table>
    </div>
    <!-- End show comments -->
    
    <!-- Show edit comments -->
    <div id="com_<?php echo $COMMENT->id; ?>" style="margin-top:3px;display:none">
    <form method="post" action="index.php?cmd=comments">
    <input type="hidden" name="process" value="1">
    <input type="hidden" name="eid" value="<?php echo $COMMENT->eventid; ?>">
    <input type="hidden" name="id" value="<?php echo $COMMENT->id; ?>">
    <input type="hidden" name="return" value="manage">
    <table width="100%" cellspacing="0" cellpadding="0">
    <tr>
      <td align="center" colspan="2" style="text-align:center;border:1px solid #FFFFFF;padding:5px;background-color:#788091;color:#FFFFFF">
      <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 $viewcomms4; ?>:</span>
        <input class="formbox" type="text" name="name" 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 $viewcomms5; ?>:</span>
        <input class="formbox" type="text" name="email" 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="formbutton2" value="<?php echo $viewcomms6; ?>" title="<?php echo $viewcomms6; ?>">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" class="editbutton" value="<?php echo $viewcomms7; ?>" title="<?php echo $viewcomms7; ?>" 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 eventid = \''.(isset($_POST['eid']) ? $_POST['eid'] : $_GET['comments']).'\' AND is_active = \'1\''),$limit,$page);
    
    } else {
    ?>
    <table width="100%" cellspacing="0" cellpadding="0">
    <tr>
      <td align="center" style="border:1px solid #788091;padding:5px;background-color:#FFFFFF;color:#333333">
      [ <?php echo $p_event14; ?> ]
    </td>
    </tr>
    </table>
    <?php
    }
    ?>
    </td>
</tr>
</table>    
</body>
</html>
