];
}
-$cols = [
- 'name' => [
- 'label' => 'volledige naam',
- 'explain' => "Alleen zichtbaar voor andere leden.",
- 'filter' => ["\n", '; '],
- 'size' => 30,
- 'filename' => 'name.txt',
- ],
- 'email' => [
- 'label' => 'e-mailadres',
- 'type' => 'email',
- 'explain' => "Voor contact van of met deze site. Wij zullen dit nooit vrij- of doorgeven.",
- 'size' => 30,
- 'filename' => 'email.txt',
- ],
- 'avatar' => [
- 'label' => 'portretfoto',
- 'type' => 'file',
- 'filename' => 'avatar.jpg',
- ],
- 'tags' => [
- 'label' => 'groepen',
- 'values' => [],
- 'filename' => 'profile/.tags',
- ],
-];
+require_once('edit.inc.php');
foreach ($cols as $col => &$colconf) {
+ if (isset($colconf['visible'])) {
+ if ($colconf['visible'] == 'admin' and empty($User['admin'])) {
+ $colconf['visible'] = FALSE;
+ continue;
+ }
+ }
+ else {
+ $colconf['visible'] = TRUE;
+ }
+
if (!isset($colconf['filename'])) {
continue; # exceptional storage
}
if (isset($colconf['values'])) {
if (!file_exists($colconf['filename'])) {
+ $colconf['visible'] = FALSE;
continue;
- #TODO: drop key
}
$tags = [];
foreach (glob($colconf['filename'] . '/*') as $tag) {
$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
}
$colconf['target'] = $colpath; # editing allowed
}
-$cols = [
- 'username' => [
- 'label' => 'login',
- 'value' => $user['name'],
- 'target' => NULL,
- 'pattern' => "[a-z0-9-]+",
- 'size' => 10,
- ],
-] + $cols;
-
-if (isset($user['pass'])) {
- $cols['newpass'] = [
- 'label' => 'wachtwoord',
- 'input' => <<<'EOT'
- <input type="password" name="oldpass" value="" placeholder="Huidig wachtwoord" />
- <input type="password" id="newpass" name="newpass" value="" placeholder="Nieuw wachtwoord" />
- <input type="password" name="passconf" value="" placeholder="Nogmaals" />
-EOT
- ,
- 'hide' => 'pass',
- ];
-}
-
$colwarn = [];
if ($_POST) {
if (!file_exists($user['dir']) and !@mkdir($user['dir'])) {
if (!isset($cols[$col]) and @$cols[$col]['type'] == 'file') {
continue; # unknown
}
- switch ($val['error']) {
- case UPLOAD_ERR_OK:
- break;
- case UPLOAD_ERR_NO_FILE:
- continue 2; # current
- default:
- $colwarn[$col] = "Afbeelding niet goed ontvangen.";
- continue 2;
- }
if (empty($cols[$col]['target'])) {
$colwarn[$col] = "Kan niet worden aangepast.";
continue;
}
- if (!@move_uploaded_file($val['tmp_name'], $cols[$col]['target'])) {
- $colwarn[$col] = "Fout bij opslaan.";
+ try {
+ require_once('upload.inc.php');
+ $target = userupload($val, NULL, $cols[$col]['target']);
+ if (!$target) continue;
+ $cols[$col]['value'] = '';
}
- foreach (@glob('thumb/*/') as $thumbres) {
- # attempt to remove old derivations
- @unlink($thumbres.'/'.$cols[$col]['target']);
+ catch (Exception $e) {
+ $colwarn[$col] = ucfirst($e->getMessage()).'.';
}
- $cols[$col]['value'] = '';
}
if (!empty($_POST['newpass'])) {
<ul class="grid">
<?php
foreach ($cols as $col => &$colconf) {
+ if (!$colconf['visible']) {
+ continue;
+ }
+
print "\t";
printf('<li><label for="%s">%s:</label>', $col, ucfirst($colconf['label']));
if (@$colconf['type'] == 'file' and isset($colconf['value'])) {
else {
if (isset($cols[$col]['filter'])) {
list ($targetstr, $inputstr) = $cols[$col]['filter'];
- $colconf['value'] = str_replace($targetstr, $inputstr, $colconf['value']);
+ $colconf['value'] = str_replace($targetstr, $inputstr, @$colconf['value']);
}
$attrs = [