<?php
class e_user
{
private $data;
function __construct( $user_id )
{
global $db;
global $_var;
$this->data = $db->row( "SELECT `user_id`, `display_name`, `url`, `email`, `avatar_url` FROM `{$db->prefix}users` WHERE `user_id` = '{$user_id}'" );
if ( !$this->get_data( 'user_id' ) )
{
e_debug::log( 'User creation failed' );
return;
}
$_var['user']['name'] = $this->get_data( 'display_name' );
$_var['user']['avatar_url'] = e_avatar::correct_url( $this->get_data( 'avatar_url' ) );
}
function get_data( $str )
{
if ( !isset( $this->data ) )
return false;
return $this->data[$str];
}
static function is_authenticated()
{
global $_user;
if ( !isset( $_user ) )
return false;
return $_user->get_data( 'user_id' );
}
static function authenticate_user( $login, $password )
{
global $db;
$value = $db->value( "SELECT `user_id` FROM `{$db->prefix}users` WHERE `email` = '{$login}' AND `password` = MD5('{$password}') LIMIT 1" );
return $value ? $value : false;
}
};
?>