D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
jnclnmuac
/
public_html
/
grievance
/
sys_admin
/
application
/
models
/
admin
/
Filename :
AdminAuthenticator.php
back
Copy
<?php /** * Model For Admin Authentication (Login/Logout) * * @author Softpro India Pvt. Ltd. */ defined('BASEPATH') OR exit('No direct script access allowed'); class AdminAuthenticator extends CI_Model { function __construct() { parent::__construct(); $this->load->database(); $this->load->library('user_agent'); $this->load->model("admin/AccessLog"); } function authLogin($username, $password) { $this->db->select('*'); $this->db->from('system_admin'); $this->db->where('sa_username', $username); $this->db->where('sa_password', MD5($password)); $this->db->where('sa_delete_status', 'F'); $query = $this->db->get(); if ($query->num_rows() == 1) { foreach ($query->result() as $rows) { $access_id = $this->AccessLog->createAccessLog($rows->admin_id, 'A', 'T', $this->input->ip_address(), "Browser:" . $this->agent->browser() . "--Version:" . $this->agent->version() . "--Mobile:" . $this->agent->mobile() . "--Platform:" . $this->agent->platform()); $admindata = array( 'id' => $rows->sa_id, 'name' => $rows->sa_name, 'email' => $rows->sa_email, 'mobile' => $rows->sa_mobile, 'username' => $rows->sa_username, 'role' => $rows->sa_role, 'type' => $rows->sa_type, 'image' => $rows->sa_image_url, 'access_grant_id' => $access_id, 'logged_in' => TRUE ); } $this->session->set_userdata($admindata); return true; } else { return false; } } function authLogout() { $access_id = $this->session->userdata('access_grant_id'); $this->AccessLog->updateAccessLog($access_id, 'F'); $admindata = array('id' => '', 'name' => '', 'email' => '', 'mobile' => '', 'username' => '', 'role' => '', 'type' => '', 'image' => '', 'access_grant_id' => '', 'logged_in' => FALSE); $this->session->unset_userdata($admindata); $this->session->sess_destroy(); } function authenticateAdminByIdAndPassword($id, $encryptedPassword) { $this->db->select("*"); $this->db->from('system_admin'); $this->db->where('sa_id', $id); $this->db->where('sa_password', $encryptedPassword); $query = $this->db->get(); if (sizeof($query->result()) == 1) { return true; } else { return false; } } function updateNewPassword($passwordUpdateData) { $this->db->where('sa_id', $passwordUpdateData['sa_id']); $this->db->update('system_admin', $passwordUpdateData); return true; } function getAdminInfoBy($adminId) { $this->db->select("*"); $this->db->from('system_admin'); $this->db->where('sa_id', $adminId); return $this->db->get(); } }