X-Git-Url: http://git.shiar.net/minimedit.git/blobdiff_plain/6c1705bd7fc4faa3db056d503afee041083ad754..v3.7-15-g1888ccc749:/login/edit.php diff --git a/login/edit.php b/login/edit.php index 15b0a2a..99afb13 100644 --- a/login/edit.php +++ b/login/edit.php @@ -17,31 +17,39 @@ and !empty($Place['user']) and $Place['user'] !== $User['name']) { 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) { $tagname = pathinfo($tag, PATHINFO_BASENAME); $target = "$tag/{$user['name']}"; $val = file_exists($target); - $tags[$tagname] = ['value' => $val]; - if (empty($User['admin'])) { - continue; # forbidden - } + $tagopt = &$colconf['values'][$tagname]; + $tagopt = ['value' => $val]; if (!is_writable($tag)) { continue; # locked tag directory } if ($val and !is_writable($target)) { continue; # existing file locked } - $tags[$tagname]['target'] = $target; + $tagopt['target'] = $target; } } @@ -123,27 +131,19 @@ if ($_POST) { 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'])) { @@ -166,12 +166,17 @@ if ($_POST) {