This repository was archived by the owner on Mar 4, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclass.user.php
More file actions
66 lines (57 loc) · 1.59 KB
/
class.user.php
File metadata and controls
66 lines (57 loc) · 1.59 KB
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
56
57
58
59
60
61
62
63
64
65
66
<?php
require 'class.timeclock.php';
class user extends timeclock {
var $userid = 0;
var $name = '';
var $email = '';
var $password = '';
var $active = 0;
var $admin = 0;
function user($userid){
parent::__construct();
$this->userid = (int)$userid;
$this->get_user();
return true;
}
function get_user(){
$query = mysql_query("SELECT * FROM ".$this->config['prefix']."users WHERE id = ".$this->userid.";", $this->conn);
if (mysql_num_rows($query) == 1) {
$r = mysql_fetch_assoc($query);
$this->id = 1;
$this->name = $r['name'];
$this->email = $r['email'];
$this->password = $r['password'];
$this->active = $r['active'];
$this->admin = $r['admin'];
return true;
} else {
return false;
}
}
function get_all_users(){
$query = mysql_query("SELECT * FROM ".$this->config['prefix']."users;", $this->conn);
if (mysql_num_rows($query) > 0) {
return $query;
} else {
return false;
}
}
function login($email, $password) {
$query = mysql_query("SELECT id FROM ".$this->config['prefix']."users WHERE email = '".$email."' AND password = '".md5($password.$this->salt)."';", $this->conn);
if (mysql_num_rows($query) == 1) {
while ($r = mysql_fetch_assoc($query)) {
$this->user = $r['id'];
}
return true;
} else {
return false;
}
}
function add($name, $email, $password, $active, $admin){
mysql_query("INSERT INTO ".$this->config['prefix']."users (name,email,password,active,admin) SET ('".$name."', '".$email."', '".md5($password.$this->salt)."', ".$active.", ".$admin.");", $this->conn);
}
function logout(){
return true;
}
}
?>