Flatten structure so webroot is the project root instead of public/
Simplifies Plesk/shared-hosting deployment (no need to set a separate document root subfolder). config.php, includes/ and sql/ are now protected via .htaccess rules instead of living outside the webroot. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
parent
4871d29afa
commit
e57fa0b73c
16 changed files with 70 additions and 50 deletions
21
.htaccess
Normal file
21
.htaccess
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
Options -Indexes
|
||||
DirectoryIndex index.php index.html
|
||||
|
||||
<IfModule mod_headers.c>
|
||||
Header set X-Content-Type-Options "nosniff"
|
||||
Header set X-Frame-Options "SAMEORIGIN"
|
||||
</IfModule>
|
||||
|
||||
# Sensible Dateien/Ordner dürfen niemals ausgeliefert werden,
|
||||
# auch wenn sie hier im Webroot liegen.
|
||||
<FilesMatch "^config(\.example)?\.php$">
|
||||
<IfModule mod_authz_core.c>
|
||||
Require all denied
|
||||
</IfModule>
|
||||
<IfModule !mod_authz_core.c>
|
||||
Deny from all
|
||||
</IfModule>
|
||||
</FilesMatch>
|
||||
|
||||
RewriteEngine On
|
||||
RewriteRule ^(includes|sql)/ - [F,L]
|
||||
27
README.md
27
README.md
|
|
@ -3,7 +3,7 @@
|
|||
Einfache PHP/MySQL-Anwendung ohne Abhaengigkeiten (kein Composer, kein Build-Schritt).
|
||||
Laeuft auf jedem klassischen Webspace mit PHP 8+ und MySQL/MariaDB.
|
||||
|
||||
Die eigentliche Gilden-Homepage (`public/index.php`) ist bewusst als Platzhalter gelassen
|
||||
Die eigentliche Gilden-Homepage (`index.php`) ist bewusst als Platzhalter gelassen
|
||||
und wird spaeter ausgebaut. Fokus dieser Version ist der Mitglieder-/Admin-Bereich.
|
||||
|
||||
## Funktionen
|
||||
|
|
@ -21,23 +21,28 @@ und wird spaeter ausgebaut. Fokus dieser Version ist der Mitglieder-/Admin-Berei
|
|||
config.example.php Vorlage fuer die Datenbank-Zugangsdaten
|
||||
config.php Deine echten Zugangsdaten (nicht einchecken/hochladen-sichtbar machen)
|
||||
sql/schema.sql Datenbankstruktur zum Import (z.B. via phpMyAdmin)
|
||||
includes/ PHP-Logik, liegt AUSSERHALB des Webroots
|
||||
public/ Das hier wird auf den Webspace hochgeladen (= Document Root der Domain)
|
||||
includes/ PHP-Logik (Datenbank, Auth, Berechtigungen, Layout)
|
||||
index.php, login.php, ... Oeffentlich aufrufbare Seiten
|
||||
admin/ Admin-Bereich (Benutzerverwaltung, Berechtigungsgruppen)
|
||||
assets/ CSS
|
||||
```
|
||||
|
||||
Wichtig: Auf dem Webspace muss der Inhalt von `public/` das Wurzelverzeichnis der Domain sein
|
||||
(z.B. `public_html/`), waehrend `includes/`, `config.php` und `sql/` **ausserhalb** davon liegen,
|
||||
also nicht direkt ueber den Browser erreichbar sind. Das ist bei den meisten Hostern
|
||||
(IONOS, Strato, All-Inkl, etc.) der Standard-Aufbau eines Hosting-Kontos.
|
||||
Alles liegt in einem einzigen Verzeichnis, das direkt als Dokumentenstamm/Document Root der
|
||||
Domain eingestellt wird (kein separater `public/`-Unterordner mehr). Damit `config.php`,
|
||||
`includes/` und `sql/` trotzdem nicht ueber den Browser erreichbar sind, blockiert eine
|
||||
`.htaccess` im Hauptverzeichnis den Zugriff darauf serverseitig (siehe `.htaccess`). Das
|
||||
funktioniert auf Apache-basiertem Hosting (Standard bei den meisten Webspace-Anbietern wie
|
||||
IONOS, Strato, All-Inkl, Plesk). Falls dein Hoster kein Apache/`.htaccess` nutzt (z.B. reines
|
||||
nginx), muss der Zugriff auf `config.php`, `includes/` und `sql/` stattdessen in der
|
||||
Server-Konfiguration gesperrt werden.
|
||||
|
||||
## Einrichtung
|
||||
|
||||
1. Datenbank (MySQL/MariaDB) beim Hoster anlegen.
|
||||
2. `sql/schema.sql` in die leere Datenbank importieren (z.B. ueber phpMyAdmin).
|
||||
3. `config.example.php` zu `config.php` kopieren und die Datenbank-Zugangsdaten eintragen.
|
||||
4. Dateien hochladen:
|
||||
- Inhalt von `public/` in das Webroot-Verzeichnis (z.B. `public_html/`)
|
||||
- `includes/`, `config.php` und `sql/` eine Ebene darueber (nicht ins Webroot!)
|
||||
4. Den gesamten Ordnerinhalt auf den Webspace hochladen (z.B. per FTP), und zwar in das
|
||||
Verzeichnis, das als Dokumentenstamm/Document Root der Domain eingestellt ist.
|
||||
5. Im Browser `https://deine-domain.de/install.php` aufrufen und den ersten
|
||||
Administrator-Account anlegen. Dabei werden automatisch die Standard-Berechtigungen
|
||||
und die Gruppen "Administrator" und "Mitglied" angelegt.
|
||||
|
|
@ -61,7 +66,7 @@ also nicht direkt ueber den Browser erreichbar sind. Das ist bei den meisten Hos
|
|||
Mit PHP's eingebautem Webserver (PHP 8+ muss installiert sein):
|
||||
|
||||
```
|
||||
php -S localhost:8000 -t public
|
||||
php -S localhost:8000
|
||||
```
|
||||
|
||||
Dazu lokal eine MySQL/MariaDB-Datenbank bereitstellen (z.B. via XAMPP/Laragon) und in `config.php`
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<?php
|
||||
require_once __DIR__ . '/../../includes/bootstrap.php';
|
||||
require_once __DIR__ . '/../includes/bootstrap.php';
|
||||
require_permission('roles.manage');
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
<?php
|
||||
require_once __DIR__ . '/../../includes/bootstrap.php';
|
||||
require_once __DIR__ . '/../includes/bootstrap.php';
|
||||
require_permission('roles.manage');
|
||||
|
||||
$pdo = db();
|
||||
|
|
@ -93,7 +93,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||
$allPermissions = $pdo->query('SELECT id, `key`, description FROM permissions ORDER BY `key`')->fetchAll();
|
||||
|
||||
$pageTitle = $isEdit ? 'Berechtigungsgruppe bearbeiten' : 'Berechtigungsgruppe anlegen';
|
||||
include __DIR__ . '/../../includes/header.php';
|
||||
include __DIR__ . '/../includes/header.php';
|
||||
?>
|
||||
<div class="panel">
|
||||
<h1><?= $isEdit ? 'Berechtigungsgruppe bearbeiten' : 'Neue Berechtigungsgruppe' ?></h1>
|
||||
|
|
@ -146,4 +146,4 @@ include __DIR__ . '/../../includes/header.php';
|
|||
<button type="submit" class="button-secondary">Berechtigung anlegen</button>
|
||||
</form>
|
||||
</div>
|
||||
<?php include __DIR__ . '/../../includes/footer.php'; ?>
|
||||
<?php include __DIR__ . '/../includes/footer.php'; ?>
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
<?php
|
||||
require_once __DIR__ . '/../../includes/bootstrap.php';
|
||||
require_once __DIR__ . '/../includes/bootstrap.php';
|
||||
require_permission('roles.manage');
|
||||
|
||||
$roles = db()->query(
|
||||
|
|
@ -14,7 +14,7 @@ $roles = db()->query(
|
|||
)->fetchAll();
|
||||
|
||||
$pageTitle = 'Berechtigungsgruppen';
|
||||
include __DIR__ . '/../../includes/header.php';
|
||||
include __DIR__ . '/../includes/header.php';
|
||||
?>
|
||||
<div class="panel">
|
||||
<h1>Berechtigungsgruppen</h1>
|
||||
|
|
@ -54,4 +54,4 @@ include __DIR__ . '/../../includes/header.php';
|
|||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<?php include __DIR__ . '/../../includes/footer.php'; ?>
|
||||
<?php include __DIR__ . '/../includes/footer.php'; ?>
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
<?php
|
||||
require_once __DIR__ . '/../../includes/bootstrap.php';
|
||||
require_once __DIR__ . '/../includes/bootstrap.php';
|
||||
require_permission('users.delete');
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
<?php
|
||||
require_once __DIR__ . '/../../includes/bootstrap.php';
|
||||
require_once __DIR__ . '/../includes/bootstrap.php';
|
||||
|
||||
$editId = isset($_GET['id']) ? (int) $_GET['id'] : null;
|
||||
$isEdit = $editId !== null;
|
||||
|
|
@ -98,7 +98,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||
}
|
||||
|
||||
$pageTitle = $isEdit ? 'Benutzer bearbeiten' : 'Benutzer anlegen';
|
||||
include __DIR__ . '/../../includes/header.php';
|
||||
include __DIR__ . '/../includes/header.php';
|
||||
?>
|
||||
<div class="panel">
|
||||
<h1><?= $isEdit ? 'Benutzer bearbeiten' : 'Neuen Benutzer anlegen' ?></h1>
|
||||
|
|
@ -149,4 +149,4 @@ include __DIR__ . '/../../includes/header.php';
|
|||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<?php include __DIR__ . '/../../includes/footer.php'; ?>
|
||||
<?php include __DIR__ . '/../includes/footer.php'; ?>
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
<?php
|
||||
require_once __DIR__ . '/../../includes/bootstrap.php';
|
||||
require_once __DIR__ . '/../includes/bootstrap.php';
|
||||
require_permission('users.view');
|
||||
|
||||
$canCreate = user_has_permission('users.create');
|
||||
|
|
@ -18,7 +18,7 @@ $users = db()->query(
|
|||
)->fetchAll();
|
||||
|
||||
$pageTitle = 'Benutzerverwaltung';
|
||||
include __DIR__ . '/../../includes/header.php';
|
||||
include __DIR__ . '/../includes/header.php';
|
||||
?>
|
||||
<div class="panel">
|
||||
<h1>Benutzerverwaltung</h1>
|
||||
|
|
@ -72,4 +72,4 @@ include __DIR__ . '/../../includes/header.php';
|
|||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<?php include __DIR__ . '/../../includes/footer.php'; ?>
|
||||
<?php include __DIR__ . '/../includes/footer.php'; ?>
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
<?php
|
||||
require_once __DIR__ . '/../includes/bootstrap.php';
|
||||
require_once __DIR__ . '/includes/bootstrap.php';
|
||||
require_permission('dashboard.view');
|
||||
|
||||
$user = current_user();
|
||||
|
|
@ -7,7 +7,7 @@ $canViewUsers = user_has_permission('users.view');
|
|||
$canManageRoles = user_has_permission('roles.manage');
|
||||
|
||||
$pageTitle = 'Dashboard';
|
||||
include __DIR__ . '/../includes/header.php';
|
||||
include __DIR__ . '/includes/header.php';
|
||||
?>
|
||||
<div class="panel">
|
||||
<h1>Willkommen, <?= e($user['display_name'] !== '' ? $user['display_name'] : $user['username']) ?>!</h1>
|
||||
|
|
@ -36,4 +36,4 @@ include __DIR__ . '/../includes/header.php';
|
|||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php include __DIR__ . '/../includes/footer.php'; ?>
|
||||
<?php include __DIR__ . '/includes/footer.php'; ?>
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
<?php
|
||||
require_once __DIR__ . '/../includes/bootstrap.php';
|
||||
require_once __DIR__ . '/includes/bootstrap.php';
|
||||
|
||||
$pageTitle = 'Startseite';
|
||||
include __DIR__ . '/../includes/header.php';
|
||||
include __DIR__ . '/includes/header.php';
|
||||
?>
|
||||
<div class="hero">
|
||||
<h1>Aion2 Gilde</h1>
|
||||
|
|
@ -13,4 +13,4 @@ include __DIR__ . '/../includes/header.php';
|
|||
<p><a class="button" href="/dashboard.php">Zum Dashboard</a></p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php include __DIR__ . '/../includes/footer.php'; ?>
|
||||
<?php include __DIR__ . '/includes/footer.php'; ?>
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
<?php
|
||||
require_once __DIR__ . '/../includes/bootstrap.php';
|
||||
require_once __DIR__ . '/includes/bootstrap.php';
|
||||
|
||||
$pdo = db();
|
||||
|
||||
|
|
@ -7,7 +7,7 @@ $userCount = (int) $pdo->query('SELECT COUNT(*) FROM users')->fetchColumn();
|
|||
if ($userCount > 0) {
|
||||
http_response_code(403);
|
||||
$pageTitle = 'Installation abgeschlossen';
|
||||
include __DIR__ . '/../includes/header.php';
|
||||
include __DIR__ . '/includes/header.php';
|
||||
?>
|
||||
<div class="panel panel-narrow">
|
||||
<h1>Installation bereits abgeschlossen</h1>
|
||||
|
|
@ -15,7 +15,7 @@ if ($userCount > 0) {
|
|||
<p><a class="button" href="/login.php">Zum Login</a></p>
|
||||
</div>
|
||||
<?php
|
||||
include __DIR__ . '/../includes/footer.php';
|
||||
include __DIR__ . '/includes/footer.php';
|
||||
exit;
|
||||
}
|
||||
|
||||
|
|
@ -99,7 +99,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||
}
|
||||
|
||||
$pageTitle = 'Installation';
|
||||
include __DIR__ . '/../includes/header.php';
|
||||
include __DIR__ . '/includes/header.php';
|
||||
?>
|
||||
<div class="panel panel-narrow">
|
||||
<h1>Ersteinrichtung</h1>
|
||||
|
|
@ -133,4 +133,4 @@ include __DIR__ . '/../includes/header.php';
|
|||
<button type="submit">Administrator anlegen</button>
|
||||
</form>
|
||||
</div>
|
||||
<?php include __DIR__ . '/../includes/footer.php'; ?>
|
||||
<?php include __DIR__ . '/includes/footer.php'; ?>
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
<?php
|
||||
require_once __DIR__ . '/../includes/bootstrap.php';
|
||||
require_once __DIR__ . '/includes/bootstrap.php';
|
||||
|
||||
if (current_user()) {
|
||||
redirect('/dashboard.php');
|
||||
|
|
@ -23,7 +23,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||
}
|
||||
|
||||
$pageTitle = 'Login';
|
||||
include __DIR__ . '/../includes/header.php';
|
||||
include __DIR__ . '/includes/header.php';
|
||||
?>
|
||||
<div class="panel panel-narrow">
|
||||
<h1>Login</h1>
|
||||
|
|
@ -43,4 +43,4 @@ include __DIR__ . '/../includes/header.php';
|
|||
<button type="submit">Anmelden</button>
|
||||
</form>
|
||||
</div>
|
||||
<?php include __DIR__ . '/../includes/footer.php'; ?>
|
||||
<?php include __DIR__ . '/includes/footer.php'; ?>
|
||||
5
logout.php
Normal file
5
logout.php
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
<?php
|
||||
require_once __DIR__ . '/includes/bootstrap.php';
|
||||
|
||||
logout();
|
||||
redirect('/login.php');
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
Options -Indexes
|
||||
|
||||
<IfModule mod_headers.c>
|
||||
Header set X-Content-Type-Options "nosniff"
|
||||
Header set X-Frame-Options "SAMEORIGIN"
|
||||
</IfModule>
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
<?php
|
||||
require_once __DIR__ . '/../includes/bootstrap.php';
|
||||
|
||||
logout();
|
||||
redirect('/login.php');
|
||||
Loading…
Reference in a new issue