consistently use empty() to check user existence
[minimedit.git] / page.inc.php
index 393d614dade2fd2004ba5ad94c40da611da8d302..54a39445b42994d777bc5e97fc23d47b7499c888 100644 (file)
@@ -7,10 +7,10 @@ print "<header>\n";
 ob_start();
 include DOCROOT.'menu.html';
 ob_start();
-if (isset($User)) {
+if (!empty($User)) {
        print '<div class="login"><p>';
        printf('<span>Ingelogd: <b><a href="%s">%s</a></b></span>', '/login', $User['name']);
-       if ($User['admin']) {
+       if (!empty($User['admin'])) {
                $editpage = $Page.$Args;
                if (is_dir($editpage)) {
                        if (file_exists("$editpage/index.html")) {
@@ -33,7 +33,7 @@ $nav = preg_replace_callback('{<a href="([^"]+)">(.*?)</a>}', function ($m) {
        $html = $request == $m[1] ? $m[2] : $m[0]; # text or full link
        return $m[1] == substr($request, 0, strlen($m[1])) ? "<b>$html</b>" : $html;
 }, $nav);
-if (isset($User)) {
+if (!empty($User)) {
        $nav = preg_replace('{\s*<li class="logout">.*?</li>}', '', $nav);
 }
 else {
@@ -50,7 +50,7 @@ register_shutdown_function(function () {
        print "</footer>\n";
 
        global $User;
-       if (isset($User) and $User['admin']) {
+       if (!empty($User['admin'])) {
                print '<script src="//cdn.ckeditor.com/4.7.3/full-all/ckeditor.js"></script>'."\n";
                print '<script src="/edit.js"></script>'."\n";
        }