$v){ $_SESSION[SITE_KEY]['cfx:user']['param'][$k] = $v; } self::saveparam(); } } public function saveparam(){ $param = json_encode($_SESSION[SITE_KEY]['cfx:user']['param']); $sql='UPDATE '.PREFIX.'cfxuser SET param = \''.$param.'\' WHERE id ="'.self::id().'"'; BD::E($sql); } public function autoLogin(){ if(user::auto()){ $code = _VAR::FILTER(cfx_cookie::get(self::$CFX_COOKIE_USER),FILTER_SANITIZE_URLKEY); $validate=_VAR::FILTER(cfx_cookie::get(self::$CFX_COOKIE_USER_VALIDATE),FILTER_SANITIZE_URLKEY); if(md5($code.SITE_KEY_COOKIE)==$validate){ $code = str_replace('-', ':', $code ); self::login($code,user::auto()); } } } public function login($key, $auto=0){ if( self::logged() ) return true; $sql='SELECT * FROM '.PREFIX.'cfxuser WHERE pass ="'.$key.'"'; $res=BD::C($sql); if(BD::N()){ if((int)$res['active']==1){ unset($res['pass']); $res['param'] = json_decode($res['param'],true); $_SESSION[SITE_KEY]['cfx:user']=$res; $sql='UPDATE '.PREFIX.'cfxuser SET seccion = "'.date("Y-m-d H:i:s").'" WHERE pass ="'.$key.'"'; BD::E($sql); $key = str_replace(':', '-', $key ); cfx_cookie::set(self::$CFX_COOKIE_USER_AUTOLOGIN, $auto, COOKIE_TIMER_SESSION,"/"); cfx_cookie::set(self::$CFX_COOKIE_USER, $key, COOKIE_TIMER_SESSION,"/"); cfx_cookie::set(self::$CFX_COOKIE_USER_VALIDATE, md5($key.SITE_KEY_COOKIE), COOKIE_TIMER_SESSION,"/"); $_SESSION[SITE_KEY]['cfx:user']['login']=true; } }else{ self::close(); } } public function close(){ unset($_SESSION[SITE_KEY]['cfx:user']); cfx_cookie::set(self::$CFX_COOKIE_USER_AUTOLOGIN, false, time()-3666,"/"); cfx_cookie::set(self::$CFX_COOKIE_USER, false, time()-3666,"/"); cfx_cookie::set(self::$CFX_COOKIE_USER_VALIDATE, false, time()-3666,"/"); } public function access( $user = 'all', $admin = 'all'){ if( $user == 'all' ) return true; if( $admin == 'all' && user::admin() ) return true; $user=explode(',', $user); foreach( $user as $nivel ) if( user::nivel() == (int)trim($nivel) )return true; $admin=explode(',', $admin); foreach( $admin as $nivel_admin ) if( user::admin() == (int)trim($nivel_admin) )return true; return false; } public function get($id, $p='*'){ if($id){ $sql='SELECT '.$p.' FROM '.PREFIX.'cfxuser WHERE id ="'.$id.'"'; $res=BD::C($sql); if(BD::N()){ unset($res['pass']); if($res['param']) $res['param'] = json_decode($res['param'] , true); return $res; }else return NULL; }else return NULL; } } */ class USER_EVENT extends EVENT{ const LOGIN = 'login'; const RELOAD = 'reload'; const EXT = 'ext'; } class user{ public static $cookie_param=NULL; public static $name_scene="user"; public $name='scene'; public static $__param=array(); public static $user=NULL; public static $event = NULL; public function _kuser(){ $ns = TOOLS::encrypt_num(TOOLS::encrypt(client::IP())); return '_u_'.TOOLS::encrypt_num(self::$name_scene).$ns; } public function get(){ if(!self::$user) self::$user = new user(); if(!self::$event) self::$event = new USER_EVENT(); return self::$user; } public function ext($name){ $nameext = "ext_".$name; if( isset( self::get()->{$nameext} )){ return self::get()->{$nameext}; } $ext = self::$event->dispatchEvent(USER_EVENT::EXT, self::get(), $name ); self::get()->{$nameext} = $ext[0]; return self::get()->{$nameext}; } public function __construct(){ } public function __call($name, $arguments=NULL){ if($arguments==NULL){ $this->get()->{$name}; }else{ $this->get()->{$name}=$arguments[0]; } return $this->get()->{$name}; } public function _get_cookie(){ if(self::$cookie_param){ $code = cfx_cookie::get(self::_kuser()); if( $code ){ $code = FILTER::_($code,FILTER_SANITIZE_URLKEY); self::$cookie_param= explode(".",$code); }else self::$cookie_param= array(0,0,0); } return self::$cookie_param; } public function auto(){ $p = self::_get_cookie(); return (int)$p[0]; } public function autoLogin(){ $id_user = SS::_get("user-id-logged"); if($id_user){ self::get()->id($id_user); self::reload(); }elseif( user::auto() && !self::get()->logged() ){ $p = self::_get_cookie(); if( $p[1] ){ $mun = TOOLS::encrypt_num( md5(SITE_KEY) ); $id = $p[1]-$mun; $sql='SELECT pass FROM '.PREFIX.'cfxuser WHERE id ="'.$id.'"'; $pass = BD::C($sql); if( $pass["pass"] ){ $key = explode(":", $pass["pass"]); if($p[2]==$key[1] && $p[3] == TOOLS::encrypt_num($key[0])){ self::login($pass["pass"],1); } } } } } public function reload(){ $sql='SELECT * FROM '.PREFIX.'cfxuser WHERE id ="'.(self::get()->id()).'"'; $res=BD::C($sql); unset($res['pass']); $res['param'] = json_decode($res['param'],true); $res['logged'] = true; foreach($res as $k => $v){ self::get()->{$k}($v); } $ext = self::$event->dispatchEvent(USER_EVENT::RELOAD, self::get() ); //self::get()->{$nameext} = $ext[0]; } public function login($key, $auto=0){ if( self::get()->logged() ) return true; $sql='SELECT `id`,`active` FROM '.PREFIX.'cfxuser WHERE pass ="'.$key.'"'; $res=BD::C($sql); if(isset($res["active"])){ if((int)$res['active']==1){ unset($res['pass']); SS::_set("user-id-logged",$res['id']); self::get()->id($res['id']); self::reload(); $sql='UPDATE '.PREFIX.'cfxuser SET seccion = "'.date("Y-m-d H:i:s").'" WHERE pass ="'.$key.'"'; BD::E($sql); $key = explode(":",$key); $mun = TOOLS::encrypt_num(md5(SITE_KEY)); $id = $res["id"]+$mun; $cookie_param = array(); $cookie_param[0]=$auto?1:0; $cookie_param[1]=$id?$id:0; $cookie_param[2]=$key[1]?$key[1]:0; $cookie_param[3]=$key[0]?TOOLS::encrypt_num($key[0]):0; if( $auto ) cfx_cookie::set(self::_kuser(), implode(".", $cookie_param), COOKIE_TIMER_SESSION,"/"); } }else{ self::close(); } } public function close(){ self::$user=NULL; SS::_set("user-id-logged",NULL); cfx_cookie::set(self::_kuser(), false, time()-3666,"/"); } public function pass($email,$pass){ $email = strtolower($email); return (TOOLS::encrypt($email)).':'.(TOOLS::encrypt($pass)); } } class admin{ public static function logged(){ return self::_get_p('login'); } public static function id(){ return self::_get_p('id'); } public static function level(){ return self::_get_p('level'); } public static function email(){ return self::_get_p('email'); } public static function name(){ return self::_get_p('name'); } public static function param(){ return self::_get_p('param'); } public static function ext(){ return self::_get_p('ext'); } private static function _get_p($name){ return $_SESSION[SITE_KEY]['cfx:user_admin'][$name]; } public static function login($key){ if( self::logged() ) return true; $sql='SELECT * FROM '.PREFIX.'cfxuser_admin WHERE pass ="'.$key.'"'; $res=BD::C($sql); if((int)$res['id_admin'] && (int)$res['active']==1){ unset($res['pass']); $res['param'] = json_decode($res['param'],true); $res['ext'] = json_decode($res['ext'],true); $_SESSION[SITE_KEY]['cfx:user_admin']=$res; $sql='UPDATE '.PREFIX.'cfxuser_admin SET seccion = "'.date("Y-m-d H:i:s").'" WHERE pass ="'.$key.'"'; BD::E($sql); $_SESSION[SITE_KEY]['cfx:user_admin']['login']=true; }else{ self::close(); } } public static function close(){ unset($_SESSION[SITE_KEY]['cfx:user_admin']); } } if ( !function_exists('sys_get_temp_dir') ){ function sys_get_temp_dir(){ if ( !empty($_ENV['TMP']) ){ return realpath( $_ENV['TMP'] ); } else if ( !empty($_ENV['TMPDIR']) ){ return realpath( $_ENV['TMPDIR'] ); } else if ( !empty($_ENV['TEMP']) ){ return realpath( $_ENV['TEMP'] ); } else{ $temp_file = tempnam( md5(uniqid(rand(), TRUE)), '' ); if ( $temp_file ){ $temp_dir = realpath( dirname($temp_file) ); unlink( $temp_file ); return $temp_dir; }else{ return FALSE; } } } } /*class token{ public function set($token_name='cfx'){ $_SESSION['token-'.$token_name] = md5(date('Y-m-d H:i:s').rand()); } public function validate($token_name,$token_code){ $token = self::get($token_name); self::set($token_name); return ($token == $token_code)?true:false; } public function get($token_name){ if(!$_SESSION['token-'.$token_name]){ self::set($token_name); } return $_SESSION['token-'.$token_name]; } }*/ class token{ public static $publicKey = NULL; public static function set($token_name='cfx'){ SS::_set('token-'.$token_name, md5(date('Y-m-d H:i:s').rand())); } public static function validate($token_name,$token_code){ if(!trim($token_code))return false; $token = self::get($token_name); self::set($token_name); return ($token == $token_code)?true:false; } public static function get($token_name){ if(!SS::_get('token-'.$token_name)){ self::set($token_name); } return SS::_get('token-'.$token_name); } public static function get_public_key(){ if( self::$publicKey ) return self::$publicKey; return self::$publicKey = TOOLS::encrypt( client::IP() . $_SERVER['HTTP_USER_AGENT']) ; } public static function getKeyForm(){ return self::get_public_key(); } public static function getValForm(){ return sha1(self::getKeyForm() . md5($_SERVER['HTTP_USER_AGENT'])); } public static function validateForm(){ $val = isset($_REQUEST[self::getKeyForm()])?$_REQUEST[self::getKeyForm()]:NULL; return ($val == self::getValForm())?true:false; } public static function validate_request($val=NULL){ if(!$val)$val = $_REQUEST[self::get_public_key()]; return ($val == sha1(self::get_public_key() . md5($_SERVER['HTTP_USER_AGENT']) ))?true:false; } } ?>
Fatal error: Class 'USER_EVENT' not found in /var/www/vhosts/currusco.com/httpdocs/core/plugin/global/gl.user.php on line 74