Файл: system/classes/User.php
Строк: 57
<?php
Class User {
private static $id = false;
public static function aut()
{
global $db;
if(isset($_SESSION['login']) && isset($_SESSION['password']))
{
$us_l = $_SESSION['login'];
$us_p = $_SESSION['password'];
}
if(isset($us_l) && isset($us_p))
{
if($db->n_r("SELECT * FROM `users` where `login` = '".$db->guard($us_l)."' and `password` = '".$db->guard($us_p)."' LIMIT 1")== 1)
{
$idi = $db->fass("SELECT `id` FROM `users` where `login` = '".$db->guard($us_l)."' and `password` = '".$db->guard($us_p)."' LIMIT 1");
self::$id=$idi['id'];
$db->query("UPDATE `users` set `date_last_entry` = '".time()."' where `id` = '".$id."' ");
}
return true;
}
else
{
return false;
}
}
public static function ID()
{
if(self::aut())
{
return self::$id;
}
else
{
return false;
}
}
public static function settings($var = '', $userId=null)
{
global $db;
if(self::aut())
{
if($userId == null)
{
$query = $db->fass("SELECT * FROM `user_settings` where `id` = '".self::ID()."'");
return $query[$var];
}
else
{
$query= $db->fass("SELECT * FROM `user_settings` where `id` = '".$userId."'");
return $query[$var];
}
}
}
public static function profile($var, $userId=null)
{
global $db;
if(self::aut())
{
if($userId == null)
{
$query = $db->fass("SELECT * FROM `users` where `id` = '".self::ID()."'");
return $query[$var];
}
else
{
$query = $db->fass("SELECT * FROM `users` where `id` = '".$userId."' ");
return $query[$var];
}
}
}
public function level($uid=null)
{
if(self::aut())
{
return self::profile('level', $uid);
}
}
public function panel()
{
if(self::aut())
{
Tmp::div('panel', (self::level(self::ID()) >= 2 ? '<a href="/apanel">'.Language::config('apanel').'</a> | ' : NULL). ' <a href="/panel">'.Language::config('panel').'</a> | <a href="/exit">'.Language::config('exit').'</a>');
}
else
{
Tmp::div('panel', '<a href="/login">'.Language::config('aut').'</a> | <a href="/reg">'.Language::config('reg').'</a>');
if($_SERVER['REQUEST_URI'] !== '/')
{
header('Location: /');
}
}
}
}
?>