config->load('trafstat'); $this->load->helper('config'); $this->load->helper('url'); $this->load->library('session'); $this->lang->load('login', 'russian'); $this->load->helper('language'); } function index() { // разушим текущую сессию $this->session->sess_destroy(); $data['title'] = config('trafstat_name').' '.config('trafstat_version'); if (count($this->error)) $data['error'] = $this->error; $this->load->view('login', $data); } // авторизация пользователя function auth() { $login = $this->input->post('login'); $passwd = $this->input->post('passwd'); $autologin = $this->input->post('autologin'); if ($login && $passwd) { $this->load->database(); $this->load->model('user'); $user = $this->user->get_by_login($login); if ($user) { if (sha1("$passwd|".config('trafstat_passwd_salt')) === $user['passwd']) { $this->load->helper('string'); $expire = $this->input->post('autologin') ? config('trafstat_expire_session') : 0; $session = array( 'id' => $user['id'], 'hash' => random_string('alnum', 32) ); $this->user->update_by_id($session['id'], array('hash' => $session['hash'])); $this->session->sess_create($session, $expire); redirect('', 'location'); } } } $this->error[] = lang('login_error_1'); $this->index(); } }