1
0
Fork 0

Switch to INI-based configuration

master
Anonymous Contributor 2023-09-06 17:34:32 +02:00
parent 598e55dd6f
commit f9453d5dec
4 changed files with 53 additions and 32 deletions

View File

@ -4,6 +4,7 @@ declare(strict_types=1);
namespace Mcp;
use PDO;
use Exception;
class Mcp implements ConnectionProvider
{
@ -41,8 +42,19 @@ class Mcp implements ConnectionProvider
public function __construct($basedir)
{
$this->templateDir = $basedir.DIRECTORY_SEPARATOR.'templates';
require $basedir.DIRECTORY_SEPARATOR.'config.php';
$this->config = $RUNTIME;
$this->config = array();
try {
$config = parse_ini_file($basedir.DIRECTORY_SEPARATOR.'config.ini', true);
foreach ($config['general'] as $key => $val) {
$this->config[$key] = $val;
}
unset($config['general']);
$this->config = array_merge($config, $this->config);
} catch (Exception $e) {
error_log('Could not load config, aborting. Error: '.$e->getMessage());
http_response_code(500);
exit();
}
}
public function db(): PDO

View File

@ -67,7 +67,7 @@ class Register extends RequestHandler
$email = trim($_POST['email']);
$avatar = null;
if (isset($this->app->config('default-avatar')[$_POST['avatar']]['UUID'])) {
if (isset($this->app->config('default-avatar')[$_POST['avatar']])) {
$avatar = trim($_POST['avatar']);
} else {
$this->displayPage("Der gewählte Standardavatar existiert nicht.");

38
config.example.ini Normal file
View File

@ -0,0 +1,38 @@
[general]
; Domain, unter der das MCP erreichbar ist
domain = example.com
; Mindestlänge des Passworts, wird bei Registrierung und Änderung überprüft
password-min-length = 8
; URL der Nutzungsbedingungen des Grids
tos-url = https://example.com/tos.html
; Name und UUID eines oder mehrerer Standardavatare
default-avatar[Twinster Kid] = 0817c915-293a-4041-b5a4-c7c53666bcc6
; Liste von Domains, deren E-Mail-Adressen als nicht für Password-Reset-Mails nutzbar zu behandeln sind
reset-blocked-domains[] = example.com
reset-blocked-domains[] = invalid.net
; Art der Einschränkung des Aufrufs von Cronjobs: key (API-Key benötigt) oder none (keine Einschränkung)
cron-restriction = key
; API-Key, der zum erfolgreichen Aufruf von Cronjobs übermittelt werden muss.
cron-key = changeme
; Host, Name und Zugangsdaten zur MySQL-Datenbank. Muss mit der Datenbank der Robust-Instanz übereinstimmen.
[mysql]
host = localhost
db = Robust
user = OpenSim
password = secret
; Zugangsdaten zum Mailserver
[smtp]
host = smtp.example.com
port = 465
address = noreply@example.com
; Name, der neben der Absenderadresse stehen soll
name = MyGrid Support
password = secret
; Daten des Grids, die u.a. auf der Welcome-Page angezeigt werden
[grid]
name = OpenSim
main-news = Yet another OpenSim Grid.
homeurl = http://...:8002

View File

@ -1,29 +0,0 @@
<?php
$RUNTIME['PDO'] = new PDO('mysql:host=...;dbname=...', '...', '...');
$RUNTIME['GRID']['NAME'] = "OpenSim";
$RUNTIME['GRID']['MAIN_NEWS'] = "Yet an other OpenSim Grid.";
$RUNTIME['GRID']['HOMEURL'] = "http://...:8002";
$RUNTIME['SMTP']['SERVER'] = "localhost";
$RUNTIME['SMTP']['PORT'] = 25;
$RUNTIME['SMTP']['ADDRESS'] = "noreply@localhost";
$RUNTIME['SMTP']['NAME'] = "4Creative";
$RUNTIME['SMTP']['PASS'] = "...";
$RUNTIME['TOOLS']['IMAGESERVICE'] = "https://image-service.4creative.net/";
$RUNTIME['TOOLS']['TOS'] = "https://4creative.net/nutzung.html";
$RUNTIME['DEFAULTAVATAR']["AVATAR1"]['UUID'] = "0817c915-293a-4041-b5a4-c7c53666bcc6";
$RUNTIME['SIDOMAN']['URL'] = "https://sidoman.4creative.net/";
$RUNTIME['SIDOMAN']['CONTAINER'] = "...";
$RUNTIME['SIDOMAN']['PASSWORD'] = "...";
$RUNTIME['DOMAIN'] = "mcp.4creative.net";
$RUNTIME['IAR']['BASEURL'] = "https://mcp.4creative.net/data/";
$RUNTIME['PASSWORD_MIN_LENGTH'] = 8;
$RUNTIME['CRON_RESTRICTION'] = 'key';
$RUNTIME['CRON_KEY'] = 'changeme';