current()) { header('Location: ' . WWW_URL); exit; } $error = 0; if (!empty($_POST['login']) && !empty($_POST['password']) && csrf_check()) { if ($users->login($_POST['login'], $_POST['password'])) { $url = null; if (!empty($_POST['nc']) && $_POST['nc'] == 'redirect') { $url = $users->appSessionCreateAndGetRedirectURL(); } elseif (!empty($_POST['nc'])) { $users->appSessionCreate($_POST['nc']); $error = -1; } else { $url = './'; } if ($url) { header('Location: ' . $url); exit; } } else { $error = 1; } } html_head('Login'); if ($error == -1) { echo '

You are logged in, you can close this window or tab and go back to the app.

'; html_foot(); exit; } if ($error) { echo '

Invalid login or password

'; } echo '
'; if (isset($_GET['nc'])) { printf('', htmlspecialchars($_GET['nc'])); echo '

An external application is trying to access your data. Please login to continue and allow access.

'; } echo html_csrf(); echo '
Login
'; html_foot();