...
11
.gitignore
vendored
|
|
@ -1,8 +1,3 @@
|
|||
/vendor/
|
||||
/node_modules/
|
||||
/.env
|
||||
/storage/img_storage/*
|
||||
!/storage/img_storage/.gitkeep
|
||||
/storage/*.log
|
||||
/public/mix-manifest.json
|
||||
.DS_Store
|
||||
__pycache__/
|
||||
*.pyc
|
||||
*.sql
|
||||
|
|
|
|||
10
motorradig/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
/vendor/
|
||||
/node_modules/
|
||||
/.env
|
||||
/*.sql
|
||||
/storage/img_storage/*
|
||||
!/storage/img_storage/.gitkeep
|
||||
/storage/*.log
|
||||
/public/mix-manifest.json
|
||||
.DS_Store
|
||||
.credentials
|
||||
|
|
@ -47,6 +47,39 @@ $out = function (string $msg): void {
|
|||
|
||||
echo "Starte Datenbank-Bereinigung...\n";
|
||||
|
||||
// Tabelle für den Online-Mitgliedsantrag anlegen (idempotent)
|
||||
if (!tableExists($pdo, 'membership_applications')) {
|
||||
$pdo->exec('CREATE TABLE `membership_applications` (
|
||||
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`user_id` bigint(20) unsigned NULL DEFAULT NULL,
|
||||
`nachname` varchar(255) NOT NULL,
|
||||
`vorname` varchar(255) NOT NULL,
|
||||
`strasse` varchar(255) DEFAULT NULL,
|
||||
`plz_ort` varchar(255) DEFAULT NULL,
|
||||
`telefon` varchar(255) DEFAULT NULL,
|
||||
`email` varchar(255) DEFAULT NULL,
|
||||
`geburtsdatum` date DEFAULT NULL,
|
||||
`motorrad` varchar(255) DEFAULT NULL,
|
||||
`aufnahme_ab` date DEFAULT NULL,
|
||||
`ort_datum_1` varchar(255) DEFAULT NULL,
|
||||
`unterschrift_1` varchar(255) DEFAULT NULL,
|
||||
`mandatsreferenz` varchar(255) DEFAULT NULL,
|
||||
`glaeubiger_id` varchar(255) DEFAULT NULL,
|
||||
`kontoinhaber` varchar(255) DEFAULT NULL,
|
||||
`kreditinstitut` varchar(255) DEFAULT NULL,
|
||||
`bic` varchar(255) DEFAULT NULL,
|
||||
`iban` varchar(255) DEFAULT NULL,
|
||||
`ort_datum_2` varchar(255) DEFAULT NULL,
|
||||
`unterschrift_2` varchar(255) DEFAULT NULL,
|
||||
`created_at` timestamp NULL DEFAULT NULL,
|
||||
`updated_at` timestamp NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;');
|
||||
$out("Tabelle 'membership_applications' angelegt");
|
||||
} else {
|
||||
$out("Tabelle 'membership_applications' existiert bereits (übersprungen)");
|
||||
}
|
||||
|
||||
// Unbenutzte Tabellen entfernen
|
||||
foreach (['migrations', 'failed_jobs', 'galleries', 'gallery_items', 'password_resets'] as $table) {
|
||||
if (tableExists($pdo, $table)) {
|
||||
|
|
@ -23,6 +23,21 @@ body, html {
|
|||
|
||||
.color-link { color:black; }
|
||||
|
||||
/* Mitgliederliste: kompakt und mobiltauglich */
|
||||
.member-list .list-group-item {
|
||||
font-size: 0.95rem;
|
||||
}
|
||||
.member-list .badge {
|
||||
flex-shrink: 0;
|
||||
white-space: nowrap;
|
||||
margin-left: 0.5rem;
|
||||
}
|
||||
@media (max-width: 575.98px) {
|
||||
.member-list .list-group-item {
|
||||
font-size: 0.85rem;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* a:visited { color:cyan !important; }
|
||||
*/
|
||||
|
Before Width: | Height: | Size: 730 KiB After Width: | Height: | Size: 730 KiB |
|
Before Width: | Height: | Size: 141 KiB After Width: | Height: | Size: 141 KiB |
|
Before Width: | Height: | Size: 898 KiB After Width: | Height: | Size: 898 KiB |
|
Before Width: | Height: | Size: 74 KiB After Width: | Height: | Size: 74 KiB |
|
Before Width: | Height: | Size: 280 B After Width: | Height: | Size: 280 B |
|
Before Width: | Height: | Size: 8.3 KiB After Width: | Height: | Size: 8.3 KiB |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 39 KiB |
|
Before Width: | Height: | Size: 88 KiB After Width: | Height: | Size: 88 KiB |
|
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 36 KiB |
|
Before Width: | Height: | Size: 646 KiB After Width: | Height: | Size: 646 KiB |
|
Before Width: | Height: | Size: 118 KiB After Width: | Height: | Size: 118 KiB |
|
Before Width: | Height: | Size: 169 KiB After Width: | Height: | Size: 169 KiB |
|
Before Width: | Height: | Size: 69 KiB After Width: | Height: | Size: 69 KiB |
|
Before Width: | Height: | Size: 848 KiB After Width: | Height: | Size: 848 KiB |
|
Before Width: | Height: | Size: 69 KiB After Width: | Height: | Size: 69 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 9.7 KiB After Width: | Height: | Size: 9.7 KiB |
|
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 4.4 KiB |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 128 KiB After Width: | Height: | Size: 128 KiB |
|
Before Width: | Height: | Size: 205 KiB After Width: | Height: | Size: 205 KiB |
|
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 4.4 KiB |
|
Before Width: | Height: | Size: 205 KiB After Width: | Height: | Size: 205 KiB |
|
|
@ -95,6 +95,7 @@ class AdminController
|
|||
public function deleteGuests(): void
|
||||
{
|
||||
if (Auth::user()->isAdmin()) {
|
||||
db()->execute("DELETE FROM `bookings` WHERE user_id IN (SELECT id FROM `users` WHERE role = 'GUEST')");
|
||||
db()->execute("DELETE FROM `users` WHERE role = 'GUEST'");
|
||||
}
|
||||
|
||||
142
motorradig/src/Controllers/HomeController.php
Normal file
|
|
@ -0,0 +1,142 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
use App\Core\Auth;
|
||||
use App\Models\MembershipApplication;
|
||||
use App\Models\Page;
|
||||
|
||||
class HomeController
|
||||
{
|
||||
public function pageHome(): void
|
||||
{
|
||||
$page = Page::byName('home');
|
||||
$content = $page->content ?? '';
|
||||
|
||||
// Führende/abschließende Anführungszeichen entfernen (wie im Original)
|
||||
$content = rtrim(ltrim($content, '"'), '"');
|
||||
|
||||
view('home', ['content' => $content]);
|
||||
}
|
||||
|
||||
public function pageActivities(): void
|
||||
{
|
||||
$page = Page::byName('activities');
|
||||
|
||||
view('activities', ['content' => $page->content ?? '']);
|
||||
}
|
||||
|
||||
public function becomeMember(): void
|
||||
{
|
||||
view('become_member');
|
||||
}
|
||||
|
||||
public function meetings(): void
|
||||
{
|
||||
view('meetings');
|
||||
}
|
||||
|
||||
public function mitgliedsantrag(): void
|
||||
{
|
||||
view('mitgliedsantrag');
|
||||
}
|
||||
|
||||
public function storeMitgliedsantrag(): void
|
||||
{
|
||||
validate([
|
||||
'nachname' => 'required',
|
||||
'vorname' => 'required',
|
||||
'strasse' => 'required',
|
||||
'plz_ort' => 'required',
|
||||
'geburtsdatum' => 'required',
|
||||
'aufnahme_ab' => 'required',
|
||||
'kontoinhaber' => 'required',
|
||||
'iban' => 'required',
|
||||
]);
|
||||
|
||||
$user = Auth::user();
|
||||
|
||||
$nachname = (string) input('nachname');
|
||||
$vorname = (string) input('vorname');
|
||||
$strasse = (string) input('strasse');
|
||||
$plzOrt = (string) input('plz_ort');
|
||||
$telefon = (string) input('telefon');
|
||||
$email = (string) input('email');
|
||||
$geburtsdatum = (string) input('geburtsdatum');
|
||||
$motorrad = (string) input('motorrad');
|
||||
$aufnahmeAb = (string) input('aufnahme_ab');
|
||||
$ortDatum1 = (string) input('ort_datum_1');
|
||||
$unterschrift1 = (string) input('unterschrift_1');
|
||||
$mandatsref = (string) input('mandatsreferenz');
|
||||
$glaeubigerId = (string) input('glaeubiger_id');
|
||||
$kontoinhaber = (string) input('kontoinhaber');
|
||||
$kreditinstitut = (string) input('kreditinstitut');
|
||||
$bic = (string) input('bic');
|
||||
$iban = (string) input('iban');
|
||||
$ortDatum2 = (string) input('ort_datum_2');
|
||||
$unterschrift2 = (string) input('unterschrift_2');
|
||||
|
||||
MembershipApplication::create([
|
||||
'user_id' => $user?->id,
|
||||
'nachname' => $nachname,
|
||||
'vorname' => $vorname,
|
||||
'strasse' => $strasse,
|
||||
'plz_ort' => $plzOrt,
|
||||
'telefon' => $telefon,
|
||||
'email' => $email,
|
||||
'geburtsdatum' => $geburtsdatum,
|
||||
'motorrad' => $motorrad,
|
||||
'aufnahme_ab' => $aufnahmeAb,
|
||||
'ort_datum_1' => $ortDatum1,
|
||||
'unterschrift_1' => $unterschrift1,
|
||||
'mandatsreferenz' => $mandatsref,
|
||||
'glaeubiger_id' => $glaeubigerId,
|
||||
'kontoinhaber' => $kontoinhaber,
|
||||
'kreditinstitut' => $kreditinstitut,
|
||||
'bic' => $bic,
|
||||
'iban' => $iban,
|
||||
'ort_datum_2' => $ortDatum2,
|
||||
'unterschrift_2' => $unterschrift2,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
|
||||
$body = "Neuer Mitgliedsantrag über die Website\n"
|
||||
. "========================================\n\n"
|
||||
. "Persönliche Angaben\n"
|
||||
. " Nachname: " . $nachname . "\n"
|
||||
. " Vorname: " . $vorname . "\n"
|
||||
. " Straße, Nr.: " . $strasse . "\n"
|
||||
. " PLZ, Ort: " . $plzOrt . "\n"
|
||||
. " Telefon: " . $telefon . "\n"
|
||||
. " E-Mail: " . $email . "\n"
|
||||
. " Geburtsdatum: " . $geburtsdatum . "\n"
|
||||
. " Motorrad: " . $motorrad . "\n"
|
||||
. " Aufnahme ab: " . $aufnahmeAb . "\n"
|
||||
. " Ort / Datum: " . $ortDatum1 . "\n"
|
||||
. " Unterschrift: " . $unterschrift1 . "\n\n"
|
||||
. "SEPA-Lastschriftmandat\n"
|
||||
. " Mandatsreferenz: " . $mandatsref . "\n"
|
||||
. " Gläubiger-ID: " . $glaeubigerId . "\n"
|
||||
. " Kontoinhaber: " . $kontoinhaber . "\n"
|
||||
. " Kreditinstitut: " . $kreditinstitut . "\n"
|
||||
. " BIC: " . $bic . "\n"
|
||||
. " IBAN: " . $iban . "\n"
|
||||
. " Ort / Datum: " . $ortDatum2 . "\n"
|
||||
. " Unterschrift: " . $unterschrift2 . "\n";
|
||||
|
||||
send_mail(
|
||||
(string) config('app.membership_notify_email'),
|
||||
'Neuer Mitgliedsantrag: ' . $vorname . ' ' . $nachname,
|
||||
$body,
|
||||
'Motorrad-IG <motorradig@aol.com>',
|
||||
$email
|
||||
);
|
||||
|
||||
$_SESSION['_flash']['status'] = 'Vielen Dank! Dein Mitgliedsantrag wurde gespeichert.';
|
||||
|
||||
redirect('/mitgliedsantrag');
|
||||
}
|
||||
}
|
||||
|
|
@ -95,6 +95,7 @@ class TourController
|
|||
}
|
||||
|
||||
$creator = User::find((int) $tour->user_id);
|
||||
$canManage = $this->canManageBookings($tour);
|
||||
|
||||
$users = [];
|
||||
foreach (Booking::forTour((int) $tour->id) as $booking) {
|
||||
|
|
@ -110,9 +111,10 @@ class TourController
|
|||
$tour->deadline = german_date($tour->deadline);
|
||||
|
||||
view('tour.show_old', [
|
||||
'tour' => $tour,
|
||||
'users' => $users,
|
||||
'creator' => $creator,
|
||||
'tour' => $tour,
|
||||
'users' => $users,
|
||||
'creator' => $creator,
|
||||
'canManage' => $canManage,
|
||||
]);
|
||||
|
||||
return;
|
||||
|
|
@ -124,10 +126,11 @@ class TourController
|
|||
$tour->deadline = german_date($tour->deadline);
|
||||
|
||||
view('tour.show', [
|
||||
'tour' => $tour,
|
||||
'users' => $users,
|
||||
'creator' => $creator,
|
||||
'rooms' => $rooms,
|
||||
'tour' => $tour,
|
||||
'users' => $users,
|
||||
'creator' => $creator,
|
||||
'rooms' => $rooms,
|
||||
'canManage' => $canManage,
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
@ -171,6 +174,10 @@ class TourController
|
|||
redirect('/tour');
|
||||
}
|
||||
|
||||
if (!Auth::user()->isAdmin()) {
|
||||
redirect('/tour');
|
||||
}
|
||||
|
||||
validate([
|
||||
'tour_id' => 'required',
|
||||
'name' => 'required|min:3',
|
||||
|
|
@ -226,31 +233,34 @@ class TourController
|
|||
redirect('/tour/' . $tour_id);
|
||||
}
|
||||
|
||||
public function joinRoom4user(string $tour_id, string $room_id, string $user_id): void
|
||||
public function joinRoom4user(string $tour_id, string $room_id): void
|
||||
{
|
||||
Booking::joinRoom((int) $tour_id, (int) $user_id, (int) $room_id);
|
||||
$userId = (int) input('user_id', 0);
|
||||
|
||||
$tour = Tour::find((int) $tour_id);
|
||||
$rooms = array_map(fn(array $row) => (object) $row, TourRoom::fetchRooms((int) $tour_id));
|
||||
if ($userId > 0) {
|
||||
Booking::joinRoom((int) $tour_id, $userId, (int) $room_id);
|
||||
}
|
||||
|
||||
$tour->start = german_date($tour->start);
|
||||
$tour->deadline = german_date($tour->deadline);
|
||||
|
||||
view('tour.edit', ['tour' => $tour, 'rooms' => $rooms]);
|
||||
redirect('/tour/' . $tour_id . '/edit');
|
||||
}
|
||||
|
||||
public function cancelBooking(string $tour_id): void
|
||||
{
|
||||
if (!$this->canManageBookings(Tour::find((int) $tour_id))) {
|
||||
redirect('/tour');
|
||||
}
|
||||
|
||||
Booking::deleteForUser((int) $tour_id, (int) Auth::id());
|
||||
redirect('/tour');
|
||||
}
|
||||
|
||||
public function cancelBookingAdmin(string $tour_id, string $user_id): void
|
||||
{
|
||||
if (Auth::user()->isAdmin()) {
|
||||
Booking::deleteForUser((int) $tour_id, (int) $user_id);
|
||||
if (!$this->canManageBookings(Tour::find((int) $tour_id))) {
|
||||
redirect('/tour/' . $tour_id);
|
||||
}
|
||||
|
||||
Booking::deleteForUser((int) $tour_id, (int) $user_id);
|
||||
redirect('/tour/' . $tour_id);
|
||||
}
|
||||
|
||||
|
|
@ -267,4 +277,13 @@ class TourController
|
|||
|
||||
redirect('/tour/' . $tour_id . '/edit');
|
||||
}
|
||||
|
||||
private function canManageBookings(?Tour $tour): bool
|
||||
{
|
||||
$user = Auth::user();
|
||||
|
||||
return $user !== null
|
||||
&& $tour !== null
|
||||
&& ($user->isAdmin() || (int) $user->id === (int) $tour->user_id);
|
||||
}
|
||||
}
|
||||
|
|
@ -12,7 +12,38 @@ class UserController
|
|||
{
|
||||
public function index(): void
|
||||
{
|
||||
view('users.index', ['users' => User::all()]);
|
||||
$users = User::all();
|
||||
|
||||
// Nach Nachname sortieren (bei Gleichstand nach vollem Namen).
|
||||
usort($users, function (User $a, User $b): int {
|
||||
$cmp = strnatcasecmp(last_name($a->name), last_name($b->name));
|
||||
|
||||
return $cmp !== 0 ? $cmp : strnatcasecmp($a->name, $b->name);
|
||||
});
|
||||
|
||||
$perPage = 20;
|
||||
$total = count($users);
|
||||
$lastPage = max(1, (int) ceil($total / $perPage));
|
||||
$page = max(1, (int) input('page', 1));
|
||||
|
||||
// Paginator nur für Desktop-Browser und wenn es mehr als eine Seite gibt.
|
||||
$paginate = is_desktop() && $total > $perPage;
|
||||
|
||||
if ($paginate) {
|
||||
$page = min($page, $lastPage);
|
||||
$users = array_slice($users, ($page - 1) * $perPage, $perPage);
|
||||
}
|
||||
|
||||
view('users.index', [
|
||||
'users' => $users,
|
||||
'paginator' => [
|
||||
'enabled' => $paginate,
|
||||
'page' => $page,
|
||||
'lastPage' => $lastPage,
|
||||
'total' => $total,
|
||||
'perPage' => $perPage,
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
public function create(): void
|
||||
|
|
@ -64,6 +95,10 @@ class UserController
|
|||
|
||||
$current = Auth::user();
|
||||
|
||||
if (!$current->isAdmin() && (int) $current->id !== (int) $userId) {
|
||||
redirect('/member');
|
||||
}
|
||||
|
||||
validate([
|
||||
'name' => 'required|min:3',
|
||||
'email' => 'required|email',
|
||||
|
|
@ -80,4 +80,16 @@ class Auth
|
|||
redirect('/login');
|
||||
}
|
||||
}
|
||||
|
||||
/** Erfordert Login und eine bestimmte Rolle (z. B. 'ADMIN'). */
|
||||
public static function requireRole(string $role): void
|
||||
{
|
||||
self::requireLogin();
|
||||
|
||||
$user = self::user();
|
||||
|
||||
if ($user === null || $user->role !== $role) {
|
||||
redirect('/');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -14,27 +14,27 @@ class Router
|
|||
{
|
||||
private array $routes = [];
|
||||
|
||||
public function get(string $path, array $handler, bool $auth = false): void
|
||||
public function get(string $path, array $handler, bool|string $auth = false): void
|
||||
{
|
||||
$this->add('GET', $path, $handler, $auth);
|
||||
}
|
||||
|
||||
public function post(string $path, array $handler, bool $auth = false): void
|
||||
public function post(string $path, array $handler, bool|string $auth = false): void
|
||||
{
|
||||
$this->add('POST', $path, $handler, $auth);
|
||||
}
|
||||
|
||||
public function put(string $path, array $handler, bool $auth = false): void
|
||||
public function put(string $path, array $handler, bool|string $auth = false): void
|
||||
{
|
||||
$this->add('PUT', $path, $handler, $auth);
|
||||
}
|
||||
|
||||
public function delete(string $path, array $handler, bool $auth = false): void
|
||||
public function delete(string $path, array $handler, bool|string $auth = false): void
|
||||
{
|
||||
$this->add('DELETE', $path, $handler, $auth);
|
||||
}
|
||||
|
||||
private function add(string $method, string $path, array $handler, bool $auth): void
|
||||
private function add(string $method, string $path, array $handler, bool|string $auth): void
|
||||
{
|
||||
$this->routes[] = [
|
||||
'method' => $method,
|
||||
|
|
@ -77,8 +77,10 @@ class Router
|
|||
array_shift($matches); // volles Match entfernen
|
||||
$params = array_map('rawurldecode', $matches);
|
||||
|
||||
if ($route['auth']) {
|
||||
if ($route['auth'] === true) {
|
||||
Auth::requireLogin();
|
||||
} elseif (is_string($route['auth'])) {
|
||||
Auth::requireRole($route['auth']);
|
||||
}
|
||||
|
||||
[$class, $action] = $route['handler'];
|
||||
12
motorradig/src/Models/MembershipApplication.php
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Core\Model;
|
||||
|
||||
class MembershipApplication extends Model
|
||||
{
|
||||
protected static string $table = 'membership_applications';
|
||||
}
|
||||
|
|
@ -18,6 +18,9 @@ return [
|
|||
'env' => getenv('APP_ENV') ?: 'production',
|
||||
'debug' => (getenv('APP_DEBUG') ?: 'false') === 'true',
|
||||
'url' => getenv('APP_URL') ?: 'http://localhost',
|
||||
|
||||
// Empfänger der E-Mail-Benachrichtigung bei neuen Mitgliedsanträgen.
|
||||
'membership_notify_email' => getenv('MEMBERSHIP_NOTIFY_EMAIL') ?: 'dirk@fischergruppe.de',
|
||||
],
|
||||
|
||||
'db' => [
|
||||
|
|
@ -82,6 +82,22 @@ function input(string $key, $default = null)
|
|||
return $_POST[$key] ?? $_GET[$key] ?? $default;
|
||||
}
|
||||
|
||||
/** Prüft, ob für ein Feld mindestens eine Datei hochgeladen wurde. */
|
||||
function has_upload(string $field): bool
|
||||
{
|
||||
if (empty($_FILES[$field])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ((array) ($_FILES[$field]['name'] ?? []) as $name) {
|
||||
if (is_string($name) && $name !== '') {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Alter Eingabewert nach fehlgeschlagener Validierung (für Formulare). */
|
||||
function old(string $key, $default = null)
|
||||
{
|
||||
|
|
@ -180,6 +196,29 @@ function today(): string
|
|||
return date('Y-m-d');
|
||||
}
|
||||
|
||||
/**
|
||||
* Versendet eine Text-E-Mail über die PHP-Mailfunktion (sendmail/SMTP des Servers).
|
||||
* Liefert true bei Erfolg. Schlägt der Versand fehl, bleibt die Rückgabe false,
|
||||
* ohne die laufende Anfrage zu unterbrechen.
|
||||
*/
|
||||
function send_mail(string $to, string $subject, string $body, string $from = '', string $replyTo = ''): bool
|
||||
{
|
||||
$headers = [];
|
||||
if ($from !== '') {
|
||||
$headers[] = 'From: ' . $from;
|
||||
}
|
||||
if ($replyTo !== '') {
|
||||
$headers[] = 'Reply-To: ' . $replyTo;
|
||||
}
|
||||
$headers[] = 'MIME-Version: 1.0';
|
||||
$headers[] = 'Content-Type: text/plain; charset=UTF-8';
|
||||
|
||||
// Betreff als RFC 2047 (UTF-8/Base64) kodieren, damit Umlaute korrekt ankommen.
|
||||
$subject = '=?UTF-8?B?' . base64_encode($subject) . '?=';
|
||||
|
||||
return @mail($to, $subject, $body, implode("\r\n", $headers));
|
||||
}
|
||||
|
||||
/** Asset-Pfad unter /. */
|
||||
function asset(string $path): string
|
||||
{
|
||||
|
|
@ -192,6 +231,36 @@ function current_path(): string
|
|||
return parse_url($_SERVER['REQUEST_URI'] ?? '/', PHP_URL_PATH) ?: '/';
|
||||
}
|
||||
|
||||
/** true, wenn es sich um einen Desktop-Browser handelt (kein Touch-/Mobile-User-Agent). */
|
||||
function is_desktop(): bool
|
||||
{
|
||||
$ua = $_SERVER['HTTP_USER_AGENT'] ?? '';
|
||||
|
||||
$mobile = ['Mobi', 'Android', 'iPhone', 'iPad', 'iPod', 'Windows Phone', 'IEMobile', 'BlackBerry', 'Opera Mini', 'Silk'];
|
||||
|
||||
foreach ($mobile as $token) {
|
||||
if (stripos($ua, $token) !== false) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Liefert den Nachnamen (letztes Wort) eines vollständigen Namens. */
|
||||
function last_name(string $fullName): string
|
||||
{
|
||||
$name = trim($fullName);
|
||||
|
||||
if ($name === '') {
|
||||
return '';
|
||||
}
|
||||
|
||||
$parts = preg_split('/\s+/', $name);
|
||||
|
||||
return (string) end($parts);
|
||||
}
|
||||
|
||||
/** Absoluter Pfad in storage/. */
|
||||
function storage_path(string $rel = ''): string
|
||||
{
|
||||
|
|
@ -240,9 +309,10 @@ function validate(array $rules): array
|
|||
|
||||
foreach ($rules as $field => $ruleString) {
|
||||
$value = $_POST[$field] ?? null;
|
||||
$hasFile = has_upload($field);
|
||||
|
||||
foreach (explode('|', $ruleString) as $rule) {
|
||||
if ($rule === 'required' && ($value === null || trim((string) $value) === '')) {
|
||||
if ($rule === 'required' && !$hasFile && ($value === null || trim((string) $value) === '')) {
|
||||
$errors[$field][] = 'Das Feld ' . $field . ' ist erforderlich.';
|
||||
}
|
||||
|
||||
|
|
@ -18,6 +18,8 @@ $router->get('/', [HomeController::class, 'pageHome']);
|
|||
$router->get('/home', [HomeController::class, 'pageHome']);
|
||||
$router->get('/activities', [HomeController::class, 'pageActivities']);
|
||||
$router->get('/become_member', [HomeController::class, 'becomeMember']);
|
||||
$router->get('/mitgliedsantrag', [HomeController::class, 'mitgliedsantrag']);
|
||||
$router->post('/mitgliedsantrag', [HomeController::class, 'storeMitgliedsantrag']);
|
||||
$router->get('/meetings', [HomeController::class, 'meetings'], true);
|
||||
|
||||
// Mitglieder
|
||||
|
|
@ -28,18 +30,18 @@ $router->get('/member/{id}', [UserController::class, 'show'], true);
|
|||
$router->get('/member/{id}/edit', [UserController::class, 'edit'], true);
|
||||
$router->put('/member/{id}', [UserController::class, 'update'], true);
|
||||
$router->delete('/member/{id}', [UserController::class, 'destroy'], true);
|
||||
$router->get('/admin/destroy_user/{user_id}', [UserController::class, 'destroy'], true);
|
||||
$router->post('/admin/destroy_user/{user_id}', [UserController::class, 'destroy'], 'ADMIN');
|
||||
|
||||
// Admin
|
||||
$router->get('/admin/upload_tourplan', [AdminController::class, 'uploadTourplan'], true);
|
||||
$router->post('/admin/store_tourplan', [AdminController::class, 'storeTourplan'], true);
|
||||
$router->get('/admin/upload_mitgliedsantrag', [AdminController::class, 'uploadMitgliedsantrag'], true);
|
||||
$router->post('/admin/store_mitgliedsantrag', [AdminController::class, 'storeMitgliedsantrag'], true);
|
||||
$router->get('/admin/edit_home', [AdminController::class, 'editHome'], true);
|
||||
$router->get('/admin/edit_activities', [AdminController::class, 'editActivities'], true);
|
||||
$router->post('/admin/store_home', [AdminController::class, 'storeHome'], true);
|
||||
$router->post('/admin/store_activities', [AdminController::class, 'storeActivities'], true);
|
||||
$router->get('/delete_guests', [AdminController::class, 'deleteGuests'], true);
|
||||
$router->get('/admin/upload_tourplan', [AdminController::class, 'uploadTourplan'], 'ADMIN');
|
||||
$router->post('/admin/store_tourplan', [AdminController::class, 'storeTourplan'], 'ADMIN');
|
||||
$router->get('/admin/upload_mitgliedsantrag', [AdminController::class, 'uploadMitgliedsantrag'], 'ADMIN');
|
||||
$router->post('/admin/store_mitgliedsantrag', [AdminController::class, 'storeMitgliedsantrag'], 'ADMIN');
|
||||
$router->get('/admin/edit_home', [AdminController::class, 'editHome'], 'ADMIN');
|
||||
$router->get('/admin/edit_activities', [AdminController::class, 'editActivities'], 'ADMIN');
|
||||
$router->post('/admin/store_home', [AdminController::class, 'storeHome'], 'ADMIN');
|
||||
$router->post('/admin/store_activities', [AdminController::class, 'storeActivities'], 'ADMIN');
|
||||
$router->post('/delete_guests', [AdminController::class, 'deleteGuests'], 'ADMIN');
|
||||
|
||||
// Touren
|
||||
$router->get('/tour/index_old', [TourController::class, 'indexOld'], true);
|
||||
|
|
@ -54,13 +56,12 @@ $router->put('/tour/{id}', [TourController::class, 'update'], true);
|
|||
$router->delete('/tour/{id}', [TourController::class, 'destroy'], true);
|
||||
$router->post('/tour/upload_gallery/{tour_id}', [TourController::class, 'uploadGallery']);
|
||||
|
||||
$router->get('/tour/{tour_id}/join/{room_id}', [TourController::class, 'joinRoom'], true);
|
||||
$router->get('/tour/{tour_id}/join4user/{room_id}/{user_id}', [TourController::class, 'joinRoom4user'], true);
|
||||
$router->get('/tour/{tour_id}/cancelBooking', [TourController::class, 'cancelBooking'], true);
|
||||
$router->get('/tour/{tour_id}/cancelBookingAdmin/{user_id}', [TourController::class, 'cancelBookingAdmin'], true);
|
||||
$router->get('/tour/{tour_id}/create_room/{capacity}', [TourController::class, 'createRoom'], true);
|
||||
$router->get('/tour/{tour_id}/delete_room/{room_id}', [TourController::class, 'deleteRoom'], true);
|
||||
$router->get('/tour/{tour_id}/assign_room_for_user/{user_id}', [TourController::class, 'deleteRoom'], true);
|
||||
$router->post('/tour/{tour_id}/join/{room_id}', [TourController::class, 'joinRoom'], true);
|
||||
$router->post('/tour/{tour_id}/join4user/{room_id}', [TourController::class, 'joinRoom4user'], 'ADMIN');
|
||||
$router->post('/tour/{tour_id}/cancelBooking', [TourController::class, 'cancelBooking'], true);
|
||||
$router->post('/tour/{tour_id}/cancelBookingAdmin/{user_id}', [TourController::class, 'cancelBookingAdmin'], true);
|
||||
$router->post('/tour/{tour_id}/create_room/{capacity}', [TourController::class, 'createRoom'], 'ADMIN');
|
||||
$router->post('/tour/{tour_id}/delete_room/{room_id}', [TourController::class, 'deleteRoom'], 'ADMIN');
|
||||
|
||||
// Bilder (Zugriff wird im Controller geprüft)
|
||||
$router->get('/img_storage/{category}/{imageName}', [ImageController::class, 'getImage']);
|
||||
|
|
@ -68,10 +69,10 @@ $router->get('/img_storage/{category}/{imageName}', [ImageController::class, 'ge
|
|||
// Galerie
|
||||
$router->get('/tour/gallery/{gallery_id}', [GalleryController::class, 'show']);
|
||||
$router->post('/tour/gallery/{gallery_id}', [GalleryController::class, 'store'], true);
|
||||
$router->get('/tour/gallery/{gallery_id}/delete_image/{imageName}', [GalleryController::class, 'deleteImage'], true);
|
||||
$router->post('/tour/gallery/{gallery_id}/delete_image/{imageName}', [GalleryController::class, 'deleteImage'], 'ADMIN');
|
||||
$router->put('/tour/gallery/{gallery_id}/name_image/{imageName}', [GalleryController::class, 'nameImage'], true);
|
||||
$router->get('/tour/gallery/{gallery_id}/show_deleted', [GalleryController::class, 'showDeletedImages'], true);
|
||||
$router->get('/tour/gallery/{gallery_id}/restore_image/{imageName}', [GalleryController::class, 'restoreImage'], true);
|
||||
$router->get('/tour/gallery/{gallery_id}/show_deleted', [GalleryController::class, 'showDeletedImages'], 'ADMIN');
|
||||
$router->post('/tour/gallery/{gallery_id}/restore_image/{imageName}', [GalleryController::class, 'restoreImage'], 'ADMIN');
|
||||
|
||||
// Authentifizierung
|
||||
$router->get('/login', [AuthController::class, 'showLoginForm']);
|
||||
|
|
@ -49,6 +49,9 @@
|
|||
<li class="nav-item" style="font-size:1.5rem">
|
||||
<a class="nav-link <?= $active('/become_member') ?>" href="/become_member">Mitglied werden</a>
|
||||
</li>
|
||||
<li class="nav-item" style="font-size:1.5rem">
|
||||
<a class="nav-link <?= $active('/mitgliedsantrag') ?>" href="/mitgliedsantrag">Mitgliedsantrag(Test)</a>
|
||||
</li>
|
||||
|
||||
<?php if ($user && $user->role !== 'GUEST'): ?>
|
||||
<li class="nav-item" style="font-size:1.5rem">
|
||||
|
|
@ -84,13 +87,15 @@
|
|||
</a>
|
||||
|
||||
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown">
|
||||
<a class="dropdown-item" href="/admin/edit_home">Seite: Startseite bearbeiten</a>
|
||||
<a class="dropdown-item" href="/admin/edit_activities">Seite: Aktivitäten bearbeiten</a>
|
||||
<a class="dropdown-item" href="/admin/upload_tourplan">Tourenplan(pdf) hochladen</a>
|
||||
<a class="dropdown-item" href="/admin/upload_mitgliedsantrag">Mitgliedsantrag(pdf) hochladen</a>
|
||||
|
||||
<?php if ($user->role !== 'GUEST'): ?>
|
||||
<a class="dropdown-item" href="/delete_guests">Gast Mitglieder löschen</a>
|
||||
<?php if ($user->role === 'ADMIN'): ?>
|
||||
<a class="dropdown-item" href="/admin/edit_home">Seite: Startseite bearbeiten</a>
|
||||
<a class="dropdown-item" href="/admin/edit_activities">Seite: Aktivitäten bearbeiten</a>
|
||||
<a class="dropdown-item" href="/admin/upload_tourplan">Tourenplan(pdf) hochladen</a>
|
||||
<a class="dropdown-item" href="/admin/upload_mitgliedsantrag">Mitgliedsantrag(pdf) hochladen</a>
|
||||
<form action="/delete_guests" method="POST" style="margin:0;">
|
||||
<?= csrf_field() ?>
|
||||
<button type="submit" class="dropdown-item" style="width:100%;text-align:left;border:0;background:none;">Gast Mitglieder löschen</button>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
|
||||
<a class="dropdown-item" href="#"
|
||||