Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ README.md
.gitattributes
.gitignore
debug.sh
public/impressum.html
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use nix
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.env
.env.dev
dev.env
discordguild.php
f.php
test.php
Expand All @@ -23,3 +23,5 @@ buildpush.sh
html/install-php-extensions
composer.lock
info.php
*.env
!example.*.env
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,23 @@
# DevCord Devmarkt

## setup dev environment
- copy .env.dev.example to .env.dev
- copy example.dev.env to dev.env
- enter all properties
- add the bot to your server
- run `docker compose -f compose.debug.yaml up`

## Impressum
To provide an impressum, you can either:

1. **Use the default template**: Fill in the following environment variables in your `.env` file:
- `IMPRESSUM_NAME`
- `IMPRESSUM_STREET`
- `IMPRESSUM_CITY`
- `IMPRESSUM_EMAIL`

2. **Mount a custom file**: Create an `impressum.html` file in the `public` directory or mount it via docker-compose:
```yaml
volumes:
- ./impressum.html:/var/www/public/impressum.html
```
If `public/impressum.html` exists (either in the image or mounted), it will be used instead of the template.
8 changes: 5 additions & 3 deletions compose.debug.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
services:
mysql:
container_name: mysql_dev
image: mysql
command: --default-authentication-plugin=mysql_native_password
image: mysql:9.7
environment:
MYSQL_ROOT_PASSWORD: test
MYSQL_DATABASE: test
Expand All @@ -15,11 +14,14 @@ services:
- "8080:80"
volumes:
- ./:/var/www/
# - ./impressum.html:/var/www/public/impressum.html
depends_on:
- mysql
environment:
MYSQL_HOST: mysql_dev
MYSQL_DATABASE: test
MYSQL_USER: root
MYSQL_PASSWORD: test
BOT_REDIRECT_URI: http://localhost:8080/login.php?
BOT_BASE_URI: http://localhost:8080
env_file: .env.dev
env_file: dev.env
1 change: 1 addition & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ services:
dockerfile: Dockerfile
volumes:
- ./:/var/www/
# - ./impressum.html:/var/www/public/impressum.html
ports:
- "8080:80"
env_file: .env
1 change: 1 addition & 0 deletions debug.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,6 @@ RUN chown -R www-data:www-data /var/www
COPY docker/start-apache /usr/local/bin

ENV APP_PATH=/var/www
COPY docker/000-default.conf /etc/apache2/sites-available/000-default.conf

CMD ["start-apache"]
4 changes: 2 additions & 2 deletions docker/000-default.conf
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www
DocumentRoot /var/www/public

<Directory /var/www>
<Directory /var/www/public>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
Expand Down
11 changes: 11 additions & 0 deletions docker/start-apache
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
#!/usr/bin/env bash

# Generate impressum from template if it doesn't exist
if [ ! -f /var/www/public/impressum.html ]; then
echo "Generating /var/www/public/impressum.html from template..."
cp /var/www/docker/templates/impressum.html.template /var/www/public/impressum.html
sed -i "s/IMPRESSUM_NAME/${IMPRESSUM_NAME:-}/g" /var/www/public/impressum.html
sed -i "s/IMPRESSUM_STREET/${IMPRESSUM_STREET:-}/g" /var/www/public/impressum.html
sed -i "s/IMPRESSUM_CITY/${IMPRESSUM_CITY:-}/g" /var/www/public/impressum.html
sed -i "s/IMPRESSUM_EMAIL/${IMPRESSUM_EMAIL:-}/g" /var/www/public/impressum.html
fi

