login: support eol in text configuration files
[minimedit.git] / login / edit.php
index 99afb13a62b745cfe08068c340815aa480cb1ff4..e60cf59bb046414c705bf1df138817f456e44e95 100644 (file)
@@ -57,7 +57,7 @@ foreach ($cols as $col => &$colconf) {
        $colpath = $user['dir'] . '/' . $colconf['filename'];
        if (file_exists($colpath)) {
                $colconf['value'] = $filetype != 'txt' ? '' :
-                       file_get_contents($colpath);
+                       rtrim(file_get_contents($colpath));
        }
        if (file_exists($user['dir']) and !is_writable($user['dir'])) {
                continue;  # locked parent directory
@@ -122,6 +122,9 @@ if ($_POST) {
                        }
                        continue;
                }
+               if (@$cols[$col]['type'] != 'file') {
+                       $val .= "\n"; # eol in text files
+               }
                if (file_put_contents($cols[$col]['target'], $val) === FALSE) {
                        $colwarn[$col] = "Fout bij opslaan.";
                }