diff --git a/config.sample.php b/config.sample.php
index 69252d1..b3fe96f 100644
--- a/config.sample.php
+++ b/config.sample.php
@@ -1,8 +1,17 @@
"example.com",
+ "access_token" => "To be used for sending the registration notification",
-$webroot="https://myregisterdomain.net/";
-$howToURL = "https://my-url-for-storing-howTos.net";
+ // Which e-mail-adresse shall the bot use to send e-mails?
+ "register_email" => 'register_bot@example.com',
+ // Where should the bot post registration requests to?
+ "register_room" => '$registerRoomID:example.com',
+
+ // Where is the public part of the bot located? make sure you have a / at the end
+ "webroot" => "https://myregisterdomain.net/",
+
+ // optional: Do you have a place where howTo's are located? If not leave this value out
+ "howToURL" => "https://my-url-for-storing-howTos.net",
+]
?>
diff --git a/cron.php b/cron.php
index 384ce0f..1d3e5f4 100644
--- a/cron.php
+++ b/cron.php
@@ -20,9 +20,9 @@ foreach ($mx_db->query($sql) as $row) {
try {
switch ($state) {
case RegisterState::PendingEmailSend:
- $verify_url = $webroot . "/verify.php?t=" . $row["verify_token"];
+ $verify_url = $config["webroot"] . "/verify.php?t=" . $row["verify_token"];
$success = send_mail_pending_verification(
- $homeserver,
+ $config["homeserver"],
$row["first_name"] . " " . $row["last_name"],
$row["email"],
$row["verify_url"]);
@@ -35,8 +35,8 @@ foreach ($mx_db->query($sql) as $row) {
break;
case RegisterState::PendingAdminSend:
require_once("MatrixConnection.php");
- $adminUrl = $webroot . "/verify_admin.php?t=" . $row["admin_token"];
- $mxConn = new MatrixConnection($homeserver, $access_token);
+ $adminUrl = $config["webroot"] . "/verify_admin.php?t=" . $row["admin_token"];
+ $mxConn = new MatrixConnection($config["homeserver"], $config["access_token"]);
$mxMsg = new MatrixMessage();
$mxMsg->set_body($first_name . ' ' . $last_name . " möchte sich registrieren und hat folgende Notiz hinterlassen:\r\n"
. $row["note"] . "\r\n"
@@ -45,12 +45,12 @@ foreach ($mx_db->query($sql) as $row) {
. $row["note"] . "
"
. "Zum Bearbeiten hier klicken");
$mxMsg->set_type("m.text");
- $response = $mxConn->send($register_room, $mxMsg);
+ $response = $mxConn->send($config["register_room"], $mxMsg);
if ($response) {
$mx_db->setRegistrationStateById(RegisterState::PendingAdminVerify, $row["id"]);
- send_mail_pending_approval($homeserver, $first_name . " " . $last_name, $email);
+ send_mail_pending_approval($config["homeserver"], $first_name . " " . $last_name, $email);
} else {
throw new Exception("Could not send notification for ".$row["first_name"]." ".$row["last_name"]."(".$row["id"].") to admins.");
}
@@ -61,18 +61,18 @@ foreach ($mx_db->query($sql) as $row) {
$password = addUser($row["first_name"], $row["last_name"], $row["username"], $row["email"]);
if ($password != NULL) {
// send registration_success
- $res = send_mail_registration_success($homeserver, $first_name . " " . $last_name, $email, $username, $password, $howToURL);
+ $res = send_mail_registration_success($config["homeserver"], $first_name . " " . $last_name, $email, $username, $password, $config["howToURL"]);
if ($res) {
$mx_db->setRegistrationStateById(RegisterState::AllDone, $row["id"]);
} else {
$mx_db->setRegistrationStateById(RegisterState::PendingSendRegistrationMail, $row["id"]);
}
} else {
- send_mail_registration_allowed_but_failed($homeserver, $first_name . " " . $last_name, $email);
+ send_mail_registration_allowed_but_failed($config["homeserver"], $first_name . " " . $last_name, $email);
$mxMsg = new MatrixMessage();
$mxMsg->set_type("m.text");
$mxMsg->set_body("Fehler beim Registrieren von " . $first_name . " " . $last_name . ".");
- $mxConn->send($register_room, $mxMsg);
+ $mxConn->send($config["register_room"], $mxMsg);
throw new Exception($language["REGISTRATION_FAILED"]);
}
break;
diff --git a/public/index.php b/public/index.php
index eda0435..1379f21 100644
--- a/public/index.php
+++ b/public/index.php
@@ -60,10 +60,10 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
}
$verify_token = $res["verify_token"];
- $verify_url = $webroot . "/verify.php?t=" . $verify_token;
+ $verify_url = $config["webroot"] . "/verify.php?t=" . $verify_token;
require_once "../mail_templates.php";
$success = send_mail_pending_verification(
- $homeserver,
+ $config["homeserver"],
$first_name . " " . $last_name,
$email,
$verify_url);
@@ -82,12 +82,12 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
print("
" . $e->getMessage() . "
"); - print("Zur Registrierungsseite"); + print("Zur Registrierungsseite"); } } else { $_SESSION["token"] = bin2hex(random_bytes(16)); ?> -