<?php

/**
 * @package     JohnCMS
 * @link        http://johncms.com
 * @copyright   Copyright (C) 2008-2011 JohnCMS Community
 * @license     LICENSE.txt (see attached file)
 * @version     VERSION.txt (see attached file)
 * @author      http://johncms.com/about
 */

define('_IN_JOHNCMS', 1);

require('../incfiles/core.php');
$lng_profile = core::load_lng('profile');

/*
-----------------------------------------------------------------
Закрываем от неавторизованных юзеров
-----------------------------------------------------------------
*/
if (!$user_id) {
    require('../incfiles/head.php');
    echo functions::display_error($lng['access_guest_forbidden']);
    require('../incfiles/end.php');
    exit;
}

/*
-----------------------------------------------------------------
Получаем данные пользователя
-----------------------------------------------------------------
*/
$user = functions::get_user($user);
if (!$user) {
    require('../incfiles/head.php');
    echo functions::display_error($lng['user_does_not_exist']);
    require('../incfiles/end.php');
    exit;
}

/*
-----------------------------------------------------------------
Переключаем режимы работы
-----------------------------------------------------------------
*/
$array = array(
    'activity'  => 'includes/profile',
    'ban'       => 'includes/profile',
    'edit'      => 'includes/profile',
    'images'    => 'includes/profile',
    'info'      => 'includes/profile',
    'ip'        => 'includes/profile',
    'guestbook' => 'includes/profile',
    'karma'     => 'includes/profile',
    'status'     => 'includes/profile',
    'office'    => 'includes/profile',
    'password'  => 'includes/profile',
    'reset'     => 'includes/profile',
    'settings'  => 'includes/profile',
    'stat'      => 'includes/profile',
    'friends'   => 'includes/profile'
);
$path = !empty($array[$act]) ? $array[$act] . '/' : '';
if (array_key_exists($act, $array) && file_exists($path . $act . '.php')) {
    require_once($path . $act . '.php');
} else {
    /*
    -----------------------------------------------------------------
    Анкета пользователя
    -----------------------------------------------------------------
    */
    $headmod = 'profile,' . $user['id'];
    $textl = $lng['profile'] . ': ' . htmlspecialchars($user['name']);
    require('../incfiles/head.php');

    // Меню анкеты
    $menu = array();
 if ($user['id'] != $user_id && $rights >= 7 && $rights > $user['rights'])   {
        $menu[] = '<a href="profile.php?act=edit&amp;user=' . $user['id'] . '">' . $lng['edit'] . '</a>';
    }
    if ($user['id'] != $user_id && $rights >= 7 && $rights > $user['rights']) {
        $menu[] = '<a href="' . $set['homeurl'] . '/' . $set['admp'] . '/index.php?act=usr_del&amp;id=' . $user['id'] . '">' . $lng['delete'] . '</a>';
    }
    if ($user['id'] != $user_id && $rights > $user['rights']) {
        $menu[] = '<a href="profile.php?act=ban&amp;mod=do&amp;user=' . $user['id'] . '">' . $lng['ban_do'] . '</a>';
    }
    if (!empty($menu)) {
        echo '<div class="topmenu">' . functions::display_menu($menu) . '</div>';
    }

if ($user['id'] == $user_id)
if (empty($user['yearofbirth']) || empty($user['imname']) || empty($user['live']) || empty($user['about'])) {
echo '<div align="center" class="menu"><b>Sizning anketangiz to\'liq to\'ldirilmagan! Yanada ko\'proq do\'stlar orttirish uchun aketangizni to\'ldirishni maslahat beramiz !!!</b><br/><hr>
<span class="currentpage"><a href="/users/profile.php?act=edit"><font color="red">Anketani to\'ldirish</a></span></font></div>';
}

$p_ank = mysql_result(mysql_query("SELECT `prosm_ank` FROM `users` WHERE `id` = '" . $user['id'] . "';"), 0);
$i_ank = (int) $p_ank;
$r_ank = $i_ank + 1;
if (file_exists(('../files/users/photo/' . $user['id'] . '_small.jpg'))) {}
else if ($user['id'] == $user_id) {
echo '<div align="center" class="menu"><a href="'.$home.'/users/profile.php?act=images&amp;mod=up_photo&amp;user='.$user['id'].'" class="kiritish" style="max-width: 200px; color: #ff1493;">Fotosuratni o\'rnatish</a></div>';
}
// Registratsiya tasdiqlanishini kutmoqda
if ($rights >= 7 && !$user['preg'] && empty($user['regadm'])) {
    echo '<div class="rmenu">' . $lng_profile['awaiting_registration'] . '</div>';
}
//Уведомление о дне рожденья
    if ($user['dayb'] == date('j', time()) && $user['monthb'] == date('n', time())) {
        echo '<div class="menu">' . $lng['birthday'] . '!!!</div>';
    }

    $anhbia = null;
    if (file_exists('../files/users/photo/'.$user['id'].'.jpg')) {
        $anhbia = '/files/users/photo/'.$user['id'].'.jpg';
    }else{
        if (file_exists(('../files/users/avatar/' . $user['id'] . '.png'))) {
            $anhbia = '/files/users/avatar/'.$user['id'].'.png';
        } else {
            $anhbia = '/images/empty.png';
        }
    }
    $ava = null;
    if (file_exists(('../files/users/avatar/' . $user['id'] . '.png'))) {
        $ava = '/avatar/'.$user['id'].'-35-70.png';
    } else {
        $ava = '/avatar/default-35-70.png';
    }
  echo '<div class="menu"><style>#profile{background:url('.$anhbia.');background-position: center;background-size: cover;width: 100%;height: auto;margin: 10px 0 10px 0; background-repeat: no-repeat;} .contect{ background-color:rgba(1, 46, 69,0.2); width:100%; height: auto; padding-top:100px;padding-bottom:8px;} #pagina{width:100%;margin:0 auto;padding:0} #page_body{padding-top:2px;clear:both;margin:0} #wrapper{z-index:2;position:relative;margin-top:7px;}</style>
    <div id="profile"><DIV class="contect"><DIV id="pagina"><DIV id="page_body"><table cellpadding="0" cellspacing="0"><tr><td>' . functions::display_user($user, $arg) . '
</td></tr></table></div></div></div></div>';
echo '</div></div>';

  // FOTOSURATLAR
$umumiy = mysql_result(mysql_query("SELECT COUNT(*) FROM `cms_album_files` WHERE `user_id` = '" .$user['id']. "'"), 0);
$fotoalbom = mysql_query("SELECT * FROM `cms_album_files` WHERE `user_id` = '" .$user['id']. "' ORDER BY `time` ");
$fotosurat = mysql_fetch_array($fotoalbom);

if ($umumiy) {
  if (file_exists('../files/users/album/' . $user['id'] . '/' . $fotosurat['img_name'] . '')) {
    $fotoalbom = mysql_query("SELECT * FROM `cms_album_files` WHERE `user_id` = '" .$user['id']. "' ORDER BY `time` desc LIMIT 5");
echo '<div class="phdr"><b>Yangi fotosuratlar</b></div><div class="menu" align="center">';
$i=0;
while ($fotosurat = mysql_fetch_array($fotoalbom)) {
$i++;
echo $i % 2 ? '<div style="display: inline-block; position: relative;  top: 0px; margin-left: -10px;">' : '<div style="display: inline-block; position: relative;  top: 8px; margin-left: -10px;">';
echo ' <img style="margin: 2px; border-radius: 15px; border: .14em solid #B9B4B4; width: 55px; height: 55px;" src="../files/users/album/' . $fotosurat['user_id'] . '/' . $fotosurat['img_name'] . '" alt="#" />';
echo '</div>';
	}
	echo '</div>';
  }
}
/*
// tizim xabari
    $new_sys_mail = mysql_result(mysql_query("SELECT COUNT(*) FROM `cms_mail` WHERE `from_id`='$user_id' AND `read`='0' AND `sys`='1' AND `delete`!='$user_id';"), 0);
// chat
$new_chat = mysql_result(mysql_query('select count(*) from `m_chat` where `time` >  ' . (time() - 3600*24) . ''), 0);

$minut = date("H", time() + $set['timeshift'] * 3600); if($minut == 00){ $chatga = mysql_result(mysql_query('select count(*) from `m_chat`'), 0); }
$soat = date("H", time() + $set['timeshift'] * 3600); if($soat == 00){
mysql_query("UPDATE `users` SET `m_chat_last` = '" . time() . "' WHERE `id` = '$user_id'");

} $m_c_chat = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `m_chat` WHERE `time` > '" . $datauser['m_chat_last'] . "'"), 0);
if($m_c_chat ==  0){
$m_c_chat = '';
} else { 
$m_c_chat = '+' . $m_c_chat . ''; }


  // shaxsiy xabar
$new_mail = mysql_result(mysql_query("SELECT COUNT(*) FROM `cms_mail` LEFT JOIN `cms_contact` ON `cms_mail`.`user_id`=`cms_contact`.`from_id` AND `cms_contact`.`user_id`='$user_id' WHERE `cms_mail`.`from_id`='$user_id' AND `cms_mail`.`sys`='0' AND `cms_mail`.`read`='0' AND `cms_mail`.`delete`!='$user_id' AND `cms_contact`.`ban`!='1' AND `cms_mail`.`spam`='0'"), 0);



$offer = mysql_result(mysql_query("SELECT COUNT(*) FROM `cms_contact` WHERE `from_id`='$user_id' AND `type`='2' AND `friends`='0' AND `ban`='0'"), 0);
if ($user_id) {
echo ' <div class="phdr"><table style="width:100%" cellspacing="0" cellpadding="0"><tbody><tr>';

// bosh sahifa
echo '<td><a href="../index.php"><img src="/ico/menu.png" alt="" /><br><font color="white">Menu</a></font></td>';

	$mexmon = mysql_result(mysql_query("SELECT FROM `my_guests` WHERE `my_id` = ''.$user_id.'' AND `type` = '0'"), 0);
	// mehmon
$new_guests = @mysql_result(@mysql_query("SELECT COUNT(*) FROM `my_guests` WHERE `my_id` = '" . $user_id . "' AND `type` = '0';"), 0);   
if ($new_guests>0) {
echo '<td><a href="/users/my_guests.php"><img src="/images/panel/guest.png" alt="" /><br><font color="white">+' . $new_guests . '</a></font></td>';   }
if(time() > $datauser['money_time'] + 3600 * 24){
$bonus = mysql_fetch_assoc(mysql_query("SELECT * FROM `shop` WHERE `id`=1"));
    $mon = $datauser['balans'] + $bonus['price'];
    mysql_query("UPDATE `users` SET `balans` = '$mon', `money_time` = '".time()."' WHERE `id` = '$user_id'");
echo '<b></b>';
    }

// Xabarlar
if ($new_mail) echo '<td><a href="' . $home . '/mail/index.php?act=new"><img src="/ico/ls.png" alt="Pochta" /><br><font color="white">Xabar +' . $new_mail . '</a></font></td>'; if ($new_sys_mail) echo '<td><a class="active" href="' . $home . '/mail/index.php?act=systems"><img src="/ico/ls.png" alt="Pochta" /><br>Sistema +' . $new_sys_mail . '</a></td>'; if ($offer) echo '<td><a class="active" href="' . $home . '/users/profile.php?act=friends&do=offers"><img src="/ico/ls.png" alt="Pochta" /><br><font color="white">Taklif +' . $offer . '</a></font></td>';
// Forum
echo '<td><a href="/forum/index.php?act=new"><img src="/ico/for.png"><br><font color="white">Lenta</a></font></td>';
// online
echo '<td><a href="/users/index.php?act=online"><img src="../ico/online.png" alt="" /><br><font color="white">Online</a>'.$users.'</font></td>';

// kunlik bonus
$holat = mysql_fetch_array(mysql_query("SELECT * FROM `kunbonus` WHERE `user_id` = '".$user_id."' AND `time` > '".(time() - 86400)."';"));
if (!$holat) { echo '<td><a href="/foydali/bonus.php"><img src="../ico/sistema.png" width="17" style="margin-bottom: -6px;"> <br><font color="white">Bonus</a></font></td>';}
// Chat

 $chat_javob2 = mysql_query("SELECT * FROM `chat_javob` where `kimga_id` = '" . $datauser['id'] . "' AND `yangi` = '1' ORDER BY `time` DESC LIMIT 1");  
 $chat_javob = mysql_fetch_assoc($chat_javob2);  
 $chat_javob_azo2 = mysql_query("SELECT * FROM `users` where `id` = '" . $chat_javob['kim_id'] . "'");  
$chat_javob_azo = mysql_fetch_assoc($chat_javob_azo2);  
if(!empty($chat_javob_azo['id'])) 
 $chat_jav = ' - <b> ' . $chat_javob_azo['name'] . ' </b>'; 
$total_chat = mysql_result(mysql_query("SELECT COUNT(*) FROM `m_chat` where `time` >= '" . (time() - 86400) . "'"), 0);
echo '<td><a href="/chat"><img src="../ico/chat.png" alt="" /><br><font color="white">Chat  '.$chat_jav.'</a></font></td>';

// anketa
echo '<td><a href="/users/profile.php"><img src="../images/lenta/fikr.png" width="19" style="margin-bottom: -5px;"><br><font color="white">Anketa</a></font></td>';

echo '<td><a href="/users/profile.php?act=office"><img src="/ico/user.png" alt=""/><br><font color="white">Kabinet</a></font></td>';}
echo '</div>';*/


// MALUMOT
echo '<div class="phdr"><b>Ma\'lumotlar</b></div><div class="menu">';
// id raqami
echo '<img src="/images/green.gif" alt="S" /> ID raqami: <b>'.$user['id'].'</b><br/>';
// logini
echo '<img src="/images/green.gif" alt="S" /> Login: <b>'.$user['name_lat'].'</b><br/>';
// ismi
if (!empty($user['imname'])) {
echo '<img src="/images/green.gif" alt="S" /> Ismi: <b>'.$user['imname'].'</b><br/>';
}
// dasxati
if (!isset($arg['stshide']) && !empty($user['status'])) {
echo '<img src="/images/green.gif" alt="S" /> Dasxati: <b>' . $user['status'] . '</b><br/>';
}

// sungi tashrif
if (time() > $user['lastdate'] + 900) {
$lastvisit = date("d.m.Y (H:i)", $user['lastdate']);
if (isset($lastvisit))
echo '<img src="/images/green.gif" alt="S" /> So\'nggi tashrif: <b>' . $lastvisit . '</b><br/>';
}
//yashash joyi
if (!empty($user['live'])) {
echo '<img src="/images/green.gif" alt="S" /> Yashash joyi: <b> '.$user['live'].'</b><br />';
}
// yoshi
if(!empty($user['yearofbirth'])){
function calc_age($d, $m, $y) {
$age = date('Y') - $y;
$_m = date('m');
if($_m < $m || ($_m == $m && date('d') < $d))
$age--;

return $age;
}
$user_age = calc_age($user['dayb'], $user['monthb'], $user['yearofbirth']);
echo '<img src="/images/green.gif" alt="S" /> Yoshi: <b>'.$user_age.' da</b><br/>';
}
// tangalari
echo '<img src="/images/green.gif" alt="S" /> Tangalari:<b>' . $user['balans'] . '</b><br/>';
@mysql_query("UPDATE `users` SET `prosm_ank` = '" . $r_ank . "' WHERE `id` = '" . $user['id'] . "';");
echo '<img src="/images/green.gif" alt="S" /> Anketa <b> ' . $r_ank . '</b> marta ko\'rilgan</b><br/>';
// qayerda
if ($user['id'] != core::$user_id) {
echo '<img src="/images/info.png" alt="S" />  Hozirda: <b> ' . functions::display_place($user['id'], $user['place']) . '</b>';
}

$p_ank = mysql_result(mysql_query("SELECT `prosm_ank` FROM `users` WHERE `id` = '" . $user['id'] . "';"), 0);
$i_ank = (int) $p_ank;
$r_ank = $i_ank + 1;

echo '<p align="left"><img src="/images/contacts.png" alt="S" /> <a href="profile.php?act=info&amp;user=' . $user['id'] . '"><b>Shaxsiy ma\'lumotlar &raquo;</b></a></p></div>';

if ($user_id && $user['id'] == $user_id) {
echo '
        <div class="menu"><form action="search.php" method="post">
<div class="search-box">
<center><input type="text" name="search" placeholder="do\'stlarni topish"/></center>
<button name="submit" type="submit"><span class="fa fa-search"></span></button>
                </div>
            </form>
        </div>';
}

 /*   // Информация о юзере
    $arg = array(
        'lastvisit' => 1,
        'iphist'    => 1,
        'addinfo'    => 1,
        'header'    => '<div><a href="profile.php?act=info&amp;user=' . $user['id'] . '">Giới thiệu</a> · <a href="profile.php?act=friends&amp;user=' . $user['id'] . '">' . $lng_profile['friends'] . '</a> · <a href="album.php?act=list&amp;user=' . $user['id'] . '">Album ảnh</a> · <a href="profile.php?act=stat&amp;user=' . $user['id'] . '">' . $lng['statistics'] . '</a> · <a href="profile.php?act=activity&amp;user=' . $user['id'] . '">Nhật ký hoạt động</a></div>'
    );

    if ($user['id'] != core::$user_id) {
        $arg['footer'] = '<span class="gray">' . core::$lng['where'] . ':</span> ' . functions::display_place($user['id'], $user['place']);
    }

  
    include 'stt.php';

  // Карма
    if ($set_karma['on']) {
        $karma = $user['karma_plus'] - $user['karma_minus'];
        if ($karma > 0) {
            $images = ($user['karma_minus'] ? ceil($user['karma_plus'] / $user['karma_minus']) : $user['karma_plus']) > 10 ? '2' : '1';
            echo '<div class="gmenu">';
        } else if ($karma < 0) {
            $images = ($user['karma_plus'] ? ceil($user['karma_minus'] / $user['karma_plus']) : $user['karma_minus']) > 10 ? '-2' : '-1';
            echo '<div class="rmenu">';
        } else {
            $images = 0;
            echo '<div class="menu">';
        }
        echo '<table  width="100%"><tr><td width="22" valign="top"><img src="' . $set['homeurl'] . '/images/k_' . $images . '.gif"/></td><td>' .
            '<b>' . $lng['karma'] . ' (' . $karma . ')</b>' .
            '<div class="sub">' .
            '<span class="green"><a href="profile.php?act=karma&amp;user=' . $user['id'] . '&amp;type=1">' . $lng['vote_for'] . ' (' . $user['karma_plus'] . ')</a></span> | ' .
            '<span class="red"><a href="profile.php?act=karma&amp;user=' . $user['id'] . '">' . $lng['vote_against'] . ' (' . $user['karma_minus'] . ')</a></span>';
        if ($user['id'] != $user_id) {
            if (!$datauser['karma_off'] && (!$user['rights'] || ($user['rights'] && !$set_karma['adm'])) && $user['ip'] != $datauser['ip']) {
                $sum = mysql_result(mysql_query("SELECT SUM(`points`) FROM `karma_users` WHERE `user_id` = '$user_id' AND `time` >= '" . $datauser['karma_time'] . "'"), 0);
                $count = mysql_result(mysql_query("SELECT COUNT(*) FROM `karma_users` WHERE `user_id` = '$user_id' AND `karma_user` = '" . $user['id'] . "' AND `time` > '" . (time() - 86400) . "'"), 0);
                if (!$ban && $datauser['postforum'] >= $set_karma['forum'] && $datauser['total_on_site'] >= $set_karma['karma_time'] && ($set_karma['karma_points'] - $sum) > 0 && !$count) {
                    echo '<br /><a href="profile.php?act=karma&amp;mod=vote&amp;user=' . $user['id'] . '">' . $lng['vote'] . '</a>';
                }
            }
        } else {
            $total_karma = mysql_result(mysql_query("SELECT COUNT(*) FROM `karma_users` WHERE `karma_user` = '$user_id' AND `time` > " . (time() - 86400)), 0);
            if ($total_karma > 0) {
                echo '<br /><a href="profile.php?act=karma&amp;mod=new">' . $lng['responses_new'] . '</a> (' . $total_karma . ')';
            }
        }
        echo '</div></td></tr></table></div>';
    }
*/
   

    if ($user_id && $user['id'] != $user_id) {
        echo '<div class="menu">';
        // Контакты
        if (!functions::is_ignor($user['id']) && functions::is_contact($user['id']) != 2) {
            if (!functions::is_friend($user['id'])) {
                $fr_in = mysql_result(mysql_query("SELECT COUNT(*) FROM `cms_contact` WHERE `type`='2' AND `from_id`='$user_id' AND `user_id`='{$user['id']}'"), 0);
                $fr_out = mysql_result(mysql_query("SELECT COUNT(*) FROM `cms_contact` WHERE `type`='2' AND `user_id`='$user_id' AND `from_id`='{$user['id']}'"), 0);
                if ($fr_in == 1) {
                    $friend = '<a class="underline" href="profile.php?act=friends&amp;do=ok&amp;id=' . $user['id'] . '">' . $lng_profile['confirm_friendship'] . '</a> | <a class="underline" href="profile.php?act=friends&amp;do=no&amp;id=' . $user['id'] . '">' . $lng_profile['decline_friendship'] . '</a>';
                } else if ($fr_out == 1) {
                    $friend = '<a class="underline" href="profile.php?act=friends&amp;do=cancel&amp;id=' . $user['id'] . '">' . $lng_profile['canceled_demand_friend'] . '</a>';
                } else {
                    $friend = '<a href="profile.php?act=friends&amp;do=add&amp;id=' . $user['id'] . '">' . $lng_profile['in_friend'] . '</a>';
                }
            } else {
                $friend = '<a href="profile.php?act=friends&amp;do=delete&amp;id=' . $user['id'] . '">' . $lng_profile['remov_friend'] . '</a>';
            }
            echo '<div>' . functions::image('add.gif') . $friend . '</div>';
        }

        if (functions::is_contact($user['id']) != 2) {
            echo '<div><img src="../images/del.png" width="16" height="16"/>&#160;<a href="../mail/index.php?act=ignor&amp;id=' . $user['id'] . '&amp;add">' . $lng_profile['add_ignor'] . '</a></div>';
        } else {
            echo '<div><img src="../images/del.png" width="16" height="16"/>&#160;<a href="../mail/index.php?act=ignor&amp;id=' . $user['id'] . '&amp;del">Do\'stlikni bekor qilish</a></div>';
        }
       
if (!functions::is_ignor($user['id']) && functions::is_contact($user['id']) != 2 && empty($ban['1']) && empty($ban['3'])) {
echo '<a href="../mail/index.php?act=write&amp;id=' . $user['id'] . '" class="kiritish" style="max-width: 200px;">' . functions::image('mail-inbox.png') . 'Shaxsiy xabar</a>';
        }
$bancount = @mysql_result(mysql_query("SELECT COUNT(*) FROM `cms_ban_users` WHERE `user_id` = '" . $user['id'] . "'"), 0);

    if ($user_id && $bancount) {
        echo '<br><img src="../images/block.gif" width="16" height="16"/>&#160;<a href="profile.php?act=ban&amp;user=' . $user['id'] . '">' . $lng['infringements'] . '</a> (' . $bancount . ')</div>';
    }
echo '</div>';
    }

if ($user_id && $user['id'] == $user_id) {

$total_photo = mysql_result(mysql_query("SELECT COUNT(*) FROM `cms_album_files` WHERE `user_id` = '$user_id'"), 0);
$total_friends = mysql_result(mysql_query("SELECT COUNT(*) FROM `cms_contact` WHERE `user_id`='$user_id' AND `type`='2' AND `friends`='1'"), 0);
$new_friends = mysql_result(mysql_query("SELECT COUNT(*) FROM `cms_contact` WHERE `from_id`='$user_id' AND `type`='2' AND `friends`='0';"), 0);
$online_friends = mysql_result(mysql_query("SELECT COUNT(*) FROM `cms_contact` LEFT JOIN `users` ON `cms_contact`.`from_id`=`users`.`id` WHERE `cms_contact`.`user_id`='$user_id' AND `cms_contact`.`type`='2' AND `cms_contact`.`friends`='1' AND `lastdate` > " . (time() - 300) . ""), 0);


echo '<div class="menu">';
//Входящие сообщения
$count_input = mysql_result(mysql_query("
SELECT COUNT(*) 
FROM `cms_mail` 
LEFT JOIN `cms_contact` 
ON `cms_mail`.`user_id`=`cms_contact`.`from_id` 
AND `cms_contact`.`user_id`='$user_id' 
WHERE `cms_mail`.`from_id`='$user_id' 
AND `cms_mail`.`sys`='0' AND `cms_mail`.`delete`!='$user_id' 
AND `cms_contact`.`ban`!='1' AND `spam`='0'"), 0);
echo '<div>' . functions::image('mail-inbox.png') . '<a href="../mail/index.php?act=input">' . $lng_profile['received'] . '</a>&nbsp;(' . $count_input . ($new_mail ? '/<span class="red">+' . $new_mail . '</span>' : '') . ')</div>';
//Исходящие сообщения
$count_output = mysql_result(mysql_query("SELECT COUNT(*) FROM `cms_mail` LEFT JOIN `cms_contact` ON `cms_mail`.`from_id`=`cms_contact`.`from_id` AND `cms_contact`.`user_id`='$user_id' 
WHERE `cms_mail`.`user_id`='$user_id' AND `cms_mail`.`delete`!='$user_id' AND `cms_mail`.`sys`='0' AND `cms_contact`.`ban`!='1'"), 0);
//Исходящие непрочитанные сообщения
$count_output_new = mysql_result(mysql_query("SELECT COUNT(*) FROM `cms_mail` LEFT JOIN `cms_contact` ON `cms_mail`.`from_id`=`cms_contact`.`from_id` AND `cms_contact`.`user_id`='$user_id' 
WHERE `cms_mail`.`user_id`='$user_id' AND `cms_mail`.`delete`!='$user_id' AND `cms_mail`.`read`='0' AND `cms_mail`.`sys`='0' AND `cms_contact`.`ban`!='1'"), 0);
echo '<div>' . functions::image('mail-send.png') . '<a href="../mail/index.php?act=output">' . $lng_profile['sent'] . '</a>&nbsp;(' . $count_output . ($count_output_new ? '/<span class="red">+' . $count_output_new . '</span>' : '') . ')</div>';
$count_systems = mysql_result(mysql_query("SELECT COUNT(*) FROM `cms_mail` WHERE `from_id`='$user_id' AND `delete`!='$user_id' AND `sys`='1'"), 0);
//Системные сообщения
$count_systems_new = mysql_result(mysql_query("SELECT COUNT(*) FROM `cms_mail` WHERE `from_id`='$user_id' AND `delete`!='$user_id' AND `sys`='1' AND `read`='0'"), 0);
echo '<div>' . functions::image('mail-info.png') . '<a href="../mail/index.php?act=systems">' . $lng_profile['systems'] . '</a>&nbsp;(' . $count_systems . ($count_systems_new ? '/<span class="red">+' . $count_systems_new . '</span>' : '') . ')</div>';
//Файлы
$count_file = mysql_result(mysql_query("SELECT COUNT(*) FROM `cms_mail` WHERE (`user_id`='$user_id' OR `from_id`='$user_id') AND `delete`!='$user_id' AND `file_name`!='';"), 0);
echo '<div>' . functions::image('file.gif') . '<a href="../mail/index.php?act=files">' . $lng['files'] . '</a>&nbsp;(' . $count_file . ')</div>';

//Контакты
$count_contacts = mysql_result(mysql_query("SELECT COUNT(*) FROM `cms_contact` WHERE `user_id`='" . $user_id . "' AND `ban`!='1';"), 0);
echo '<div>' . functions::image('user.png') . '<a href="../mail/">' . $lng['contacts'] . '</a>&nbsp;(' . $count_contacts . ')</div>';
//Заблокированные
$count_ignor = mysql_result(mysql_query("SELECT COUNT(*) FROM `cms_contact` WHERE `user_id`='" . $user_id . "' AND `ban`='1';"), 0);
echo '<div>' . functions::image('user-ok.png') . '<a href="profile.php?act=friends">' . $lng_profile['friends'] . '</a>&#160;(' . $total_friends . ($new_friends ? '/<span class="red">+' . $new_friends . '</span>' : '') . ')&#160;<a href="profile.php?act=friends&amp;do=online">' . $lng['online'] . '</a> (' . $online_friends . ')</div>';
echo '<div>' . functions::image('user-block.png') . '<a href="../mail/index.php?act=ignor">' . $lng_profile['banned'] . '</a>&nbsp;(' . $count_ignor . ')</div>';
echo '' . functions::image('rate.gif') . '<a href="profile.php?act=stat">' . $lng['statistics'] . '</a><br>' .
    '' . functions::image('photo.gif') . '<a href="album.php?act=list">' . $lng['photo_album'] . '</a>&#160;(' . $total_photo . ')<br>' .
    '' . functions::image('guestbook.gif') . '<a href="profile.php?act=guestbook">' . $lng['guestbook'] . '</a>&#160;(' . $user['comm_count'] . ')';
if ($rights >= 1) {
    $guest = counters::guestbook(2);
    echo '<br>' . functions::image('forbidden.png') . '<a href="../guestbook/index.php?act=ga&amp;do=set">' . $lng['admin_club'] . '</a> (<span class="red">' . $guest . '</span>)';
}
// Блок настроек
echo '<br>' . functions::image('settings.png') . '<a href="profile.php?act=settings">' . $lng['system_settings'] . '</a><br>' .
    '' . functions::image('user-edit.png') . '<a href="profile.php?act=edit">' . $lng_profile['profile_edit'] . '</a><br>' .
    '' . functions::image('lock.png') . '<a href="profile.php?act=password">' . $lng['change_password'] . '</a>';
if ($rights >= 1) {
    echo '<br>' . functions::image('forbidden.png') . '<span class="red"><a href="../' . $set['admp'] . '/index.php"><b>' . $lng['admin_panel'] . '</b></a></span>';
}
$users = mysql_result(mysql_query("SELECT COUNT(*) FROM `users` WHERE `lastdate` > '" . (time() - 300) . "'"), 0); 
 $guests = mysql_result(mysql_query("SELECT COUNT(*) FROM `cms_sessions` WHERE `lastdate` > '" . (time() - 300) . "'"), 0); 
$hammasi=$users+$guests;
echo '<br> ' . functions::image('user.png') . '<a href="/users/index.php?act=online">Hozir saytda: '.$users.'</a>';
if ($user['id'] != $user_id){
$g = mysql_result(mysql_query("SELECT * FROM `my_guests` WHERE `my_id` = '" . $user['id'] . "' AND `guest_id` = '" . $user_id . "' LIMIT 1;"), 0);
if (!empty($g)) {
@mysql_query("UPDATE `my_guests` SET `time` = '" . time() . "', `type` = '0' WHERE `my_id` = '" . $user['id'] . "' AND `guest_id` = '" . $user_id . "';");
} else {
@mysql_query("INSERT INTO `my_guests` SET
`my_id` = '" . $user['id'] . "',
`time` = '" . time() . "',
`guest_id` = '" . $user_id . "',
`type` = '0';");
}
//Фиксация просмотра анкеты

} else {
//Ссылка на страницу гостей для владельца анкеты
$all_guests = @mysql_result(@mysql_query("SELECT COUNT(*) FROM `my_guests` WHERE `my_id` = '" . $user_id . "';"), 0);
$new_guests = @mysql_result(@mysql_query("SELECT COUNT(*) FROM `my_guests` WHERE `my_id` = '" . $user_id . "' AND `type` = '0';"), 0);
echo '<br><img src="../images/green.gif" alt="*"/>&nbsp;<a href="' . $home . '/users/my_guests.php?">Mehmonlar</a>&nbsp;(' . $all_guests . ($new_guests > 0 ? '/<span class="red">' . $new_guests . '</span>' : '') . ')';
}
//mehmon oxiri
echo '</div>'; 
/*
// MALUMOT
if ($user['id'] == $user_id) {
echo '<div class="phdr"><b>Ma\'lumotlar</b></div><div class="menu">';
// id raqami
echo '<img src="/images/green.gif" alt="S" /> ID raqami: <b>'.$user['id'].'</b><br/>';
// logini
echo '<img src="/images/green.gif" alt="S" /> Login: <b>'.$user['name_lat'].'</b><br/>';
// ismi
if (!empty($user['imname'])) {
echo '<img src="/images/green.gif" alt="S" /> Ismi: <b>'.$user['imname'].'</b><br/>';
}

// sungi tashrif
if (time() > $user['lastdate'] + 900) {
$lastvisit = date("d.m.Y (H:i)", $user['lastdate']);
if (isset($lastvisit))
echo '<img src="/images/green.gif" alt="S" /> So\'nggi tashrif: <b>' . $lastvisit . '</b><br/>';
}
//yashash joyi
if (!empty($user['live'])) {
echo '<img src="/images/green.gif" alt="S" /> Yashash joyi: <b> '.$user['live'].'</b><br />';
}
// yoshi
if(!empty($user['yearofbirth'])){
function calc_age($d, $m, $y) {
$age = date('Y') - $y;
$_m = date('m');
if($_m < $m || ($_m == $m && date('d') < $d))
$age--;

return $age;
}
$user_age = calc_age($user['dayb'], $user['monthb'], $user['yearofbirth']);
echo '<img src="/images/green.gif" alt="S" /> Yoshi: <b>'.$user_age.' da</b><br/>';
}
// tangalari
echo '<img src="/images/green.gif" alt="S" /> Tangalari:<b>' . $user['balans'] . '</b><br/>';
@mysql_query("UPDATE `users` SET `prosm_ank` = '" . $r_ank . "' WHERE `id` = '" . $user['id'] . "';");
echo '<img src="/images/green.gif" alt="S" /> Anketa <b> ' . $r_ank . '</b> marta ko\'rilgan</b><br/>';
// qayerda
if ($user['id'] != core::$user_id) {
echo '<img src="/images/green.gif" alt="S" />  Hozirda: <b> ' . functions::display_place($user['id'], $user['place']) . '</b>';
}

$p_ank = mysql_result(mysql_query("SELECT `prosm_ank` FROM `users` WHERE `id` = '" . $user['id'] . "';"), 0);
$i_ank = (int) $p_ank;
$r_ank = $i_ank + 1;

echo '<p align="left"><img src="/images/contacts.png" alt="S" /> <a href="profile.php?act=info&amp;user=' . $user['id'] . '"><b>Shaxsiy ma\'lumotlar &raquo;</b></a></p></div>';
}*/
    echo '<div class="phdr"><font color="white"><a href="index.php">Foydalanuvchilar</a></font></div>';
}}

require_once('../incfiles/end.php');