4 // by Mischa Peters <mischa at high5 dot nl>
5 // Copyright (c) 2022 High5!
6 // License Info: LICENSE.TXT
10 // Template File: login.tpl
12 // Template variables:
17 // GET / POST variables:
22 require_once './functions.inc.php';
23 include './languages/' . check_language () . '.lang';
25 if ($_SERVER['REQUEST_METHOD'] == "POST") {
26 $username = filter_input(INPUT_POST, 'username', FILTER_VALIDATE_EMAIL);
27 $password = filter_input(INPUT_POST, 'password', FILTER_DEFAULT);
29 if (!empty($username) && !empty($password)) {
31 $sth = $dbh->prepare("SELECT password FROM admin WHERE username=?");
32 $sth->bindParam(1, $username, PDO::PARAM_STR);
34 $row = $sth->fetch(PDO::FETCH_ASSOC);
36 $sth = $dbh->prepare("SELECT password FROM mailbox WHERE username=?");
37 $sth->bindParam(1, $username, PDO::PARAM_STR);
39 $row = $sth->fetch(PDO::FETCH_ASSOC);
40 $location = "password.php";
42 $location = "list-domain.php";
46 if (!empty($row['password'])) {
47 if (!password_verify($password, $row['password'])) {
48 $message = $LANG['Login_incorrect'];
51 $message = $LANG['Login_incorrect'];
54 if (empty($message)) {
56 $_SESSION['sessid']['username'] = $username;
57 header("Location: $location");
61 include './templates/header.tpl';
62 include './templates/login.tpl';
63 include './templates/footer.tpl';