auth: create user object regardless of login
[minimedit.git] / widget / reply.php
index cedcc4919699194fe60926bf5a67adf316dfa38c..edffaa75ceb3b6bc9de79f34d79af2b4d94bff72 100644 (file)
@@ -10,14 +10,15 @@ if ($_POST) {
        require_once 'upload.inc.php';
        try {
                $html = messagehtml($_POST['reply']);
-               if ($_FILES and isset($_FILES['image'])) {
+               if ($_FILES and !empty($_FILES['image'])) {
                        $target = 'data/upload';
                        if (!file_exists($target)) {
                                throw new Exception("er is geen uploadmap aanwezig op $target");
                        }
                        $target .= '/' . $User->login;
-                       $result = userupload($_FILES['image'], $target);
-                       $html .= sprintf('<p><img src="/thumb/640x/%s" /></p>', $result);
+                       if ($result = userupload($_FILES['image'], $target)) {
+                               $html .= sprintf('<p><img src="/thumb/640x/%s" /></p>', $result);
+                       }
                }
                $query = $Db->set('comments', [
                        'page'    => $Page,
@@ -102,7 +103,7 @@ while ($row = $query->fetch()) {
        print "</li>\n";
 }
 
-if ($User) {
+if ($User->login) {
        print '<li>';
        print '<form method="post" action="" enctype="multipart/form-data">';
        if (isset($Issue) and $User->admin("edit $Page")) {