<?php
/**************************************************************************************************
|
| iDocScript - Document Sharing Script
| http://www.idocscript.com
| webmaster@idocscript.com
|
|**************************************************************************************************
|
| By using this software you agree that you have read and acknowledged our End-User License 
| Agreement available at http://www.idocscript.com/eula.html and to be bound by it.
|
| Copyright (c) 2011 iDocScript.com. All rights reserved.
|**************************************************************************************************/
include("include/config.php");
include("include/functions/import.php");

$did = intval($_REQUEST['item_id']);
STemplate::assign('did',$did);
$comment = cleanit($_REQUEST['comment']);
STemplate::assign('comment',$comment);
$USERID = intval($_SESSION['USERID']);
STemplate::assign('USERID',$USERID);

if ($did > 0 && is_numeric($did))
{
	if($USERID > 0 && is_numeric($USERID))
	{
		if($comment != "")
		{
			$query = "insert into docs_comments set DID='".mysql_real_escape_string($did)."', USERID='".mysql_real_escape_string($USERID)."', details='".mysql_real_escape_string($comment)."', time_added='".time()."'";
			$conn->execute($query);
		}
		else
		{
			$error = $lang['315'];	
		}
	}
	
	$query = "SELECT A.*, B.username FROM docs_comments A, members B WHERE DID='".mysql_real_escape_string($did)."' AND A.USERID=B.USERID ORDER BY CID desc";
	$executequery = $conn->execute($query);
	$showcomments =  $executequery->getarray();
	STemplate::assign('showcomments',$showcomments);
}
STemplate::assign('error',$error);
STemplate::assign('message',$message);
STemplate::display('postcomment.tpl');
?>