opensmtpdadmin/login.php
2022-08-18 14:01:52 +02:00

55 lines
1.2 KiB
PHP

<?php
//
// OpenSMTPD Admin
// by Mischa Peters <mischa at high5 dot nl>
// Copyright (c) 2022 High5!
// License Info: LICENSE.TXT
//
// File: login.php
//
// Template File: login.tpl
//
// Template Variables:
//
// tMessage
// tUsername
//
// Form POST \ GET Variables:
//
// fUsername
// fPassword
//
require("./variables.inc.php");
require("./config.inc.php");
require("./functions.inc.php");
include("./languages/" . check_language () . ".lang");
if ($_SERVER['REQUEST_METHOD'] == "POST") {
$fUsername = escape_string ($_POST['fUsername']);
$fPassword = escape_string ($_POST['fPassword']);
$result = db_query("SELECT password FROM admin WHERE username='$fUsername' AND active='1'");
if ($result['rows'] == 1) {
$row = db_array($result['result']);
if (!password_verify($fPassword, $row['password'])) {
$error = 1;
$tMessage = $PALANG['pLogin_password_incorrect'];
$tUsername = $fUsername;
}
} else {
$error = 1;
$tMessage = $PALANG['pLogin_username_incorrect'];
}
if ($error != 1) {
session_start();
$_SESSION['sessid']['username'] = $fUsername;
header("Location: main.php");
exit;
}
}
include("./templates/header.tpl");
include("./templates/login.tpl");
include("./templates/footer.tpl");
?>