login/edit: set correct id for input fields
[minimedit.git] / login / edit.php
index bb2278faf2b02f22250656a9b6f2158d8329111a..fe70ef95144dc5e348584c4ed0f09d3eaae388d6 100644 (file)
@@ -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,13 +113,22 @@ if ($_POST) {
 foreach ($cols as $col => &$colconf) {
        print "\t";
        printf('<label for="%s">%s:</label> ', $col, ucfirst($colconf['label']));
+       if (@$colconf['type'] == 'file' and isset($colconf['value'])) {
+               printf('<a href="/%s"><img src="/thumb/%s/%s" /></a><br />',
+                       $colconf['target'],
+                       200, $colconf['target']
+               );
+       }
        print "<input";
        if (empty($colconf['target'])) print ' readonly';
-       printf(' type="%s" name="%s" id="%1$s" value="%s"',
+       printf(' type="%s" name="%s" id="%2$s" value="%s"',
                @$colconf['type'] ?: 'text',
                $col,
                htmlspecialchars(@$colconf['value'])
        );
+       if (@$colconf['type'] == 'file') {
+               printf(' accept="%s"', 'image/jpeg');
+       }
        print ' placeholder="Niet ingesteld"';
        print " />";