Файл: vsime.com/system/functions/profile.php
Строк: 196
<?
//профиль юзера
function profile($user_data, $prov=0)
{
global $dbi;
if (is_numeric($user_data))$query_text = "`id` = '$user_data'";
else $query_text = "`nick` = '$user_data'";
$query = mysqli_query($dbi, "SELECT * FROM `user` WHERE $query_text");
if (mysqli_num_rows($query)!=0)
{
$ank = mysqli_fetch_array($query);
$ank['anketa'] = mysqli_fetch_array(mysqli_query($dbi, "SELECT * FROM `anketa` WHERE `id_user` = '$ank[id]'"));
// считаем возраст пользователя
if ($ank['anketa']['d_r'] && $ank['anketa']['m_r'] && $ank['anketa']['g_r'])
{
$ank['anketa']['age'] = date("Y") - $ank['anketa']['g_r'];
if (date("n") < $ank['anketa']['m_r'])$ank['anketa']['age'] = $ank['anketa']['age'] - 1;
elseif (date("n") == $ank['anketa']['m_r'] && date("j") < $ank['anketa']['d_r'])$ank['anketa']['age'] = $ank['anketa']['age'] - 1;
} else $ank['anketa']['age'] = 0;
// выигранные дуэли
$ank['duels_wins'] = mysqli_result("SELECT COUNT(*) FROM `duels` WHERE (`id_user` = '$ank[id]' OR `id_ank` = '$ank[id]') AND `ok` = '1' AND `winer` = '$ank[id]'");
// проигранные дуэли
$ank['duels_losses'] = mysqli_result("SELECT COUNT(*) FROM `duels` WHERE (`id_user` = '$ank[id]' OR `id_ank` = '$ank[id]') AND `ok` = '1' AND `winer` != '$ank[id]' AND `winer` != 'draw'");
$ank['level'] = 0;
$query_is = mysqli_query($dbi, "SELECT * FROM `user_group_is` WHERE `id_user` = '$ank[id]' ORDER BY `id_group` DESC");
while ($post_is = mysqli_fetch_array($query_is))
{
$group = mysqli_fetch_array(mysqli_query($dbi, "SELECT * FROM `user_group` WHERE `id` = '$post_is[id_group]'"));
if ($group['id'] >= 1 && $group['id'] <= 3 && $ank['level'] < 1)$ank['level'] = 1;
elseif ($group['id'] == 4 && $ank['level'] < 2)$ank['level'] = 2;
elseif ($group['id'] == 5 && $ank['level'] < 3)$ank['level'] = 3;
}
// обрезаеM E-mail
if ($ank['email'])
{
$exp_email = explode('@', $ank['email']);
$count_fst_part_chars = strlen2($exp_email[0]);
$fst_part = NULL;
for ($i = 1; $i <= $count_fst_part_chars; $i++)
{
$fst_part .= '*';
}
$ank['email_cut'] = "$fst_part@$exp_email[1]";
} else $ank['email_cut'] = '@';
// обрезаеM номер телефона
if ($ank['telephone'])
{
$array_chars = str_split($ank['telephone']);
$i = strlen2($ank['telephone']);
$ank['telephone_cut'] = NULL;
foreach ($array_chars AS $key => $value) {
$i--;
if ($i >= 4)$ank['telephone_cut'] .= $value;
else $ank['telephone_cut'] .= '*';
}
} else $ank['telephone_cut'] = NULL;
} else {
$ank = array();
$ank['id'] = 0;
$ank['nick'] = 'Система';
$ank['level'] = 0;
$ank['akt_rating'] = 0;
$ank['nick_color'] = NULL;
$ank['age'] = 0;
$ank['anketa'] = NULL;
}
if ($prov==0) {
return $ank;
} else {
if ($ank['id'])return true; else return false;
}
}
// вывод ника
function profile_nick($user_id, $link=0, $color=1, $need_link=NULL)
{
global $config;
$ank = profile($user_id);
$ank['nick'];
if ($link==1 && $ank['id'] != 0)$ank['nick'] = "<a href='".($need_link!=NULL?$need_link:$config['profile_page']."$ank[id]")."'><font color =#79358c>$ank[nick]</font></a>";
return $ank['nick']."n";
}
// вывод иконки юзера
function profile_icon($user_id)
{
$ank = profile($user_id);
if ($ank['id']!=0)
{
if ($ank['date_last']>(time()-600))$icon_status = "on"; else $icon_status = "off";
if ($ank['anketa']['pol']==1)$icon_pol = "man"; else $icon_pol = "woman";
if ($ank['level']>=2)$icon_group = "admin_"; elseif ($ank['level']==1)$icon_group = "mod_"; else $icon_group = NULL;
$icon_ank = "/i/user_icons/".$icon_group.$icon_pol."_".$icon_status.".png";
echo "<img src='$icon_ank' /> n";
} else {
echo "<img src='/i/user_icons/man_off.png' /> n";
}
}
// вывод медальки юзера
function profile_medal($user_id)
{
$ank = profile($user_id);
if ($ank['akt_rating']>=3)
{
if ($ank['akt_rating']>=3 && $ank['akt_rating']<6)$ank['akt_rating_icon'] = "/i/medals/bronze.png";
elseif ($ank['akt_rating']>=6 && $ank['akt_rating']<12)$ank['akt_rating_icon'] = "/i/medals/silver.png";
elseif ($ank['akt_rating']>=12)$ank['akt_rating_icon'] = "/i/medals/gold.png";
return " <img src='$ank[akt_rating_icon]' />n";
}
}
?>