From: Mischa POSLAWSKY Date: Wed, 4 Oct 2017 22:58:16 +0000 (+0200) Subject: consistently use empty() to check user existence X-Git-Tag: v2.4~3 X-Git-Url: http://git.shiar.nl/minimedit.git/commitdiff_plain/6ce5695197ca6b3137a44d775baff00aaa6e0673 consistently use empty() to check user existence Succinct without causing PHP notices even for array access. --- diff --git a/edit.php b/edit.php index 9ba0d04..4e51097 100644 --- a/edit.php +++ b/edit.php @@ -7,7 +7,7 @@ function abort($body, $status = NULL) { exit; } -if (!@$User['admin']) +if (empty($User['admin'])) abort("geen beheersrechten", '401 unauthorised'); if ($_FILES) { diff --git a/login.php b/login.php index 3b59064..9c5f06e 100644 --- a/login.php +++ b/login.php @@ -15,19 +15,19 @@ elseif (isset($_GET['logout'])) { $message = 'Uitgelogd.'; } -if (isset($_GET['goto']) and isset($User)) { +if (empty($User)) { + ob_clean(); + require_once 'login.inc.php'; + return TRUE; +} + +if (isset($_GET['goto'])) { ob_clean(); $target = ltrim($_GET['goto'], '/'); header("Location: /$target"); http_response_code(302); exit; } - -if (empty($User)) { - ob_clean(); - require_once 'login.inc.php'; - return TRUE; -} ?>

Ingelogd als .

diff --git a/page.inc.php b/page.inc.php index 393d614..54a3944 100644 --- a/page.inc.php +++ b/page.inc.php @@ -7,10 +7,10 @@ print "
\n"; ob_start(); include DOCROOT.'menu.html'; ob_start(); -if (isset($User)) { +if (!empty($User)) { print '