Switch to INI-based configuration
parent
598e55dd6f
commit
f9453d5dec
16
app/Mcp.php
16
app/Mcp.php
|
@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||||
namespace Mcp;
|
namespace Mcp;
|
||||||
|
|
||||||
use PDO;
|
use PDO;
|
||||||
|
use Exception;
|
||||||
|
|
||||||
class Mcp implements ConnectionProvider
|
class Mcp implements ConnectionProvider
|
||||||
{
|
{
|
||||||
|
@ -41,8 +42,19 @@ class Mcp implements ConnectionProvider
|
||||||
public function __construct($basedir)
|
public function __construct($basedir)
|
||||||
{
|
{
|
||||||
$this->templateDir = $basedir.DIRECTORY_SEPARATOR.'templates';
|
$this->templateDir = $basedir.DIRECTORY_SEPARATOR.'templates';
|
||||||
require $basedir.DIRECTORY_SEPARATOR.'config.php';
|
$this->config = array();
|
||||||
$this->config = $RUNTIME;
|
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
|
public function db(): PDO
|
||||||
|
|
|
@ -67,7 +67,7 @@ class Register extends RequestHandler
|
||||||
$email = trim($_POST['email']);
|
$email = trim($_POST['email']);
|
||||||
|
|
||||||
$avatar = null;
|
$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']);
|
$avatar = trim($_POST['avatar']);
|
||||||
} else {
|
} else {
|
||||||
$this->displayPage("Der gewählte Standardavatar existiert nicht.");
|
$this->displayPage("Der gewählte Standardavatar existiert nicht.");
|
||||||
|
|
|
@ -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
|
|
@ -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';
|
|
Loading…
Reference in New Issue