summaryrefslogtreecommitdiff
path: root/intern.gospeladlershof.de/code
diff options
context:
space:
mode:
authorHorus32016-09-28 14:43:44 +0200
committerHorus32016-09-28 14:43:44 +0200
commit6decb91aa4cc27c83c866d1b128dc719aeb1c986 (patch)
tree477a08f5296bbf4ab75b53893b25f900b6e0ad8f /intern.gospeladlershof.de/code
parent4c39424720d6be708896f42b73a93df3c2637a10 (diff)
parent006da29841a225675fc7dc4981b69336409737e1 (diff)
downloadgospeladlershof.de-6decb91aa4cc27c83c866d1b128dc719aeb1c986.tar.gz
Merge branch 'master' of git.iamfabulous.de:gospeladlershof.de
Diffstat (limited to 'intern.gospeladlershof.de/code')
-rw-r--r--intern.gospeladlershof.de/code/config.php3
-rw-r--r--intern.gospeladlershof.de/code/db.php25
-rw-r--r--intern.gospeladlershof.de/code/deploy.php10
-rw-r--r--intern.gospeladlershof.de/code/export.php12
-rw-r--r--intern.gospeladlershof.de/code/konzert/insert.php31
-rw-r--r--intern.gospeladlershof.de/code/konzert/update.php33
-rw-r--r--intern.gospeladlershof.de/code/login.php47
-rw-r--r--intern.gospeladlershof.de/code/logout.php9
-rw-r--r--intern.gospeladlershof.de/code/proben/insert.php29
-rw-r--r--intern.gospeladlershof.de/code/proben/update.php33
-rw-r--r--intern.gospeladlershof.de/code/session.php12
-rw-r--r--intern.gospeladlershof.de/code/termine.php21
12 files changed, 265 insertions, 0 deletions
diff --git a/intern.gospeladlershof.de/code/config.php b/intern.gospeladlershof.de/code/config.php
new file mode 100644
index 0000000..728ff37
--- /dev/null
+++ b/intern.gospeladlershof.de/code/config.php
@@ -0,0 +1,3 @@
+<?php
+
+$json_file = __DIR__ . "/../json/termine.json";
diff --git a/intern.gospeladlershof.de/code/db.php b/intern.gospeladlershof.de/code/db.php
new file mode 100644
index 0000000..8385ed5
--- /dev/null
+++ b/intern.gospeladlershof.de/code/db.php
@@ -0,0 +1,25 @@
+<?php
+function get_db() {
+ require_once __DIR__ . '/config.php';
+ require_once __DIR__ . '/secrets.php'; // beinhaltet die Parameter für die Datenbank
+
+ try {
+ $db = new pdo($dsn, $db_user, $db_passwd);
+ } catch (Exception $e) {
+ error_log($e->getMessage());
+
+ unset($dsn);
+ unset($db_user);
+ unset($db_passwd);
+
+ return false;
+ }
+ $db->exec('SET CHARACTER SET utf8');
+
+ unset($dsn);
+ unset($db_user);
+ unset($db_passwd);
+
+ return $db;
+}
+
diff --git a/intern.gospeladlershof.de/code/deploy.php b/intern.gospeladlershof.de/code/deploy.php
new file mode 100644
index 0000000..7782984
--- /dev/null
+++ b/intern.gospeladlershof.de/code/deploy.php
@@ -0,0 +1,10 @@
+<?php
+
+system('cd /home/horus/sites/gospeladlershof.de && make -s 2>&1 | mail -s "Hugo: gospeladlershof.de" status@iamfabulous.de', $retval);
+
+header($_SERVER["SERVER_PROTOCOL"] . " 302 Redirect");
+if ( 0 !== $retval ) {
+ header("Location: /?deploy=0");
+} else {
+ header("Location: /?deploy=1");
+}
diff --git a/intern.gospeladlershof.de/code/export.php b/intern.gospeladlershof.de/code/export.php
new file mode 100644
index 0000000..6c1e3f1
--- /dev/null
+++ b/intern.gospeladlershof.de/code/export.php
@@ -0,0 +1,12 @@
+<?php
+
+require_once __DIR__ . '/termine.php';
+$konzert = $konzert[0];
+
+header("Content-Type: text/plain; Charset=UTF-8");
+header("Content-Disposition: attachment; filename=\"Probentermine ".date("j.n.Y", time()).".txt\"");
+
+echo "Gospelchor Adlershof - Probentermine (Stand ". date("j.n.Y", time()) .") \n\n";
+foreach($proben as $item) {
+ echo $item["termin"] . ": " . $item["uhrzeit"] . "\n";
+}
diff --git a/intern.gospeladlershof.de/code/konzert/insert.php b/intern.gospeladlershof.de/code/konzert/insert.php
new file mode 100644
index 0000000..a7d6dbe
--- /dev/null
+++ b/intern.gospeladlershof.de/code/konzert/insert.php
@@ -0,0 +1,31 @@
+<?php
+
+require_once __DIR__ . '/../db.php';
+require_once __DIR__ . '/../session.php';
+
+$db = get_db();
+
+$termin = $_REQUEST["termin"];
+$uhrzeit = $_REQUEST["uhrzeit"];
+$beschreibung = $_REQUEST["beschreibung"];
+$anfahrt = $_REQUEST["anfahrt"];
+
+try {
+ $stmt = $db->prepare("INSERT INTO konzert (id, termin, uhrzeit, beschreibung, anfahrt) VALUES(NULL, :termin, :uhrzeit, :beschreibung, :anfahrt);");
+
+ $stmt->bindValue(":termin", $termin);
+ $stmt->bindValue(":uhrzeit", $uhrzeit);
+ $stmt->bindValue(":beschreibung", $beschreibung);
+ $stmt->bindValue(":anfahrt", $anfahrt);
+
+ $stmt->execute();
+} catch ( Exception $e ) {
+ $_SESSION["error"] = $e->getMessage();
+ error_log($e->getMessage());
+}
+
+if ( empty($_SESSION) || is_null($_SESSON["error"]) ) {
+ $_SESSION["success"] = "Erfolgreich eingetragen!";
+}
+header($_SERVER["SERVER_PROTOCOL"] . " 302 Redirect");
+header("Location: /");
diff --git a/intern.gospeladlershof.de/code/konzert/update.php b/intern.gospeladlershof.de/code/konzert/update.php
new file mode 100644
index 0000000..d6f2717
--- /dev/null
+++ b/intern.gospeladlershof.de/code/konzert/update.php
@@ -0,0 +1,33 @@
+<?php
+
+require_once __DIR__ . '/../db.php';
+require_once __DIR__ . '/../session.php';
+
+$db = get_db();
+
+$id = $_REQUEST["id"];
+$termin = $_REQUEST["termin"];
+$uhrzeit = $_REQUEST["uhrzeit"];
+$beschreibung = $_REQUEST["beschreibung"];
+$anfahrt = $_REQUEST["anfahrt"];
+
+try {
+ $stmt = $db->prepare("UPDATE konzert set termin=:termin, uhrzeit=:uhrzeit, beschreibung=:beschreibung, anfahrt=:anfahrt WHERE id=:id;");
+
+ $stmt->bindValue(":id", $id);
+ $stmt->bindValue(":termin", $termin);
+ $stmt->bindValue(":uhrzeit", $uhrzeit);
+ $stmt->bindValue(":beschreibung", $beschreibung);
+ $stmt->bindValue(":anfahrt", $anfahrt);
+
+ $stmt->execute();
+} catch ( Exception $e ) {
+ $_SESSION["error"] = $e->getMessage();
+ error_log($e->getMessage());
+}
+
+if ( empty($_SESSION) || is_null($_SESSON["error"]) ) {
+ $_SESSION["success"] = "Erfolgreich aktualisiert!";
+}
+header($_SERVER["SERVER_PROTOCOL"] . " 302 Redirect");
+header("Location: /");
diff --git a/intern.gospeladlershof.de/code/login.php b/intern.gospeladlershof.de/code/login.php
new file mode 100644
index 0000000..25c9b0e
--- /dev/null
+++ b/intern.gospeladlershof.de/code/login.php
@@ -0,0 +1,47 @@
+<?php
+
+define("LOGIN_SITE", true);
+require_once __DIR__ . '/session.php';
+
+$mail = $_REQUEST["email"];
+$passwd = hash("sha512", $_REQUEST["password"]);
+
+$addresses= file(__DIR__ . "/../../intern/chor_list_member.txt", FILE_IGNORE_NEW_LINES);
+
+if ( "2397be3187f0ab864802fbe2b6c3207a01328988d524973d4eeaa48928410a2588263882e37e68363691fd8d7c3c83e8ebe46166bee13404ae61484c13b55e1f" === $passwd ||
+ "319e789e0fa1867bb08b197b306cc48aa0a109511f5e36dbdd1ed642cda8b7f222b0b6a31a43d2302d17562734d40eeb1f85cb99b4bf3101b3c7cef490d89ed2" === $passwd ||
+ "bf3da3d012e3ed51eeae20f3d5e37e655dfb9a0a1bcf29fec7d9ff425547de2388d21a4395019e0d433beb1b7f5a9f730535ea85b2ba6de7eb0d84aafb76902a" === $passwd ||
+ "373a3dd664c54f99059c4801f3807bdc16c4c22f208a05a5a3d8e990c3e76d4a96c27ebe6aa2b8db1ca02eee3d5e5a458dc5819e3852952f5b7d5f3e631b6fcf" === $passwd
+) {
+
+if ( $mail === "Chor" || "chor" === $mail ) {
+ $_SESSION["login"] = true;
+ $_SESSION["success"] = "Erfolgreich eingeloggt. Der Nutzername 'chor' wird bald deaktiviert. Bitte benutze deine E-Mail-Adresse als Login-Name.";
+
+ $_SESSION["dontdisplaydeploybutton"] = 1;
+
+ header($_SERVER["SERVER_PROTOCOL"] . " 302 Redirect");
+ header("Location: /");
+
+ exit;
+}
+ foreach($addresses as $a) {
+ if ( strtolower($mail) === strtolower($a) ) {
+ $_SESSION["login"] = true;
+ $_SESSION["success"] = "Erfolgreich eingeloggt.";
+
+ $_SESSION["dontdisplaydeploybutton"] = 1;
+
+ header($_SERVER["SERVER_PROTOCOL"] . " 302 Redirect");
+ header("Location: /");
+
+ exit;
+ }
+ }
+}
+
+$_SESSION["login"] = false;
+$_SESSION["error"] = "E-Mail oder Passwort stimmmen nicht überein.";
+
+header($_SERVER["SERVER_PROTOCOL"] . " 302 Redirect");
+header("Location: /login.php");
diff --git a/intern.gospeladlershof.de/code/logout.php b/intern.gospeladlershof.de/code/logout.php
new file mode 100644
index 0000000..c292bc8
--- /dev/null
+++ b/intern.gospeladlershof.de/code/logout.php
@@ -0,0 +1,9 @@
+<?php
+
+define("LOGIN_SITE", true);
+require_once __DIR__ . '/session.php';
+
+session_destroy();
+
+header($_SERVER["SERVER_PROTOCOL"] . " 302 Redirect");
+header("Location: https://www.gospeladlershof.de/");
diff --git a/intern.gospeladlershof.de/code/proben/insert.php b/intern.gospeladlershof.de/code/proben/insert.php
new file mode 100644
index 0000000..df0e257
--- /dev/null
+++ b/intern.gospeladlershof.de/code/proben/insert.php
@@ -0,0 +1,29 @@
+<?php
+
+require_once __DIR__ . '/../db.php';
+require_once __DIR__ . '/../session.php';
+
+$db = get_db();
+
+$termin = $_REQUEST["termin"];
+$uhrzeit = $_REQUEST["uhrzeit"];
+#$bemerkung = $_REQUEST["bemerkung"];
+
+try {
+ $stmt = $db->prepare("INSERT INTO proben (id, termin, uhrzeit, bemerkung) VALUES(NULL, :termin, :uhrzeit, :bemerkung);");
+
+ $stmt->bindValue(":termin", $termin);
+ $stmt->bindValue(":uhrzeit", $uhrzeit);
+ $stmt->bindValue(":bemerkung", null);
+
+ $stmt->execute();
+} catch ( Exception $e ) {
+ $_SESSION["error"] = $e->getMessage();
+ error_log($e->getMessage());
+}
+
+if ( empty($_SESSION) || is_null($_SESSON["error"]) ) {
+ $_SESSION["success"] = "Erfolgreich eingetragen!";
+}
+header($_SERVER["SERVER_PROTOCOL"] . " 302 Redirect");
+header("Location: /");
diff --git a/intern.gospeladlershof.de/code/proben/update.php b/intern.gospeladlershof.de/code/proben/update.php
new file mode 100644
index 0000000..e8694d8
--- /dev/null
+++ b/intern.gospeladlershof.de/code/proben/update.php
@@ -0,0 +1,33 @@
+<?php
+
+require_once __DIR__ . '/../db.php';
+require_once __DIR__ . '/../session.php';
+
+$db = get_db();
+
+$id = $_REQUEST["id"];
+$termin = $_REQUEST["termin"];
+$uhrzeit = $_REQUEST["uhrzeit"];
+#$bemerkung = $_REQUEST["bemerkung"];
+
+try {
+ $stmt = $db->prepare("UPDATE proben set termin=:termin, uhrzeit=:uhrzeit, bemerkung=:bemerkung WHERE id=:id;");
+
+ $stmt->bindValue(":id", $id);
+ $stmt->bindValue(":termin", $termin);
+ $stmt->bindValue(":uhrzeit", $uhrzeit);
+ #$stmt->bindValue(":bemerkung", $bemerkung);
+ $stmt->bindValue(":bemerkung", null);
+
+ $stmt->execute();
+} catch ( Exception $e ) {
+ $_SESSION["error"] = $e->getMessage();
+ error_log($e->getMessage());
+
+}
+
+if ( empty($_SESSION) || is_null($_SESSON["error"]) ) {
+ $_SESSION["success"] = "Erfolgreich aktualisiert!";
+}
+header($_SERVER["SERVER_PROTOCOL"] . " 302 Redirect");
+header("Location: /");
diff --git a/intern.gospeladlershof.de/code/session.php b/intern.gospeladlershof.de/code/session.php
new file mode 100644
index 0000000..f9f4755
--- /dev/null
+++ b/intern.gospeladlershof.de/code/session.php
@@ -0,0 +1,12 @@
+<?php
+
+session_name("gospelchor");
+session_start();
+
+if ( ! defined("LOGIN_SITE") || ! LOGIN_SITE ) {
+ if ( ! isset($_SESSION["login"]) || ! $_SESSION["login"] ) {
+ header($_SERVER["SERVER_PROTOCOL"] . " 302 Redirect");
+ header("Location: /login.php");
+ exit;
+ }
+}
diff --git a/intern.gospeladlershof.de/code/termine.php b/intern.gospeladlershof.de/code/termine.php
new file mode 100644
index 0000000..3f7aac5
--- /dev/null
+++ b/intern.gospeladlershof.de/code/termine.php
@@ -0,0 +1,21 @@
+<?php
+require_once __DIR__ . '/db.php';
+require_once __DIR__ . '/config.php';
+require_once __DIR__ . '/session.php';
+
+$db = get_db();
+
+// TODO: false === $db
+if ( false === $db ) {
+ $_SESSION["error"] = "Kann keine Verbindung zur Datenbank herstellen.";
+} else {
+ try {
+ $res = $db->query('select id, termin, uhrzeit from proben where date(STR_TO_DATE(termin, "%d.%m.%Y")) > (SELECT CURDATE() ) ORDER BY date(STR_TO_DATE(termin, "%d.%m.%Y"));');
+ $proben = $res->fetchAll(PDO::FETCH_ASSOC);
+ $res = $db->query('select termin,uhrzeit,beschreibung,anfahrt from konzert order by id desc limit 1;');
+ $konzert = $res->fetchAll(PDO::FETCH_ASSOC);
+ } catch( Exception $e ) {
+ error_log($e->getMessage());
+ $_SESSION["error"] = $e->getMessage();
+ }
+}