-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmainUser.php
executable file
·55 lines (52 loc) · 1.67 KB
/
mainUser.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
/*
[Giovanni Rescigno - Clone Computers 2013 V1.0b GPL 2.0]
this class holds info about the over state of all of the users in the system
*/
class UsersInfo{
private $usersFileLocation;
function __construct($fileLocation){
$this->usersFileLocation = $fileLocation;
}
/*
this method checks if are any users and
if there are not than it will return false
*/
function isUsers(){
$userFileHandle = new MarkUpFile($this->usersFileLocation );
if($userFileHandle->Read() == false){
$userFileHandle->Close();
return false;
}
else{
$userFileHandle->Close();
return true;
}
}
/*
this method returns all of the users in in a user object (refur to dataStructs.php and the User Class)
so that the login system can see all of the users are that are on the system
*/
function getAllUsers(){
$systemUsersFile = new MarkUpFile($this->usersFileLocation);
$systemUsersArray = $systemUsersFile->Read();
$systemUsersObjectArray = array();
foreach($systemUsersArray as $singaUser){
$systemUsersObjectArray = array_merge($systemUsersObjectArray, array(
new User(rtrim($singaUser[1], "\r "), rtrim($singaUser[2], "\r "), rtrim($singaUser[3], "\r "))
));
}
$systemUsersFile->Close();
return $systemUsersObjectArray;
}
/*
this method adds a new user.
it has three perameters userName password (not hashed) and rank (admin or user)
*/
function createNewUser($userName, $UnhashedPass, $type){
$systemUsersFileHandle = new MarkUpFile($this->usersFileLocation);
$systemUsersFileHandle->Write(false, array(array($userName, hash('ripemd160', $UnhashedPass), $type)));
$systemUsersFileHandle->Close();
}
}
?>