<?php

function user($user = NULL) {

    global $set, $time;

    $ank = mysql_fetch_array(mysql_query("SELECT `id`, `nick`, `browser`, `country`, `activity`, `online`, `sex`, `rating`, `money`, `ncolor`, `ncolor2`, `group_access`, `date_reg`, `date_last` FROM `user` WHERE `id` = $user LIMIT 1"));
    $ash = mysql_fetch_array(mysql_query("SELECT * FROM `user_icon` WHERE `id_user` = '$ank[id]' LIMIT  1"));

    if ($ank['id'] > 0) {
        if ($ash['time'] >= $time) {
            $imag = mysql_fetch_assoc(mysql_query("SELECT id_icon FROM `user_icon` WHERE `id_user` = '" . $ank['id'] . "' LIMIT 1"));
            echo "<a href='/id$ank[id]'><img src='/user/icon/png/$imag[id_icon].png' style='padding-right: 3px;margin-top: -4px;'/> <b>";
            echo gradient("$ank[nick]", "$ank[ncolor]", "$ank[ncolor2]");
            echo "</b></a> ";
        } else {
            echo "<a href = '/id$ank[id]'><i class='fa fa-user fa-fw'></i> <b>";
            echo gradient("$ank[nick]", "$ank[ncolor]", "$ank[ncolor2]");
            echo "</b></a> ";
        }
    } elseif ($ank['id'] == 0) {
        echo "Система ";
    }


    if ($ank['group_access'] > 1) {

        if ($ank['group_access'] == 1) {
            $gr = lang('Пользователь');
        } elseif ($ank['group_access'] == 2) {
            $gr = lang('Модератор форума');
        } elseif ($ank['group_access'] == 3) {
            $gr = lang('Модератор загруз-центра');
        } elseif ($ank['group_access'] == 4) {
            $gr = lang('Модератор блогов');
        } elseif ($ank['group_access'] == 5) {
            $gr = lang('Модератор фотогалереи');
        } elseif ($ank['group_access'] == 6) {
            $gr = lang('Супермодератор');
        } elseif ($ank['group_access'] == 7) {
            $gr = lang('Администратор');
        } elseif ($ank['group_access'] == 8) {
            $gr = lang('Главный администратор');
        } elseif ($ank['group_access'] == 15) {
            $gr = lang('Создатель');
        }
    }

    if ($ank['date_last'] > (TIME - 600)) {
        if ($ank['browser'] == 'web') {
            echo " <font color='green' title='Пользователь с компьютера'><i class='fa fa-laptop fa-fw'></i></font>";
        } else {
            echo " <font color='green' title='Пользователь с телефона'><i class='fa fa-mobile fa-fw'></i></font>";
        }
    } else {
        if ($ank['browser'] == 'web') {
            echo " <font color='grey' title='Пользователь с компьютера'><i class='fa fa-laptop fa-fw'></i></font>";
        } else {
            echo " <font color='grey' title='Пользователь с телефона'><i class='fa fa-mobile fa-fw'></i></font>";
        }
    }
}

function user_one($user = NULL, $class = null) {

    global $set, $time;

    $ank = mysql_fetch_array(mysql_query("SELECT `id`, `nick`, `browser`, `country`, `activity`, `online`, `sex`, `rating`, `money`, `ncolor`, `ncolor2`, `group_access`, `date_reg`, `date_last` FROM `user` WHERE `id` = $user LIMIT 1"));
    $ash = mysql_fetch_array(mysql_query("SELECT * FROM `user_icon` WHERE `id_user` = '$ank[id]' LIMIT  1"));

    echo "<small>";
    if ($ank['id'] > 0) {
        echo "<a href='/id$ank[id]' class='$class'>";
        echo gradient("$ank[nick]", "$ank[ncolor]", "$ank[ncolor2]");
        echo "</a> ";
    } elseif ($ank['id'] == 0) {
        echo "Система ";
    }

    echo "</small>";
}
