X-Git-Url: http://git.shiar.net/minimedit.git/blobdiff_plain/494e7f29ac5a003849329e5b4271a555673c1788..d955f2d0837ca4c145546f56a8fe0d3a87f59052:/login/edit.php diff --git a/login/edit.php b/login/edit.php index 9611c7d..894264b 100644 --- a/login/edit.php +++ b/login/edit.php @@ -13,8 +13,15 @@ if (!empty($User['admin']) and $Page == 'login/edit' and $Args) { } $cols = [ - 'name' => ['label' => 'volledige naam'], - 'email' => ['label' => 'e-mailadres', 'type' => 'email'], + 'name' => [ + 'label' => 'volledige naam', + 'explain' => "Alleen zichtbaar voor andere leden.", + ], + 'email' => [ + 'label' => 'e-mailadres', + 'type' => 'email', + 'explain' => "Voor contact van of met deze site. Wij zullen dit nooit vrij- of doorgeven.", + ], 'avatar' => [ 'label' => 'portretfoto', 'type' => 'file', @@ -38,9 +45,69 @@ foreach ($cols as $col => &$colconf) { } $cols = [ - 'login' => ['label' => 'login', 'value' => $user['name'], 'target' => NULL], + 'login' => [ + 'label' => 'login', + 'value' => $user['name'], + 'target' => NULL, + 'pattern' => "[a-z0-9-]+", + ], ] + $cols; +$tagdir = 'profile/.tags'; +if (file_exists($tagdir)) { + $tags = []; + foreach (glob("$tagdir/*") as $tag) { + $tagname = pathinfo($tag, PATHINFO_BASENAME); + $target = "$tag/{$user['name']}"; + $val = file_exists($target); + $tags[$tagname] = ['value' => $val]; + if (empty($User['admin'])) { + continue; # forbidden + } + if (!is_writable($tag)) { + continue; # locked tag directory + } + if ($val and !is_writable($target)) { + continue; # existing file locked + } + $tags[$tagname]['target'] = $target; + } + + if ($tags) { + $options = ''; + foreach ($tags as $tag => $val) { + $options .= sprintf( + "\n\t\t" . + '' . + ' %s', + $tag, + $val['value'] ? ' checked' : '', + isset($val['target']) ? '' : ' readonly', + ucfirst($tag) + ); + } + + $cols['tags'] = [ + 'label' => 'groepen', + 'input' => $options, + 'values' => $tags, + ]; + } +} + +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'])) { @@ -65,6 +132,29 @@ if ($_POST) { } } + if (isset($cols['tags']) and !empty($_POST['tags'])) { + $tagok = []; + foreach ($_POST['tags'] as $col => $val) { + $tag = $cols['tags']['values'][$col]; + if (!isset($tag['target'])) { + $tagok[$col] = 'forbidden'; + } + if ($tag['value'] === !empty($val)) { + $tagok[$col] = NULL; # unaltered + } + elseif (empty($val)) { + $tagok[$col] = !@unlink($tag['target']); + } + else { + $tagok[$col] = !@symlink("../../{$user['name']}", $tag['target']); + } + } + if ($tagok = array_filter($tagok)) { + $colwarn['tags'] = "Wijziging niet opgeslagen voor " + . implode(', ', array_keys($tagok)); + } + } + foreach ($_FILES as $col => $val) { if (!isset($cols[$col]) and @$cols[$col]['type'] == 'file') { continue; # unknown @@ -95,7 +185,7 @@ if ($_POST) { if (!empty($_POST['newpass'])) { require_once('login/pass.inc.php'); if ($error = passform($user, $_POST)) { - $colwarn['pass'] = $error; + $colwarn['newpass'] = $error; } } @@ -109,10 +199,6 @@ if ($_POST) { ?>
-

- Geef een e-mailadres op waarmee we u kunnen bereiken indien nodig. - Wij zullen dit adres nooit vrij- of doorgeven. -

- +

- - -

Wachtwoord wijzigen

-