X-Git-Url: http://git.shiar.nl/minimedit.git/blobdiff_plain/39cb639d9e5a8cc13319ddf590569fd3f0c68e3d..6130d2b3fa75b7d350c3eb814b47fead3c0fcce6:/login.php diff --git a/login.php b/login.php index c9a60e3..5287678 100644 --- a/login.php +++ b/login.php @@ -1,25 +1,59 @@ %s', $input); + try { + require_once 'login/mailpass.inc.php'; + if ( $found = mailtoken($input) ) { + $message = "Er is een e-mail verstuurd naar $inputq."; + } + else { + $message = "E-mailadres $inputq is nergens ingesteld."; + } + } + catch (Exception $e) { + $message = "E-mail kon niet verstuurd worden." + . " Probeer het later nog eens of neem contact op."; + } +} +elseif (isset($_POST['login'])) { + if ($User = login($_POST['login'], $_POST['pass'])) { + login_setcookie(); + } + else { + $message = 'Ongeldige gebruikersnaam of wachtwoord.'; } - - echo '

Ongeldige gebruikersnaam of wachtwoord.

'."\n\n"; } -elseif (!empty($User)) { +elseif (isset($_GET['logout'])) { setcookie('login', '', time(), '/'); # expire immediately - echo '

Uitgelogd.

'."\n\n"; + $User = NULL; + $message = "Je bent uitgelogd. Graag tot ziens!"; } -?> -
- - - -
+if (empty($User)) { + ob_clean(); + require_once 'login/form.inc.php'; + $part = ['warn' => $message]; + print getoutput($part); + return TRUE; +} + +if (isset($_GET['goto'])) { + ob_clean(); + $target = ltrim($_GET['goto'], '/'); + header("Location: /$target"); + http_response_code(302); + exit; +} + +$part = [ + 'user' => $User['name'], +]; +print getoutput($part); + +if (empty($Args) and !empty($User['admin'])) { + include_once 'login/admin.html'; + include_once 'login/admin.php'; +}