public function user_login()
{
//$this->form_validation->set_rules('user_category', 'User type', 'trim|required');
$this->form_validation->set_rules('username', 'Username', 'trim|required');
$this->form_validation->set_rules('password', 'Password', 'trim|required');
$this->form_validation->set_rules('defaultReal', 'Security Letter', 'trim|required');
//$this->form_validation->set_rules('captcha', 'captcha', 'trim|callback_check_captcha|required' );
//$this->form_validation->set_error_delimiters('<span style="color: red;">', '</span>');
if($this->form_validation->run() === FALSE)
{
$this->session->set_flashdata('error_message', 'Invalid username / password or login type.');
$data['image']=$this->_create_captcha();
redirect('login-type-select','location');
}
else{
$uname = $this->db_helper_model->SecureSql($this->input->post('username',TRUE));
if($this->rpHash($this->input->post('defaultReal')) == $this->input->post('defaultRealHash'))
{
//$user_type = $this->db_helper_model->SecureSql($this->input->post('user_category'));
$username = $this->db_helper_model->SecureSql($this->input->post('username',TRUE));
$password = $this->db_helper_model->SecureSql($this->input->post('password',TRUE));
/* Validating User Wrong Login Attempt */
$get_userid_by_username = $this->login_model->get_user_id_by_uname($username);
$lock_status = '';
$diff_minutes = '';
$userid_attempt_check = $get_userid_by_username->userid;
if(!empty($get_userid_by_username))
{
$get_login_attempt = $this->login_model->get_login_attemp_detail($userid_attempt_check);
$lock_status = $get_login_attempt->account_lock_status;
$lock_datetime = strtotime($get_login_attempt->last_log_fail_time);
$curr_datetime = strtotime(date('Y-m-d H:i:s'));
$interval = abs($curr_datetime - $lock_datetime);
$diff_minutes = round($interval / 60);
}
if(($lock_status == '2') && ($diff_minutes <= 30))
{
$this->session->set_flashdata('error_message', 'This Account Has Been Locked For 30 Mins');
redirect('login-type-select','location');
}
//echo $lock_status;
//echo $diff_minutes; exit;
else
{
//$table = $this->input->post('hid_tbl_name');
//$hid_user_type = $this->input->post('hid_user_type');
$data['login_status'] = $this->login_model->check_username_password($username,$password);
//$data['login_status'] = $this->login_model->check_username_password($username,$password,$user_type);
if($data['login_status']!=''){
$set_user_in_session = array(
'user_id'=> $data['login_status']->id,
'username'=> $data['login_status']->username,
'designation'=> $data['login_status']->designation,
'role'=> $data['login_status']->role,
'work_role'=> $data['login_status']->work_role,
'college_id'=> $data['login_status']->college_id,
'first_name'=> $data['login_status']->first_name,
'last_name'=> $data['login_status']->last_name,
'email'=> $data['login_status']->email,
'active_status'=> $data['login_status']->active_status
);
$this->session->set_userdata($set_user_in_session);
/* Clean Attemp Details */
$update_login_lock_status = $this->login_model->func_update_login_lock_status($userid_attempt_check);
$update_login_attempt = $this->login_model->func_update_login_attempt($userid_attempt_check);
$valueofvaliduser=rand(123456789,987654321);
$this->session->set_userdata('authentication',$valueofvaliduser);
setcookie('validluser',$valueofvaliduser,0,'/','',false,true);
$get_user_assigned_page_url = $this->login_model->get_user_assigned_pageurl($data['login_status']->role,$data['login_status']->designation,$data['login_status']->college_id);
if($get_user_assigned_page_url > 0)
{
$create_pageurlid_array = array();
if(!empty($get_user_assigned_page_url))
{
foreach($get_user_assigned_page_url as $url_id)
{
array_push($create_pageurlid_array,$url_id->pageurl_id);
}
}
$this->session->set_userdata('user_assigned_pageurl_id',$create_pageurlid_array);
}
$get_user_last_login_data = $this->login_model->get_user_last_login_data();
if(!empty($get_user_last_login_data))
{
$set_session_user_last_log_info = array(
'last_login_time'=>$get_user_last_login_data->login_time,
'last_login_date'=> $get_user_last_login_data->login_date
);
}
else{
$set_session_user_last_log_info = array(
'last_login_time'=> date('h:i:s'),
'last_login_date'=> date('Y-m-d')
);
}
$this->session->set_userdata($set_session_user_last_log_info);
$desg_name = $this->global_model->get_designation_by_id($data['login_status']->designation);
$work_role_name = $this->global_model->get_designation_by_work_role_id($data['login_status']->work_role);
$college_name = $this->global_model->get_college_by_id($data['login_status']->college_id);
$designation_college_name = array('desig_name'=>$desg_name->designation,'work_role_name'=>$work_role_name->designation,'college_name'=>$college_name->college_name,'collge_sams_code'=>$college_name->college_reg_no);
$this->session->set_userdata($designation_college_name);
$session_master_data_id = $this->login_model->get_session_master_data_id();
$fin_year_data = $this->login_model->get_finance_year();
//echo $this->session->userdata('college_id'); exit;
$college_current_fy_session_details = $this->login_model->get_college_current_cur_fy_session($this->session->userdata('college_id'));
//echo $college_current_fy_session_details->session_auto_id;
//exit;
$this->session->set_userdata('session_master_auto_id',$college_current_fy_session_details->session_auto_id);
$this->session->set_userdata('fyn_ye_sess_start_date',$college_current_fy_session_details->session_yr_from);
$this->session->set_userdata('fyn_ye_sess_end_date',$college_current_fy_session_details->session_yr_to);
$this->session->set_userdata('fyn_ye_sess_name',$college_current_fy_session_details->session_name);
$this->session->set_userdata('fin_yr_id',$fin_year_data->fin_yr_id);
$this->session->set_userdata('fin_yr_name',$fin_year_data->fin_yr_name);
$this->session->sess_time_to_update=0;
//$this->session->sess_update();
//logot session security audit
$csrf_value=md5(rand(1111,9999));
setcookie('csrf_cookie_value',$csrf_value,0,'/','',false,true);
$this->session->set_userdata('csrf_cookie_value_sess',$csrf_value);
redirect('welcome','location');
}
else{
if(!empty($get_userid_by_username))
{
$set_attemp_status = $this->login_model->set_login_attempts($get_userid_by_username->userid);
}
$this->session->set_flashdata('error_message', 'Login authentication failed.Invalid username or password.');
redirect('login-type-select','location');
}
}
}
else
{
$this->session->set_flashdata('error_message', 'Login authentication failed.Invalid Security Code.');
redirect('login-type-select','location');
}
}
//$str = hash ( "sha256", $password );
}**
显示错误:
$designation_college_name = array('desig_name'=>$desg_name->designation,'work_role_name'=>$work_role_name->designation,'college_name'=>$college_name->college_name,'collge_sams_code'=>$college_name->college_reg_no);
**