From c294943eeb642d1456cc5a57be8d1f64dc03a121 Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Thu, 14 Jun 2018 11:24:18 +0200 Subject: [PATCH] login/edit: create missing user profiles --- login/edit.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/login/edit.php b/login/edit.php index 4cb3f11..75811ed 100644 --- a/login/edit.php +++ b/login/edit.php @@ -5,15 +5,11 @@ if (empty($user = &$User)) { } if (!empty($User['admin']) and $Page == 'login/edit' and $Args) { - $username = ltrim($Args, '/'); + $username = strtolower(ltrim($Args, '/')); $user = [ 'dir' => "profile/$username", 'name' => $username, ]; - if (!is_writable($user['dir'])) { - print "

Het is niet mogelijk om de gebruiker {$user['name']} aan te passen.

\n\n"; - return; - } } $cols = [ @@ -26,7 +22,7 @@ foreach ($cols as $col => &$colconf) { if (file_exists($colpath)) { $colconf['value'] = file_get_contents($colpath); } - if (!is_writable($user['dir'])) { + if (file_exists($user['dir']) and !is_writable($user['dir'])) { continue; # locked parent directory } if (isset($colconf['value']) and !is_writable($colpath)) { @@ -41,6 +37,10 @@ $cols = [ $colwarn = []; if ($_POST) { + if (!file_exists($user['dir']) and !@mkdir($user['dir'])) { + print "

Fout bij het aanmaken van gebruikersprofiel voor {$user['name']}.

\n\n"; + return; + } foreach ($_POST as $col => $val) { if (!isset($cols[$col])) { continue; # unknown @@ -53,7 +53,7 @@ if ($_POST) { $colwarn[$col] = "Kan niet worden aangepast."; continue; } - if (!file_put_contents($cols[$col]['target'], $val)) { + if (file_put_contents($cols[$col]['target'], $val) === FALSE) { $colwarn[$col] = "Fout bij opslaan."; } } -- 2.30.0