-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
135 lines (121 loc) · 4.26 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<?php
// Start session
session_start();
// Import libraries
require_once("lib/wichtelDB.php");
include_once("lib/getBaseUri.php");
// In demo mode, delete games older than 5 minutes.
if (CONFIG['demo']) {
cleanGameFiles();
}
// URL query string
$query = $_SERVER['QUERY_STRING'];
// Declare messages presented to the user
$htmltitle = "Wichtelverlosung";
$msg1 = "";
$msg2 = "";
$msg3 = "";
$msg4 = "";
$msg5 = "";
// If no query string, show start page
if (empty($_SERVER['QUERY_STRING'])) {
$msg1 = 'Wichteln?';
$msg2 = '<span class="icon"><i class="fas fa-arrow-circle-right"></i></span>
<a href="?verlosung-erstellen">Hier kann man eine Wichtelverlosung erstellen.</a>
<span class="icon"><i class="fas fa-arrow-circle-left"></i></span>';
$msg3 = 'Zur Teilnahme an einer Verlosung braucht man einen speziellen Link.';
}
// Pages for game creation
else if ($_SERVER['QUERY_STRING'] == "verlosung-erstellen"){
if (isset($_POST['session_id'])) {
// Include response for new game request
if ($_POST['session_id'] == session_id()) {
include("lib/erstellt.php");
}
// Redirect to prevent processing a request twice
else {
header('Location: ?verlosung-erstellen');
exit();
}
}
// Include page to create a game
else {
include("lib/erstellen.php");
}
}
else if (file_exists("games/{$query}.db")) {
if (isset($_POST['session_id'])) {
// Include logged-in page
if ($_POST['session_id'] == session_id()) {
include("lib/teilgenommen.php");
}
// Redirect to prevent processing a request twice
else {
header('Location: ?' . $query);
exit();
}
}
// Include login page
else {
include("lib/teilnehmen.php");
}
}
// If query string is nonsense, show error page
else {
http_response_code(404);
$htmltitle = 'Fehler 404: Verlosung nicht gefunden – Wichtelverlosung';
$msg1 = 'Diese Verlosung wurde hier nicht gefunden.';
$msg2 = '<span class="icon"><i class="fas fa-arrow-circle-right"></i></span>
<a href="' . getBaseUri() . '">Hier geht es zur Startseite</a>
<span class="icon"><i class="fas fa-arrow-circle-left"></i></span>';
$msg3 = 'Oder ist nur ein Tippfehler im Link?';
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title><?php echo $htmltitle; ?></title>
<base href="<?php echo getBaseUri(); ?>"/>
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon"/>
<link rel="apple-touch-icon-precomposed" href="favicon-152.png">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.10.2/css/all.min.css"/>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.5/css/bulma.min.css" />
<link rel="stylesheet" type="text/css" href="style/wichteln.css"/>
</head>
<body>
<section class="hero is-success is-fullheight">
<div class="hero-head">
</div>
<div class="hero-body">
<div class="container has-text-centered">
<h3 class="title">
<?php echo $msg1; ?>
</h3>
<p class="subtitle">
<?php echo $msg2; ?>
</p>
<p class="subsubtitle">
<?php echo $msg3; ?>
</p>
<?php echo $msg4; ?>
<p class="subsubsubtitle">
<?php echo $msg5; ?>
</p>
</div>
</div>
<div class="hero-foot">
<div class="container">
<div class="content has-text-centered foot-content">
<span class="icon"><i class="fas fa-gifts"></i></span>
Ein Projekt von <a href="https://www.walfriedschneider.de">Walfried Schneider</a>.<br/>
<span class="icon"><i class="fas fa-sleigh"></i></span>
Geschrieben in PHP, SQL, HTML und CSS.
</div>
</div>
</div>
</section>
</body>
</html>