И так в базу:

Код:
CREATE TABLE `usercomments` ( 
  `id` int(10) unsigned NOT NULL auto_increment, 
  `user` int(10) unsigned NOT NULL default '0', 
  `userid` int(10) unsigned NOT NULL default '0', 
  `added` datetime NOT NULL default '0000-00-00 00:00:00', 
  `text` text NOT NULL, 
  `ori_text` text NOT NULL, 
  `editedby` int(10) unsigned NOT NULL default '0', 
  `editedat` datetime NOT NULL default '0000-00-00 00:00:00', 
  `ip` varchar(15) NOT NULL default '', 
  PRIMARY KEY  (`id`), 
  KEY `user` (`user`), 
  KEY `news` (`userid`) 
) ENGINE=MyISAM  DEFAULT CHARSET=cp1251 ROW_FORMAT=DYNAMIC AUTO_INCREMENT=0 ;

В  userdetails.php:

Код:
//Tooools comment///
print("</td></tr></table>\n");

$pre_query = sql_query("SELECT MAX(id) AS preid FROM users WHERE id < $id") or sqlerr(__FILE__, __LINE__);
    $pre = mysql_fetch_array($pre_query);
    $next_query = sql_query("SELECT MIN(id) AS nextid FROM users WHERE id > $id") or sqlerr(__FILE__, __LINE__);
    $next = mysql_fetch_array($next_query);
    print("<br><br>".(isset($pre["preid"]) ? "<a href='userdetails.php?id=".$pre["preid"]."'><b><< Предыдущая </b></a>" : "<span style=\"color:#AAAAAA;font-weight:bold\"><b><< Предыдущая </b></span>")."|".(isset($next["nextid"]) ? "<a href='userdetails.php?id=".$next["nextid"]."'><b> Следующая >></b></a>" : "<span style=\"color:#AAAAAA;font-weight:bold\"><b> Следующая >></b></span>")."<br><br>");  
    begin_frame();
        $subres = sql_query("SELECT COUNT(*) FROM usercomments WHERE userid = $id");
        $subrow = mysql_fetch_array($subres);
        $count = $subrow[0];

        $limited = 1;

if (!$count) {

  print("<table style=\"margin-top: 2px;\" cellpadding=\"5\" width=\"100%\">");
  print("<tr><td class=colhead align=\"left\" colspan=\"2\">");
  print("<div style=\"float: left; width: auto;\" align=\"left\"> :: Список комментариев</div>");
  print("<div align=\"right\"><a href=userdetails.php?id=$id#comments class=altlink_white>Добавить комментарий</a></div>");
  print("</td></tr><tr><td align=\"center\">");
  print("Комментариев нет. <a href=userdetails.php?id=$id#comments>Желаете добавить?</a>");
  print("</td></tr></table><br />");

        }
        else {
              
list($pagertop, $pagerbottom, $limit) = pager($limited, $count, "userdetails.php?id=$id&", "#comments-table", array(lastpagedefault => 1));
                $subres = sql_query("SELECT c.id, c.ip,  c.text, c.user, c.added, c.editedby, c.editedat, u.avatar, u.warned, ".
                  "u.username, u.title, u.class, u.donor, u.downloaded, u.uploaded, u.gender, u.last_access, e.username AS editedbyname FROM usercomments AS c LEFT JOIN users AS u ON c.user = u.id LEFT JOIN users AS e ON c.editedby = e.id WHERE userid = " .
                  "$id ORDER BY c.id $limit") or sqlerr(__FILE__, __LINE__);
                $allrows = array();
                while ($subrow = mysql_fetch_array($subres))
                        $allrows[] = $subrow;


         print("<table id=\"comments-table\" class=main cellspacing=\"0\" cellPadding=\"5\" width=\"100%\" >");
         print("<tr><td class=\"colhead\" align=\"center\">");
         print("<div style=\"float: left; width: auto;\" align=\"left\"> :: Список комментариев</div>");
         print("<div align=\"right\"><a href=\"userdetails.php?id=$id#comments\" class=\"altlink_white\">{$tracker_lang['add_comment']}</a></div>");
         print("</td></tr>");

         print("<tr><td>");
         print($pagertop);
         print("</td></tr>");
         print("<tr><td>");
                 commenttable($allrows,'usercomment');
         print("</td></tr>");
         print("<tr><td>");
         print($pagerbottom);
         print("</td></tr>");
         print("</table>");
        }

