малко помощ за система за коментари

polkovnika3

Registered
Здравейте,някои може ли да ми помогне да преработя тази система за коментари,тaкаче да мога да трия само аз съобщенията със моето ip,да взима ip-то на човека които пише коментара :) и ако е възможно да се добави опция за писане на име,но това не е проблем :) долу е кода
ако може да се направи и всеки коментар да е със различна картинка


download: http://dox.bg/files/dw?a=87f57469bd



index.php

<?php

include_once ('php/functions.php');
include_once ('php/db_connect.php');

$page_id = 1;

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Modern Tiny Ajax Comments System</title>
<link href="css/page.css" rel="stylesheet" type="text/css" />
<link href="css/tipsy.css" rel="stylesheet" type="text/css" />

<script src="js/jquery.js" type="text/javascript"></script>
<script src="js/tipsy.js" type="text/javascript"></script>
<script src="js/count_down.js" type="text/javascript"></script>
<script src="js/comments.js" type="text/javascript"></script>
<script type="text/javascript">
$(function() {
$('.tip').tipsy({ gravity: 'e' });
});
</script>
</head>

<body>

<div id="page">

<div class="box shadow">

</div>
<div class="comments">
<?php
foreach ((array) comments($page_id) as $comment) {
?>
<div class="comment shadow effect">
<p class="left tip" title="<?php echo $comment['username'];?> Said">
<img class="avatar" src="<?php echo get_gravatar($comment['email'],40);?>" />
</p>
<p class="body right">
<?php echo nl2br($comment['comment']);?>
<div class="details small">
<span class="blue"><?php echo timeBetween($comment['time'],time());?></span> · <a class="red" href="#" onclick="$(this).delete_comment(<?php echo $comment['id'];?>); return false;">Remove</a>
</div>
</p>

</div>
<?php
}
?>
</div>
<div class="add_comment">
<div class="write shadow comment">
<p class="left">
<img class="avatar" src="#" />
</p>
<p class="textarea right">
<textarea class="left" cols="40" rows="5"></textarea>
<input class="left" value="SEND" type="submit" />
</p>
</div>
<a onclick="$(this).add_comment(<?php echo $page_id;?>);return false;" class="right effect shadow" href="#">Add Comment</a>
</div>



<p class="left createdBy effect round">
<a href="http://awcore.com/dev/3/modern-tiny-ajax-comments-system_en">Read & Download on Advanced Web Core <span class="blue">»</span></a>
</p>


</div>

</body>
</html>




ajax.php

<?php
include_once ('php/functions.php');
include_once ('php/db_connect.php');

if(isset($_POST['remove'])){
$id = intval($_POST['remove']);
if(mysql_query("DELETE FROM `comments` WHERE `id` = $id")){
exit(json_encode(array('status' => 'done')));
}
}

if(isset($_POST['page_id']) and isset($_POST['comment'])){
$user_id = 1;
$page_id = intval($_POST['page_id']);
$comment = mysql_escape_string($_POST['comment']);
$time = time();

if(mysql_query("INSERT INTO `comments` (`user_id`, `page_id`, `comment`, `time`) VALUES ($user_id, '{$page_id}', '{$comment}', '{$time}')")){
$id = mysql_insert_id();
$row = single_comment($id);

exit(json_encode(array(
'id' => $id,
'avatar' => ($row['user_id']) ? get_gravatar($row['email'],40) : '#',
'time' => timeBetween($row['time'],time()),
'comment' => $row['comment'],
)));
}
}

?>




database.sql

--
-- Table structure for table `comments`
--

CREATE TABLE IF NOT EXISTS `comments` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` int(11) NOT NULL,
`page_id` int(11) NOT NULL,
`comment` mediumtext CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`time` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=3;

--
-- Dumping data for table `comments`
--

INSERT INTO `comments` (`id`, `user_id`, `page_id`, `comment`, `time`) VALUES
(1, 1, 1, 0x54686973206973206a75737420636f6d6d656e74, 1316263677),
(2, 2, 1, 0x5468616e6b20596f75203a29, 1316287603);

-- --------------------------------------------------------

--
-- Table structure for table `users`
--

CREATE TABLE IF NOT EXISTS `users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(255) NOT NULL,
`email` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;

--
-- Dumping data for table `users`
--

INSERT INTO `users` (`id`, `username`, `email`) VALUES
(1, 'xbox360.net63.net', 'polkovnika2@abv.bg');
(2, 'xbox360.net63.net', 'polkovnika2@abv.bg');



.........
 

Горе