public function login()
{
$data['no_cache'] = TRUE;
if ($this->session->userdata('last_check')) {
$last_check = time() - $this->session->userdata('last_check');
if ($last_check < 3) {
sleep(2);
}
}
$this->session->set_userdata('last_check', time());
$this->load->library('form_validation');
$this->form_validation->set_rules('username', 'lang:lang_username', 'required');
$this->form_validation->set_rules('password', 'lang:lang_password', 'required');
$this->form_validation->set_error_delimiters('<p>', '</p>');
$this->template->set_layout(FALSE);
if ($this->form_validation->run() == false) {
$this->template->build('admin/login', $data);
} else {
$username = $this->input->post('username');
$password = $this->input->post('password');
$remember = $this->input->post('remember');
$login = $this->users_auth->login($username, $password, $remember);
if ($login !== TRUE) {
$data['error'] = $login;
$this->template->build('admin/login', $data);
} else {
$this->users_auth->redirect(TRUE);
}
}
}