View file love/otvety/inc/them.php

File size: 3.06Kb
<?
include_once '../sys/inc/thead.php';
title();
$id_razd=(int)abs((int)$_GET['tid']);

$them=mysql_fetch_array(mysql_query("SELECT * FROM `otvety_t` WHERE `id` = '$_GET[tid]' LIMIT 1"));
$razd=mysql_fetch_array(mysql_query("SELECT * FROM `otvety_razd` WHERE `id` = '$them[id_razdel]' LIMIT 1"));
echo "<div class=\"trow\">\n";
echo "<a href=\"/otvety\">Ответы</a> / <a href=\"iindex.php?rid=$razd[id]\">$razd[name]</a> / $them[name]<br />\n";
echo "</div>\n";

aut();


$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `otvety_p` WHERE `id_them`= $id_razd"),0);
$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];



if (isset($_GET['act']) && $_GET['act']=='add')
{
$msg=esc($_POST['msg']);
$tid=intval($_GET['tid']);

$msg=stripcslashes(htmlspecialchars($msg));
$tid=stripcslashes(htmlspecialchars($tid));

if (!isset($err))
{
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `otvety_p` WHERE `id_them` = '".mysql_real_escape_string($tid)."' AND `msg` = '".mysql_real_escape_string($msg)."' LIMIT 1"),0)!=0)msg("Ваше ответ повторяет предыдущее");
else{
$msgfotokom="Обитатель $user[nick] добавил ответ на ваш вопрос [b]$them[name][/b]: ".mysql_real_escape_string($msg)."";

if (isset($user) && $user['id']!=$them[id_user])
{

mysql_query("INSERT INTO `jurnal` (`id_user`, `id_kont`, `msg`, `time`) values('0', '$them[id_user]', '$msgfotokom', '$time')");
}
mysql_query("INSERT INTO `otvety_p` (`id_them`, `id_user`, `time` ,`msg`) VALUES ('".mysql_real_escape_string($tid)."','$user[id]','$time','".mysql_real_escape_string($msg)."')");
mysql_query("UPDATE `user` SET `balls` = '".($user['balls']+1)."' WHERE `id` = '$user[id]' LIMIT 1");
msg("Ответ успешно добавлен");
header("Location: iindex.php?tid=".intval($_GET['tid'])."&amp;rid=".intval($_GET['rid'])."");
}
}
}

$q6 = mysql_query("SELECT * FROM `otvety_p` WHERE `id_them` = '".intval($_GET['tid'])."' ORDER BY `time` LIMIT $start, $set[p_str]");
while($post = mysql_fetch_array($q6))
{

$ank = mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = '$post[id_user]' LIMIT 1"));

if($num==1){ 

$num=0;
}else{ 
 
$num=1;}

echo "&raquo;<a href='/info.php?id=$ank[id]'>$ank[nick]</a>\n";
echo '('.vremja($post['time']).')<br/>';
echo esc(trim(br(bbcode(smiles(links(stripcslashes(htmlspecialchars($post['msg']))))))));
echo "<br/>";

}

if ($k_page>1)str("iindex.php?tid=$them[id]&",$k_page,$page); // Вывод страниц


echo "<form method='post' action='iindex.php?tid=".intval($_GET['tid'])."&amp;rid=".intval($_GET['rid'])."&amp;act=add'>\n";
if ($user>1)
echo "Ответ: <a href=\"/smiles.php\"><small>Смайлы</small></a><br />\n<textarea name='msg'></textarea><br />\n";
if ($user>1)
echo "<input type='submit' value='Опубликовать' /><br />\n";
echo "</form>\n";
echo '<hr color="DeepSkyBlue1" hr noshade size="1"></font>';
echo "&laquo;<a href='/love/index.php'>В знакомства</a><br/>\n";

?>