if (!$ajax) {
  print("<table style=\"margin-top: 2px;\" cellpadding=\"5\" width=\"100%\">");
  print("<tr><td class=colhead align=\"left\" colspan=\"2\">  <div id=\"comments\"></div><b>:: {$tracker_lang['add_comment']} к пользователю</b></td></tr>");
  print("<tr><td width=\"100%\" align=\"center\" >");
  //print("Ваше имя: ");
  //print("".$CURUSER['username']."<p>");
  print("<form name=comment method=\"post\" action=\"usercomment.php?action=add\">");
  print("<center><table border=\"0\"><tr><td class=\"clear\">");
  print("<div align=\"center\">". textbbcode("comment","text","") ."</div>");
  print("</td></tr></table></center>");
  print("</td></tr><tr><td  align=\"center\" colspan=\"2\">");
  print("<input type=\"hidden\" name=\"uid\" value=\"$id\"/>");
  print("<input type=\"submit\" class=btn value=\"Разместить комментарий\" />");
  print("</td></tr></form></table>");
  }
///Tooools comment///

В корень usercomment.php

Код:
<?

/*
// +--------------------------------------------------------------------------+
// | Project:    Tooools -- KinoZAL -- UserComment                            |
// +--------------------------------------------------------------------------+
*/

require_once("include/bittorrent.php");

$action = $_GET["action"];

dbconn();

loggedinorreturn();
parked();

if ($action == "add")
{
  if ($_SERVER["REQUEST_METHOD"] == "POST")
  {
    if(!is_valid_id($_POST["uid"])) stderr($tracker_lang["error"],$tracker_lang["invalid_id"]);
    
    $uid = (int) $_POST["uid"];
	  $text = trim(($_POST["text"]));
	  if (!$text)
    	stderr($tracker_lang['error'], $tracker_lang['comment_cant_be_empty']);

	  sql_query("INSERT INTO usercomments (user, userid, added, text, ori_text, ip) VALUES (" .
	      $CURUSER["id"] . ",$uid, '" .get_date_time()."', " . sqlesc($text) .
	       "," . sqlesc($text) ."," . sqlesc(getip()) . ")") or die(mysql_error());
	       
	       $newid = mysql_insert_id();

	  header("Refresh: 0; url=userdetails.php?id=$uid&viewcomm=$newid#comm$newid");
	  die;
	}

  if (!is_valid_id($_GET["uid"]))
    stderr($tracker_lang['error'], $tracker_lang['invalid_id']);
  $uid = (int) $_GET["uid"];

	stdhead("Добление комментария к пользователю");

	print("<p><form name=\"comment\" method=\"post\" action=\"usercomment.php?action=add\">\n");
	print("<input type=\"hidden\" name=\"uid\" value=\"$uid\"/>\n");
?>
	<table class="main" border="0" cellspacing="0" cellpadding="3">
	<tr>
	<td class="colhead">
<?
	print("".$tracker_lang['add_comment']." к пользователю");
?>
	</td>
	</tr>
	<tr>
	<td>
<?
	print textbbcode("comment","text","");
?>
	</td></tr></table>
<?
	//print("<textarea name=\"text\" rows=\"10\" cols=\"60\"></textarea></p>\n");
	print("<p><input type=\"submit\" value=\"Добавить\" /></p></form>\n");

	$res = sql_query("SELECT usercomments.id, text, usercomments.ip,  usercomments.added, username, title, class, users.id as user, users.avatar, users.donor, users.enabled, users.warned, users.parked FROM usercomments LEFT JOIN users ON usercomments.user = users.id WHERE userid = $uid ORDER BY comments.id DESC");

	$allrows = array();
	while ($row = mysql_fetch_array($res))
	  $allrows[] = $row;

	if (count($allrows)) {
	  print("<h2>Последние комментарии, в обратном порядке</h2>\n");
	  commenttable($allrows);
	}

  stdfoot();
	die;
}
elseif ($action == "quote")
{
  if (!is_valid_id($_GET["cid"]))
    stderr($tracker_lang['error'], $tracker_lang['invalid_id']);
  $commentid = (int) $_GET["cid"];
  $res = sql_query("SELECT c.*, u.username, u.id AS uid,  u.username FROM usercomments AS c LEFT JOIN users AS t ON c.user = c.id JOIN users AS u ON c.user = u.id WHERE c.id=$commentid") or sqlerr(__FILE__,__LINE__);
  $arr = mysql_fetch_array($res);
  if (!$arr)
  	stderr($tracker_lang['error'], $tracker_lang['invalid_id']);

 	stdhead("Добавления комментария к пользователю");

	$text = "[quote=$arr[username]]" . $arr["text"] . "[/quote]\n";

	print("<form method=\"post\" name=\"comment\" action=\"usercomment.php?action=add\">\n");
	print("<input type=\"hidden\" name=\"uid\" value=\"$arr[uid]\" />\n");
?>

	<table class="main" border="0" cellspacing="0" cellpadding="3">
	<tr>
	<td class="colhead">
<?
	print("Добавления комментария к пользователю");
?>
	</td>
	</tr>
	<tr>
	<td>
<?
	print textbbcode("comment","text","$text");
?>
	</td></tr></table>

<?

	print("<p><input type=\"submit\" value=\"Добавить\" /></p></form>\n");

	stdfoot();

}
elseif ($action == "edit")
{
  if (!is_valid_id($_GET["cid"]))
    stderr($tracker_lang['error'], $tracker_lang['invalid_id']);
  $commentid = (int) $_GET["cid"];
  $res = sql_query("SELECT nc.*, n.id AS uid FROM usercomments AS nc LEFT JOIN users AS n ON nc.userid = n.id WHERE nc.id=$commentid") or sqlerr(__FILE__,__LINE__);
  $arr = mysql_fetch_array($res);
  if (!$arr)
  	stderr($tracker_lang['error'], $tracker_lang['invalid_id']);

	if ($arr["user"] != $CURUSER["id"] && get_user_class() < UC_MODERATOR)
    stderr($tracker_lang['error'], $tracker_lang['access_denied']);

	if ($_SERVER["REQUEST_METHOD"] == "POST")
	{
	  $text = ((string)$_POST["text"]);
    $returnto = strip_tags($_POST['returnto']);

	  if ($text == "")
	  	stderr($tracker_lang['error'], $tracker_lang['comment_cant_be_empty']);
	  
	  $text = sqlesc($text);

	  $editedat = sqlesc(get_date_time());

	  sql_query("UPDATE usercomments SET text=$text,editedat=$editedat, editedby=$CURUSER[id] WHERE id=$commentid") or sqlerr(__FILE__, __LINE__);

          
    if ($returnto)
	  	header("Location: $returnto");
    else
     header("Location: $DEFAULTBASEURL/");
    die;
	}

 	stdhead("Редактирование комментария к пользователю");

	print("<form method=\"post\" name=\"comment\" action=\"usercomment.php?action=edit&amp;cid=$commentid\">\n");
	print("<input type=\"hidden\" name=\"returnto\" value=\"userdetails.php?id={$arr["uid"]}&amp;viewcomm=$commentid#comm$commentid\" />\n");
	print("<input type=\"hidden\" name=\"cid\" value=\"$commentid\" />\n");
?>

	<table class="main" border="0" cellspacing="0" cellpadding="3">
	<tr>
	<td class="colhead">
<?
	print("Редактирование комментария к пользователю");
?>
	</td>
	</tr>
	<tr>
	<td>
<?
	print textbbcode("comment","text",htmlspecialchars($arr["text"]));
?>
	</td></tr></table>

<?

	print("<p><input type=\"submit\" value=\"Отредактировать\" /></p></form>\n");

	stdfoot();
	die;
}

