-
Notifications
You must be signed in to change notification settings - Fork 12
/
userclass.php
62 lines (47 loc) · 1.63 KB
/
userclass.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
56
57
58
59
60
61
62
<?php
class User {
public $id;
public $username;
public $email;
public $lastlogin;
public $lastactivity;
public $lastip;
public $numlinks;
public $numcomments;
public $attempts;
public $created;
public $passhash;
public $salt;
public $loggedIn = false;
public function login($u) {
// this doesn't take into account any authentication
// it assumes session has already been authorized
// this can also just allow you to get user information about any user
$u = (int) $u;
if($u == 0) {
return false;
}
global $mysql;
$sql = "SELECT * FROM `user` WHERE `id` = '".$mysql->real_escape_string($u)."' LIMIT 1";
$res = $mysql->query($sql);
if($res->num_rows < 1) {
return false;
}
$user = $res->fetch_assoc();
$this->id = $u;
$this->username = htmlspecialchars($user["username"]);
$this->email = htmlspecialchars($user["email"]);
$this->lastlogin = htmlspecialchars($user["lastlogin"]);
$this->lastactivity = htmlspecialchars($user["lastactivity"]);
$this->lastip = htmlspecialchars($user["lastip"]);
$this->numlinks = htmlspecialchars($user["numlinks"]);
$this->numcomments = htmlspecialchars($user["numcomments"]);
$this->attempts = htmlspecialchars($user["attempts"]);
$this->created = htmlspecialchars($user["created"]);
$this->passhash = $user["passhash"];
$this->salt = $user["salt"];
$this->loggedIn = true;
//TODO: add last activity/last ip
return true;
}
}