Файл: vzabave/sys/func/user.php
Строк: 404
<?
##################Гридиент##################
function GradientLetter($text, $from='', $to='', $mode = 'hex') {
$text = iconv("UTF-8", "windows-1251", $text);
if ($mode == 'hex') {
$to = hexdec($to['0'].$to['1']).','.hexdec($to['2'].$to['3']).','.hexdec($to['4'].$to['5']);
$from = hexdec($from['0'].$from['1']).",".hexdec($from['2'].$from['3']).",".hexdec($from['4'].$from['5']);
}
if (empty($text)) return null; else $levels = strlen($text);
if (empty($from)) $from = array(0, 0, 255); else $from = explode(',', $from);
if (empty($to)) $to = array(255, 0, 0); else $to = explode(',', $to); $output = null;
for ($i = 1; $i <= $levels; $i++) {
for ($ii = 0; $ii < 3; $ii++) {
$tmp[$ii] = $from[$ii] - $to[$ii];
$tmp[$ii] = floor($tmp[$ii] / $levels);
$rgb[$ii] = $from[$ii] - ($tmp[$ii] * $i);
if ($rgb[$ii] > 255) $rgb[$ii] = 255;
$rgb[$ii] = dechex($rgb[$ii]);
$rgb[$ii] = strtoupper($rgb[$ii]);
if (strlen($rgb[$ii]) < 2) $rgb[$ii] = '0'.$rgb[$ii];
}
$output .= '<span style="color: #'.$rgb['0'].$rgb['1'].$rgb['2'].'">'.$text[$i-1].'</span>';
}
return iconv("windows-1251", "UTF-8", $output);
}
############################################
function nik($ref=NULL,$link=NULL)
{
global $db, $user, $wap, $rm, $usid, $name, $set, $sid, $nk, $user_system, $time, $rmmaf, $mafiozi;
if(isset($ref)&&($ref!=$user_system)) $ref=check($ref);
if ($ref!=$mafiozi){
if (!ctype_digit($ref)) {
$ruser = rus_to_k($ref);
$result = $db->sql_query ("Select * from users where ruser = '".$ruser."' LIMIT 1;");
} else {
$result = $db->sql_query ("Select * from users where id = '".$ref."' LIMIT 1;");
}
$nik = $db->sql_fetchrow ($result);
if (!isset($user))$time = (time()+$set['timesdvig']*60*60);
else if ($user['poias']!='') $time = ((time()-3*60*60)+$user['poias']*60);
if ($nik['onl'] >= ($time - $set['time_aut']))
{
if ($nik['xstatus']==1) $on_off='<img src="/img/online/gotov_boltat.png" alt="" />';
else if ($nik['xstatus']==2) $on_off='<img src="/img/online/zaniat.png" alt="" />';
else if ($nik['xstatus']==3) $on_off='<img src="/img/online/boleu.png" alt="" />';
else if ($nik['xstatus']==4) $on_off='<img src="/img/online/depressia.png" alt="" />';
else if ($nik['xstatus']==5) $on_off='<img src="/img/online/dumau.png" alt="" />';
else if ($nik['xstatus']==6) $on_off='<img src="/img/online/kuru.png" alt="" />';
else if ($nik['xstatus']==7) $on_off='<img src="/img/online/kushau.png" alt="" />';
else if ($nik['xstatus']==8) $on_off='<img src="/img/online/love.png" alt="" />';
else if ($nik['xstatus']==9) $on_off='<img src="/img/online/tv.png" alt="" />';
else if ($nik['xstatus']==10) $on_off='<img src="/img/online/music.png" alt="" />';
else if ($nik['xstatus']==11) $on_off='<img src="/img/online/vanna.png" alt="" />';
else if ($nik['xstatus']==12) $on_off='<img src="/img/online/tualet.png" alt="" />';
else if ($nik['xstatus']==13) $on_off='<img src="/img/online/sex.png" alt="" />';
else if ($nik['xstatus']==14) $on_off='<img src="/img/online/igrau.png" alt="" />';
else if ($nik['xstatus']==15) $on_off='<img src="/img/online/pivo.png" alt="" />';
else if ($nik['xstatus']==16) $on_off='<img src="/img/online/sonni.png" alt="" />';
else if ($nik['xstatus']==0){
if ($nik['sex']==1) $on_off='<img src="/img/online/man_on.gif" alt=""/>';
else if ($nik['sex']==0) $on_off='<img src="/img/online/woman_on.gif" alt="" />';
else $on_off='<img src="/img/online/on.gif" alt="" />';
}
}else{
if ($nik['sex']==1) $on_off='<img src="/img/online/man_off.gif" alt="" />';
else if ($nik['sex']==0) $on_off='<img src="/img/online/woman_off.gif" alt="" />';
else $on_off='<img src="/img/online/off.gif" alt="" />';
}
$color_nik = $nik['color_nik'];
$name = $nik['user'];
if ($user['ver']!='wml'){
if ($nik['effnik']==1) $name = '<blink>'.$name.'</blink>';
if ($nik['color_nik'] == 1) $name = GradientLetter($name, 'F90000', '00FF00');
elseif ($nik['color_nik'] == 2) $name = GradientLetter($name, 'FF0000', '000000');
elseif ($nik['color_nik'] == 3) $name = GradientLetter($name, 'EEE467', '384267');
elseif ($nik['color_nik'] == 4) $name = GradientLetter($name, 'F7FF0D', '1E49E6');
elseif ($nik['color_nik'] == 5) $name = GradientLetter($name, '000000', '00FF00');
elseif ($nik['color_nik'] == 6) $name = GradientLetter($name, 'EF33ED', 'EFCAF1');
elseif ($nik['color_nik'] == 7) $name = GradientLetter($name, '030303', '96A0A4');
elseif ($nik['color_nik'] == 8) $name = GradientLetter($name, '1C1C1C', 'FFB90F');
elseif ($nik['color_nik'] == 9) $name = GradientLetter($name, 'FF0000', '00F5FF');
elseif ($nik['color_nik'] == 10) $name = GradientLetter($name, '7D26CD', 'FF7F24');
elseif ($nik['color_nik'] == 11) $name = GradientLetter($name, '000000', 'E8E8E8');
elseif ($nik['color_nik'] == 12) $name = GradientLetter($name, 'FF0000', '00F5FF');
elseif ($nik['color_nik'] == 13) $name = GradientLetter($name, '912CEE', '90EE90');
elseif ($nik['color_nik'] == 14) $name = GradientLetter($name, 'ff1493', '9400D3');
elseif ($nik['color_nik'] == 15) $name = GradientLetter($name, '4682B4', 'B0E0E6');
elseif ($nik['color_nik'] == 16) $name = GradientLetter($name, '800000', 'FF9900');
elseif ($nik['color_nik'] == 17) $name = GradientLetter($name, '696969', 'DCDCDC');
elseif ($nik['color_nik'] == 18) $name = GradientLetter($name, 'FF8000', '000000');
elseif ($nik['color_nik'] == 19) $name = GradientLetter($name, '000000', 'FFFF00');
#if ($nik['color_nik']=='') $name = ''.$name.'';
else $name = '<font color="#'.$nik['color_nik'].'">'.$name.'</font>';
}
if ($link==NULL)$link=''.H.$nik['id'].'';
if ($ref!=$user_system){ // Если не Систеа
if (isset($nik['id'])){ // Если пользователь существует
if ($user['pic_stat']==0){
if(!isset($rm) || isset($nk)){
return '<a href="/'.$link.'">'.$name.'</a>';
}else{
return '<a href="/'.$link.'">'.$name.'</a> ';
}
}else if ($user['pic_stat']==1){
if(!isset($rm) || isset($nk)){
return '<a href="/xstatus?nk='.$nik['id'].'">'.$on_off.'</a> <a href="/'.$link.'">'.$name.'</a>';
}else{
return '<a href="/xstatus?nk='.$nik['id'].'">'.$on_off.'</a> <a href="/'.$link.'">'.$name.'</a> ';
}
}else if ($user['pic_stat']==2){
if ($user['ver']!='wml'){
if(!isset($rm) || isset($nk)){
return '<a href="/xstatus?nk='.$nik['id'].'">'.$on_off.'</a> <a href="/'.$link.'">'.$name.'</a>';
}else{
return '<a href="/xstatus?nk='.$nik['id'].'">'.$on_off.'</a> <a href="/'.$link.'">'.$name.'</a> ';
}
}else{
if(!isset($rm) || isset($nk)){
return '<a href="/'.$link.'">'.$name.'</a>';
}else{
return '<a href="/'.$link.'">'.$name.'</a> ';
}
}
}else if ($user['pic_stat']==3){
if ($user['ver']=='wml'){
if(!isset($rm) || isset($nk)){
return '<a href="/xstatus?nk='.$nik['id'].'">'.$on_off.'</a> <a href="/'.$link.'">'.$name.'</a>';
}else{
return '<a href="/xstatus?nk='.$nik['id'].'">'.$on_off.'</a> <a href="/'.$link.'">'.$name.'</a> ';
}
}else{
if(!isset($rm) || isset($nk)){
return '<a href="/'.$link.'">'.$name.'</a>';
}else{
return '<a href="/'.$link.'">'.$name.'</a> ';
}
}
}
}else { // Пользователя нет
return '[Удален]';
}
}else{ // Система
return $ref;
}
}else return '<img src="'.H.'img/bot.gif" alt="" /> <a href="inside?rmmaf='.$rmmaf.'&nk=0"><b>'.$ref.'</b></a> ';
}
function user($ref=NULL,$link=NULL)
{
global $db, $user, $ver, $rm, $usid, $name, $set, $sid,$time;
if(isset($ref)) $ref=check($ref);
if (!ctype_digit($ref)) {
$ruser = rus_to_k($ref);
$result = $db->sql_query ("Select * from users where ruser = '".$ruser."' LIMIT 1;");
} else {
$result = $db->sql_query ("Select * from users where id = '".$ref."' LIMIT 1;");
}
$nik = $db->sql_fetchrow ($result);
if ($link==NULL)return $nik['user'];
else if ($link==1) return '<a href="'.H.$nik['id'].'">'.$nik['user'].'</a>';
}
function user_inf($ref=NULL,$w=NULL)
{
global $db, $user, $ver, $rm, $usid, $name, $set, $sid,$time;
if(isset($ref)) $ref=check($ref);
if (!ctype_digit($ref)) {
$ruser = rus_to_k($ref);
$result = $db->sql_query ("Select * from users where ruser = '".$ruser."' LIMIT 1;");
} else {
$result = $db->sql_query ("Select * from users where id = '".$ref."' LIMIT 1;");
}
$nik = $db->sql_fetchrow ($result);
if ($w==NULL)return esc2($nik['id']);
else return esc2($nik[$w]);
}
function friends($f1=NULL,$f2=NULL,$w=NULL)
{
global $db, $user, $ver, $rm, $usid, $name, $set, $sid,$time;
if(isset($f1)) $f1=check($f1);
if(isset($f2)) $f2=check($f2);
if(isset($w)) $w=check($w);
$f = $db->sql_fetchrow($db->sql_query("Select * from friends WHERE `user_id` = '$f2' and `fr_id` = '$f1' and yes = '1'"));
if ($w==NULL){
if ($f1!=$f2){
if (isset($f['id']))return '1';
else return '0';
}else{
return '1';
}
}else{
if (isset($f['id']))return $f[$w];
}
}
if (!defined('vb12')) die("");
function ignor($f1=NULL,$f2=NULL,$w=NULL)
{
global $db, $user, $ver, $rm, $usid, $name, $set, $sid,$time;
if(isset($f1)) $f1=check($f1);
if(isset($f2)) $f2=check($f2);
if(isset($w)) $w=check($w);
$f = $db->sql_fetchrow($db->sql_query("Select * from ignor WHERE `user_id` = '$f1' and `ig_id` = '$f2'"));
if ($w==NULL){
if ($f1!=$f2){
if (isset($f['id']))return '1';
else return '0';
}else{
return '0';
}
}else{
if (isset($f['id']))return $f[$w];
}
}
function aut($link = NULL) // только для зарегистрированиых
{
global $db, $user;
if (!isset($user['id']))
{
if ($link==NULL)$link=H.'aut?';
header("Location: $link".SID);exit;
}
}
function unaut($link = NULL) // только для незарегистрированых
{
global $db, $user;
if (isset($user))
{
if ($link==NULL)$link=H.'index?';
header("Location: $link".SID);exit;
}
}
function levels($level=0,$link = NULL) // только для тех, у кого уровень доступа больше или равен $level
{
global $db, $user;
if (!isset($user) || $user['level']<$level)
{
if ($link==NULL)$link='/index?';
header("Location: $link&".SID);exit;
}
}
function posts_add()
{
global $db, $user;
if (isset($user))
{
$user['posts']++;
$user['dayp']++;
$db->sql_query("UPDATE `users` SET `posts` = '$user[posts]', dayp = '$user[dayp]' WHERE `id` = '$user[id]';");
}
}
function postsf_add()
{
global $db, $user;
if (isset($user))
{
$user['postsf']++;
$user['posts']++;
$user['dayp']++;
$db->sql_query("UPDATE `users` SET `postsf` = '$user[postsf]',`posts` = '$user[posts]', dayp = '$user[dayp]' WHERE `id` = '$user[id]';");
}
}
function cred_add()
{
global $db, $user;
if (isset($user))
{
$user['credits']++;
$user['daya']++;
$db->sql_query("UPDATE `users` SET `credits` = '$user[credits]', `daya` = '$user[daya]' WHERE `id` = '$user[id]';");
}
}
function who_add($rm=0,$room = NULL)
{
global $db, $user, $time, $set,$ip,$soft;
if (isset($user))
{
$db->sql_query("DELETE FROM `who` WHERE `user` = '".$user['id']."'");
$db->sql_query("DELETE FROM `who` WHERE `time` < '".($time-$set['time_aut'])."'");
$db->sql_query("INSERT INTO `who` (user,time,room,rm) values('$user[id]', '$time', '$room', '$rm')");
$db->sql_query('UPDATE `users` SET `onl` = "'.$time.'", `user_ip` = "'.$ip.'", `user_soft` = "'.$soft.'" WHERE `id` = "'.$user['id'].'";');
if($user['viz']!=date("d"))$db->sql_query('UPDATE `users` SET `viz` = "'.date("d").'", `daya` = "0", `dayp` = "0" WHERE `id` = "'.$user['id'].'";');
}
}
function medal($user=NULL)
{
global $db, $set;
$user = check($user);
$adm = $db->sql_fetchrow($db->sql_query("SELECT * from `users` where `id`='$user' limit 1;"));
if ($adm['balls']>=500 ){echo "<img src='/img/medal_bronze.gif' alt=''/>";
}else
if ($adm['balls']>=1000){echo "<img src='/img/medal_silver.gif' alt=''/>";
}else{
if ($adm['balls']>=5000)echo "<img src='/img/medal_gold.gif' alt=''/>";}
}
?>