Übernahme der Datein für weitere Bearbeitung
This commit is contained in:
parent
7402018df0
commit
9cd7882eb7
12 changed files with 66156 additions and 0 deletions
64666
PHPUnit/phpunit
Normal file
64666
PHPUnit/phpunit
Normal file
File diff suppressed because one or more lines are too long
36
assets/css/main.css
Normal file
36
assets/css/main.css
Normal file
|
@ -0,0 +1,36 @@
|
|||
@import url(normalize.css);
|
||||
.message {
|
||||
max-width: 30em;
|
||||
margin: 0 auto 15px;
|
||||
padding: 4px 12px;
|
||||
}
|
||||
|
||||
.message.error {
|
||||
background-color: #ffdddd;
|
||||
border-left: 6px solid #f44336;
|
||||
}
|
||||
|
||||
.message.sucsses {
|
||||
background-color: #ddffdd;
|
||||
border-left: 6px solid #4CAF50;
|
||||
}
|
||||
.modal {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
@media screen and (min-width: 600px){
|
||||
.message{
|
||||
border-radius: 10px;
|
||||
margin: 10px auto 15px;
|
||||
}
|
||||
.message.error {
|
||||
border: 3px solid #f44336;
|
||||
}
|
||||
.message.sucsses {
|
||||
border: 3px solid #4CAF50;
|
||||
}
|
||||
}
|
349
assets/css/normalize.css
vendored
Normal file
349
assets/css/normalize.css
vendored
Normal file
|
@ -0,0 +1,349 @@
|
|||
/*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */
|
||||
|
||||
/* Document
|
||||
========================================================================== */
|
||||
|
||||
/**
|
||||
* 1. Correct the line height in all browsers.
|
||||
* 2. Prevent adjustments of font size after orientation changes in iOS.
|
||||
*/
|
||||
|
||||
html {
|
||||
line-height: 1.15; /* 1 */
|
||||
-webkit-text-size-adjust: 100%; /* 2 */
|
||||
}
|
||||
|
||||
/* Sections
|
||||
========================================================================== */
|
||||
|
||||
/**
|
||||
* Remove the margin in all browsers.
|
||||
*/
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the `main` element consistently in IE.
|
||||
*/
|
||||
|
||||
main {
|
||||
display: block;
|
||||
}
|
||||
|
||||
/**
|
||||
* Correct the font size and margin on `h1` elements within `section` and
|
||||
* `article` contexts in Chrome, Firefox, and Safari.
|
||||
*/
|
||||
|
||||
h1 {
|
||||
font-size: 2em;
|
||||
margin: 0.67em 0;
|
||||
}
|
||||
|
||||
/* Grouping content
|
||||
========================================================================== */
|
||||
|
||||
/**
|
||||
* 1. Add the correct box sizing in Firefox.
|
||||
* 2. Show the overflow in Edge and IE.
|
||||
*/
|
||||
|
||||
hr {
|
||||
box-sizing: content-box; /* 1 */
|
||||
height: 0; /* 1 */
|
||||
overflow: visible; /* 2 */
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. Correct the inheritance and scaling of font size in all browsers.
|
||||
* 2. Correct the odd `em` font sizing in all browsers.
|
||||
*/
|
||||
|
||||
pre {
|
||||
font-family: monospace, monospace; /* 1 */
|
||||
font-size: 1em; /* 2 */
|
||||
}
|
||||
|
||||
/* Text-level semantics
|
||||
========================================================================== */
|
||||
|
||||
/**
|
||||
* Remove the gray background on active links in IE 10.
|
||||
*/
|
||||
|
||||
a {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. Remove the bottom border in Chrome 57-
|
||||
* 2. Add the correct text decoration in Chrome, Edge, IE, Opera, and Safari.
|
||||
*/
|
||||
|
||||
abbr[title] {
|
||||
border-bottom: none; /* 1 */
|
||||
text-decoration: underline; /* 2 */
|
||||
text-decoration: underline dotted; /* 2 */
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the correct font weight in Chrome, Edge, and Safari.
|
||||
*/
|
||||
|
||||
b,
|
||||
strong {
|
||||
font-weight: bolder;
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. Correct the inheritance and scaling of font size in all browsers.
|
||||
* 2. Correct the odd `em` font sizing in all browsers.
|
||||
*/
|
||||
|
||||
code,
|
||||
kbd,
|
||||
samp {
|
||||
font-family: monospace, monospace; /* 1 */
|
||||
font-size: 1em; /* 2 */
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the correct font size in all browsers.
|
||||
*/
|
||||
|
||||
small {
|
||||
font-size: 80%;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prevent `sub` and `sup` elements from affecting the line height in
|
||||
* all browsers.
|
||||
*/
|
||||
|
||||
sub,
|
||||
sup {
|
||||
font-size: 75%;
|
||||
line-height: 0;
|
||||
position: relative;
|
||||
vertical-align: baseline;
|
||||
}
|
||||
|
||||
sub {
|
||||
bottom: -0.25em;
|
||||
}
|
||||
|
||||
sup {
|
||||
top: -0.5em;
|
||||
}
|
||||
|
||||
/* Embedded content
|
||||
========================================================================== */
|
||||
|
||||
/**
|
||||
* Remove the border on images inside links in IE 10.
|
||||
*/
|
||||
|
||||
img {
|
||||
border-style: none;
|
||||
}
|
||||
|
||||
/* Forms
|
||||
========================================================================== */
|
||||
|
||||
/**
|
||||
* 1. Change the font styles in all browsers.
|
||||
* 2. Remove the margin in Firefox and Safari.
|
||||
*/
|
||||
|
||||
button,
|
||||
input,
|
||||
optgroup,
|
||||
select,
|
||||
textarea {
|
||||
font-family: inherit; /* 1 */
|
||||
font-size: 100%; /* 1 */
|
||||
line-height: 1.15; /* 1 */
|
||||
margin: 0; /* 2 */
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the overflow in IE.
|
||||
* 1. Show the overflow in Edge.
|
||||
*/
|
||||
|
||||
button,
|
||||
input { /* 1 */
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the inheritance of text transform in Edge, Firefox, and IE.
|
||||
* 1. Remove the inheritance of text transform in Firefox.
|
||||
*/
|
||||
|
||||
button,
|
||||
select { /* 1 */
|
||||
text-transform: none;
|
||||
}
|
||||
|
||||
/**
|
||||
* Correct the inability to style clickable types in iOS and Safari.
|
||||
*/
|
||||
|
||||
button,
|
||||
[type="button"],
|
||||
[type="reset"],
|
||||
[type="submit"] {
|
||||
-webkit-appearance: button;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the inner border and padding in Firefox.
|
||||
*/
|
||||
|
||||
button::-moz-focus-inner,
|
||||
[type="button"]::-moz-focus-inner,
|
||||
[type="reset"]::-moz-focus-inner,
|
||||
[type="submit"]::-moz-focus-inner {
|
||||
border-style: none;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore the focus styles unset by the previous rule.
|
||||
*/
|
||||
|
||||
button:-moz-focusring,
|
||||
[type="button"]:-moz-focusring,
|
||||
[type="reset"]:-moz-focusring,
|
||||
[type="submit"]:-moz-focusring {
|
||||
outline: 1px dotted ButtonText;
|
||||
}
|
||||
|
||||
/**
|
||||
* Correct the padding in Firefox.
|
||||
*/
|
||||
|
||||
fieldset {
|
||||
padding: 0.35em 0.75em 0.625em;
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. Correct the text wrapping in Edge and IE.
|
||||
* 2. Correct the color inheritance from `fieldset` elements in IE.
|
||||
* 3. Remove the padding so developers are not caught out when they zero out
|
||||
* `fieldset` elements in all browsers.
|
||||
*/
|
||||
|
||||
legend {
|
||||
box-sizing: border-box; /* 1 */
|
||||
color: inherit; /* 2 */
|
||||
display: table; /* 1 */
|
||||
max-width: 100%; /* 1 */
|
||||
padding: 0; /* 3 */
|
||||
white-space: normal; /* 1 */
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the correct vertical alignment in Chrome, Firefox, and Opera.
|
||||
*/
|
||||
|
||||
progress {
|
||||
vertical-align: baseline;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the default vertical scrollbar in IE 10+.
|
||||
*/
|
||||
|
||||
textarea {
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. Add the correct box sizing in IE 10.
|
||||
* 2. Remove the padding in IE 10.
|
||||
*/
|
||||
|
||||
[type="checkbox"],
|
||||
[type="radio"] {
|
||||
box-sizing: border-box; /* 1 */
|
||||
padding: 0; /* 2 */
|
||||
}
|
||||
|
||||
/**
|
||||
* Correct the cursor style of increment and decrement buttons in Chrome.
|
||||
*/
|
||||
|
||||
[type="number"]::-webkit-inner-spin-button,
|
||||
[type="number"]::-webkit-outer-spin-button {
|
||||
height: auto;
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. Correct the odd appearance in Chrome and Safari.
|
||||
* 2. Correct the outline style in Safari.
|
||||
*/
|
||||
|
||||
[type="search"] {
|
||||
-webkit-appearance: textfield; /* 1 */
|
||||
outline-offset: -2px; /* 2 */
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the inner padding in Chrome and Safari on macOS.
|
||||
*/
|
||||
|
||||
[type="search"]::-webkit-search-decoration {
|
||||
-webkit-appearance: none;
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. Correct the inability to style clickable types in iOS and Safari.
|
||||
* 2. Change font properties to `inherit` in Safari.
|
||||
*/
|
||||
|
||||
::-webkit-file-upload-button {
|
||||
-webkit-appearance: button; /* 1 */
|
||||
font: inherit; /* 2 */
|
||||
}
|
||||
|
||||
/* Interactive
|
||||
========================================================================== */
|
||||
|
||||
/*
|
||||
* Add the correct display in Edge, IE 10+, and Firefox.
|
||||
*/
|
||||
|
||||
details {
|
||||
display: block;
|
||||
}
|
||||
|
||||
/*
|
||||
* Add the correct display in all browsers.
|
||||
*/
|
||||
|
||||
summary {
|
||||
display: list-item;
|
||||
}
|
||||
|
||||
/* Misc
|
||||
========================================================================== */
|
||||
|
||||
/**
|
||||
* Add the correct display in IE 10+.
|
||||
*/
|
||||
|
||||
template {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the correct display in IE 10.
|
||||
*/
|
||||
|
||||
[hidden] {
|
||||
display: none;
|
||||
}
|
52
assets/js/main.js
Normal file
52
assets/js/main.js
Normal file
|
@ -0,0 +1,52 @@
|
|||
document.addEventListener('DOMContentLoaded', init);
|
||||
|
||||
function init() {
|
||||
//forceHttps();
|
||||
actrivateMessage();
|
||||
setTimeout(hideMessage, 3000);
|
||||
windowReload();
|
||||
}
|
||||
|
||||
function forceHttps() {
|
||||
if (location.protocol != 'https:') {
|
||||
location.href = 'https://' + location.hostname + location.pathname;
|
||||
}
|
||||
}
|
||||
|
||||
function actrivateMessage() {
|
||||
document.querySelectorAll('.modal').forEach((modal)=>{modal.style.position = 'fixed'});
|
||||
}
|
||||
|
||||
function getFileName() {
|
||||
let pathname = location.pathname;
|
||||
let fileNameRegEx = /[a-z]+\.[a-z]+/i;
|
||||
let fileName = pathname.match(fileNameRegEx);
|
||||
return (fileName === null)?'index.php':fileName[0];
|
||||
}
|
||||
|
||||
function hideMessage() {
|
||||
if (getFileName() != 'check.php') {
|
||||
document.querySelectorAll('.modal').forEach((modal) => { modal.style.display = 'none' });
|
||||
}
|
||||
}
|
||||
|
||||
function windowReload() {
|
||||
if (getFileName() == 'check.php') {
|
||||
let message = document.querySelector('.message p').innerHTML;
|
||||
let timeRegEx = /[0-9]/;
|
||||
let time = message.match(timeRegEx);
|
||||
time = time[0];
|
||||
setTimeout(updateMessage, 1000, time, message);//Starte Countdown
|
||||
}
|
||||
}
|
||||
|
||||
function updateMessage(time, message) {
|
||||
let newTime = time-1;
|
||||
message = message.replace(time, newTime);
|
||||
document.querySelector('.message p').innerHTML = message;
|
||||
if (newTime == 1) {
|
||||
setTimeout(() => {location.reload()}, 1000);
|
||||
return;
|
||||
}
|
||||
setTimeout(updateMessage, 1000, newTime, message);
|
||||
}
|
76
check.php
Normal file
76
check.php
Normal file
|
@ -0,0 +1,76 @@
|
|||
<?php
|
||||
|
||||
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);
|
||||
|
||||
/*===============================*/
|
||||
|
||||
if (isset($_SESSION["login"]) && $session->get("login") == 1) {
|
||||
if (isset($_SESSION["reload"]) && $session->get("reload") == 1) {
|
||||
$session->destroy();
|
||||
$session->start();
|
||||
$session->set("finished", 1);
|
||||
$url = "index.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 {
|
||||
$session->set("reload", 1);
|
||||
}
|
||||
if (isset($_SESSION["status"]) && $session->get("status") == "ok") {
|
||||
$message = $session->get("message");
|
||||
}
|
||||
} else {
|
||||
$session->set("status", "error");
|
||||
$session->set("message", "Nicht eingeloggt");
|
||||
$url = "index.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;
|
||||
}
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Sportwahlen | Check</title>
|
||||
<link rel="stylesheet" href="assets/css/main.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<?php if (isset($message) && $message != ""): ?>
|
||||
<div class="modal">
|
||||
<div class="message sucsses">
|
||||
<!-- Ausgabe einer eventuellen Statusmeldung -->
|
||||
<p><?php echo $message; ?></p>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif;?>
|
||||
<noscript>
|
||||
<p>
|
||||
Bitte einmal Neuladen (F5-Taste)
|
||||
</p>
|
||||
</noscript>
|
||||
<script src="assets/js/main.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
90
class/DBClass.php
Normal file
90
class/DBClass.php
Normal file
|
@ -0,0 +1,90 @@
|
|||
<!DOCTYPE html>
|
||||
<?php
|
||||
/*
|
||||
* Copyright (C) 2018 Christian Brüggen
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Stellt eine Verbindung zu einer DB bereit
|
||||
*
|
||||
* @author Christian Brüggen
|
||||
*/
|
||||
class DBClass extends stdClass
|
||||
{
|
||||
|
||||
/**
|
||||
* Zeiger auf die DB
|
||||
* @var PDO
|
||||
*/
|
||||
private $pdo = null;
|
||||
|
||||
/**
|
||||
* Das Abgrage-Statement
|
||||
* @var PDOStatement
|
||||
*/
|
||||
private $stmt = null;
|
||||
|
||||
/**
|
||||
* Verbindet mit Server und DB
|
||||
* @param string $dbname Name der Datenbank
|
||||
* @param string $user Benutzername
|
||||
* @param string $passwort Passwort des Benutzers
|
||||
* @param string $host Adresse des Datenbankservers
|
||||
*/
|
||||
public function __construct($dbname, $user, $passwort, $host)
|
||||
{
|
||||
try {
|
||||
$this->pdo = new PDO('mysql:host=' . $host . ';dbname=' . $dbname, $user, $passwort);
|
||||
} catch (PDOException $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Führt eine SQL-Anweisung ohne Rückgabe eines Datensatzes aus
|
||||
* @param string $querystring
|
||||
* @param array $params
|
||||
* @return boolean
|
||||
*/
|
||||
public function query($querystring, array $params = array())
|
||||
{
|
||||
try {
|
||||
$this->stmt = $this->pdo->prepare($querystring);
|
||||
return $this->stmt->execute($params);
|
||||
} catch (PDOException $ex) {
|
||||
$this->stmt = null;
|
||||
} catch (Exception $ex) {
|
||||
$this->stmt = null;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Führt eine SQL-Anweisung mit Rückgabe eines Datensatzes aus
|
||||
* @param string $querystring
|
||||
* @param array $params
|
||||
* @return array
|
||||
*/
|
||||
public function select($querystring, array $params = array())
|
||||
{
|
||||
if ($this->query($querystring, $params)) {
|
||||
return $this->stmt->fetchAll();
|
||||
} else {
|
||||
return array();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
110
class/Datenbank.php
Normal file
110
class/Datenbank.php
Normal file
|
@ -0,0 +1,110 @@
|
|||
<?php
|
||||
/*
|
||||
* Copyright (C) 2018 Christian Brüggen
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
class Datenbank extends DBClass
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $passwort
|
||||
* @return boolean
|
||||
*/
|
||||
public function checkLogin(string $name, string $passwort)
|
||||
{
|
||||
$sql = 'SELECT * FROM Test_v2 WHERE Name=:name AND Code=:passwort';
|
||||
|
||||
$params = array(
|
||||
'name' => strtolower($name),
|
||||
'passwort' => $passwort
|
||||
);
|
||||
|
||||
$result = $this->select($sql, $params);
|
||||
|
||||
if (count($result) == 1) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $name
|
||||
* @return boolean
|
||||
*/
|
||||
public function hasAlredySelected(string $name)
|
||||
{
|
||||
$sql = 'SELECT * FROM Test_v2 WHERE Name=:name AND Kurs IS NOT NULL AND Kurs2 IS NOT NULL AND Kurs3 IS NOT NULL ';
|
||||
|
||||
$params = array(
|
||||
'name' => $name
|
||||
);
|
||||
|
||||
$result = $this->select($sql, $params);
|
||||
|
||||
if (count($result) == 1) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return array strings
|
||||
*/
|
||||
public function selectKurse()
|
||||
{
|
||||
$sql = 'SELECT name, stunde FROM Kurse';
|
||||
|
||||
return $this->select($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param array $kurse
|
||||
* @return boolean
|
||||
*/
|
||||
public function insertSelection(string $name, array $kurse)
|
||||
{
|
||||
if (count($kurse) == 3) {
|
||||
$sql = 'UPDATE Test_v2 SET Kurs=:kurs1, Kurs2=:kurs2, Kurs3=:kurs3 WHERE name =:name';
|
||||
|
||||
$params = array(
|
||||
'name' => $name,
|
||||
'kurs1' => $kurse[0],
|
||||
'kurs2' => $kurse[1],
|
||||
'kurs3' => $kurse[2]
|
||||
);
|
||||
|
||||
return $this->query($sql, $params);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Nichtmehr nötig
|
||||
* @param string $name
|
||||
* @return boolean
|
||||
*/
|
||||
/*public function updateHasAlredySelected(string $name)
|
||||
{
|
||||
return true;
|
||||
}*/
|
||||
}
|
71
class/Session.php
Normal file
71
class/Session.php
Normal file
|
@ -0,0 +1,71 @@
|
|||
<!DOCTYPE html>
|
||||
<?php
|
||||
/*
|
||||
* Copyright (C) 2018 Christian Brüggen
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Wrapper für eine Session
|
||||
*
|
||||
* @author Christian Brüggen
|
||||
*/
|
||||
class Session
|
||||
{
|
||||
/**
|
||||
* Konstrucktor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->start();
|
||||
}
|
||||
|
||||
/**
|
||||
* Setzt einen Wert für einen Key im Session-Array
|
||||
* @param string $key Key
|
||||
* @param string $value Wert
|
||||
* @return string
|
||||
*/
|
||||
public function set(String $key, String $value = "")
|
||||
{
|
||||
return $_SESSION[$key] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gibt den Wert für einen Key im Session-Array zurück
|
||||
* @param string $key Key
|
||||
* @return string
|
||||
*/
|
||||
public function get(String $key)
|
||||
{
|
||||
return $_SESSION[$key];
|
||||
}
|
||||
|
||||
/**
|
||||
* Zerstört eine Session und ihre Werte
|
||||
*/
|
||||
public function destroy()
|
||||
{
|
||||
session_destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* Startet eine Session
|
||||
*/
|
||||
public function start()
|
||||
{
|
||||
session_start();
|
||||
}
|
||||
}
|
35
include/DBConnection.inc.php
Normal file
35
include/DBConnection.inc.php
Normal file
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (C) 2018 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/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
$servername = "localhost";
|
||||
$username = "root";
|
||||
$password = "MyStr0ngPassword#8";
|
||||
$dbname = "d03087b3";
|
||||
*/
|
||||
|
||||
$servername = "w01a0ec4.kasserver.com";
|
||||
$username = "d03087b3";
|
||||
$password = "Hallowelt123!";
|
||||
$dbname = "d03087b3";
|
||||
|
||||
/*
|
||||
$table = "Test_v2";
|
||||
$kurstable = "Kursbeschreibung";
|
||||
*/
|
98
index.php
Normal file
98
index.php
Normal file
|
@ -0,0 +1,98 @@
|
|||
<?php
|
||||
|
||||
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>
|
||||
<?php if (isset($errorMessage) && $errorMessage != ""): ?>
|
||||
<div class="modal">
|
||||
<div class="message error">
|
||||
<!-- Ausgabe einer eventuellen Fehlermeldung -->
|
||||
<p><?php echo $errorMessage; ?></p>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif;?>
|
||||
<?php if (isset($message) && $message != ""): ?>
|
||||
<div class="modal">
|
||||
<div class="message sucsses">
|
||||
<!-- Ausgabe einer eventuellen Statusmeldung -->
|
||||
<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>
|
401
temp.txt
Normal file
401
temp.txt
Normal file
|
@ -0,0 +1,401 @@
|
|||
<?php
|
||||
|
||||
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>
|
||||
<?php if (isset($errorMessage) && $errorMessage != ""): ?>
|
||||
<div class="modal">
|
||||
<div class="message error">
|
||||
<!-- Ausgabe einer eventuellen Fehlermeldung -->
|
||||
<p><?php echo $errorMessage; ?></p>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif;?>
|
||||
<?php if (isset($message) && $message != ""): ?>
|
||||
<div class="modal">
|
||||
<div class="message sucsses">
|
||||
<!-- Ausgabe einer eventuellen Statusmeldung -->
|
||||
<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>
|
||||
----------------------------------------------
|
||||
<?php
|
||||
|
||||
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);
|
||||
|
||||
/*===============================*/
|
||||
function convertName(string $name) {
|
||||
$suchmuster = array('/([A-Za-z]+)\.([A-Za-z]+)/');
|
||||
$ersetzungen = array('<span style="text-transform: capitalize;">\1 \2</span>');
|
||||
$convertedName = preg_replace($suchmuster, $ersetzungen, $name);
|
||||
return $convertedName;
|
||||
}
|
||||
function convertUmlauteFrom(string $text) {
|
||||
$suchmuster = array();
|
||||
$suchmuster[0] = '/ae/';
|
||||
$suchmuster[1] = '/ue/';
|
||||
$suchmuster[2] = '/oe/';
|
||||
|
||||
$ersetzungen = array();
|
||||
$ersetzungen[2] = 'ä';
|
||||
$ersetzungen[1] = 'ü';
|
||||
$ersetzungen[0] = 'ö';
|
||||
|
||||
$replacedtext = preg_replace($suchmuster, $ersetzungen, $text);
|
||||
return $replacedtext;
|
||||
}
|
||||
/*===============================*/
|
||||
|
||||
if (isset($_SESSION["name"])) {
|
||||
$nutzername = $_SESSION["name"];
|
||||
}
|
||||
$check = filter_input(INPUT_POST, "check", FILTER_SANITIZE_STRING);
|
||||
|
||||
if (isset($_SESSION["login"]) && $session->get("login") == 1) {
|
||||
if (isset($_SESSION["status"]) && $session->get("status") == "ok") {
|
||||
$message = $session->get("message");
|
||||
}
|
||||
} else {
|
||||
$session->set("status", "error");
|
||||
$session->set("message", "Nicht eingeloggt");
|
||||
$url = "index.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;
|
||||
}
|
||||
|
||||
$wahl = array();
|
||||
for ($i = 0; $i < (count($_POST) - 1); $i++) { //-1 Wegen hidden-Feld
|
||||
$wahl[$i] = filter_input(INPUT_POST, "wahl" . $i);
|
||||
}
|
||||
if ($check) {
|
||||
if (count($wahl) == 3) {
|
||||
if ($db->hasAlredySelected($nutzername)) {
|
||||
$message = "";
|
||||
$session->set("status", "error");
|
||||
$session->set("message", "Schon eingetragen!");
|
||||
$url = "index.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 {
|
||||
if ($db->insertSelection($nutzername, $wahl)){
|
||||
$session->set("status", "ok");
|
||||
$session->set("message", "Du bist jetzt eingetragen!<br>Du wirst in 3 Sekunden wietergeleitet.");
|
||||
$url = "check.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 {
|
||||
$session->set("status", "error");
|
||||
$session->set("message", "Beim Eintragen ist etwas schief gelaufen, versuche es später nochmal oder wende dich an den Admin.");
|
||||
$url = "index.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 {
|
||||
$message = "";
|
||||
$errorMessage = "Fehlerhafte Auswahl!";
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Sportwahlen | Wahl</title>
|
||||
<link rel="stylesheet" href="assets/css/main.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<?php if (isset($errorMessage) && $errorMessage != ""): ?>
|
||||
<div class="modal">
|
||||
<div class="message error">
|
||||
<!-- Ausgabe einer eventuellen Fehlermeldung -->
|
||||
<p><?php echo $errorMessage; ?></p>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif;?>
|
||||
<?php if (isset($message) && $message != ""): ?>
|
||||
<div class="modal">
|
||||
<div class="message sucsses">
|
||||
<!-- Ausgabe einer eventuellen Statusmeldung -->
|
||||
<p><?php echo $message; ?></p>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif;?>
|
||||
<?php
|
||||
$kurse = $db->selectKurse();
|
||||
echo '<form action="wahl.php" method="post">';
|
||||
?>
|
||||
<p class="name"><?php echo 'Hallo, ' . convertName(convertUmlauteFrom($nutzername)) . ', bitte auswählen:'; ?></p>
|
||||
<?php
|
||||
echo '<table border="1"><tr><td></td>';
|
||||
for ($i = 0; $i < count($kurse); $i++) {
|
||||
echo "<td>" . convertUmlauteFrom($kurse[$i]["name"]) . "</td>";
|
||||
}
|
||||
|
||||
for ($j = 0; $j < 3; $j++) {
|
||||
echo "<tr>";
|
||||
echo "<td>Wahl " . ($j + 1) . "</td>";
|
||||
for ($k = 0; $k < count($kurse); $k++) {
|
||||
echo "<td>";
|
||||
echo '<input type="radio" id="' . $j . '/' . $k . '" name="wahl' . $j . '" value="' . convertUmlauteFrom($kurse[$k]["name"]) . ';' . $kurse[$k]["stunde"] . '">';
|
||||
echo '<label for="' . $j . '/' . $k . '">' . $kurse[$k]["stunde"] . '</label>';
|
||||
echo "</td>";
|
||||
}
|
||||
echo "</tr>";
|
||||
}
|
||||
echo '<tr><td colspan="' . (count($kurse) + 1) . '"><input type="submit" value="Wählen"></td></tr></table>';
|
||||
?>
|
||||
<input type="hidden" name="check" value="ja">
|
||||
<?php
|
||||
echo "</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>
|
||||
------------------------------
|
||||
<?php
|
||||
|
||||
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);
|
||||
|
||||
/*===============================*/
|
||||
|
||||
if (isset($_SESSION["login"]) && $session->get("login") == 1) {
|
||||
if (isset($_SESSION["reload"]) && $session->get("reload") == 1) {
|
||||
$session->destroy();
|
||||
$session->start();
|
||||
$session->set("finished", 1);
|
||||
$url = "index.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 {
|
||||
$session->set("reload", 1);
|
||||
}
|
||||
if (isset($_SESSION["status"]) && $session->get("status") == "ok") {
|
||||
$message = $session->get("message");
|
||||
}
|
||||
} else {
|
||||
$session->set("status", "error");
|
||||
$session->set("message", "Nicht eingeloggt");
|
||||
$url = "index.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;
|
||||
}
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Sportwahlen | Check</title>
|
||||
<link rel="stylesheet" href="assets/css/main.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<?php if (isset($message) && $message != ""): ?>
|
||||
<div class="modal">
|
||||
<div class="message sucsses">
|
||||
<!-- Ausgabe einer eventuellen Statusmeldung -->
|
||||
<p><?php echo $message; ?></p>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif;?>
|
||||
<noscript>
|
||||
<p>
|
||||
Bitte einmal Neuladen (F5-Taste)
|
||||
</p>
|
||||
</noscript>
|
||||
<script src="assets/js/main.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
--------------------------------------
|
||||
document.addEventListener('DOMContentLoaded', init);
|
||||
|
||||
function init() {
|
||||
//forceHttps();
|
||||
actrivateMessage();
|
||||
setTimeout(hideMessage, 3000);
|
||||
windowReload();
|
||||
}
|
||||
|
||||
function forceHttps() {
|
||||
if (location.protocol != 'https:') {
|
||||
location.href = 'https://' + location.hostname + location.pathname;
|
||||
}
|
||||
}
|
||||
|
||||
function actrivateMessage() {
|
||||
document.querySelectorAll('.modal').forEach((modal)=>{modal.style.position = 'fixed'});
|
||||
}
|
||||
|
||||
function getFileName() {
|
||||
let pathname = location.pathname;
|
||||
let fileNameRegEx = /[a-z]+\.[a-z]+/i;
|
||||
let fileName = pathname.match(fileNameRegEx);
|
||||
return (fileName === null)?'index.php':fileName[0];
|
||||
}
|
||||
|
||||
function hideMessage() {
|
||||
if (getFileName() != 'check.php') {
|
||||
document.querySelectorAll('.modal').forEach((modal) => { modal.style.display = 'none' });
|
||||
}
|
||||
}
|
||||
|
||||
function windowReload() {
|
||||
if (getFileName() == 'check.php') {
|
||||
let message = document.querySelector('.message p').innerHTML;
|
||||
let timeRegEx = /[0-9]/;
|
||||
let time = message.match(timeRegEx);
|
||||
time = time[0];
|
||||
setTimeout(updateMessage, 1000, time, message);//Starte Countdown
|
||||
}
|
||||
}
|
||||
|
||||
function updateMessage(time, message) {
|
||||
let newTime = time-1;
|
||||
message = message.replace(time, newTime);
|
||||
document.querySelector('.message p').innerHTML = message;
|
||||
if (newTime == 1) {
|
||||
setTimeout(() => {location.reload()}, 1000);
|
||||
return;
|
||||
}
|
||||
setTimeout(updateMessage, 1000, newTime, message);
|
||||
}
|
172
wahl.php
Normal file
172
wahl.php
Normal file
|
@ -0,0 +1,172 @@
|
|||
<?php
|
||||
|
||||
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);
|
||||
|
||||
/*===============================*/
|
||||
function convertName(string $name) {
|
||||
$suchmuster = array('/([A-Za-z]+)\.([A-Za-z]+)/');
|
||||
$ersetzungen = array('<span style="text-transform: capitalize;">\1 \2</span>');
|
||||
$convertedName = preg_replace($suchmuster, $ersetzungen, $name);
|
||||
return $convertedName;
|
||||
}
|
||||
function convertUmlauteFrom(string $text) {
|
||||
$suchmuster = array();
|
||||
$suchmuster[0] = '/ae/';
|
||||
$suchmuster[1] = '/ue/';
|
||||
$suchmuster[2] = '/oe/';
|
||||
|
||||
$ersetzungen = array();
|
||||
$ersetzungen[2] = 'ä';
|
||||
$ersetzungen[1] = 'ü';
|
||||
$ersetzungen[0] = 'ö';
|
||||
|
||||
$replacedtext = preg_replace($suchmuster, $ersetzungen, $text);
|
||||
return $replacedtext;
|
||||
}
|
||||
/*===============================*/
|
||||
|
||||
if (isset($_SESSION["name"])) {
|
||||
$nutzername = $_SESSION["name"];
|
||||
}
|
||||
$check = filter_input(INPUT_POST, "check", FILTER_SANITIZE_STRING);
|
||||
|
||||
if (isset($_SESSION["login"]) && $session->get("login") == 1) {
|
||||
if (isset($_SESSION["status"]) && $session->get("status") == "ok") {
|
||||
$message = $session->get("message");
|
||||
}
|
||||
} else {
|
||||
$session->set("status", "error");
|
||||
$session->set("message", "Nicht eingeloggt");
|
||||
$url = "index.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;
|
||||
}
|
||||
|
||||
$wahl = array();
|
||||
for ($i = 0; $i < (count($_POST) - 1); $i++) { //-1 Wegen hidden-Feld
|
||||
$wahl[$i] = filter_input(INPUT_POST, "wahl" . $i);
|
||||
}
|
||||
if ($check) {
|
||||
if (count($wahl) == 3) {
|
||||
if ($db->hasAlredySelected($nutzername)) {
|
||||
$message = "";
|
||||
$session->set("status", "error");
|
||||
$session->set("message", "Schon eingetragen!");
|
||||
$url = "index.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 {
|
||||
if ($db->insertSelection($nutzername, $wahl)){
|
||||
$session->set("status", "ok");
|
||||
$session->set("message", "Du bist jetzt eingetragen!<br>Du wirst in 3 Sekunden wietergeleitet.");
|
||||
$url = "check.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 {
|
||||
$session->set("status", "error");
|
||||
$session->set("message", "Beim Eintragen ist etwas schief gelaufen, versuche es später nochmal oder wende dich an den Admin.");
|
||||
$url = "index.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 {
|
||||
$message = "";
|
||||
$errorMessage = "Fehlerhafte Auswahl!";
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Sportwahlen | Wahl</title>
|
||||
<link rel="stylesheet" href="assets/css/main.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<?php if (isset($errorMessage) && $errorMessage != ""): ?>
|
||||
<div class="modal">
|
||||
<div class="message error">
|
||||
<!-- Ausgabe einer eventuellen Fehlermeldung -->
|
||||
<p><?php echo $errorMessage; ?></p>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif;?>
|
||||
<?php if (isset($message) && $message != ""): ?>
|
||||
<div class="modal">
|
||||
<div class="message sucsses">
|
||||
<!-- Ausgabe einer eventuellen Statusmeldung -->
|
||||
<p><?php echo $message; ?></p>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif;?>
|
||||
<?php
|
||||
$kurse = $db->selectKurse();
|
||||
echo '<form action="wahl.php" method="post">';
|
||||
?>
|
||||
<p class="name"><?php echo 'Hallo, ' . convertName(convertUmlauteFrom($nutzername)) . ', bitte auswählen:'; ?></p>
|
||||
<?php
|
||||
echo '<table border="1"><tr><td></td>';
|
||||
for ($i = 0; $i < count($kurse); $i++) {
|
||||
echo "<td>" . convertUmlauteFrom($kurse[$i]["name"]) . "</td>";
|
||||
}
|
||||
|
||||
for ($j = 0; $j < 3; $j++) {
|
||||
echo "<tr>";
|
||||
echo "<td>Wahl " . ($j + 1) . "</td>";
|
||||
for ($k = 0; $k < count($kurse); $k++) {
|
||||
echo "<td>";
|
||||
echo '<input type="radio" id="' . $j . '/' . $k . '" name="wahl' . $j . '" value="' . convertUmlauteFrom($kurse[$k]["name"]) . ';' . $kurse[$k]["stunde"] . '">';
|
||||
echo '<label for="' . $j . '/' . $k . '">' . $kurse[$k]["stunde"] . '</label>';
|
||||
echo "</td>";
|
||||
}
|
||||
echo "</tr>";
|
||||
}
|
||||
echo '<tr><td colspan="' . (count($kurse) + 1) . '"><input type="submit" value="Wählen"></td></tr></table>';
|
||||
?>
|
||||
<input type="hidden" name="check" value="ja">
|
||||
<?php
|
||||
echo "</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>
|
Loading…
Reference in a new issue