<?
# МОД СЫВОРАТКА ПРАВДЫ
# KAZAMA
# 383991000
error_reporting(0);
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();



$ank['id'] = $user['id'];
if (isset($_GET['id']))$ank['id'] = intval($_GET['id']);
$q = mysql_query("SELECT * FROM `user` WHERE `id` = $ank[id] LIMIT 1");

$ank = mysql_fetch_array($q);
$qq=mysql_fetch_array(mysql_query("SELECT * FROM `sivor` ORDER BY RAND() "));

if (!isset($user)){
echo "Чтобы зайти в этот раздел надо зарегистрироваться!";
include_once '../sys/inc/tfoot.php';
}


if (isset($_GET['sivor_edit']))
{
mysql_query("UPDATE `user` SET `sivor_edit` = '".mysql_escape_string($_GET['sivor_edit'])."' WHERE `id` = '$user[id]' LIMIT 1");
header("Location: index.php");
}

if (isset($_GET['golos'])&&$_GET['id_ank']&&$_GET['sivor'])
{
$q_id_ank=mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id`='".mysql_escape_string($_GET['id_ank'])."'"));
mysql_query("UPDATE `user` SET `sivor_top` = '".($q_id_ank['sivor_top']+1)."' WHERE `id` = '".mysql_escape_string($_GET['id_ank'])."' LIMIT 1");
$q_sivor=mysql_fetch_array(mysql_query("SELECT * FROM `sivor` WHERE `id`='".mysql_escape_string($_GET['sivor'])."'"));
mysql_query("INSERT INTO `sivor_user`(`id_user`, `id_ank`, `golos`, `name`) VALUES('".$user['id']."', '".mysql_escape_string($_GET['id_ank'])."', '".mysql_escape_string($_GET['golos'])."', '".$q_sivor['name']."')");
mysql_query("INSERT INTO `jurnal` (`id_user`, `id_kont`, `msg`, `time`) values('0', '".mysql_escape_string($_GET['id_ank'])."', 'Про вас ответили в игре [url=/sivor/spisok.php]Сыворотка правды[/url]', '$time')");
header("Location: index.php");
}

///////////

$count= mysql_result(mysql_query("SELECT COUNT(*) FROM `sivor_user` WHERE `id_ank` = $user[id]",$db), 0);
echo '<div class="p_m"><center>Ответы про : <br/>';

if ($ank['sivor_edit']==0) echo 'друзей |'; else echo '<a href="?sivor_edit=0">друзей</a> |';
if ($ank['sivor_edit']==1) echo 'юзеров онлайн |'; else echo '<a href="?sivor_edit=1">юзеров онлайн</a> |';
if ($ank['sivor_edit']==2) echo 'всех юзеров '; else echo '<a href="?sivor_edit=2">всех юзеров</a> ';
echo '</center></div>';
echo "<div class='p_t'>";
echo '<td class="p_m"><center><a href="spisok.php">Ответы про меня ('.$count.')</a><br/>';
//////////
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `frends` WHERE `user` = '$user[id]' AND `i` = '1'"),0) ==0&&$user['sivor_edit']==0)echo "<div class='err'>Нет друзей</div>";



if ($ank['sivor_edit']==0)
$q = mysql_query("SELECT * FROM `frends` WHERE `user` = '$ank[id]' AND `i` = '1' AND `sivor_zapret` = '0' ORDER BY RAND() LIMIT 1");
if ($ank['sivor_edit']==1)
$q = mysql_query("SELECT `id` FROM `user` WHERE `date_last` > '".(time()-600)."' AND `sivor_zapret` = '0' ORDER BY RAND() LIMIT 1");
if ($ank['sivor_edit']==2)
$q = mysql_query("SELECT `id` FROM `user` WHERE `sivor_zapret` = '0'ORDER BY RAND() LIMIT 1");
while ($f = mysql_fetch_array($q))
{
if ($ank['sivor_edit']==0)
	$a = mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = '$f[frend]' LIMIT 1"));
else $a = mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = '$f[id]' LIMIT 1"));

	avatar($a['id']);
	echo '<br/><img src="/style/themes/'.$set['set_them'].'/user/'.$a['pol'].'.png" alt="" />';
	echo '<a href="/info.php?id='.$a['id'].'">'.$a['nick'].'</a>'.online($a['id'])."\n";
echo "<br/>$qq[name]<br/>";	
echo ' <a href="?golos=1&id_ank='.$a['id'].'&sivor='.$qq['id'].'"><img src="img/b_yes.gif" alt=""></a>  <a href="?golos=2&id_ank='.$a['id'].'&sivor='.$qq['id'].'"><img src="img/b_no.gif" alt=""></a><br/><a href="index.php?".rand(0001, 9999)."">Пропустить</a>';

}


echo "</center></div>";
if (isset($user)&&$user[level]>=3)echo "<div class=p_m><img src='img/nast.png' alt='!'> <a href='new_vopros.php'><font color=red>Создать вопрос</font></a><br/>\n";
echo '<img src="img/nast.png" alt="!"> <a href="zapret.php">Настройки</a> <br/>';
echo '<img src="img/nast.png" alt="!"> <a href="frend.php">Настройки друзей</a> <br/>';
$count_top= mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `sivor_top` >= '1'",$db), 0);
echo '<img src="img/info.gif" alt="!"> <a href="user.php">Топ ответчиков</a> ['.$count_top.']</div>';

include_once '../sys/inc/tfoot.php';
?>