elseif ($action == "delete")
{
	if (get_user_class() < UC_MODERATOR)
    stderr($tracker_lang['error'], $tracker_lang['access_denied']);

  if (!is_valid_id($_GET["cid"]))
    stderr($tracker_lang['error'], $tracker_lang['invalid_id']);
      $commentid = (int) $_GET["cid"];


	$res = sql_query("SELECT userid FROM usercomments WHERE id=$commentid")  or sqlerr(__FILE__,__LINE__);
	$arr = mysql_fetch_array($res);
	if ($arr)
    $uid = $arr["userid"];

	sql_query("DELETE FROM usercomments WHERE id=$commentid") or sqlerr(__FILE__,__LINE__);


        
	list($commentid) = mysql_fetch_row(sql_query("SELECT id FROM usercomments WHERE userid = $uid ORDER BY added DESC LIMIT 1"));

	$returnto = "userdetails.php?id=$uid&viewcomm=$commentid#comm$commentid";

	if ($returnto)
	  header("Location: $returnto");
	else
	  header("Location: $DEFAULTBASEURL/");     
	die;
}

elseif ($action == "vieworiginal")
{
	if (get_user_class() < UC_MODERATOR)
    stderr($tracker_lang['error'], $tracker_lang['access_denied']);

  $commentid = 0 + $_GET["cid"];

  if (!is_valid_id($commentid))
    stderr($tracker_lang['error'], $tracker_lang['invalid_id']);

  $res = sql_query("SELECT c.*, u.username, u.id AS uid FROM usercomments AS c LEFT JOIN users AS u ON c.user = u.id WHERE c.id=$commentid") or sqlerr(__FILE__,__LINE__);
  $arr = mysql_fetch_array($res);
  if (!$arr)
  	stderr($tracker_lang['error'], "Неверный идентификатор $commentid.");

  stdhead("Просмотр оригинала");
  print("<h1>Оригинальное содержание комментария №$commentid</h1><p>\n");
	print("<table width=500 border=1 cellspacing=0 cellpadding=5>");
  print("<tr><td class=comment>\n");
	echo htmlspecialchars($arr["ori_text"]);
  print("</td></tr></table>\n");

  $returnto = "userdetails.php?id={$arr["uid"]}&amp;viewcomm=$commentid#comm$commentid";

//$returnto = "userdetails.php?id=$userid&amp;viewcomm=$commentid#$commentid";

	if ($returnto)
     print("<p><font size=small><a href=$returnto>Назад</a></font></p>\n");

	stdfoot();
	die;
}
else
	stderr($tracker_lang['error'], "Unknown action");

die;
?>