Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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 .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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# 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`
7 changes: 4 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,13 @@ services:
- "8080:80"
volumes:
- ./:/var/www/
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 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
File renamed without changes.
File renamed without changes.
85 changes: 0 additions & 85 deletions impressum.html

This file was deleted.

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.
14 changes: 7 additions & 7 deletions index.php → public/index.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php
include_once('pdo.php');
include_once('php/login.inc.php');
include_once('php/token.inc.php');
include_once('php/checklogin.php');
include_once('php/request.inc.php');
include_once('php/devmarkt.class.php');
include_once('../php/pdo.php');
include_once('../php/login.inc.php');
include_once('../php/token.inc.php');
include_once('../php/checklogin.php');
include_once('../php/request.inc.php');
include_once('../php/devmarkt.class.php');
$mysql = new MySQL();
$base_url = getenv("BOT_BASE_URI");
$discordInvite = getenv('GUILD_INVITE');
Expand Down Expand Up @@ -129,7 +129,7 @@

?>

<form id="form" method="POST" action="php/devmarkt.inc.php">
<form id="form" method="POST" action="devmarkt.inc.php">

<?php

Expand Down
Loading
Loading