2021-03-01 16:56:53 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
class Config {
|
|
|
|
|
|
|
|
private $config = [];
|
|
|
|
|
|
|
|
public function loadConfig(string $config_path) {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Einlesen der Konfiguration.
|
|
|
|
* Anmerkung: Das @ unterdrückt die ausgabe von Warnungen. Ein
|
|
|
|
* Fehlen der Konfigurationsdatei erzeugt keine Exception!
|
|
|
|
*/
|
|
|
|
|
|
|
|
$this->config = @parse_ini_file($config_path);
|
|
|
|
if ($this->config === false)
|
|
|
|
{
|
2021-03-01 19:45:04 +01:00
|
|
|
throw new Exception("Failed to parse configuration at {$config_path}");
|
2021-03-01 16:56:53 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getDbDriver(): string {
|
|
|
|
$driver = $this->config['driver'] ?? "PDO_PGSQL";
|
|
|
|
return $driver;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getDbFile(): string {
|
|
|
|
$file = $this->config['file'] ?? "./request.db";
|
|
|
|
return $file;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getDbHost(): string {
|
|
|
|
$host = $this->config['host'] ?? "localhost";
|
|
|
|
return $host;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getDbPort(): int {
|
|
|
|
$port = $this->config['port'] ?? 5432;
|
|
|
|
return $port;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getDbBase(): string {
|
|
|
|
$database = $this->config['database'] ?? "requests";
|
|
|
|
return $database;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getDbUser(): string {
|
|
|
|
$user = $this->config['user'] ?? "matrixadmin";
|
|
|
|
return $user;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getDbPass(): string {
|
|
|
|
$password = $this->config['password'] ?? "geheim";
|
|
|
|
return $password;
|
|
|
|
}
|
|
|
|
|
2021-03-01 23:22:05 +01:00
|
|
|
public function getLogLevel(): int {
|
|
|
|
$loglevel = strtoupper($this->config['loglevel']) ?? LOG_INFO;
|
2021-03-01 16:56:53 +01:00
|
|
|
return $loglevel;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getLogFile(): string {
|
|
|
|
$logfile = $this->config['logfile'] ?? "log/register.log";
|
|
|
|
return $logfile;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getMxDomain(): string {
|
|
|
|
$driver = $this->config['mxdomain'] ?? "matrix.kraut.space";
|
|
|
|
return $driver;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getBaseURL(): string {
|
|
|
|
$baseurl = $this->config['baseurl'] ?? "";
|
|
|
|
return $baseurl;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getValidator(): string {
|
|
|
|
$validator = $this->config['validator'] ?? "validator.php?token=";
|
|
|
|
return $validator;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getMailFrom(): string {
|
|
|
|
$mailfrom = $this->config['mailfrom'] ?? "";
|
|
|
|
return $mailfrom;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getMailSubject(): string {
|
|
|
|
$mailsubject = $this->config['mailsubject'] ?? "Ihr Matrix Account";
|
|
|
|
return $mailsubject;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getMailClosure(): string {
|
|
|
|
$mailclosure = $this->config['mailclosure'] ?? "MfG";
|
|
|
|
return $mailclosure;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|