This repository has been archived by the owner on Feb 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathusers.php
104 lines (76 loc) · 2.84 KB
/
users.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
<?php
// Initialize the language-module
$_language->read_module('users');
if(isset($_GET['userID'])) $userID = $_GET['userID'];
else $userID = '';
use SleekDB\Store;
$userStore = new Store('users', $databaseDirectory, $configuration);
if($action == 'new'){
$password = new_password($password_length);
eval ("\$new_user = \"".gettemplate("new_user", "htm")."\";");
echo $new_user;
}elseif($action == 'edit'){
$user = $userStore->findById($userID);
if(isset($user['name'])){
$name = $user['name'];
}else {
$name = '';
}
if(isset($user['email'])){
$email = $user['email'];
}else {
$email = '';
}
eval ("\$edit_user = \"".gettemplate("edit_user", "htm")."\";");
echo $edit_user;
}elseif($action == 'save'){
if($_POST['last'] == 'new'){
$grandID = $_POST['grandid'];
$name = $_POST['name'];
$email = $_POST['email'];
$password = $_POST['password'];
$passwordHash = password_hash($password, PASSWORD_DEFAULT);
$newUser = [
"grandID" => "$grandID",
"name" => "$name",
"email" => "$email",
"password" => "$passwordHash",
];
$newUser = $userStore->insert($newUser);
header('Location: admin.php?site=users&status=created');
}elseif($_POST['last'] == 'edit'){
$name = $_POST['name'];
$email = $_POST['email'];
$password = $_POST['password'];
$passwordHash = password_hash($password, PASSWORD_DEFAULT);
$id = $_POST['id'];
$userStore->updateById($id, [
"name" => "$name",
"email" => "$email",
"password" => "$passwordHash"
]);
header('Location: admin.php?site=users&status=edited');
}
}elseif($action == 'delete'){
}else{
eval ("\$container_head = \"".gettemplate("container_head", "htm")."\";");
echo $container_head;
eval ("\$title_users = \"".gettemplate("title_users", "htm")."\";");
echo $title_users;
eval ("\$users_list_head = \"".gettemplate("users_list_head", "htm")."\";");
echo $users_list_head;
$users = $userStore->findAll();
foreach($users as $user){
$grandid = $user['grandID'];
$name = $user['name'];
$id = $user['_id'];
$actions = '<a class="button small secondary" href="admin.php?site=users&action=edit&userID='.$id.'">'.$_language->module['edit'].'</a>';
eval ("\$users_list_item = \"".gettemplate("users_list_item", "htm")."\";");
echo $users_list_item;
}
eval ("\$users_list_foot = \"".gettemplate("users_list_foot", "htm")."\";");
echo $users_list_foot;
eval ("\$container_foot = \"".gettemplate("container_foot", "htm")."\";");
echo $container_foot;
}
?>