%PDF- %GIF98; %PNG;
Server : ApacheSystem : Linux sh00666.bluehost.com 5.14.0-687.26.1.el9_8.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Jul 14 16:32:02 EDT 2026 x86_64 User : ndkhermy ( 1200) PHP Version : 8.5.12 Disable Function : NONE Directory : /home1/ndkhermy/public_html/website_1ec2d7c2/apps/libraries/ |
Upload File : |
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Login
{
public function __construct(){
$this->CI =& get_instance();
}
function redirect(){
$isLogin = $this->CI->session->userdata('isLogin');
$backUrl = $this->CI->session->userdata('backUrl');
if(!empty($isLogin)){
empty($backUrl) ? $backUrl = 'home' : '';
$this->CI->session->unset_userdata('isLogin');
}
redirect($this->CI->config->item('SITEURL'));
return TRUE;
}
public function check_login() {
$user_id = $this->CI->session->userdata('bh_admin_id');
if ($user_id=='') {
$msg = array('login' => '<p>You must be logged in to access secure area.</p>');
redirect(BASE_URL.'admin/login?msg=login',$msg);
}
}
function process_login($email, $password)
{
//set where options
$this->CI->db->where('email_id', $email);
$this->CI->db->where('password', $password);
//query table for the user
$query = $this->CI->db->get('bh_admin');
//count number of rows
$numrows = $query->num_rows();
//if count of row == 1
if ($numrows == 1) {
$data = $query->result_array();
$this->CI->session->set_userdata('logged_in', '1');
$this->CI->session->set_userdata('bh_admin_name', $data[0]["username"]);
$this->CI->session->set_userdata('bh_admin_role', $data[0]["roles"]);
$this->CI->session->set_userdata('bh_admin_id', $data[0]["admin_id"]);
$this->CI->session->set_userdata('bh_admin_email_id', $data[0]["email_id"]);
} else {
$this->CI->session->set_userdata('logged_in', '');
return FALSE;
}
}
public function check_front_login() {
$user_id = $this->CI->session->userdata('bh_front_user_id');
if ($user_id=='') {
$msg = array('login' => '<p>You must be logged in to access user dashboard area.</p>');
redirect(BASE_URL.'login?msg=login',$msg);
}
}
function process_front_guest_login($email, $password){
//set where options
$this->CI->db->where('email_id', $email);
$this->CI->db->where('password', md5($password));
//query table for the user
$query = $this->CI->db->get('bh_users');
//count number of rows
$numrows = $query->num_rows();
//if count of row == 1
if ($numrows == 1) {
$data = $query->result_array();
$this->CI->session->set_userdata('front_logged_in', '1');
echo $this->CI->session->set_userdata('bh_front_user_id', $data[0]["user_id"]);
$this->CI->session->set_userdata('bh_front_email_id', $data[0]["email_id"]);
$this->CI->session->set_userdata('bh_front_username', $data[0]["first_name"]);
} else {
$this->CI->session->set_userdata('front_logged_in', '');
return FALSE;
}
}
function process_front_login($email, $password)
{
//set where options
$this->CI->db->where('email_id', $email);
$this->CI->db->where('password', $password);
$this->CI->db->where('status', "1");
//query table for the user
$query = $this->CI->db->get('bh_users');
//count number of rows
$numrows = $query->num_rows();
//if count of row == 1
if ($numrows == 1) {
$data = $query->result_array();
$this->CI->session->set_userdata('front_logged_in', '1');
$this->CI->session->set_userdata('bh_front_user_id', $data[0]["user_id"]);
$this->CI->session->set_userdata('bh_front_email_id', $data[0]["email_id"]);
$this->CI->session->set_userdata('bh_front_username', $data[0]["first_name"]);
} else {
$this->CI->session->set_userdata('front_logged_in', '');
return FALSE;
}
}
public function MaxDisplayOrder($table){
$this->CI->db->select("*");
$this->CI->db->from($table);
$this->CI->db->order_by('DisplayOrder','desc');
$query=$this->CI->db->get();
$maxdata = $query->result_array();
$displayorder = $maxdata[0]['DisplayOrder'];
return ($displayorder +1);
}
public function PriceRound($price){
return number_format($price,2);
}
public function token(){
$token = md5(uniqid(rand(), true));
$this->CI->session->set_userdata('token',$token);
return $token;
}
public function trackingno(){
$token = mt_rand(100,999);
$currentdate = date('dmyhis');
return 'MPL'.$currentdate.$token;
}
}