The SSH host key has changed on 8 April, 2022 to this one: SHA256:573uTBSeh74kvOo0HJXi5ijdzRm8me27suzNEDlGyrQ
A PHP based password store
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
1.2 KiB

<?php
require 'config.php';
include 'sanitychecks.php';
include 'session.php';
include 'class.db.php';
$loginerror = false;
$valid = false;
if (
array_key_exists('username', $_POST)
&& array_key_exists('password', $_POST)
&& !(
array_key_exists('loginuser', $_SESSION)
&& pwsdbh($dbDSN)->userExists($_SESSION['loginuser'])
)
)
{
try
{
if (($valid = pwsdbh($dbDSN)->authUser($_POST['username'], $_POST['password'])) === true)
{
$_SESSION['loginuser'] = $_POST['username'];
}
}
catch (PWSdbhException $e)
{
$loginerror = $e->getMessage();
}
}
if ($valid === true)
{
$params = (array_key_exists('redirect', $_POST) && ($_POST['redirect'] != '')) ? '?' . $_POST['redirect'] : '';
header('Location: index.php' . $params);
echo 'Login successful. If you are not redirected, <a href="index.php' . $params . '">click here</a>.';
exit;
}
include 'smarty_init.php';
if (array_key_exists('redir', $_GET))
{
$tpl->assign('redirect', $_GET['redir']);
}
elseif (array_key_exists('redirect', $_POST))
{
$tpl->assign('redirect', $_POST['redirect']);
}
else
{
$tpl->assign('redirect', '');
}
if (array_key_exists('username', $_POST))
{
$tpl->assign('username', $_POST['username']);
}
$tpl->assign('loginerror', $loginerror);
$tpl->display('login.tpl');