Файл: core/autoload/user.class.php
Строк: 59
<?
class user {
static function icon($id = 2, $type = 1) {
$us = self::data($id);
$ico = ' <i class="fa fa-user" aria-hidden="true"></i> ';
return $ico;
}
static function avatar($id = 2, $type = 'min') {
$us = self::data($id);
/*
if ($type == 1) {
$avatar = ' <img src="/files/avatars/big/default.png" alt="avatar" style="max-width:99%"> ';
}*/
//if ($type == 2) {
//return $us['avatar'];
if (!is_array($type)) {
$type = 'min';
}
$avatar = [
'min' => "/files/avatars/big/{$us['avatar']}",
'mid' => "/files/avatars/mid/{$us['avatar']}",
'big' => "/files/avatars/min/{$us['avatar']}",
];
//}
$avatar = ' <img src="'. $avatar[$type] .'" class="avatar"> ';
return $avatar;
}
static function nick($id = 2, $type = 1) {
$us = self::data($id,(is_numeric($id) ? 'id' : 'link'));
$nick = output($us['login'], 'html');
if ($type == 4 || $type == 5) {
$icon = self::icon($us['id']);
}
if ($type == 2) {
$nick = $nick;
}
if ($type == 3) {
$nick = '<a class="user_nick" href="/@'. $us['link'] .'">'. $nick .'</a>';
}
if ($type == 4) {
$nick = '<a class="user_nick" href="/@'. $us['link'] .'"> '. $icon .' '. $nick .'</a>';
}
if ($type == 5) {
$nick = $icon .' '. $nick;
}
if ($type == 6) {
$nick = '/@'. $us['link'];
}
if ($type == 7) {
$nick = '<a class="user_nick" href="/@'. $us['link'] .'">@'. $us['link'] .'</a>';
}
return $nick;
}
static function data($uid = 2, $typeid = 'id') {
//$registry = Registry::getInstance();
//$sql = $registry->get('sql');
global $sql;
if (is_numeric($uid) AND $typeid == 'id') {
$sqlType = "`id` = ?";
} else {
$sqlType = "`link` = ?";
}
$CacheData = array(
'NameKey' => $uid,
'LifeTime' => 0,
'type' => 'users'
);
$CacheGet = CacheHade::get($CacheData);
if (is_array($CacheGet) AND count($CacheGet) > 1) {
$CacheData['data'] = $CacheGet;
} else {
$check = $sql->rowCount("SELECT * FROM `users` where {$sqlType}", array($uid));
if ($check == 0) {
$CacheData['data'] = false;
} else {
$CacheData['data'] = $sql->fetch("SELECT * FROM `users` where {$sqlType}", array($uid));
}
CacheHade::save($CacheData);
}
$us = $CacheData['data'];
return $us;
}
}
/*
class data extends user
{
public static function output($var = 'dddddd') {
return $var;
}
}
echo data::output();*/