DBObj = $DBObj; $this->loginPage = Constant::get('BASE_URL').$this->loginPage; $this->db = S_db2::getInstance(); } function setTableName($name) { $this->auth_table_name = $name; } function setWhere($where) { if ($where) { $this->query_where = " AND " . $where; } } function checkLogin() { if ( !$this->isLogged() ) { $this->notLogedIn(); } } function getData($key = null) { require_once('class/Session.php'); $arr = Session::getData($this->ses_arr_name, $this->ses_arr_name); if ($arr) { $arr = $this->DBObj->DBLogin($arr); } if ($key != null && array_key_exists($key, $arr)) { return $arr[$key]; } return $arr; } function isLogged() { $arr = $this->getData(); return (bool)$arr; } function setLogin2($page = '') { if ($page == '') { $page = CURR_PAGE_FULL; } require_once('class/Session.php'); if (strlen(@$_SERVER['QUERY_STRING'])) { $page.='?'.$_SERVER['QUERY_STRING']; } Session::setData($this->ses_arr_name, 'login_to', Constant::get('BASE_URL').'/'.$page); return true; } function getLogin2() { require_once('class/Session.php'); $login_to = Session::getData($this->ses_arr_name, 'login_to'); Session::clearData($this->ses_arr_name, 'login_to'); return $login_to; } function notLogedIn($user = false) { $this->setLogin2(); require_once('class/HTTP.php'); skHTTP::redirect($this->loginPage); } function logout() { require_once('class/Session.php'); Session::clearData($this->ses_arr_name, $this->ses_arr_name); return true; } function login($user) { require_once('class/Session.php'); $user = $this->DBObj->DBLogin($user); if ($user) { Session::setData($this->ses_arr_name, $this->ses_arr_name, $user); require_once('class/HTTP.php'); $url = $this->getLogin2(); if ($url == '') { $url = BASE_URL . '/' . str_replace('/login', '', CURR_PAGE); } skHTTP::redirect($url); //skHTTP::redirect($this->getLogin2()); return true; } else { return array('login' => 'Bad login or password'); } } function getLoginForm(&$Doc) { if ($this->isFocusLogin){ $Doc->addItemProp('initFuncs', "function(){ document.getElementsByName('login')[0].focus(); }"); } require_once 'class/Form/Form.class.php'; $form = new Form($Doc, 'sssssssssss'); $form->addFormRule(array(&$this, 'login')); $form->setTitle('Login form'); require_once('class/Session.php'); $login = Form::createElement('text', 'login', 'Login', array('class' => 'inp_login', 'value' => Session::getData(CURR_PAGE, 'login') ) ); $form->addElement($login); $form->setCancelType(FORM_CBT_RESET); $password =& Form::createElement('password', 'password', 'Password', array('class' => 'inp_login')); $form->style_pref = 'login_'; $form->addElement($password); $password->setValue(''); $action = Form::createElement('hidden', 'action', 'login'); $form->addElement($action); $form->cancelTitle = 'Reset'; $form->submitTitle = 'Login'; return $form; } } /* require_once('class/Auth/AuthLite.php'); class Auth extends AuthLite { var $auth_table_name; function Auth($table_name) { $this->AuthLite($table_name); } function setTableName($name) { $this->auth_table_name = $name; } function setWhere($where) { if ($where) { $this->query_where = " AND " . $where; } } function getData() { $user_data = WACSG_base::getData($this->ses_arr_name, $this->ses_arr_name); if ($user_data) { $user_data = $this->_DBLogin($user_data); } return $user_data; } } */ ?>