From 2ee336e09b872ed963686e5e05871b9e7a636f28 Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Sat, 16 Jun 2018 15:05:49 +0200 Subject: [PATCH] login/edit: treat avatar as jpeg images --- login/edit.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) 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 " />"; -- 2.30.0