-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathclass.User.php
124 lines (105 loc) · 2.27 KB
/
class.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<?php
/* A class representing a User.
Each user has a userId, a password, a join date, a level, a signature, an email
address, a boolean variable indicating whether their email address is visible
or not, an URL to their avatar (if any), a boolean variable indicating whether
they are banned or not, a number of topics and a number of posts.
The noOfTopics and noOfPosts are cached here for performance reasons instead of
recounting the number of posts each time it is required.
The object is constructed from a string in the following format:
userId
password
joinDate
level
sig
email
mustHideEmail
avatar
isBanned
noOfTopics
noOfPosts
Each User has a file in the Users directory identified by the users' name,
consisting of the user string:
db/Users/<username>.dat
*/
class User
{
private $userId;
private $password;
private $joinDate;
private $level;
private $sig;
private $email;
private $hideEmail;
private $avatar;
private $banned;
private $topics;
private $posts;
public function __construct($str)
{
$arr = explode("\n",$str);
$this->userId = trim($arr[0]);
$this->password = trim($arr[1]);
$this->banned = trim($arr[2]);
$this->topics = trim($arr[3]);
$this->posts = trim($arr[4]);
$this->joinDate = trim($arr[5]);
$this->level = trim($arr[6]);
$this->sig = trim($arr[7]);
$this->email = trim($arr[8]);
if (trim($arr[9]) == 1)
{
$this->hideEmail = true;
}
else
{
$this->hideEmail = false;
}
$this->avatar = trim($arr[10]);
}
public function getUserId()
{
return trim($this->userId);
}
public function getPassword()
{
return trim($this->password);
}
public function isBanned()
{
return $this->banned;
}
public function getJoinDate()
{
return trim($this->joinDate);
}
public function getLevel()
{
return trim($this->level);
}
public function getNoPosts()
{
return $this->posts;
}
public function getNoTopics()
{
return $this->topics;
}
public function getSig()
{
return $this->sig;
}
public function getEmail()
{
return $this->email;
}
public function isHideEmail()
{
return $this->hideEmail;
}
public function getAvatar()
{
return $this->avatar;
}
}
?>