Initial commit: Add Docker setup, database schema, and basic PHP application structure
This commit is contained in:
12
apache/Dockerfile
Normal file
12
apache/Dockerfile
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
FROM php:8.2-apache
|
||||||
|
|
||||||
|
# Apache Rewrite aktivieren
|
||||||
|
RUN a2enmod rewrite
|
||||||
|
|
||||||
|
# PHP-Extensions für MariaDB
|
||||||
|
RUN docker-php-ext-install pdo pdo_mysql
|
||||||
|
|
||||||
|
# VHost kopieren
|
||||||
|
COPY vhost.conf /etc/apache2/sites-available/000-default.conf
|
||||||
|
|
||||||
|
WORKDIR /var/www/html
|
||||||
12
apache/vhost.conf
Normal file
12
apache/vhost.conf
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<VirtualHost *:80>
|
||||||
|
ServerAdmin webmaster@localhost
|
||||||
|
DocumentRoot /var/www/html
|
||||||
|
|
||||||
|
<Directory /var/www/html>
|
||||||
|
AllowOverride All
|
||||||
|
Require all granted
|
||||||
|
</Directory>
|
||||||
|
|
||||||
|
ErrorLog ${APACHE_LOG_DIR}/error.log
|
||||||
|
CustomLog ${APACHE_LOG_DIR}/access.log combined
|
||||||
|
</VirtualHost>
|
||||||
55
db/init/001_schema.sql
Normal file
55
db/init/001_schema.sql
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
-- Identitäten
|
||||||
|
CREATE TABLE identities (
|
||||||
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||||
|
) ENGINE=InnoDB;
|
||||||
|
|
||||||
|
-- Stammdaten (Key-Value)
|
||||||
|
CREATE TABLE identity_fields (
|
||||||
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
identity_id INT NOT NULL,
|
||||||
|
field_key VARCHAR(50) NOT NULL,
|
||||||
|
field_value TEXT NOT NULL,
|
||||||
|
FOREIGN KEY (identity_id)
|
||||||
|
REFERENCES identities(id)
|
||||||
|
ON DELETE CASCADE
|
||||||
|
) ENGINE=InnoDB;
|
||||||
|
|
||||||
|
-- Zugriffstoken (UUIDs)
|
||||||
|
CREATE TABLE access_tokens (
|
||||||
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
identity_id INT NOT NULL,
|
||||||
|
uuid CHAR(36) NOT NULL UNIQUE,
|
||||||
|
expires_at DATETIME NULL,
|
||||||
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
FOREIGN KEY (identity_id)
|
||||||
|
REFERENCES identities(id)
|
||||||
|
ON DELETE CASCADE
|
||||||
|
) ENGINE=InnoDB;
|
||||||
|
|
||||||
|
-- Feldrechte pro Token
|
||||||
|
CREATE TABLE token_permissions (
|
||||||
|
token_id INT NOT NULL,
|
||||||
|
field_key VARCHAR(50) NOT NULL,
|
||||||
|
PRIMARY KEY (token_id, field_key),
|
||||||
|
FOREIGN KEY (token_id)
|
||||||
|
REFERENCES access_tokens(id)
|
||||||
|
ON DELETE CASCADE
|
||||||
|
) ENGINE=InnoDB;
|
||||||
|
|
||||||
|
-- Dateien (Bilder, PDFs, etc.)
|
||||||
|
CREATE TABLE files (
|
||||||
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
identity_id INT NOT NULL,
|
||||||
|
token_id INT NULL,
|
||||||
|
filename VARCHAR(255) NOT NULL,
|
||||||
|
stored_name VARCHAR(255) NOT NULL,
|
||||||
|
mime_type VARCHAR(100),
|
||||||
|
uploaded_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
FOREIGN KEY (identity_id)
|
||||||
|
REFERENCES identities(id)
|
||||||
|
ON DELETE CASCADE,
|
||||||
|
FOREIGN KEY (token_id)
|
||||||
|
REFERENCES access_tokens(id)
|
||||||
|
ON DELETE SET NULL
|
||||||
|
) ENGINE=InnoDB;
|
||||||
28
docker-compose.yml
Normal file
28
docker-compose.yml
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
version: "3.9"
|
||||||
|
|
||||||
|
services:
|
||||||
|
web:
|
||||||
|
build: ./apache
|
||||||
|
container_name: apache_web
|
||||||
|
ports:
|
||||||
|
- "80:80"
|
||||||
|
volumes:
|
||||||
|
- ./www:/var/www/html
|
||||||
|
depends_on:
|
||||||
|
- db
|
||||||
|
|
||||||
|
db:
|
||||||
|
image: mariadb:11
|
||||||
|
container_name: mariadb
|
||||||
|
restart: unless-stopped
|
||||||
|
environment:
|
||||||
|
MYSQL_ROOT_PASSWORD: rootpass
|
||||||
|
MYSQL_DATABASE: appdb
|
||||||
|
MYSQL_USER: appuser
|
||||||
|
MYSQL_PASSWORD: apppass
|
||||||
|
volumes:
|
||||||
|
- db_data:/var/lib/mysql
|
||||||
|
- ./db/init:/docker-entrypoint-initdb.d:ro
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
db_data:
|
||||||
8
www/.htaccess
Normal file
8
www/.htaccess
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
RewriteEngine On
|
||||||
|
|
||||||
|
# Nur wenn keine echte Datei / kein echtes Verzeichnis
|
||||||
|
RewriteCond %{REQUEST_FILENAME} !-f
|
||||||
|
RewriteCond %{REQUEST_FILENAME} !-d
|
||||||
|
|
||||||
|
# UUID weiterreichen
|
||||||
|
RewriteRule ^([a-fA-F0-9-]+)$ card.php?uuid=$1 [L,QSA]
|
||||||
14
www/card.php
Normal file
14
www/card.php
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
<?php
|
||||||
|
$uuid = $_GET['uuid'] ?? 'keine UUID';
|
||||||
|
if(isset($_COOKIE['PHPSESSID'])){
|
||||||
|
session_start();
|
||||||
|
if($_SESSION['is_admin']??false){
|
||||||
|
header('Location: /admin.php?uuid='. $uuid);
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "UUID: " . htmlspecialchars($uuid);
|
||||||
|
|
||||||
|
//TODO
|
||||||
|
|
||||||
Reference in New Issue
Block a user