Файл: mob-lave.ru/core/function/user.php
Строк: 85
<?php
// --------- Функции определения пользователя ------------ //
function online($user=NULL){ // Онлайн
global $system;
$anks = mysql_fetch_array(mysql_query("SELECT * FROM `$system[perfix]_users` WHERE `id` = '$user' LIMIT 1"));
if ($anks['online'] < time()-$system['online']){
if ($anks['pol']==1)
$onl='<img src="/design/images/user/man_off.png" alt=""/>';
else
$onl='<img src="/design/images/user/woman_off.png" alt=""/>';
echo "$onl ";
}else if ($anks['level'] == 1){
if ($anks['pol']==1)
$mod='<img src="/design/images/user/man_mod.png" alt=""/>';
else
$mod='<img src="/design/images/user/woman_mod.png" alt=""/>';
echo "$mod ";
}else if ($anks['level'] > 1){
if ($anks['pol']==1)
$adm='<img src="/design/images/user/man_adm.png" alt=""/>';
else
$adm='<img src="/design/images/user/woman_adm.png" alt=""/>';
echo "$adm ";
}else if ($anks['level'] == 0){
if ($anks['pol']==1)
$usver='<img src="/design/images/user/man.png" alt=""/>';
else
$usver='<img src="/design/images/user/girl.png" alt=""/>';
echo "$usver ";
}
}
// ----------- только для зарегистрированых ---------- //
function reg($link = NULL) {
global $user;
if (!isset($user)){
if ($link==NULL)$link='/index.php?'.SID;
header("Location: $link");
exit;
}
}
// --------- только для незарегистрированых ----------- //
function unreg($link = NULL) {
global $user;
if (isset($user)){
if ($link==NULL)$link='/index.php?'.SID;
header("Location: $link");
exit;
}
}
function get_user($user_id=0){
global $system;
if ($user_id!=0){
static $users;
$user_id=intval($user_id);
$users[0]=false;
if (!isset($users[$user_id])){
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `$system[perfix]_users` WHERE `id` = '$user_id'"),0)==1){
$users[$user_id]=mysql_fetch_assoc(mysql_query("SELECT * FROM `$system[perfix]_users` WHERE `id` = '$user_id' LIMIT 1"));
}
else $users[$user_id]=false;
}
return $users[$user_id];
}
}
// ------------- Права ---------------- //
function user_access($access,$u_id=null,$exit=false){
global $system;
if ($u_id==null)global $user;
else $user=get_user($u_id);
if (!isset($user['us_prava']) || $user['us_prava']==null)
{
if ($exit!==false){header("Location: $exit");exit;}
else return false;
}
if ($exit!==false)
{
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `$system[perfix]_user_group_access` WHERE `id_group` = '$user[us_prava]' AND `id_access` = '".check($access)."'"),0)==0)
{
header("Location: $exit");exit;
}
}
else
return (mysql_result(mysql_query("SELECT COUNT(*) FROM `$system[perfix]_user_group_access` WHERE `id_group` = '$user[us_prava]' AND `id_access` = '".check($access)."'"),0)==1?true:false);
}
// ------------ Аватар -------------- //
function avatar($ID, $link = false, $w = '50'){
global $set, $system;
$p = mysql_fetch_array(mysql_query("SELECT `id` FROM `$system[perfix]_users` WHERE `id` = '$ID' LIMIT 1"));
$a = mysql_fetch_array(mysql_query("SELECT `id`,`title`,`id_albom`,`avatar` FROM `$system[perfix]_foto_foto` WHERE `id_user` = '$ID' AND `avatar` = '1' LIMIT 1"));
if($a['avatar'] == 1){
if($link == true) echo '<a href="/moduls/foto/'.$p['id'].'/'.$a['id_albom'].'/'.$a['id'].'"><img src="/files/foto/'.$p['id'].$a['id_albom'].$a['id'].'.jpg" alt="'.htmlspecialchars($a['title']).'" width="'.$w.'" /></a>';
else echo "<img src='/files/foto/$p[id]$a[id_albom]$a[id].jpg' alt='".htmlspecialchars($a['title'])."' width='$w'/>";
}
else if($a['avatar'] == 0)
echo "<img src='/files/foto/avatar.png' alt='avatar' width='".$w."'/>";
}
// ---------- Логин --------- //
function login($login){
return $login;
}
?>