<?
include 'connect.php';
//Если id получен 
if(isset($_GET['id'])){
$id=num($_GET['id']);
$req = mysql_query("SELECT * FROM `users` WHERE `id` = '$id' LIMIT 1");
   if (mysql_num_rows($req)) {
   $user = mysql_fetch_assoc($req);
   }
}

//Если никто не выбрался
if(empty($user['id'])){
   if($u['id']){
   $req = mysql_query("SELECT * FROM `users` WHERE `id` = '".$u['id']."' LIMIT 1");
   $user = mysql_fetch_assoc($req);
   } else {
   header ("Location: index.php");
   exit;
   }
}

include 'head.php';
switch($_GET['s'])
{
case 'ok':
akt_rating($u['id'],1,10);
if($_GET['s'])mysql_query("UPDATE `users` SET `act` = '".($u['act']+$number)."' WHERE `id` = '$u[id]' LIMIT 1");
echo '<div class = "title">';
echo "Привет, <b>".$user['login']."</b>!<br />";
if($user['sex'] == 'm') echo 'Последний раз ты у нас был: <b>'.vremya($user['online']).'</b><hr>'; else echo 'Последний раз ты у нас была: <b>'.vremya($user['online']).'</b><hr>';

$cusers_online = mysql_result(mysql_query("SELECT COUNT(*) FROM `users` WHERE `online` > '".(time()-$system['online_time'])."'"), 0);
echo 'Сейчас на сайте: <a href = "users.php?online=1"> '.$cusers_online.'</a></font>';
echo '</div>';

break;

}
echo "</div>";
if($u['id']<=2 OR $u['id']==176){
echo "<div class='overfl_hid' vertical-align: middle;>";
echo "<b>Что можна сделать:</b></br>";
if($user['photos'] == '0'){
echo"<a href='kvest.php?foto'><img src=\"http://new-i09.spaces.ru/com_closed.gif\" alt=\"\"/> Добавить фото <span class='middle' style='color:#666666'>(+0.1 к рейтингу)</span><a>"; 
}
else
{
echo"<a href='kvest.php?foto'><img src=\"http://new-i09.spaces.ru/com_open.gif\" alt=\"\"/> Добавить фото <span class='middle' style='color:#339966'>(+0.1 к рейтингу)</span><a>"; 
}
echo "</br>";
if($u['ank']==0)
{
echo "<a href='kvest.php?anketa'><img src='http://new-i09.spaces.ru/com_closed.gif' alt=''> Заполнить анкету <span class='middle' style='color:#666666'>(+0.1 к рейтингу)</span>";
}
else
{
echo "<a href='kvest.php?anketa'><img src='http://new-i09.spaces.ru/com_open.gif' alt=''> Заполнить анкету <span class='middle' style='color:#339966'>(+0.1 к рейтингу)</span>";
}
echo "</div>";
}
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `vijet1` WHERE `id_user` = '$user[id]'"),0)==0){
mysql_query("INSERT INTO `vijet1` (id_user, vijet_text, url) values('$user[id]', 'Мой сайт', '/page.php')");
mysql_query("INSERT INTO `vijet1` (id_user, vijet_text, url) values('$user[id]', 'Чат', '/chat.php')");
mysql_query("INSERT INTO `vijet1` (id_user, vijet_text, url) values('$user[id]', 'Форум', '/forum.php')");
mysql_query("INSERT INTO `vijet1` (id_user, vijet_text, url) values('$user[id]', 'Знакомства', '/love.php')");
}
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `vijet` WHERE `id_user` = '$user[id]'"),0)==0){
mysql_query("INSERT INTO `vijet` (id_user, id_vijet, pos) values('$user[id]', '1', '1')");
mysql_query("INSERT INTO `vijet` (id_user, id_vijet, pos) values('$user[id]', '2', '2')");
mysql_query("INSERT INTO `vijet` (id_user, id_vijet, pos) values('$user[id]', '3', '3')");
mysql_query("INSERT INTO `vijet` (id_user, id_vijet, pos) values('$user[id]', '4', '4')");
mysql_query("INSERT INTO `vijet` (id_user, id_vijet, pos) values('$user[id]', '5', '5')");
mysql_query("INSERT INTO `vijet` (id_user, id_vijet, pos) values('$user[id]', '6', '6')");
}

$test = mysql_result(mysql_query("SELECT COUNT(*) FROM `users` WHERE `act` > '0.00' AND `id` = '".$u['id']."'"), 0.00);
$rating = '';
echo '<div class="block_2">';
echo "<b></a>Ваш рейтинг:</b> ".$u['rating']."";
echo "</div>";
//Виджет 1
echo "<div class='block_2'>";
$q_vijet1=mysql_query("SELECT * FROM `vijet1` WHERE `id_user` = '$user[id]' LIMIT 4");
while ($vijet1 = mysql_fetch_assoc($q_vijet1))
{
echo '&nbsp;<a href="'.$vijet1['url'].'">'.$vijet1['vijet_text'].'</a></br>';
}
echo "</div>";
//
//виджеты

$q_vijet=mysql_query("SELECT * FROM `vijet` WHERE `id_user` = '$user[id]' ORDER BY pos");
while ($vijet = mysql_fetch_assoc($q_vijet))
{
echo "<div class='block_2'>";
$vijet_set=mysql_fetch_assoc(mysql_query("SELECT * FROM `vijet_set` WHERE `id` = $vijet[id_vijet] LIMIT 1"));
echo '<img src="'.$vijet_set['img'].'" alt=""><b><a href="'.$vijet_set['url'].'">'.$vijet_set['text'].'</a></b><br />';
echo "</div>";
}

echo "<div class='lol' style='text-align:right;'><img src=\"http://new-i09.spaces.ru/settings.gif\" alt=\"\"/><a href='start_set.php'>Настроить эту страницу </a></a></div>\n";

include 'foot.php';

?>