diff --git a/images/key_add.png b/images/key_add.png
new file mode 100644
index 0000000..d407403
Binary files /dev/null and b/images/key_add.png differ
diff --git a/lang/de.php b/lang/de.php
index 137a73b..dfe317d 100644
--- a/lang/de.php
+++ b/lang/de.php
@@ -42,6 +42,7 @@ $lang = array(
'lang_logout' => 'Abmelden',
'lang_options' => 'Optionen',
'lang_option_none' => '(kein)',
+ 'lang_pass_set' => 'Neues Kennwort einstellen',
'lang_reset' => 'Zurücksetzen',
'lang_search' => 'Suche',
'lang_statistics' => 'Statistik',
diff --git a/lang/en.php b/lang/en.php
index ccd242f..e654402 100644
--- a/lang/en.php
+++ b/lang/en.php
@@ -42,6 +42,7 @@ $lang = array(
'lang_logout' => 'Logout',
'lang_options' => 'Options',
'lang_option_none' => '(none)',
+ 'lang_pass_set' => 'Set new password',
'lang_reset' => 'Reset',
'lang_search' => 'Search',
'lang_statistics' => 'Statistics',
diff --git a/tpl/useredit.tpl b/tpl/useredit.tpl
index 9c3f2b1..7703237 100644
--- a/tpl/useredit.tpl
+++ b/tpl/useredit.tpl
@@ -60,7 +60,7 @@
{$lang_user_role_add}
-
+
role)} checked="checked"{/if}
|
@@ -69,7 +69,7 @@
{$lang_user_role_edit}
-
+
role)} checked="checked"{/if}
|
@@ -79,7 +79,7 @@
{$lang_user_role_delete}
-
+
role)} checked="checked"{/if}
|
diff --git a/tpl/userview.tpl b/tpl/userview.tpl
index f233a54..cf34eb8 100644
--- a/tpl/userview.tpl
+++ b/tpl/userview.tpl
@@ -50,13 +50,13 @@
{if in_array('add', $user->role)}
-
+
{/if}
{if in_array('edit', $user->role)}
-
+
{/if}
{if in_array('delete', $user->role)}
-
+
{/if}
{if in_array('manage', $user->role)}
@@ -66,4 +66,22 @@
{/if}
|
+{if $suser_manage}
+
+
+{if $newpass}
+ {$lang_options_newpassword1}
+{else}
+ {$lang_pass_set}
+{/if}
+ |
+
+{if $newpass}
+ {$newpass}
+{else}
+
+{/if}
+ |
+
+{/if}
diff --git a/user.php b/user.php
index c3920b6..5655046 100644
--- a/user.php
+++ b/user.php
@@ -18,6 +18,23 @@ if (isset($_REQUEST['id'])) {
$id = (int) $_REQUEST['id'] or $id = 0;
}
+function makepwd($length) {
+ mt_srand((double) microtime() * 1000000);
+ $digits = "0123456789";
+ $chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+ $umlauts = "ÄÖÜäöüß";
+ $specials = "!§$%&/()=?[]{}+~*#.,;:<>|";
+ $vocals = "AEIOUaeiou";
+ $consonants = "BCDFGHJKLMNPQRSTVWXYZbcdfghjklmnpqrstvwxyz";
+ $passwd = '';
+ $possible = $chars . $digits;
+ $l = strlen($possible)-1;
+ for ($k = 0; $k < $length; $k += 1) {
+ $passwd .= $possible[mt_rand(0, $l)];
+ }
+ return $passwd;
+}
+
// ========== ACTIONS START ===================================================
switch ($submit = form_get_action()) {
@@ -28,6 +45,22 @@ switch ($submit = form_get_action()) {
case 'edit': $action = ACT_EDIT; break;
case 'del': $action = ACT_DELETE; break;
+ case 'pass':
+ // Create new random password to display once
+ $newpass = makepwd(8);
+ $sql = "UPDATE user SET user_pass=:pass WHERE user_id=:id";
+ $sth = $dbh->prepare($sql);
+ $sth->bindValue(':id', $id, PDO::PARAM_INT);
+ $sth->bindValue(':pass', password_hash($newpass, PASSWORD_BCRYPT), PDO::PARAM_STR);
+ try {
+ $sth->execute();
+ } catch (PDOException $e) {
+ $g_warning->Add($e->getMessage());
+ }
+ $smarty->assign('newpass', $newpass);
+ $action = ACT_VIEW;
+ break;
+
case 'insert':
$user_name = strtolower(sanitize($_POST['user_name']));
$user_displayname = sanitize($_POST['user_displayname']);