X-Git-Url: http://git.shiar.net/minimedit.git/blobdiff_plain/70383597b40ed24f48b4bfdf79e82e1d6d02bb73..a92a5dd241cdcf08d3378a393a54d0a24a07b48e:/login/edit.php
diff --git a/login/edit.php b/login/edit.php
index cfbc2d7..bd39f5e 100644
--- a/login/edit.php
+++ b/login/edit.php
@@ -41,6 +41,19 @@ $cols = [
'login' => ['label' => 'login', 'value' => $user['name'], 'target' => NULL],
] + $cols;
+if (isset($user['pass'])) {
+ $cols['newpass'] = [
+ 'label' => 'wachtwoord',
+ 'input' => <<<'EOT'
+
+
+
+EOT
+ ,
+ 'hide' => 'pass',
+ ];
+}
+
$colwarn = [];
if ($_POST) {
if (!file_exists($user['dir']) and !@mkdir($user['dir'])) {
@@ -85,13 +98,17 @@ if ($_POST) {
if (!@move_uploaded_file($val['tmp_name'], $cols[$col]['target'])) {
$colwarn[$col] = "Fout bij opslaan.";
}
+ foreach (@glob('thumb/*/') as $thumbres) {
+ # attempt to remove old derivations
+ @unlink($thumbres.'/'.$cols[$col]['target']);
+ }
$cols[$col]['value'] = '';
}
if (!empty($_POST['newpass'])) {
require_once('login/pass.inc.php');
if ($error = passform($user, $_POST)) {
- $colwarn['pass'] = $error;
+ $colwarn['newpass'] = $error;
}
}
@@ -115,54 +132,58 @@ foreach ($cols as $col => &$colconf) {
print "\t";
printf('
', $col, ucfirst($colconf['label']));
if (@$colconf['type'] == 'file' and isset($colconf['value'])) {
- printf('![](/thumb/%s/%s)
',
+ printf('![](/thumb/%s/%s?%s)
',
$colconf['target'],
- 200, $colconf['target']
+ 200, $colconf['target'], filemtime($colconf['target'])
);
}
- print "Wijzigen',
+ "document.getElementById('$hide').removeAttribute('hidden'); this.remove()",
+ $hide
+ );
}
- print ' placeholder="Niet ingesteld"';
- print " />";
- if ($error = @$colwarn[$col]) {
- print " $error\n";
+ if (isset($colconf['input'])) {
+ print $colconf['input'];
}
- print "\n";
-}
+ else {
+ $attrs = [
+ 'type' => @$colconf['type'] ?: 'text',
+ 'name' => $col,
+ 'id' => $col,
+ 'value' => htmlspecialchars(@$colconf['value']),
+ 'placeholder' => "Niet ingesteld",
+ 'readonly' => empty($colconf['target']),
+ ];
+ if (@$colconf['type'] == 'file') {
+ $attrs['accept'] = "image/jpeg";
+ }
-if (isset($user['pass'])) {
- $hide = empty($_POST['newpass']);
-?>
- >
-
-
-
-
- $attrval) {
+ if ($attrval === FALSE) {
+ continue;
+ }
+ print ' ' . $attr;
+ if ($attrval !== TRUE) {
+ printf('="%s"', $attrval);
+ }
+ }
+ print ' />';
+ }
+
+ if ($hide) {
+ print '';
+ }
+
+ if ($error = @$colwarn[$col]) {
print " $error\n";
}
-?>
-
-\n";
}
?>
-
+
-
-
- Wachtwoord wijzigen
-