From: Mischa POSLAWSKY Date: Sat, 16 Jun 2018 13:05:49 +0000 (+0200) Subject: login/edit: treat avatar as jpeg images X-Git-Tag: v3.2~13 X-Git-Url: http://git.shiar.net/minimedit.git/commitdiff_plain/2ee336e09b872ed963686e5e05871b9e7a636f28 login/edit: treat avatar as jpeg images --- diff --git a/login/edit.php b/login/edit.php index bb2278f..e44d059 100644 --- a/login/edit.php +++ b/login/edit.php @@ -22,9 +22,10 @@ $cols = [ ]; foreach ($cols as $col => &$colconf) { - $colpath = "{$user['dir']}/$col.txt"; + $filetype = @$colconf['type'] == 'file' ? 'jpg' : 'txt'; + $colpath = "{$user['dir']}/$col.$filetype"; if (file_exists($colpath)) { - $colconf['value'] = @$colconf['type'] == 'file' ? '' : + $colconf['value'] = $filetype != 'txt' ? '' : file_get_contents($colpath); } if (file_exists($user['dir']) and !is_writable($user['dir'])) { @@ -112,6 +113,9 @@ if ($_POST) { foreach ($cols as $col => &$colconf) { print "\t"; printf(' ', $col, ucfirst($colconf['label'])); + if (@$colconf['type'] == 'file' and isset($colconf['value'])) { + printf('
', $colconf['target']); + } print " &$colconf) { $col, htmlspecialchars(@$colconf['value']) ); + if (@$colconf['type'] == 'file') { + printf(' accept="%s"', 'image/jpeg'); + } print ' placeholder="Niet ingesteld"'; print " />";