GIF89a;
Server IP : 172.26.0.195 / Your IP : 3.147.51.75 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/css/../../jobs/../alumni/application/controllers/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
<?php /** * Description of User * * @author Softpro India Pvt. Ltd. */ class Authentication extends CI_Controller { public function __construct() { parent::__construct(); $this->load->model("CourseManager"); $this->load->model("CourseManager"); $this->load->model("AuthenticationManager"); $this->load->model("user/UserManagement"); $this->load->model("admin/BranchManagement"); } public function index() { if ($this->sessionvalidator->validateSession("userData")) { redirect("user/Dashboard"); } else { redirect("Home#loginModal"); } } public function login() { if ($this->sessionvalidator->validateSession("userData")) { $this->load->view("user/Dashboard"); } else { $this->load->view("admin/login"); } } public function signUp() { $viewData["courses"] = $this->CourseManager->getAll()->result(); $viewData["branch"] = $this->BranchManagement->getAllBranches()->result(); $this->load->view("register", $viewData); } public function saveData() { $this->form_validation->set_rules("fullName", "full name", "required", array("required" => "Enter Your Full Name.")); $this->form_validation->set_rules("email", "email", "required|valid_email", array("required" => "Enter Your Email.", "valid_email" => "Enter A Valid Email.")); $this->form_validation->set_rules("passingYear", "passing year", "required", array("required" => "Select Passing Year.")); $this->form_validation->set_rules("password", "password", "required", array("required" => "Enter Your Password.")); $this->form_validation->set_rules("DOB", "DOB", "required", array("required" => "Select Your D.O.B.")); $this->form_validation->set_rules("course", "course", "required", array("required" => "Select Your Course.")); $this->form_validation->set_rules("gender", "gender", "required", array("required" => "Choose your Gender.")); $this->form_validation->set_rules("mobile", "mobile", "required|max_length[10]|min_length[10]|numeric", array("required" => "Enter Your Mobile Number.", "max_length" => "Mobile Number Must Be Of 10 Digits.", "min_length" => "Mobile Number Must Be Of 10 Digits.", "numeric" => "Mobile Number Must Be Digits.")); $this->form_validation->set_rules("confirmPassword", "confirm password", "required|matches[password]", array("required" => "Re-enter Your Password To Confirm.")); $this->form_validation->set_rules("collegeBranch", "collegeBranch", "required", array("required" => "Select College Branch.")); if ($this->form_validation->run() == false) { $this->signUp(); } else { $email = addslashes(trim($this->input->post("email"))); if (sizeof($this->AuthenticationManager->checkUserExistance($email)->result()) > 0) { $this->session->set_flashdata("errorMessage", "Email Already Exists."); $this->signUp(); } else { //sign up code $passing_year = $this->input->post("passingYear"); $curyear = date("Y"); //Getting current year of the server machine $curmonth = date("m"); //Getting current month of the server machine $user_type; $due = $this->CourseManager->getCourseByID($this->input->post("course"))->result(); //gives you the course_duration corresponding to the given courseID $pass = $this->input->post("password"); if ($passing_year > $curyear) { //If passing year is greater than current year the user will be Student $user_type = "Student"; } else if ($passing_year == $curyear) { //In case the passing year selected and the current year matches if ($curmonth <= 7) { $user_type = "Student"; } //Then checking for month. For date earlier than June the user will be Student and otherwise Alumni else { $user_type = "Alumni"; } } else { $user_type = "Alumni"; } //For year less than current year the user will be Alumni $admit = $passing_year - $due[0]->c_duration; //Calculating the year of admission $session = $admit . "-" . $passing_year; //Formulating the session of the person $enc_password = MD5("$pass"); //Encrypting the password $signupArray = array( "name" => addslashes(trim($this->input->post("fullName"))), "email" => $email, "passing_year" => $this->input->post("passingYear"), "password" => $enc_password, "dob" => date('Y-m-d', strtotime(str_replace('/', '-', $this->input->post('DOB')))), "c_id" => $this->input->post("course"), "gender" => $this->input->post("gender"), "mobile" => $this->input->post("mobile"), "college_loc" => $this->input->post("collegeBranch"), "date_added" => date('Y-m-d'), "user_type" => $user_type, "session" => $session ); //print_r($signupArray); $userID = $this->AuthenticationManager->saveSignUpData($signupArray); if ($userID > 0) { //signup successful $this->session->set_flashdata("successMessage", "Signup Successfull."); redirect("Home#loginModal"); } else { //signup failed $this->session->set_flashdata("errorMessage", "Signup Failed."); $this->signUp(); } } } } public function authLogin() { $this->form_validation->set_rules("email", "email", "required", array("required" => "Enter Your Email.")); $this->form_validation->set_rules("password", "password", "required", array("required" => "Enter Your Password.")); if ($this->form_validation->run() == false) { $this->session->set_flashdata("errorMessage", validation_errors()); redirect("Home#loginModal"); } else { $email = $this->input->post("email"); $password = $this->input->post("password"); $enc_password = md5("$password"); $validUser = $this->AuthenticationManager->authenticateUser($email, $enc_password)->result(); $branch = $this->BranchManagement->getAllBranches()->result(); if (sizeof($validUser)) { if ($validUser[0]->user_status == "t") { //allowed user $profile = $this->UserManagement->getUserProfileDetails($validUser[0]->userid)->result()[0]; $profileImg; if ($profile->p_photo == "" || $profile->p_photo == null) { $profileImg = "assets/user/uploads/profileimg.png"; } else { $profileImg = $profile->p_photo; } $userData = array("profileImg" => $profileImg, "email" => $validUser[0]->email, "name" => $validUser[0]->name, "userid" => $validUser[0]->userid, "user_role" => $validUser[0]->user_type, "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("userData", $userData); $this->updateSiginLog($validUser[0]->userid, $validUser[0]->login_count); redirect("user/Dashboard"); } else { //disabled user $this->session->set_flashdata("errorMessage", "You are temporarily locked."); $this->index(); } } else { $this->session->set_flashdata("errorMessage", "Wrong credentials."); redirect("Home#loginModal"); } } } public function authLogout() { $userData = $this->session->userdata("userData"); $this->updatelogoutLog($userData["userid"]); $this->session->unset_userdata('userData'); $this->session->sess_destroy(); redirect("Home#loginModal"); } public function updateSiginLog($userid, $loginCount) { if ($this->sessionvalidator->validateSession("userData")) { $accessLogData = array( "last_login_time" => date("h:i:s"), "last_login_date" => date("Y-m-d"), "from_ip" => $_SERVER["REMOTE_ADDR"], "login_count" => $loginCount + 1); $this->AuthenticationManager->updateAccessLog($userid, $accessLogData); } else { redirect("admin/"); } } public function updatelogoutLog($userid) { if ($this->sessionvalidator->validateSession("userData")) { $accessLogData = array( "last_logout_time" => date("h:i:s"), "last_logout_date" => date("Y-m-d")); $this->AuthenticationManager->updateAccessLog($userid, $accessLogData); } else { redirect("admin/"); } } } ?>