2021-12-05 12:56:23 +00:00
|
|
|
<?php
|
2021-12-05 13:04:53 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2021 Eichehome
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2021-12-05 13:21:13 +00:00
|
|
|
|
2021-12-05 12:56:23 +00:00
|
|
|
error_reporting(E_ALL); //Debuging
|
|
|
|
require_once 'include/DBConnection.inc.php';
|
|
|
|
function autoloader($classname)
|
|
|
|
{
|
|
|
|
include 'class/' . $classname . '.php';
|
|
|
|
}
|
|
|
|
spl_autoload_register('autoloader');
|
|
|
|
|
|
|
|
$session = new Session();
|
|
|
|
$db = new Datenbank($dbname, $username, $password, $servername);
|
|
|
|
|
|
|
|
/*===============================*/
|
|
|
|
$nutzername = filter_input(INPUT_POST, "name", FILTER_SANITIZE_STRING);
|
|
|
|
$password = filter_input(INPUT_POST, "passwort", FILTER_SANITIZE_NUMBER_INT);
|
|
|
|
$check = filter_input(INPUT_POST, "check", FILTER_SANITIZE_STRING);
|
|
|
|
|
|
|
|
|
|
|
|
if ($check) {
|
|
|
|
if ($nutzername && $password) {
|
|
|
|
if ($db->checkLogin($nutzername, $password)) {
|
|
|
|
$session->set("name", $nutzername);
|
|
|
|
$session->set("login", 1);
|
|
|
|
$session->set("status", "ok");
|
|
|
|
$session->set("message", "Erfolgreich eingeloggt!");
|
|
|
|
$session->set("site", "index");
|
|
|
|
$url = "wahl.php";
|
|
|
|
header("Location: $url");
|
|
|
|
echo '<script type="text/javascript">';
|
|
|
|
echo 'window.location.href="'.$url.'";';
|
|
|
|
echo '</script>';
|
|
|
|
echo '<noscript>';
|
|
|
|
echo '<meta http-equiv="refresh" content="0;url='.$url.'" />';
|
|
|
|
echo '</noscript>'; exit;
|
|
|
|
} else {
|
|
|
|
$errorMessage = "Logindaten fehlerhaft!";
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$errorMessage = ($nutzername || $password) ? "Logindaten fehlerhaft!" : "Logindaten fehlen!";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($_SESSION["status"]) && $session->get("status") == "error") {
|
|
|
|
$errorMessage = $session->get("message");
|
|
|
|
$session->set("message");
|
|
|
|
$session->set("status");
|
|
|
|
$session->destroy();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($_SESSION["finished"]) && $session->get("finished")) {
|
|
|
|
$message = "Du kannst das Fenster jetzt schließen!";
|
|
|
|
$session->destroy();
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
|
|
|
|
<head>
|
|
|
|
<meta charset="utf-8">
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
|
<title>Sportwahlen | Login</title>
|
|
|
|
<link rel="stylesheet" href="assets/css/main.css">
|
|
|
|
</head>
|
|
|
|
|
|
|
|
<body>
|
2021-12-05 13:21:13 +00:00
|
|
|
<!-- Ausgabe einer eventuellen Fehlermeldung -->
|
2021-12-05 12:56:23 +00:00
|
|
|
<?php if (isset($errorMessage) && $errorMessage != ""): ?>
|
|
|
|
<div class="modal">
|
|
|
|
<div class="message error">
|
|
|
|
<p><?php echo $errorMessage; ?></p>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<?php endif;?>
|
2021-12-05 13:21:13 +00:00
|
|
|
<!-- Ausgabe einer eventuellen Statusmeldung -->
|
2021-12-05 12:56:23 +00:00
|
|
|
<?php if (isset($message) && $message != ""): ?>
|
|
|
|
<div class="modal">
|
|
|
|
<div class="message sucsses">
|
|
|
|
<p><?php echo $message; ?></p>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<?php endif;?>
|
|
|
|
<form action="index.php" method="POST">
|
|
|
|
<input type="text" name="name" value="">
|
|
|
|
<input type="password" name="passwort" value="">
|
|
|
|
<input type="hidden" name="check" value="ja">
|
|
|
|
<button>Login</button>
|
|
|
|
</form>
|
|
|
|
<noscript>
|
|
|
|
<p>
|
|
|
|
JavaScript wird für Annehmlichkeiten verwendet, um diese nutzen zu können, sollten Sie dies auch aktivieren.
|
|
|
|
</p>
|
|
|
|
</noscript>
|
|
|
|
<script src="assets/js/main.js"></script>
|
|
|
|
</body>
|
|
|
|
|
|
|
|
</html>
|