]>
git.datanom.net - webcal.git/blob - utils/newuser.php
3 require_once 'config.inc.php';
4 require_once 'user_validate.php';
5 require_once 'helper.php';
9 if (! defined($_SESSION['__ROOT__']) && empty($_SESSION['__ROOT__'])) {
12 header('Location: ' . WEB_ROOT
. 'error.html');
16 if (! has_admin_role()) {
19 header('Location: ' . WEB_ROOT
. 'error.html');
23 require_once 'persistens.php';
25 include TOP_FOLDER
.'/include/header.inc.php';
26 include TOP_FOLDER
.'/include/menu.inc.php';
27 $self =$_SERVER['PHP_SELF'];
28 $db = Persistens
::getInstance(DBDRIVER
);
30 if (count($_POST) > 0 && isset($_POST['action'])) {
32 if (strtolower($_POST['action']) == 'add') {
33 if ($_POST['pwd1'] != $_POST['pwd2']) {
34 $result = "Password does not match";
37 $data = create_user_data(
38 $_POST['uid'], $_POST['pwd1'], $_POST['role']);
39 $result = $db->newUser($data);
40 if ($result === TRUE) {
41 $name = $db->getRoleName((int) $_POST['role']);
42 $result = "{$_POST['uid']} with role: {$name['name']} added";
44 $result = nl2br($result);
48 <p style="text-align: center">
54 $roles = $db->getRoles();
55 $select = '<select name="role">';
56 foreach ($roles as $role) {
57 $select .= "<option value=\"{$role['id']}\">{$role['name']}</option>";
59 $select .= "</select>";
61 <form action
="$self" method
="post" id
="new_form">
63 <table
class="config">
65 <th colspan
="2" style
="text-align: center">New user
</th
>
68 <td
class="config">Username
</td
>
69 <td
class="config"><input name
="uid" type
="text"/></td
>
72 <td
class="config">User role
</td
>
73 <td
class="config">$select</td
>
76 <td
class="config">Password
</td
>
77 <td
class="config"><input name
="pwd1" type
="password"/></td
>
80 <td
class="config">Repeat Password
</td
>
81 <td
class="config"><input name
="pwd2" type
="password"/></td
>
84 <td
class="config" colspan
="2" style
="text-align: center">
85 <input type
="submit" name
="action" value
="Add"/>
94 print "<div id=\"ui\">$pageView</div>";
96 include TOP_FOLDER
.'/include/footer.inc.php';
This page took 0.067373 seconds and 6 git commands to generate.