714b5c56d096638fb1fb46ac02989ebddd43e238
[minimedit.git] / login.php
1 <?php
2 $message = NULL;
3
4 if (isset($_POST['login'])) {
5         if ($User = login($_POST['login'], $_POST['pass'])) {
6                 login_setcookie();
7         }
8         else {
9                 $message = 'Ongeldige gebruikersnaam of wachtwoord.';
10         }
11 }
12 elseif (isset($_GET['logout'])) {
13         setcookie('login', '', time(), '/'); # expire immediately
14         $User = NULL;
15         $message = 'Uitgelogd.';
16 }
17
18 if (empty($User)) {
19         ob_clean();
20         require_once 'login.inc.php';
21         return TRUE;
22 }
23
24 if (isset($_GET['goto'])) {
25         ob_clean();
26         $target = ltrim($_GET['goto'], '/');
27         header("Location: /$target");
28         http_response_code(302);
29         exit;
30 }
31
32 $part = [
33         'user'  => $User['name'],
34 ];
35 print getoutput($part);
36
37 if (empty($Args) and !empty($User['admin'])) {
38         include_once 'admin/index.html';
39         include_once 'admin.php';
40 }