Merge branch 'fix_language_ref' of into master

This commit is contained in:
Matthias
2018-03-19 14:48:48 +01:00
committed by Gitea
4 changed files with 31 additions and 21 deletions

View File

@@ -172,12 +172,10 @@ class mxDatabase
*/
function addRegistration($first_name, $last_name, $username, $note, $email) {
if ($this->userPendingRegistrations($username)) {
require_once("language.php");
throw new Exception($language["USERNAME_PENDING_REGISTRATION"]." (requested)");
throw new Exception("USERNAME_PENDING_REGISTRATION");
}
if ($this->userRegistered($username)) {
require_once("language.php");
throw new Exception($language["USERNAME_REGISTERED"] . " (registered)");
throw new Exception("USERNAME_REGISTERED");
}
$verify_token = bin2hex(random_bytes(16));

View File

@@ -20,32 +20,32 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
try {
if (!isset($_SESSION["token"]) || !isset($_POST["token"]) || $_SESSION["token"] != $_POST["token"]) {
// token not present or invalid
throw new Exception($language["UNKNOWN_SESSION"]);
throw new Exception("UNKNOWN_SESSION");
}
if (!isset($_POST["username"])) {
throw new Exception($language["UNKNOWN_USERNAME"]);
throw new Exception("UNKNOWN_USERNAME");
}
if (strlen($_POST["username"] > 20 || strlen($_POST["username"]) < 3)) {
throw new Exception($language["USERNAME_LENGTH_INVALID"]);
throw new Exception("USERNAME_LENGTH_INVALID");
}
if (ctype_alnum($_POST['username']) != true) {
throw new Exception($language["USERNAME_NOT_ALNUM"]);
throw new Exception("USERNAME_NOT_ALNUM");
}
if (isset($config["getPasswordOnRegistration"]) && $config["getPasswordOnRegistration"] &&
$_POST["password"] != $_POST["password_confirm"]) {
throw new Exception($language["PASSWORD_NOT_MATCH"]);
throw new Exception("PASSWORD_NOT_MATCH");
}
if (isset($_POST["note"]) && strlen($_POST["note"]) > 50) {
throw new Exception($language["NOTE_LENGTH_EXEEDED"]);
throw new Exception("NOTE_LENGTH_EXEEDED");
}
if (!isset($_POST["email"]) || !filter_var($_POST["email"], FILTER_VALIDATE_EMAIL)) {
throw new Exception($language["EMAIL_INVALID_FORMAT"]);
throw new Exception("EMAIL_INVALID_FORMAT");
}
if (isset($_POST["first_name"]) && ! preg_match("/[A-Z][a-z]+/", $_POST["first_name"])) {
throw new Exception($language["FIRSTNAME_INVALID_FORMAT"]);
throw new Exception("FIRSTNAME_INVALID_FORMAT");
}
if (isset($_POST["last_name"]) && ! preg_match("/[A-Z][a-z]+/", $_POST["last_name"])) {
throw new Exception($language["SIRNAME_INVALID_FORMAT"]);
throw new Exception("SIRNAME_INVALID_FORMAT");
}
$first_name = filter_var($_POST["first_name"], FILTER_SANITIZE_STRING);
@@ -87,7 +87,11 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
print("<title>" . $language["REGISTRATION_REQUEST_FAILED"] . "</title>");
print("</head><body>");
print("<h1>" . $language["REGISTRATION_REQUEST_FAILED"] . "</h1>");
print("<p>" . $e->getMessage() . "</p>");
if (isset($language[$e->getMessage()])) {
print("<p>" . $language[$e->getMessage()] . "</p>");
} else {
print("<p>" . $e->getMessage() . "</p>");
}
print("<a href=\"" . $config["webroot"] . "/index.php" . "\">Zur Registrierungsseite</a>");
}
} else {

View File

@@ -22,7 +22,7 @@ try {
throw new Exception("Method not allowed");
}
if (!isset($_GET["t"])) {
throw new Exception($language["UNKNOWN_TOKEN"]);
throw new Exception("UNKNOWN_TOKEN");
}
$token = filter_var($_GET["t"], FILTER_SANITIZE_STRING);
@@ -30,7 +30,7 @@ try {
$user = $mx_db->getUserForVerify($token);
if ($user == NULL) {
throw new Exception($language["UNKNOWN_TOKEN"]);
throw new Exception("UNKNOWN_TOKEN");
}
$first_name = $user["first_name"];
$last_name = $user["last_name"];
@@ -69,7 +69,11 @@ try {
print("<title>" . $language["VERIFICATION_FAILED"] . "</title>");
print("</head><body>");
print("<h1>" . $language["VERIFICATION_FAILED"] . "</h1>");
print("<p>" . $e->getMessage() . "</p>");
if (isset($language[$e->getMessage()])) {
print("<p>" . $language[$e->getMessage()] . "</p>");
} else {
print("<p>" . $e->getMessage() . "</p>");
}
print("<a href=\"" . $config["webroot"] . "/index.php" . "\">Zur Registrierungsseite</a>");
}
?>

View File

@@ -22,7 +22,7 @@ try {
throw new Exception("Method not allowed");
}
if (!isset($_GET["t"])) {
throw new Exception($language["UNKNOWN_TOKEN"]);
throw new Exception("UNKNOWN_TOKEN");
}
$token = filter_var($_GET["t"], FILTER_SANITIZE_STRING);
@@ -42,7 +42,7 @@ try {
$user = $mx_db->getUserForApproval($token);
if ($user == NULL) {
throw new Exception($language["UNKNOWN_TOKEN"]);
throw new Exception("UNKNOWN_TOKEN");
}
$first_name = $user["first_name"];
@@ -74,7 +74,7 @@ try {
$mxMsg->set_type("m.text");
$mxMsg->set_body("Fehler beim Registrieren von " . $first_name . " " . $last_name . ".");
$mxConn->send($config["register_room"], $mxMsg);
throw new Exception($language["REGISTRATION_FAILED"]);
throw new Exception("REGISTRATION_FAILED");
}
print("<title>" . $language["ADMIN_VERIFY_SITE_TITLE"] . "</title>");
@@ -160,7 +160,11 @@ background: rgba(255, 255, 255, 0.8);
print("<title>" . $language["REGISTRATION_FAILED"] . "</title>");
print("</head><body>");
print("<h1>" . $language["REGISTRATION_FAILED"] . "</h1>");
print("<p>" . $e->getMessage() . "</p>");
if (isset($language[$e->getMessage()])) {
print("<p>" . $language[$e->getMessage()] . "</p>");
} else {
print("<p>" . $e->getMessage() . "</p>");
}
print("<a href=\"" . $config["webroot"] . "/index.php" . "\">Zur Registrierungsseite</a>");
}
?>