Файл: wapxl.ru/shaxty/classes/user_func.php
Строк: 339
<?php
class user extends core
{
public static 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);
}
// Функция пинка
public static function kiks($w=NULL)
{
if(isset($w)) $w=func::checkin($w);
$ban= core::$db -> queryFetch("SELECT * FROM `kik_users` WHERE `user_id`=? AND `ban_time`>? LIMIT 1;", array(core::$user_id, core::$realtime));
if ($ban > 0) {
echo '<b>'.core::$user['user'].'</b>, Вы не можете писать на форуме,в приват, осталять комментарии и т.д., так как <b>вы выпнуты</b> на <b>'.func::kikt($ban['ban_time']).'</b><br />Причина: <b>'.$ban['ban_reason'].'</b><br />';
echo '<br />';
include_once (H.'shaxty/foot.php');
}
}
/* проверка авторизации*/
/*public static function check_login($link = NULL) {
$user= core::$db -> queryFetch("SELECT * FROM `users` WHERE `id`=? LIMIT 1;", array(core::$user_id));
if (core::$user_id == 0){
if ($link==NULL)$link='/nous.php?';
header("Location: $link".SID);exit;
}
}*/
public static function colornick( $nick , $colornick)
{
$arr = explode('::',$colornick);
$count = mb_strlen( $nick, 'UTF-8' );
for( $i = 0, $return = ''; $i < $count; $i++ )
{
$s++;
$return .= '<span style="color:#' . $arr[$s] . ';">' . mb_substr( $nick, $i, 1, 'UTF-8' ) . '</span>';
}
return $return ;
}
public static function nik($ref=NULL,$link=NULL)
{
$ref=func::checkin($ref);
if ($ref==core::$set['login_system'] || $ref==core::$set['login_umnik'] || $ref==core::$set['login_fluder'] || $ref==core::$set['login_mafiozi']){
if ($link==NULL)return $ref;
else return '<a href="'.H2.''.$link.'">'.$ref.'</a> ';
}
if($ref=== '0')return core::$set['login_system'];
if($ref=== '01')return core::$set['login_system'];
if($ref=== '02')return core::$set['login_umnik'];
if($ref=== '03')return core::$set['login_fluder'];
if (!ctype_digit($ref)) {
$ruser = func::rus_lat(func::rus_utf_tolower($ref));
$result= core:: $db -> query("SELECT * FROM `users` WHERE `ruser`=? LIMIT 1;", array($ruser));
} else {
$result= core:: $db -> query("SELECT * FROM `users` WHERE `id`=? LIMIT 1;", array($ref));
}
$nik = $result -> fetch();
if (!isset($nik['id'])){
$inf = core:: $db -> queryFetch("SELECT * FROM `users_del` where `user_id`=?;", array($ref));
if (!isset($inf['nik']))return '[Удален]';
else if (isset($inf['nik']))return $inf['nik'];
}
if ($nik['onl'] >= (core::$realtime - 1500))
{
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 ($nik['color_nik'] == 1) $name = self::GradientLetter($name, 'F90000', '00FF00');
elseif ($nik['color_nik'] == 2) $name = self::GradientLetter($name, 'FF0000', '000000');
elseif ($nik['color_nik'] == 3) $name = self::GradientLetter($name, 'EEE467', '384267');
elseif ($nik['color_nik'] == 4) $name = self::GradientLetter($name, 'F7FF0D', '1E49E6');
elseif ($nik['color_nik'] == 5) $name = self::GradientLetter($name, '000000', '00FF00');
elseif ($nik['color_nik'] == 6) $name = self::GradientLetter($name, 'EF33ED', 'EFCAF1');
elseif ($nik['color_nik'] == 7) $name = self::GradientLetter($name, '030303', '96A0A4');
elseif ($nik['color_nik'] == 8) $name = self::GradientLetter($name, '000000', 'DDE4DA');
elseif ($nik['color_nik'] == 9) $name = self::GradientLetter($name, '000000', '0000FF');
elseif ($nik['color_nik'] == 10) $name = self::GradientLetter($name, 'FF0000', 'A80AEA');
elseif ($nik['color_nik'] == 11) $name = self::GradientLetter($name, '0000FF', '0ADFEC');
elseif ($nik['color_nik'] == 12) $name = self::GradientLetter($name, 'FCD05B', 'E665F9');
elseif ($nik['color_nik'] == 13) $name = self::GradientLetter($name, '4ECF0F', 'FAB600');
elseif ($nik['color_nik'] == 14) $name = self::GradientLetter($name, 'ff50ed', 'ff1900');
elseif ($nik['color_nik'] == 15) $name = self::GradientLetter($name, '3e00f8', '002468');
//////////////
if ($nik['effnik']==1) $name = '<blink>'.$name.'</blink>';
if ($nik['color_nik']!='')$name = '<font color="#'.$nik['color_nik'].'">'.$name.'</font>';
if ($nik['color_nik']=='' && $nik['colornick']!='')$name = self::colornick($name,$nik['colornick']);
//if ($link==NULL)$link= $nik['id'];
$adres = $nik['id'];
if ($link==NULL)$link="/anketa_".$adres.'';
return '<a href="'.$link.'" class="href">'.$name.'</a> '.$on_off.' ';
}
public static function us($ref=NULL,$link=NULL)
{
$ref=func::checkin($ref);
if ($ref == core::$set['login_system'] || $ref == core::$set['login_umnik'] || $ref == core::$set['login_fluder'] || $ref == core::$set['login_mafiozi']){
if ($link==NULL)return $ref;
else return '<a href="'.H2.''.$link.'">'.$ref.'</a> ';
}
if($ref=== '01')return core::$set['login_system'];
if($ref=== '02')return core::$set['login_umnik'];
if($ref=== '03')return core::$set['login_fluder'];
if (!ctype_digit($ref)) {
$ruser = func::rus_lat(func::rus_utf_tolower($ref));
$result= core:: $db -> query("SELECT * FROM `users` WHERE `ruser`=? LIMIT 1;", array($ruser));
} else {
$result= core:: $db -> query("SELECT * FROM `users` WHERE `id`=? LIMIT 1;", array($ref));
}
$nik = $result -> fetch();
if (!isset($nik['id'])){
$inf = core:: $db -> queryFetch("SELECT * FROM `users_del` where `user_id`=?;", array($ref));
if (!isset($inf['nik']))return '[Удален]';
else if (isset($inf['nik']))return $inf['nik'];
}
if ($link==NULL)return $nik['user'];
else if ($link==1){
$adres = $nik['id'];
if ($link==NULL)$link="/anketa_".$adres.'';
return '<a href="'.$link.'" class="href">'.$nik['user'].'</a>';
}
}
public static function user_inf($ref=NULL,$w=NULL)
{
if(isset($ref)) $ref=func::checkin($ref);
if (!ctype_digit($ref)) {
$ruser = func::rus_lat(func::rus_utf_tolower($ref));
$result= core:: $db -> query("SELECT * FROM `users` WHERE `ruser`=? LIMIT 1;", array($ruser));
} else {
$result= core:: $db -> query("SELECT * FROM `users` WHERE `id`=? LIMIT 1;", array($ref));
}
$nik = $result -> fetch();
if($nik>0){
if ($w==NULL)return $nik['id'];
else return $nik[$w];
}else{
return false;
}
}
public static function friends($f1=NULL,$f2=NULL)
{
$f1=func::checkin((int)$f1);
$f2=func::checkin((int)$f2);
//$f = mysql_fetch_array(mysql_query("Select * from friends WHERE `user_id` = '$f2' and `fr_id` = '$f1' and yes = '1'"));
$f= core:: $db -> queryFetch("SELECT * FROM `friends` WHERE `user_id`=? and `fr_id`=? and `yes`=?", array($f1, $f2, 1));
if ($f1!=$f2){
if($f>0)return $f['id'];
else return false;
}else{
return 1;
}
}
public static function ignor($f1=NULL,$f2=NULL)
{
if(isset($f1)) $f1=func::checkin($f1);
if(isset($f2)) $f2=func::checkin($f2);
if(isset($w)) $w=func::checkin($w);
$f= core:: $db -> queryFetch("SELECT * FROM `ignor` WHERE `user_id`=? and `ig_id`=? LIMIT 1;", array($f1, $f2));
if ($f1==$f2)return false;
if (isset($f['id']))return $f['id'];
else return false;
}
public static function levels($levels=0,$link = NULL) // только для тех, у кого уровень доступа больше или равен $level
{
if (!isset(core::$user_id) || core::$user['level']<$levels)
{
if ($link==NULL)$link='/index.php';
header("Location: $link");exit;
}
}
}