Compare commits
1 Commits
79341b4c88
...
ffce2fc28b
| Author | SHA1 | Date | |
|---|---|---|---|
| ffce2fc28b |
382
public/index.php
382
public/index.php
@@ -15,216 +15,220 @@
|
|||||||
*/
|
*/
|
||||||
require_once "../language.php";
|
require_once "../language.php";
|
||||||
if (!file_exists("../config.php")) {
|
if (!file_exists("../config.php")) {
|
||||||
print($language["NO_CONFIGURATION"]);
|
print($language["NO_CONFIGURATION"]);
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
require_once "../config.php";
|
require_once "../config.php";
|
||||||
|
|
||||||
// enforce admin via https
|
// enforce admin via https
|
||||||
if (!isset($_SERVER['HTTPS'])) {
|
if (!isset($_SERVER['HTTPS'])) {
|
||||||
header('Location: https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], true, 301);
|
header('Location: https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'], true, 301);
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||||
try {
|
try {
|
||||||
if (!isset($_SESSION["token"]) || !isset($_POST["token"]) || $_SESSION["token"] != $_POST["token"]) {
|
if (!isset($_SESSION["token"]) || !isset($_POST["token"]) || $_SESSION["token"] != $_POST["token"]) {
|
||||||
// token not present or invalid
|
// token not present or invalid
|
||||||
throw new Exception("UNKNOWN_SESSION");
|
throw new Exception("UNKNOWN_SESSION");
|
||||||
}
|
}
|
||||||
if (!isset($_POST["username"])) {
|
if (!isset($_POST["username"])) {
|
||||||
throw new Exception("UNKNOWN_USERNAME");
|
throw new Exception("UNKNOWN_USERNAME");
|
||||||
}
|
}
|
||||||
if (strlen($_POST["username"] > 20 || strlen($_POST["username"]) < 3)) {
|
if (strlen($_POST["username"] > 20 || strlen($_POST["username"]) < 3)) {
|
||||||
throw new Exception("USERNAME_LENGTH_INVALID");
|
throw new Exception("USERNAME_LENGTH_INVALID");
|
||||||
}
|
}
|
||||||
if (ctype_alnum($_POST['username']) != true) {
|
if (ctype_alnum($_POST['username']) != true) {
|
||||||
throw new Exception("USERNAME_NOT_ALNUM");
|
throw new Exception("USERNAME_NOT_ALNUM");
|
||||||
}
|
}
|
||||||
if (isset($config["getPasswordOnRegistration"]) && $config["getPasswordOnRegistration"] &&
|
if (isset($config["getPasswordOnRegistration"]) && $config["getPasswordOnRegistration"] &&
|
||||||
$_POST["password"] != $_POST["password_confirm"]) {
|
$_POST["password"] != $_POST["password_confirm"]) {
|
||||||
throw new Exception("PASSWORD_NOT_MATCH");
|
throw new Exception("PASSWORD_NOT_MATCH");
|
||||||
}
|
}
|
||||||
if (isset($_POST["note"]) && strlen($_POST["note"]) > 50) {
|
if (isset($_POST["note"]) && strlen($_POST["note"]) > 50) {
|
||||||
throw new Exception("NOTE_LENGTH_EXEEDED");
|
throw new Exception("NOTE_LENGTH_EXEEDED");
|
||||||
}
|
}
|
||||||
if (!isset($_POST["email"]) || !filter_var($_POST["email"], FILTER_VALIDATE_EMAIL)) {
|
if (!isset($_POST["email"]) || !filter_var($_POST["email"], FILTER_VALIDATE_EMAIL)) {
|
||||||
throw new Exception("EMAIL_INVALID_FORMAT");
|
throw new Exception("EMAIL_INVALID_FORMAT");
|
||||||
}
|
}
|
||||||
if (isset($_POST["first_name"]) && !preg_match("/[A-Z][a-z]+/", $_POST["first_name"])) {
|
if (isset($_POST["first_name"]) && ! preg_match("/[A-Z][a-z]+/", $_POST["first_name"])) {
|
||||||
throw new Exception("FIRSTNAME_INVALID_FORMAT");
|
throw new Exception("FIRSTNAME_INVALID_FORMAT");
|
||||||
}
|
}
|
||||||
if (isset($_POST["last_name"]) && !preg_match("/[A-Z][a-z]+/", $_POST["last_name"])) {
|
if (isset($_POST["last_name"]) && ! preg_match("/[A-Z][a-z]+/", $_POST["last_name"])) {
|
||||||
throw new Exception("SIRNAME_INVALID_FORMAT");
|
throw new Exception("SIRNAME_INVALID_FORMAT");
|
||||||
}
|
}
|
||||||
|
|
||||||
$first_name = filter_var($_POST["first_name"], FILTER_SANITIZE_STRING);
|
$first_name = filter_var($_POST["first_name"], FILTER_SANITIZE_STRING);
|
||||||
$last_name = filter_var($_POST["last_name"], FILTER_SANITIZE_STRING);
|
$last_name = filter_var($_POST["last_name"], FILTER_SANITIZE_STRING);
|
||||||
$username = filter_var($_POST["username"], FILTER_SANITIZE_STRING);
|
$username = filter_var($_POST["username"], FILTER_SANITIZE_STRING);
|
||||||
if (isset($_POST["password"])) {
|
if (isset($_POST["password"])) {
|
||||||
$password = filter_var($_POST["password"], FILTER_SANITIZE_STRING);
|
$password = filter_var($_POST["password"], FILTER_SANITIZE_STRING);
|
||||||
}
|
}
|
||||||
$note = filter_var($_POST["note"], FILTER_SANITIZE_STRING);
|
$note = filter_var($_POST["note"], FILTER_SANITIZE_STRING);
|
||||||
$email = filter_var($_POST["email"], FILTER_VALIDATE_EMAIL);
|
$email = filter_var($_POST["email"], FILTER_VALIDATE_EMAIL);
|
||||||
|
|
||||||
require_once("../database.php");
|
require_once("../database.php");
|
||||||
$res = $mx_db->addRegistration($first_name, $last_name, $username, $note, $email);
|
$res = $mx_db->addRegistration($first_name, $last_name, $username, $note, $email);
|
||||||
|
|
||||||
if (!isset($res["verify_token"])) {
|
if (!isset($res["verify_token"])) {
|
||||||
error_log("sth. went wrong. registration did not throw but admin_token not set");
|
error_log("sth. went wrong. registration did not throw but admin_token not set");
|
||||||
throw Exception("Unknown Error");
|
throw Exception ("Unknown Error");
|
||||||
}
|
}
|
||||||
$verify_token = $res["verify_token"];
|
$verify_token = $res["verify_token"];
|
||||||
|
|
||||||
$verify_url = $config["webroot"] . "/verify.php?t=" . $verify_token;
|
$verify_url = $config["webroot"] . "/verify.php?t=" . $verify_token;
|
||||||
require_once "../mail_templates.php";
|
require_once "../mail_templates.php";
|
||||||
$success = send_mail_pending_verification(
|
$success = send_mail_pending_verification(
|
||||||
$config["homeserver"], $first_name . " " . $last_name, $email, $verify_url);
|
$config["homeserver"],
|
||||||
|
$first_name . " " . $last_name,
|
||||||
|
$email,
|
||||||
|
$verify_url);
|
||||||
|
|
||||||
$mx_db->setRegistrationStateVerify(
|
$mx_db->setRegistrationStateVerify(
|
||||||
($success ? RegisterState::PendingEmailVerify : RegisterState::PendingEmailSend), $verify_token);
|
($success ? RegisterState::PendingEmailVerify : RegisterState::PendingEmailSend),
|
||||||
|
$verify_token);
|
||||||
|
|
||||||
print("<title>Erfolgreich</title>");
|
print("<title>Erfolgreich</title>");
|
||||||
print("</head><body>");
|
print("</head><body>");
|
||||||
print("<h1>Erfolgreich</h1>");
|
print("<h1>Erfolgreich</h1>");
|
||||||
print("<p>Bitte überprüfe deine E-Mails um deine E-Mail-Adresse zu bestätigen.</p>");
|
print("<p>Bitte überprüfe deine E-Mails um deine E-Mail-Adresse zu bestätigen.</p>");
|
||||||
print("<a href=\"" . $config["webroot"] . "/index.php" . "\">Zur Registrierungsseite</a>");
|
print("<a href=\"" . $config["webroot"] . "/index.php" . "\">Zur Registrierungsseite</a>");
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
print("<title>" . $language["REGISTRATION_REQUEST_FAILED"] . "</title>");
|
print("<title>" . $language["REGISTRATION_REQUEST_FAILED"] . "</title>");
|
||||||
print("</head><body>");
|
print("</head><body>");
|
||||||
print("<h1>" . $language["REGISTRATION_REQUEST_FAILED"] . "</h1>");
|
print("<h1>" . $language["REGISTRATION_REQUEST_FAILED"] . "</h1>");
|
||||||
if (isset($language[$e->getMessage()])) {
|
if (isset($language[$e->getMessage()])) {
|
||||||
print("<p>" . $language[$e->getMessage()] . "</p>");
|
print("<p>" . $language[$e->getMessage()] . "</p>");
|
||||||
} else {
|
} else {
|
||||||
print("<p>" . $e->getMessage() . "</p>");
|
print("<p>" . $e->getMessage() . "</p>");
|
||||||
}
|
}
|
||||||
print("<a href=\"" . $config["webroot"] . "/index.php" . "\">Zur Registrierungsseite</a>");
|
print("<a href=\"" . $config["webroot"] . "/index.php" . "\">Zur Registrierungsseite</a>");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$_SESSION["token"] = bin2hex(random_bytes(16));
|
$_SESSION["token"] = bin2hex(random_bytes(16));
|
||||||
?>
|
?>
|
||||||
<title>Registriere dich für <?php echo $config["homeserver"]; ?></title>
|
<title>Registriere dich für <?php echo $config["homeserver"]; ?></title>
|
||||||
<link href="//netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap.min.css" rel="stylesheet">
|
<link href="//netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap.min.css" rel="stylesheet">
|
||||||
<style>
|
<style>
|
||||||
body{
|
body{
|
||||||
background-color: #525252;
|
background-color: #525252;
|
||||||
}
|
}
|
||||||
.centered-form{
|
.centered-form{
|
||||||
margin-top: 60px;
|
margin-top: 60px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.centered-form .panel{
|
.centered-form .panel{
|
||||||
background: rgba(255, 255, 255, 0.8);
|
background: rgba(255, 255, 255, 0.8);
|
||||||
box-shadow: rgba(0, 0, 0, 0.3) 20px 20px 20px;
|
box-shadow: rgba(0, 0, 0, 0.3) 20px 20px 20px;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<script type="text/javascript" src="//code.jquery.com/jquery-1.11.1.min.js"></script>
|
<script type="text/javascript" src="//code.jquery.com/jquery-1.11.1.min.js"></script>
|
||||||
<script type="text/javascript" src="//netdna.bootstrapcdn.com/bootstrap/3.1.0/js/bootstrap.min.js"></script>
|
<script type="text/javascript" src="//netdna.bootstrapcdn.com/bootstrap/3.1.0/js/bootstrap.min.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="row centered-form">
|
<div class="row centered-form">
|
||||||
<div class="col-xs-12 col-sm-8 col-md-4 col-sm-offset-2 col-md-offset-4">
|
<div class="col-xs-12 col-sm-8 col-md-4 col-sm-offset-2 col-md-offset-4">
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<div class="panel-heading">
|
<div class="panel-heading">
|
||||||
<h3 class="panel-title">Bitte für <?php echo $config["homeserver"]; ?> registrieren<small>2-Schritt-Registrierung</small></h3>
|
<h3 class="panel-title">Bitte für <?php echo $config["homeserver"]; ?> registrieren<small>2-Schritt-Registrierung</small></h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<form name="regForm" role="form" action="index.php" method="post">
|
<form name="regForm" role="form" action="index.php" method="post">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-xs-6 col-sm-6 col-md-6">
|
<div class="col-xs-6 col-sm-6 col-md-6">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<input type="text" name="first_name" id="first_name" class="form-control input-sm"
|
<input type="text" name="first_name" id="first_name" class="form-control input-sm"
|
||||||
placeholder="Vorname" pattern="[A-Z][a-z]+">
|
placeholder="Vorname" pattern="[A-Z][a-z]+">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-xs-6 col-sm-6 col-md-6">
|
<div class="col-xs-6 col-sm-6 col-md-6">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<input type="text" name="last_name" id="last_name" class="form-control input-sm"
|
<input type="text" name="last_name" id="last_name" class="form-control input-sm"
|
||||||
placeholder="Nachname" pattern="[A-Z][a-z]+">
|
placeholder="Nachname" pattern="[A-Z][a-z]+">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<input type="email" name="email" id="email" class="form-control input-sm" placeholder="E-Mail-Adresse" required>
|
<input type="email" name="email" id="email" class="form-control input-sm" placeholder="E-Mail-Adresse" required>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<input type="text" name="note" id="note" class="form-control input-sm" placeholder="Notiz zu dir (max. 50 Zeichen)">
|
<input type="text" name="note" id="note" class="form-control input-sm" placeholder="Notiz zu dir (max. 50 Zeichen)">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<input type="text" name="username" id="username" class="form-control input-sm"
|
<input type="text" name="username" id="username" class="form-control input-sm"
|
||||||
placeholder="Nutzername (für den Login)" pattern="[a-z1-9]{3,20}" required>
|
placeholder="Nutzername (für den Login)" pattern="[a-z1-9]{3,20}" required>
|
||||||
</div>
|
</div>
|
||||||
<?php if (isset($config["getPasswordOnRegistration"]) && $config["getPasswordOnRegistration"]) { ?>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-xs-6 col-sm-6 col-md-6">
|
|
||||||
<div class="form-group">
|
|
||||||
<input type="password" name="password" id="password" class="form-control input-sm" placeholder="Passwort" required>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-xs-6 col-sm-6 col-md-6">
|
|
||||||
<div class="form-group">
|
|
||||||
<input type="password" name="password_confirm" id="password_confirm" class="form-control input-sm" placeholder="Passwort bestätigen" required>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<?php } ?>
|
|
||||||
<input type="hidden" name="token" id="token" value="<?php echo $_SESSION["token"]; ?>">
|
|
||||||
<input type="submit" value="Registrieren" class="btn btn-info btn-block">
|
|
||||||
|
|
||||||
</form>
|
|
||||||
<p>Hinweis: <br />
|
|
||||||
<?php echo $config["homeserver"]; ?> ist ein geschlossenes Chat-Netzwerk in dem jeder Nutzer bestätigt werden muss.<br />
|
|
||||||
Du bekommst eine E-Mail wenn jemand deine Mitgliedschaft bestätigt hat. An diese wird auch dein initiales Passwort gesendet.
|
|
||||||
Hinterlasse also bitte einen Hinweis zu dir (der nur den entsprechenden Personen gezeigt wird).<br />
|
|
||||||
Liebe Grüße vom Team von <?php echo $config["homeserver"]; ?>
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<script type="text/javascript">
|
|
||||||
var first_name = document.getElementById("first_name");
|
|
||||||
first_name.oninvalid = function (event) {
|
|
||||||
event.target.setCustomValidity("Vorname muss das Format <Großbuchstabe><Kleinbuchstaben> haben");
|
|
||||||
}
|
|
||||||
first_name.onkeyup = function (event) {
|
|
||||||
event.target.setCustomValidity("");
|
|
||||||
}
|
|
||||||
var last_name = document.getElementById("last_name");
|
|
||||||
last_name.oninvalid = function (event) {
|
|
||||||
event.target.setCustomValidity("Nachname muss das Format <Großbuchstabe><Kleinbuchstaben> haben");
|
|
||||||
}
|
|
||||||
last_name.onkeyup = function (event) {
|
|
||||||
event.target.setCustomValidity("");
|
|
||||||
}
|
|
||||||
var user_name = document.getElementById("username");
|
|
||||||
user_name.oninvalid = function (event) {
|
|
||||||
event.target.setCustomValidity("Nutzername darf zwischen 3 und 20 kleine Buchstaben und Zahlen enthalten");
|
|
||||||
}
|
|
||||||
user_name.onkeyup = function (event) {
|
|
||||||
event.target.setCustomValidity("");
|
|
||||||
}
|
|
||||||
<?php if (isset($config["getPasswordOnRegistration"]) && $config["getPasswordOnRegistration"]) { ?>
|
<?php if (isset($config["getPasswordOnRegistration"]) && $config["getPasswordOnRegistration"]) { ?>
|
||||||
var password = document.getElementById("password")
|
<div class="row">
|
||||||
, confirm_password = document.getElementById("password_confirm");
|
<div class="col-xs-6 col-sm-6 col-md-6">
|
||||||
function validatePassword() {
|
<div class="form-group">
|
||||||
if (password.value != confirm_password.value) {
|
<input type="password" name="password" id="password" class="form-control input-sm" placeholder="Passwort" required>
|
||||||
confirm_password.setCustomValidity("Passwörter stimmen nicht überein");
|
</div>
|
||||||
} else {
|
</div>
|
||||||
confirm_password.setCustomValidity('');
|
<div class="col-xs-6 col-sm-6 col-md-6">
|
||||||
}
|
<div class="form-group">
|
||||||
}
|
<input type="password" name="password_confirm" id="password_confirm" class="form-control input-sm" placeholder="Passwort bestätigen" required>
|
||||||
password.onchange = validatePassword;
|
</div>
|
||||||
confirm_password.onkeyup = validatePassword;
|
</div>
|
||||||
|
</div>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</script>
|
<input type="hidden" name="token" id="token" value="<?php echo $_SESSION["token"]; ?>">
|
||||||
<?php } ?>
|
<input type="submit" value="Registrieren" class="btn btn-info btn-block">
|
||||||
</body>
|
|
||||||
|
</form>
|
||||||
|
<p>Hinweis: <br />
|
||||||
|
<?php echo $config["homeserver"]; ?> ist ein geschlossenes Chat-Netzwerk in dem jeder Nutzer bestätigt werden muss.<br />
|
||||||
|
Du bekommst eine E-Mail wenn jemand deine Mitgliedschaft bestätigt hat. An diese wird auch dein initiales Passwort gesendet.
|
||||||
|
Hinterlasse also bitte einen Hinweis zu dir (der nur den entsprechenden Personen gezeigt wird).<br />
|
||||||
|
Liebe Grüße vom Team von <?php echo $config["homeserver"]; ?>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<script type="text/javascript">
|
||||||
|
var first_name = document.getElementById("first_name");
|
||||||
|
first_name.oninvalid = function(event) {
|
||||||
|
event.target.setCustomValidity("Vorname muss das Format <Großbuchstabe><Kleinbuchstaben> haben");
|
||||||
|
}
|
||||||
|
first_name.onkeyup = function(event) {
|
||||||
|
event.target.setCustomValidity("");
|
||||||
|
}
|
||||||
|
var last_name = document.getElementById("last_name");
|
||||||
|
last_name.oninvalid = function(event) {
|
||||||
|
event.target.setCustomValidity("Nachname muss das Format <Großbuchstabe><Kleinbuchstaben> haben");
|
||||||
|
}
|
||||||
|
last_name.onkeyup = function(event) {
|
||||||
|
event.target.setCustomValidity("");
|
||||||
|
}
|
||||||
|
var user_name = document.getElementById("username");
|
||||||
|
user_name.oninvalid = function(event) {
|
||||||
|
event.target.setCustomValidity("Nutzername darf zwischen 3 und 20 kleine Buchstaben und Zahlen enthalten");
|
||||||
|
}
|
||||||
|
user_name.onkeyup = function (event) {
|
||||||
|
event.target.setCustomValidity("");
|
||||||
|
}
|
||||||
|
<?php if (isset($config["getPasswordOnRegistration"]) && $config["getPasswordOnRegistration"]) { ?>
|
||||||
|
var password = document.getElementById("password")
|
||||||
|
, confirm_password = document.getElementById("password_confirm");
|
||||||
|
function validatePassword(){
|
||||||
|
if(password.value != confirm_password.value) {
|
||||||
|
confirm_password.setCustomValidity("Passwörter stimmen nicht überein");
|
||||||
|
} else {
|
||||||
|
confirm_password.setCustomValidity('');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
password.onchange = validatePassword;
|
||||||
|
confirm_password.onkeyup = validatePassword;
|
||||||
|
<?php } ?>
|
||||||
|
</script>
|
||||||
|
<?php } ?>
|
||||||
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -15,78 +15,79 @@
|
|||||||
*/
|
*/
|
||||||
require_once "../language.php";
|
require_once "../language.php";
|
||||||
if (!file_exists("../config.php")) {
|
if (!file_exists("../config.php")) {
|
||||||
print($language["NO_CONFIGURATION"]);
|
print($language["NO_CONFIGURATION"]);
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
require_once "../config.php";
|
require_once "../config.php";
|
||||||
require_once "../mail_templates.php";
|
require_once "../mail_templates.php";
|
||||||
|
|
||||||
// enforce admin via https
|
// enforce admin via https
|
||||||
if (!isset($_SERVER['HTTPS'])) {
|
if (!isset($_SERVER['HTTPS'])) {
|
||||||
header('Location: https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], true, 301);
|
header('Location: https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'], true, 301);
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if ($_SERVER["REQUEST_METHOD"] != "GET") {
|
if ($_SERVER["REQUEST_METHOD"] != "GET") {
|
||||||
throw new Exception("Method not allowed");
|
throw new Exception("Method not allowed");
|
||||||
}
|
}
|
||||||
if (!isset($_GET["t"])) {
|
if (!isset($_GET["t"])) {
|
||||||
throw new Exception("UNKNOWN_TOKEN");
|
throw new Exception("UNKNOWN_TOKEN");
|
||||||
}
|
}
|
||||||
$token = filter_var($_GET["t"], FILTER_SANITIZE_STRING);
|
$token = filter_var($_GET["t"], FILTER_SANITIZE_STRING);
|
||||||
|
|
||||||
require_once("../database.php");
|
require_once("../database.php");
|
||||||
|
|
||||||
$user = $mx_db->getUserForVerify($token);
|
$user = $mx_db->getUserForVerify($token);
|
||||||
if ($user == NULL) {
|
if ($user == NULL) {
|
||||||
throw new Exception("UNKNOWN_TOKEN");
|
throw new Exception("UNKNOWN_TOKEN");
|
||||||
}
|
}
|
||||||
$first_name = $user["first_name"];
|
$first_name = $user["first_name"];
|
||||||
$last_name = $user["last_name"];
|
$last_name = $user["last_name"];
|
||||||
$note = $user["note"];
|
$note = $user["note"];
|
||||||
$email = $user["email"];
|
$email = $user["email"];
|
||||||
$admin_token = $user["admin_token"];
|
$admin_token = $user["admin_token"];
|
||||||
|
|
||||||
require_once("../MatrixConnection.php");
|
require_once("../MatrixConnection.php");
|
||||||
$adminUrl = $config["webroot"] . "/verify_admin.php?t=" . $admin_token;
|
$adminUrl = $config["webroot"] . "/verify_admin.php?t=" . $admin_token;
|
||||||
$mxConn = new MatrixConnection($config["homeserver"], $config["access_token"]);
|
$mxConn = new MatrixConnection($config["homeserver"], $config["access_token"]);
|
||||||
$mxMsg = new MatrixMessage();
|
$mxMsg = new MatrixMessage();
|
||||||
$mxMsg->set_body($first_name . ' ' . $last_name . "möchte sich registrieren und hat folgende Notiz hinterlassen:\r\n"
|
$mxMsg->set_body($first_name . ' ' . $last_name . "möchte sich registrieren und hat folgende Notiz hinterlassen:\r\n"
|
||||||
. $note . "\r\n"
|
. $note . "\r\n"
|
||||||
. "Zum Bearbeiten hier klicken:\r\n" . $adminUrl);
|
. "Zum Bearbeiten hier klicken:\r\n" . $adminUrl);
|
||||||
$mxMsg->set_formatted_body($first_name . ' ' . $last_name . " möchte sich registrieren und hat folgende Notiz hinterlassen:<br />"
|
$mxMsg->set_formatted_body($first_name . ' ' . $last_name . " möchte sich registrieren und hat folgende Notiz hinterlassen:<br />"
|
||||||
. $note . "<br />"
|
. $note . "<br />"
|
||||||
. "Zum Bearbeiten <a href=\"" . $adminUrl . "\">hier</a> klicken");
|
. "Zum Bearbeiten <a href=\"". $adminUrl . "\">hier</a> klicken");
|
||||||
$mxMsg->set_type("m.text");
|
$mxMsg->set_type("m.text");
|
||||||
$response = $mxConn->send($config["register_room"], $mxMsg);
|
$response = $mxConn->send($config["register_room"], $mxMsg);
|
||||||
|
|
||||||
if ($response) {
|
if ($response) {
|
||||||
$message = $language["SEND_MATRIX_FAIL"];
|
$message = $language["SEND_MATRIX_FAIL"];
|
||||||
}
|
}
|
||||||
$mx_db->setRegistrationStateVerify(
|
$mx_db->setRegistrationStateVerify(
|
||||||
($response ? RegisterState::PendingAdminVerify : RegisterState::PendingAdminSend), $token);
|
($response ? RegisterState::PendingAdminVerify : RegisterState::PendingAdminSend),
|
||||||
|
$token);
|
||||||
|
|
||||||
send_mail_pending_approval($config["homeserver"], $first_name . " " . $last_name, $email);
|
send_mail_pending_approval($config["homeserver"], $first_name . " " . $last_name, $email);
|
||||||
|
|
||||||
print("<title>" . $language["VERIFICATION_SUCEEDED"] . "</title>");
|
print("<title>" . $language["VERIFICATION_SUCEEDED"] . "</title>");
|
||||||
print("</head><body>");
|
print("</head><body>");
|
||||||
print("<h1>" . $language["VERIFICATION_SUCEEDED"] . "</h1>");
|
print("<h1>" . $language["VERIFICATION_SUCEEDED"] . "</h1>");
|
||||||
print("<p>" . $language["VERIFICATION_SUCCESS_BODY"] . "</p>");
|
print("<p>" . $language["VERIFICATION_SUCCESS_BODY"] . "</p>");
|
||||||
print("<a href=\"" . $config["webroot"] . "/index.php" . "\">Zur Registrierungsseite</a>");
|
print("<a href=\"" . $config["webroot"] . "/index.php" . "\">Zur Registrierungsseite</a>");
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
print("<title>" . $language["VERIFICATION_FAILED"] . "</title>");
|
print("<title>" . $language["VERIFICATION_FAILED"] . "</title>");
|
||||||
print("</head><body>");
|
print("</head><body>");
|
||||||
print("<h1>" . $language["VERIFICATION_FAILED"] . "</h1>");
|
print("<h1>" . $language["VERIFICATION_FAILED"] . "</h1>");
|
||||||
if (isset($language[$e->getMessage()])) {
|
if (isset($language[$e->getMessage()])) {
|
||||||
print("<p>" . $language[$e->getMessage()] . "</p>");
|
print("<p>" . $language[$e->getMessage()] . "</p>");
|
||||||
} else {
|
} else {
|
||||||
print("<p>" . $e->getMessage() . "</p>");
|
print("<p>" . $e->getMessage() . "</p>");
|
||||||
}
|
}
|
||||||
print("<a href=\"" . $config["webroot"] . "/index.php" . "\">Zur Registrierungsseite</a>");
|
print("<a href=\"" . $config["webroot"] . "/index.php" . "\">Zur Registrierungsseite</a>");
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -15,170 +15,170 @@
|
|||||||
*/
|
*/
|
||||||
require_once "../language.php";
|
require_once "../language.php";
|
||||||
if (!file_exists("../config.php")) {
|
if (!file_exists("../config.php")) {
|
||||||
print($language["NO_CONFIGURATION"]);
|
print($language["NO_CONFIGURATION"]);
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
require_once "../config.php";
|
require_once "../config.php";
|
||||||
require_once "../mail_templates.php";
|
require_once "../mail_templates.php";
|
||||||
|
|
||||||
// enforce admin via https
|
// enforce admin via https
|
||||||
if (!isset($_SERVER['HTTPS'])) {
|
if (!isset($_SERVER['HTTPS'])) {
|
||||||
header('Location: https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], true, 301);
|
header('Location: https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'], true, 301);
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if ($_SERVER["REQUEST_METHOD"] != "GET") {
|
if ($_SERVER["REQUEST_METHOD"] != "GET") {
|
||||||
throw new Exception("Method not allowed");
|
throw new Exception("Method not allowed");
|
||||||
}
|
}
|
||||||
if (!isset($_GET["t"])) {
|
if (!isset($_GET["t"])) {
|
||||||
throw new Exception("UNKNOWN_TOKEN");
|
throw new Exception("UNKNOWN_TOKEN");
|
||||||
}
|
}
|
||||||
$token = filter_var($_GET["t"], FILTER_SANITIZE_STRING);
|
$token = filter_var($_GET["t"], FILTER_SANITIZE_STRING);
|
||||||
|
|
||||||
require_once("../database.php");
|
require_once("../database.php");
|
||||||
|
|
||||||
$action = NULL;
|
$action = NULL;
|
||||||
if (isset($_GET["allow"])) {
|
if (isset($_GET["allow"])) {
|
||||||
$action = RegisterState::RegistrationAccepted;
|
$action = RegisterState::RegistrationAccepted;
|
||||||
}
|
}
|
||||||
$decline_reason = NULL;
|
$decline_reason = NULL;
|
||||||
if (isset($_GET["deny"])) {
|
if (isset($_GET["deny"])) {
|
||||||
$action = RegisterState::RegistrationDeclined;
|
$action = RegisterState::RegistrationDeclined;
|
||||||
if (isset($_GET["reason"])) {
|
if (isset($_GET["reason"])) {
|
||||||
$decline_reason = filter_var($_GET["reason"], FILTER_SANITIZE_STRING);
|
$decline_reason = filter_var($_GET["reason"], FILTER_SANITIZE_STRING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$user = $mx_db->getUserForApproval($token);
|
$user = $mx_db->getUserForApproval($token);
|
||||||
if ($user == NULL) {
|
if ($user == NULL) {
|
||||||
throw new Exception("UNKNOWN_TOKEN");
|
throw new Exception("UNKNOWN_TOKEN");
|
||||||
}
|
}
|
||||||
|
|
||||||
$first_name = $user["first_name"];
|
$first_name = $user["first_name"];
|
||||||
$last_name = $user["last_name"];
|
$last_name = $user["last_name"];
|
||||||
$username = $user["username"];
|
$username = $user["username"];
|
||||||
$note = $user["note"];
|
$note = $user["note"];
|
||||||
$email = $user["email"];
|
$email = $user["email"];
|
||||||
|
|
||||||
if ($action == RegisterState::RegistrationAccepted) {
|
if ($action == RegisterState::RegistrationAccepted) {
|
||||||
$mx_db->setRegistrationStateAdmin(RegisterState::PendingRegistration, $token);
|
$mx_db->setRegistrationStateAdmin(RegisterState::PendingRegistration, $token);
|
||||||
|
|
||||||
// register user
|
// register user
|
||||||
require_once("../MatrixConnection.php");
|
require_once("../MatrixConnection.php");
|
||||||
$mxConn = new MatrixConnection($config["homeserver"], $config["access_token"]);
|
$mxConn = new MatrixConnection($config["homeserver"], $config["access_token"]);
|
||||||
|
|
||||||
// generate a password with 8 characters
|
// generate a password with 8 characters
|
||||||
$password = $mx_db->addUser($first_name, $last_name, $username, $email);
|
$password = $mx_db->addUser($first_name, $last_name, $username, $email);
|
||||||
if ($password != NULL) {
|
if ($password != NULL) {
|
||||||
// send registration_success
|
// send registration_success
|
||||||
$res = send_mail_registration_success($config["homeserver"], $first_name . " " . $last_name, $email, $username, $password, $config["howToURL"]);
|
$res = send_mail_registration_success($config["homeserver"], $first_name . " " . $last_name, $email, $username, $password, $config["howToURL"]);
|
||||||
if ($res) {
|
if ($res) {
|
||||||
$mx_db->setRegistrationStateAdmin(RegisterState::AllDone, $token);
|
$mx_db->setRegistrationStateAdmin(RegisterState::AllDone, $token);
|
||||||
} else {
|
} else {
|
||||||
$mx_db->setRegistrationStateAdmin(RegisterState::PendingSendRegistrationMail, $token);
|
$mx_db->setRegistrationStateAdmin(RegisterState::PendingSendRegistrationMail, $token);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
send_mail_registration_allowed_but_failed($config["homeserver"], $first_name . " " . $last_name, $email);
|
send_mail_registration_allowed_but_failed($config["homeserver"], $first_name . " " . $last_name, $email);
|
||||||
$mxMsg = new MatrixMessage();
|
$mxMsg = new MatrixMessage();
|
||||||
$mxMsg->set_type("m.text");
|
$mxMsg->set_type("m.text");
|
||||||
$mxMsg->set_body("Fehler beim Registrieren von " . $first_name . " " . $last_name . ".");
|
$mxMsg->set_body("Fehler beim Registrieren von " . $first_name . " " . $last_name . ".");
|
||||||
$mxConn->send($config["register_room"], $mxMsg);
|
$mxConn->send($config["register_room"], $mxMsg);
|
||||||
throw new Exception("REGISTRATION_FAILED");
|
throw new Exception("REGISTRATION_FAILED");
|
||||||
}
|
}
|
||||||
|
|
||||||
print("<title>" . $language["ADMIN_VERIFY_SITE_TITLE"] . "</title>");
|
print("<title>" . $language["ADMIN_VERIFY_SITE_TITLE"] . "</title>");
|
||||||
print("</head><body>");
|
print("</head><body>");
|
||||||
print("<h1>" . $language["ADMIN_VERIFY_SITE_TITLE"] . "</h1>");
|
print("<h1>" . $language["ADMIN_VERIFY_SITE_TITLE"] . "</h1>");
|
||||||
print("<p>" . $language["ADMIN_REGISTER_ACCEPTED_BODY"] . "</p>");
|
print("<p>" . $language["ADMIN_REGISTER_ACCEPTED_BODY"] . "</p>");
|
||||||
} elseif ($action == RegisterState::RegistrationDeclined) {
|
} elseif ($action == RegisterState::RegistrationDeclined) {
|
||||||
$mx_db->setRegistrationStateAdmin(RegisterState::RegistrationDeclined, $token);
|
$mx_db->setRegistrationStateAdmin(RegisterState::RegistrationDeclined, $token);
|
||||||
send_mail_registration_decline($config["homeserver"], $first_name . " " . $last_name, $email, $decline_reason);
|
send_mail_registration_decline($config["homeserver"], $first_name . " " . $last_name, $email, $decline_reason);
|
||||||
print("<title>" . $language["ADMIN_VERIFY_SITE_TITLE"] . "</title>");
|
print("<title>" . $language["ADMIN_VERIFY_SITE_TITLE"] . "</title>");
|
||||||
print("</head><body>");
|
print("</head><body>");
|
||||||
print("<h1>" . $language["ADMIN_VERIFY_SITE_TITLE"] . "</h1>");
|
print("<h1>" . $language["ADMIN_VERIFY_SITE_TITLE"] . "</h1>");
|
||||||
print("<p>" . $language["ADMIN_REGISTER_DECLINED_BODY"] . "</p>");
|
print("<p>" . $language["ADMIN_REGISTER_DECLINED_BODY"] . "</p>");
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
print("<title>" . $language["ADMIN_VERIFY_SITE_TITLE"] . "</title>");
|
print("<title>" . $language["ADMIN_VERIFY_SITE_TITLE"] . "</title>");
|
||||||
?>
|
?>
|
||||||
<link href="//netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap.min.css" rel="stylesheet">
|
<link href="//netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap.min.css" rel="stylesheet">
|
||||||
<style>
|
<style>
|
||||||
body{
|
body{
|
||||||
background-color: #525252;
|
background-color: #525252;
|
||||||
}
|
}
|
||||||
.centered-form{
|
.centered-form{
|
||||||
margin-top: 60px;
|
margin-top: 60px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.centered-form .panel{
|
.centered-form .panel{
|
||||||
background: rgba(255, 255, 255, 0.8);
|
background: rgba(255, 255, 255, 0.8);
|
||||||
box-shadow: rgba(0, 0, 0, 0.3) 20px 20px 20px;
|
box-shadow: rgba(0, 0, 0, 0.3) 20px 20px 20px;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<script type="text/javascript" src="//code.jquery.com/jquery-1.11.1.min.js"></script>
|
<script type="text/javascript" src="//code.jquery.com/jquery-1.11.1.min.js"></script>
|
||||||
<script type="text/javascript" src="//netdna.bootstrapcdn.com/bootstrap/3.1.0/js/bootstrap.min.js"></script>
|
<script type="text/javascript" src="//netdna.bootstrapcdn.com/bootstrap/3.1.0/js/bootstrap.min.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="row centered-form">
|
<div class="row centered-form">
|
||||||
<div class="col-xs-12 col-sm-8 col-md-4 col-sm-offset-2 col-md-offset-4">
|
<div class="col-xs-12 col-sm-8 col-md-4 col-sm-offset-2 col-md-offset-4">
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<div class="panel-heading">
|
<div class="panel-heading">
|
||||||
<h3 class="panel-title"><?php echo $language["ADMIN_VERIFY_SITE_TITLE"]; ?></h3>
|
<h3 class="panel-title"><?php echo $language["ADMIN_VERIFY_SITE_TITLE"] ; ?></h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<form name="appForm" role="form" action="verify_admin.php" method="GET">
|
<form name="appForm" role="form" action="verify_admin.php" method="GET">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-xs-6 col-sm-6 col-md-6">
|
<div class="col-xs-6 col-sm-6 col-md-6">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<input type="text" id="first_name" class="form-control input-sm"
|
<input type="text" id="first_name" class="form-control input-sm"
|
||||||
value="<?php echo $first_name; ?>" disabled=true>
|
value="<?php echo $first_name; ?>" disabled=true>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-xs-6 col-sm-6 col-md-6">
|
<div class="col-xs-6 col-sm-6 col-md-6">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<input type="text" id="last_name" class="form-control input-sm"
|
<input type="text" id="last_name" class="form-control input-sm"
|
||||||
value="<?php echo $last_name; ?>" disabled=true>
|
value="<?php echo $last_name; ?>" disabled=true>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<input type="text" id="note" class="form-control input-sm" value="<?php echo $note; ?>" disabled=true>
|
<input type="text" id="note" class="form-control input-sm" value="<?php echo $note; ?>" disabled=true>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<input type="text" id="username" class="form-control input-sm"
|
<input type="text" id="username" class="form-control input-sm"
|
||||||
value="<?php echo $username; ?>" disabled=true>
|
value="<?php echo $username; ?>" disabled=true>
|
||||||
</div>
|
</div>
|
||||||
<input type="hidden" name="t" id="token" value="<?php echo $token; ?>">
|
<input type="hidden" name="t" id="token" value="<?php echo $token; ?>">
|
||||||
<input type="submit" name="allow" value="Bestätigen" class="btn btn-info btn-block">
|
<input type="submit" name="allow" value="Bestätigen" class="btn btn-info btn-block">
|
||||||
<input type="submit" name="deny" value="Ablehnen" class="btn btn-info btn-block">
|
<input type="submit" name="deny" value="Ablehnen" class="btn btn-info btn-block">
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
} // else - no action provided
|
} // else - no action provided
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
print("<title>" . $language["REGISTRATION_FAILED"] . "</title>");
|
print("<title>" . $language["REGISTRATION_FAILED"] . "</title>");
|
||||||
print("</head><body>");
|
print("</head><body>");
|
||||||
print("<h1>" . $language["REGISTRATION_FAILED"] . "</h1>");
|
print("<h1>" . $language["REGISTRATION_FAILED"] . "</h1>");
|
||||||
if (isset($language[$e->getMessage()])) {
|
if (isset($language[$e->getMessage()])) {
|
||||||
print("<p>" . $language[$e->getMessage()] . "</p>");
|
print("<p>" . $language[$e->getMessage()] . "</p>");
|
||||||
} else {
|
} else {
|
||||||
print("<p>" . $e->getMessage() . "</p>");
|
print("<p>" . $e->getMessage() . "</p>");
|
||||||
}
|
}
|
||||||
print("<a href=\"" . $config["webroot"] . "/index.php" . "\">Zur Registrierungsseite</a>");
|
print("<a href=\"" . $config["webroot"] . "/index.php" . "\">Zur Registrierungsseite</a>");
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
< /body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user