-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathuser.php
55 lines (38 loc) · 1.5 KB
/
user.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
if ( !defined( 'BASEPATH' ) )
exit( 'No direct script access allowed' );
class User extends CI_Model {
protected $action_user_id = 1, $table = 'users';
private $cached_users = array();
public function __construct( $id = null ) {
parent::__construct();
}
public function login( $u, $p ) {
if ( !$u || !$p )
return alerts( 'error', 'are you kidding me ? how did u do it :D !!', false );
$query = $this->db->get_where( $this->table, array(
'login' => $u
), 1 );
if ( $query->num_rows() == 0 )
return alert( 'error', "ERROR OMG THE USER NAME DOESNOT EXIST :(,,RUNN", false );
$query = $query->first_row();
$hashedpwd = md5( $p . $query->salt );
if ( $query->password != $hashedpwd )
return alerts( 'error', "OH NO MR. THIS IS INCORRECT PASSWORD<br/>", false );
//#USER HAS LOGED IN ;;;DO WT EVER U LIKE TO DO NOW;;
$this->session->set_userdata( 'action_user', $query ); //SAVE HIM TO SESSION
//#UPDATE USER LOGIN TIME
return alerts( 'success', "success login for {$query->login} @ date('Y-m-d H:i:s')", true );
}
public function in_group( $obj, $role ) {
return true;
}
public function pwd_has_changed() {
return FALSE;
}
public function delete() {
}
}
/*========
End model/User.php
========*/