-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
zimbelstern
committed
Oct 23, 2020
0 parents
commit 8fd75ca
Showing
22 changed files
with
832 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Options -Indexes -MultiViews |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2020 Walfried Schneider | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# 🎄 Wichtelverlosungen | ||
Dieses Programm stellt eine Web-Oberfläche zur Verfügung, auf der Verlosungen durchgeführt werden können, bei denen jeder teilnehmenden Person ([Wichtel](https://de.wikipedia.org/wiki/Wichteln)) geheim eine andere zugelost wird. Das Programm wurde in PHP und SQL geschrieben und basiert auf einem datenschutzfreundlichen, ausgeklügelten Prinzip, bei dem keine E-Mail-Adressen benötigt werden. Die Angabe des (Spitz-)Namens genügt. | ||
|
||
## 📃 Anleitung | ||
|
||
### 🦌 Wichtelverlosungen erstellen | ||
Zum Erstellen von Verlosungen muss mit dem Browser in das Installationsverzeichnis navigiert werden. Nun müssen ein möglichst eindeutiger Titel und die genaue Anzahl der Wichtel festgelegt werden. Verlosungen mit nur drei Wichteln sind möglich, das Ergebnis einer solchen Verlosung ist allerdings aus logischen Gründen nie geheim. | ||
|
||
Mit der Wichtelverlosung wird ein Link erstellt, der nun an alle Wichtel weitergegeben werden muss. | ||
|
||
### 🎁 An Wichtelverlosungen teilnehmen | ||
Alle Wichtel benötigen den Link, um zur Verlosung zu gelangen. Dort müssen sie zunächst nur ihren Namen eintragen, um im Lostopf zu landen. Anschließend erhalten sie einen Weihnachtscode (Passwort), der später benötigt wird, um das personalisierte, geheime Ergebnis der Verlosung einzusehen. Wenn sich *alle* Wichtel angemeldet haben, wird automatisch jedem Wichtel eine andere Person zugelost. Mit ihrem persönlichen Weihnachtscode können sich die Wichtel nun erneut einloggen, um zu sehen, wen sie beschenken werden. | ||
|
||
## 📦 Installation | ||
Auf dem Webserver muss PHP und die Bibliothek *php-sqlite3* installiert sein. Die Dateien müssen entpackt und auf dem Server abgelegt werden. Ein Hintergrundbild ist aus rechtlichen Gründen nicht in diesem Repository enthalten, muss separat [über pixabay.com](https://pixabay.com/photos/christmas-new-year-s-eve-postcard-1911637/) heruntergeladen und als background.jpg im Verzeichnis images abgelegt werden. | ||
|
||
|
||
### ⚙ Konfiguration | ||
Die Konfiguration kann in der Datei `lib/config.php` geändert werden. Nach der Installation läuft das Programm zunächst im Demo-Modus. Im Demo-Modus kann prinzipiell jeder Verlosungen erstellen, jedoch werden alle Verlosungen, die länger als fünf Minuten nicht mehr geändert wurden, gelöscht. Das Ändern des Wertes `"demo"` von `true` zu `false` deaktiviert den Demo-Modus. Das Erstellen von Verlosungen ist dann nur noch mit einem der Server-Passwörter in der Liste `"serverpasswords"` möglich; Verlosungen bleiben aber zeitlich unbegrenzt erhalten. | ||
Beim Abschalten des Demo-Modus empfiehlt es sich zudem, ggf. vorhandene `.sql`-Dateien (*nicht* die `.htaccess`-Datei!) im games-Verzeichnis zu löschen. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Deny from all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Deny from all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php const CONFIG = array( | ||
// In demo mode, all games will be deleted after 10 minutes. | ||
"demo" => true, | ||
|
||
// A list of passwords required to create a game. | ||
"serverpasswords" => array("password1", "password2") | ||
); | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
// Set HTML title | ||
$htmltitle = "Wichtelverlosung erstellen"; | ||
|
||
// Prepare field or demo notification | ||
$passfield = ' | ||
<div class="control has-icons-left"> | ||
<input class="input" type="password" name="serverpass" placeholder="Serverpasswort (beim Admin erfragen)" required pattern="^[a-zA-Z0-9äöüßÄÖÜ ]{1,36}$" maxlength="36"> | ||
<span class="icon is-left"><i class="fas fa-key"></i></span> | ||
</div>'; | ||
if (CONFIG['demo']) { | ||
$passfield = ' | ||
<div class="button is-block is-static"> | ||
<span class="icon is-left"><i class="fas fa-lock"></i></span> Demo-Modus (Testen für 5 Minuten) | ||
</div>'; | ||
} | ||
|
||
// Set messages and create formular | ||
$msg1 = $htmltitle; | ||
$msg2 = "Titel der Verlosung und Anzahl der Wichtel eintragen."; | ||
$msg4 = '<div class="container max-500"> | ||
<div class="box"> | ||
<form action="?verlosung-erstellen" method="post"> | ||
<input type="hidden" name="session_id" value="' . session_id() . '"/> | ||
<div class="field"> | ||
<div class="control has-icons-left"> | ||
<input class="input" type="text" name="titel" placeholder="Titel (Buchstaben, Ziffern, Leerzeichen)" required pattern="^[a-zA-Z0-9äöüßÄÖÜ ]{1,36}$" maxlength="36" autofocus> | ||
<span class="icon is-left"><i class="fas fa-gift"></i></span> | ||
</div> | ||
</div> | ||
<div class="field"> | ||
<div class="control has-icons-left"> | ||
<input class="input" type="number" name="anzahl" placeholder="Anzahl der Wichtel (3–100)" required pattern="^[3-9]$|^[1-9][0-9]$|^100$" maxlength="3"> | ||
<span class="icon is-left"><i class="fas fa-users"></i></span> | ||
</div> | ||
</div> | ||
<div class="field">'.$passfield.' | ||
</div> | ||
<button class="button is-block is-info is-fullwidth">Erstellen</button> | ||
</form> | ||
</div> | ||
</div> | ||
'; | ||
$msg5 = "Übrigens: Hier muss ein Cookie angelegt werden."; | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
// Set HTML title (fallback) | ||
$htmltitle = "Die Wichtelverlosung wurde nicht erstellt"; | ||
|
||
// Set error messages (fallback) | ||
$msg1 = "Die Wichtelverlosung wurde nicht erstellt."; | ||
$msg2 = "Es ist folgender Fehler aufgetreten:"; | ||
$msg4 = ' | ||
<div class="column is-4 is-offset-4"> | ||
<a class="arrow-left" href="?verlosung-erstellen"></a> | ||
</div> | ||
'; | ||
|
||
// If strings are valid and game does not yet exist, create game | ||
// Else set corresponding error messages | ||
if (titleIsValid($_POST['titel'])) { | ||
if (numberIsValid($_POST['anzahl'])) { | ||
if (CONFIG['demo'] || serverpassIsValid($_POST['serverpass'])) { | ||
$dbtitle = $_POST['titel']; | ||
$dbname = str_replace(' ', '', strtolower(iconv("utf-8","ascii//TRANSLIT", $dbtitle))); | ||
$dbnum = intval($_POST['anzahl']); | ||
if (!gameExists($dbname)) { | ||
createGame($dbname, $dbtitle, $dbnum); | ||
$gamelink = getWichtelBaseUri($dbname); | ||
$htmltitle = "Die Wichtelverlosung wurde erstellt"; | ||
$msg1 = "Die Wichtelverlosung wurde erstellt."; | ||
$msg2 = 'Die Verlosung findest du unter folgendem Link:<br/><a href="' . $gamelink . '">' . $gamelink .'</a>'; | ||
$msg3 = "Gib diesen Link an alle Wichtel weiter."; | ||
$msg4 = ""; | ||
if (CONFIG['demo']) { | ||
$msg5 = "Demo-Modus: Die Verlosung wird nach fünf Minuten automatisch gelöscht!"; | ||
} | ||
session_regenerate_id(); | ||
} | ||
else { | ||
$msg3 = "Eine Verlosung mit ähnlichem Namen existiert schon."; | ||
} | ||
} | ||
else { | ||
$msg3 = "Das eingegebene Serverpasswort ist nicht gültig."; | ||
} | ||
} | ||
else if (intval($_POST['anzahl']) == 2) { | ||
$msg3 = "Zwei Wichtel? Bist du dir sicher, dass du das mit dem Wichteln verstanden hast?"; | ||
} | ||
else { | ||
$msg3 = "Die Teilnehmeranzahl liegt nicht zwischen 3 und 100."; | ||
} | ||
} | ||
else { | ||
$msg3 = "Der Titel enthält ungültige Zeichen. Es sind nur deutsche Buchstaben, Zahlen und Leerzeichen erlaubt."; | ||
} | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
function getBaseUri() { | ||
$url=strtok($_SERVER["REQUEST_URI"],'?'); | ||
return $url; | ||
} | ||
|
||
function getExtendedBaseUri() { | ||
$url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"; | ||
return $url; | ||
} | ||
|
||
?> |
Oops, something went wrong.