<?php
include_once '../../sys/inc/start.php';
include_once '../../sys/inc/compress.php';
include_once '../../sys/inc/sess.php';
include_once '../../sys/inc/home.php';
include_once '../../sys/inc/settings.php';
include_once '../../sys/inc/db_connect.php';
include_once '../../sys/inc/ipua.php';
include_once '../../sys/inc/fnc.php';
include_once '../../sys/inc/user.php';
$set['title']='Ответы про меня';
include_once '../../sys/inc/thead.php';
title();
aut();



if (!isset($user)){
echo "Гостям вход запрешён";
include_once '../sys/inc/tfoot.php';
}

if (isset($_GET['win']))
{
if ($user['balls']>50){
mysql_query("UPDATE `user` SET `balls` = '".($user['balls']-50)."' WHERE `id` = '$user[id]' LIMIT 1");
mysql_query("UPDATE `sivor_user` SET `win` = '1' WHERE `id` = '".mysql_escape_string($_GET['win'])."' LIMIT 1");
header("Location: otv.php");
}
else {
echo '<div class=err>Не достаточно баллов<div>';
}
}
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `sivor_user` WHERE `id_ank` = '$user[id]'"), 0);
$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];
echo "<table class='post'>\n";
if ($k_post==0)
{
echo "   <tr>\n";
echo "  <td class='p_t'>\n";
echo "Нет ответов!\n";
echo "  </td>\n";
echo "   </tr>\n";
}
$q = mysql_query("SELECT * FROM `sivor_user` WHERE `id_ank` = '$user[id]' ORDER BY `id` DESC LIMIT $start, $set[p_str]");
while ($f = mysql_fetch_array($q))
{
echo "   <tr>\n";
$q_user=mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id`='".$f['id_user']."'"));
echo "  <td class='icon14'>\n";
echo "".status($q_user['id'])."";
echo "  </td>\n";
echo "  <td class='p_t'>\n";
echo "$f[name]<br/>\n";
if (isset($user) && $f['golos']==1)echo "[<b><font color=blue>ДА</font></b>]\n"; else echo "[<b><font color=red>НЕТ</font></b>]\n";
if (isset($user) && $f['win']==1)echo "<a href='/info.php?id=$q_user[id]'><span style=\"color:$q_user[ncolor]\">$q_user[nick]</span></a>";
if (isset($user) && $f['win']==0) echo "<a href='?win=$f[id]'>Кто ответил?</a> (50 бал.)";
echo "  </td>\n";
echo "   </tr>\n";
}

echo "</table>\n";


if ($k_page>1)str("index.php?",$k_page,$page); // Вывод страниц


echo "<div class='aut'><a href='index.php'>Назад</a></div>";
include_once '../../sys/inc/tfoot.php';
?>