?
Current Path : /home1/savoy/public_html/savoyglobal.net/sibs_draft/system/application/models/ |
Linux gator3171.hostgator.com 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64 |
Current File : /home1/savoy/public_html/savoyglobal.net/sibs_draft/system/application/models/user.php |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');?> <?php /* * To change this template, choose Tools | Templates * and open the template in the editor. */ class user extends Model { function user() { parent::Model(); $this->load->model('customermodel'); } function authenticate($username,$password) { $ip=$this->input->post('ip'); $profile= $this->customermodel->getSingleFieldValue('users','role_id','username',$username); // echo $profile.'ps';die(); if($profile=="") { $profile='NULL'; } $uid= $this->customermodel->getSingleFieldValue('users','id','username',$username); if($uid=="") { $uid='NULL'; } $logintime=$today = date("Y-m-d H:i:s"); $password1=md5($password); $query= $this->db->query("select * from users where username='$username' and password='$password1'"); $data['numrows']=$query->num_rows(); if($query->num_rows()>0) { $lastid= $this->getSingleValue('login_details','id','username',$username); $clogintime= $this->getSingleValue('login_details','login_time','username',$username); $result= $query->row(); $data['userid']= $result->id; $data['username']=$username; $data['clogintime']=$logintime; $data['lastid']=$lastid; $data['roleid']= $result->role_id; $data['staffid']= $result->staff_id; $query1= $this->db->query("select * from login_details where username='$username' and id>='$lastid'"); $data['attempt']=($query1->num_rows())-1; $tblValues=array('profile'=>$profile,'username'=>$username,'password'=>$password1,'login_time '=>$logintime,'userid '=>$uid,'ip_address '=>$ip,'status '=>'Success'); $datas=$this->db->insert('login_details', $tblValues); return $data; } else { $tblValues=array('profile'=>$profile,'username'=>$username,'password'=>$password,'login_time '=>$logintime,'userid '=>$uid,'failing_time '=>$logintime,'ip_address '=>$ip,'status '=>'failed'); $datas=$this->db->insert('login_details', $tblValues); } } function getSingleValue($table,$field,$condition,$value) { $data=$this->db->query("select max(". $field. ") as ".$field." from ". $table . " where ". $condition . "='". $value ."' and status='Success'"); $result= $data->row(); if($result) { return $result->$field; } else { return ""; } } function view_attempt($name,$id) { $refid=$id+1; $data=array(); $res=$this->db->query("select * from login_details where userid ='". $name . "' and id>='". $refid . "' and status='failed'"); foreach ($res->result_array() as $row) { $data[] = $row; } return $data; } } ?>