sed -i "s/Listen 80/Listen ${PORT:-80}/g" /etc/apache2/ports.conf
sed -i "s/:80/:${PORT:-80}/g" /etc/apache2/sites-enabled/*
apache2-foreground
10 changes: 5 additions & 5 deletions impressum.html → docker/templates/impressum.html.template
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<html>
<head>
<title>Datenschutzerkl&auml;rung - DevCord</title>
<title>Impressum - DevCord</title>
<link rel="shortcut icon" type="image/x-icon" href="assets/img/favicon.png" />
<link rel="stylesheet" href="assets/css/style.css" />
</head>
Expand All @@ -13,9 +13,9 @@ <h1>Impressum</h1>

<h2>Angaben gem&auml;&szlig; &sect; 5 TMG</h2>
<p>
Max Schlosser<br />
Gro&szlig;br&ouml;sern 4<br />
02627 Radibor
IMPRESSUM_NAME<br />
IMPRESSUM_STREET<br />
IMPRESSUM_CITY
</p>

<p>
Expand All @@ -24,7 +24,7 @@ <h2>Angaben gem&auml;&szlig; &sect; 5 TMG</h2>
</p>

<h2>Kontakt</h2>
<p>E-Mail: kontakt@max-schlosser.de</p>
<p>E-Mail: IMPRESSUM_EMAIL</p>

<p>
Wir sind nicht bereit oder verpflichtet, an Streitbeilegungsverfahren vor einer
Expand Down
8 changes: 7 additions & 1 deletion .env.dev.example → example.dev.env
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
BOT_TOKEN=""
BOT_CLIENT_SECRET=""
BOT_CLIENT_ID=""

GUILD_DEVMARKT_REQUEST_CHANNEL=""
GUILD_DEVMARKT_CHANNEL=""
GUILD_ID=""
Expand All @@ -10,4 +11,9 @@ CHECK_EMOTE=""
BLOCK_EMOTE=""
BOT_ACCESS_TOKEN=""
THREAD_TYPE=""
MAX_DESCRIPTION_SIZE=""
MAX_DESCRIPTION_SIZE=""

IMPRESSUM_NAME=""
IMPRESSUM_STREET=""
IMPRESSUM_CITY=""
IMPRESSUM_EMAIL=""
7 changes: 6 additions & 1 deletion .env.example → example.env
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,9 @@ BOT_REDIRECT_URI=""
BOT_BASE_URI=""
BOT_ACCESS_TOKEN=""

MAX_DESCRIPTION_SIZE=""
MAX_DESCRIPTION_SIZE=""

IMPRESSUM_NAME=""
IMPRESSUM_STREET=""
IMPRESSUM_CITY=""
IMPRESSUM_EMAIL=""
87 changes: 0 additions & 87 deletions pdo.php

This file was deleted.

6 changes: 3 additions & 3 deletions php/devmarkt.inc.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
include_once('../pdo.php');
include_once('pdo.php');
include_once('login.inc.php');
include_once('token.inc.php');
include_once('request.inc.php');
Expand All @@ -21,12 +21,12 @@
$devmarktChannel = getenv('GUILD_DEVMARKT_CHANNEL');

if ($login->isBlocked()) {
header('Location: index.php');
header('Location: ' . $base_url . '/index.php');
}

if ($login->isOnCoolDown()
&& !($login->isModerator())) {
header('Location: index.php');
header('Location: ' . $base_url . '/index.php');
}

if (!(isset($_POST['titel'], $_POST['type'], $_POST['beschreibung'], $_POST['color']))) {
Expand Down
87 changes: 86 additions & 1 deletion php/pdo.php
Original file line number Diff line number Diff line change
@@ -1,2 +1,87 @@
<?php
include_once(getenv("APP_PATH") . '/pdo.php');
session_start();
error_reporting(E_ALL ^ E_DEPRECATED);
$base_url = getenv("BOT_BASE_URI");
$devmarkt_anfragen = getenv("GUILD_DEVMARKT_REQUEST_CHANNEL");
$devmarkt = getenv("GUILD_DEVMARKT_CHANNEL");
$guild_id = getenv("GUILD_ID");
$moderator_id = getenv("GUILD_MOD_ID");
$redirect_uri = getenv("BOT_REDIRECT_URI");

class MySQL
{

private $host, $database, $username, $password;

private $pdo;

public function __construct()
{

$this->host = getenv("MYSQL_HOST");
$this->database = getenv("MYSQL_DATABASE");
$this->username = getenv("MYSQL_USER");
$this->password = getenv("MYSQL_PASSWORD");
$options = array(
PDO::ATTR_ERRMODE => PDO::ERRMODE_SILENT,
PDO::ATTR_PERSISTENT => false,
);
$this->pdo = new PDO('mysql:host=' . $this->host . ';dbname=' . $this->database, $this->username, $this->password, $options);
$this->loadTables();

}

public function loadTables()
{

$pdoConnection = $this->getPDO();

$stmt = 'CREATE TABLE IF NOT EXISTS `dc_users` ( `id` INT NOT NULL AUTO_INCREMENT , `discord_id` VARCHAR(255) NOT NULL , `auth_code` VARCHAR(255) NOT NULL , `refresh_code` VARCHAR(255) NOT NULL , `rang` VARCHAR(50) NOT NULL , `login_token` VARCHAR(255),`blocked` BOOLEAN, `thread` VARCHAR(200) NULL DEFAULT NULL, PRIMARY KEY (`id`)) ENGINE = InnoDB;';
$qry = $pdoConnection->prepare($stmt);
$qry->execute();

$stmt1 = 'CREATE TABLE `anfragen` ( `id` INT NOT NULL AUTO_INCREMENT , `by_discord_id` VARCHAR(255) NOT NULL , `title` VARCHAR(100) NOT NULL , `type` VARCHAR(20) NOT NULL , `description` VARCHAR(' . getenv("MAX_DESCRIPTION_SIZE") . ') NOT NULL , `link` VARCHAR(100) NOT NULL , `req_id` VARCHAR(100) NOT NULL , `status` VARCHAR(100) NOT NULL , `processed_by` VARCHAR(100) NOT NULL ,`message_id` VARCHAR(100),`date` VARCHAR(100),`date_processed` VARCHAR(100),`color` VARCHAR(100),`reason` VARCHAR(500),`options` VARCHAR(200), PRIMARY KEY (`id`)) ENGINE = InnoDB;';
$qry1 = $pdoConnection->prepare($stmt1);
$qry1->execute();

}

public function getPDO()
{

return $this->pdo;

}

public function close()
{

$this->pdo->close();

}

public function query($qry)
{
return $this->pdo->query($qry);

}

public function inTable($table, $column, $user)
{

$pdoConnection = $this->pdo;

$stmt = "SELECT * FROM `" . $table . "` WHERE `" . $column . "`=:user";
$qry = $pdoConnection->prepare($stmt);
$qry->bindParam(":user", $user);
$qry->execute();

if ($qry->fetchColumn() == 0) {
return false;
}
return true;
}

}

?>
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
11 changes: 5 additions & 6 deletions case.php → public/case.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
<?php
include_once('pdo.php');
require 'vendor/autoload.php';
include_once('php/checklogin.php');
include_once('php/token.inc.php');
include_once('php/login.inc.php');
include_once('php/request.inc.php');
include_once('../php/pdo.php');
include_once('../php/checklogin.php');
include_once('../php/token.inc.php');
include_once('../php/login.inc.php');
include_once('../php/request.inc.php');

if (!isset($_GET['req_id'])) {
header('Location: index.php?error=nothing_set');
Expand Down
File renamed without changes.
2 changes: 2 additions & 0 deletions public/devmarkt.inc.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
include_once('../php/devmarkt.inc.php');
File renamed without changes.
Loading
Loading