$sr = dirname(dirname(__FILE__));
require($sr . '/top/config/config.inc.php');
include($sr . '/lib/headers.lib.php');
require($sr . '/lib/string.lib.php');
require($sr . '/lib/mysql.lib.php');
require($sr . '/top/mainstat.php');
include('../inc/header.inc.php');
$handler_top = mysqli_connect(TOP_HOST, TOP_DBUSER, TOP_DBPASSWD, TOP_DBNAME);
mysqli_query($handler_top, "SET NAMES utf8");
$id = intval($id);
column_header("Комментарии");
if ($id)
{
view_vote_form($id);
$result = mysqli_query($handler_top, "SELECT id,name,describ FROM sites WHERE id='".$id."'");
$row = mysqli_fetch_array($result);
mysqli_free_result($result);
print("
");
}
print("");
if (!isset($from)) $from = 0;
if (!isset($to)) $to = COMMENTS_PER_PAGE;
if (isset($from) && isset($to))
{
if (!ereg('^[0-9]+',$from) || !ereg('^[0-9]+',$to))
{
$from = 0;
$to = COMMENTS_PER_PAGE;
}
}
if ($cmd=="add")
{
if ($ontespom != "222")
{
error("Ваш комментарий является спамом или у Вас отключен Javascript.");
column_footer();
include($sr . '/inc/footer.inc.php');
exit;
}
if (antiabuse($comment))
{
error("Предположительно, в Вашем комментарии содержится ненормативная лексика или сообщение, вероятно, является спамом. Попробуйте изменить содержание комментария.");
column_footer();
include($sr . '/inc/footer.inc.php');
exit;
}
if (!string_isemail($email))
{
error("Некорректный e-mail адрес.");
column_footer();
include($sr . '/inc/footer.inc.php');
exit;
}
if (!isset($numespame) || !isset($comment) || !isset($email))
{
error("Заполните все поля.");
column_footer();
include($sr . '/inc/footer.inc.php');
exit;
}
$comment = substr($comment,0,COMMENT_SIZE);
// Security
$numespame = htmlspecialchars($numespame);
$comment = htmlspecialchars($comment);
$comment = addslashes($comment);
$numespame = addslashes($numespame);
$email = addslashes($email);
$comment = nl2br($comment);
// ---
$ip = getenv("REMOTE_ADDR");
mysqli_query($handler_top, "INSERT INTO comments VALUES ('','".$id."','".$numespame."','".$email."','".$ip."','".time()."','".$comment."')");
}
if ($id) view_comments($id,$from,$to);
?>
if ($id) view_comments_form($id);
else
{
error("Чьи комментарии? Введите идентификационный номер.");
}
column_footer();
include($sr . '/inc/footer.inc.php'); ?>
function view_comments($id,$from,$to)
{
$result = mysqli_query($handler_top, "SELECT count(*) FROM comments WHERE siteid='".$id."'");
$max = db_fetch_array($result);
db_free_result($result);
if ($from)
{
$from_minus = $from - COMMENTS_PER_PAGE;
if ($from_minus < 0) $from_minus = 0;
print("< предыдущие");
}
if ($to > COMMENTS_PER_PAGE) print(" | ");
$from_plus = $from + COMMENTS_PER_PAGE;
if ($to && ($from_plus<$max[0]))
{
$from_plus = $from + COMMENTS_PER_PAGE;
print("следующие >");
}
print("
");
$result = mysqli_query($handler_top, "SELECT * FROM comments WHERE siteid='".$id."' ORDER BY id DESC LIMIT ".$from.",".COMMENTS_PER_PAGE);
$c=0;
while($row=db_fetch_array($result))
{
$time = gmdate("d-m-Y, H:i:s", $row['addtime']);
print("");
print("| ".$row['name']." | ");
print("| ".$time." | ");
print("| ".$row['comment']." | ");
print(" ");
print(" ");
$c++;
}
if (!$c) print("Комментариев к этому ресурсу нет.
");
db_free_result($result);
print(" | | ");
print(" | ");
print(" ");
}
function view_comments_form($id)
{
?>
}
function view_vote_form($id)
{
?>
} ?> |