1
0
Fork 0

Add user-friendly invite code error messages

master release/1.3.1
Anonymous Contributor 2023-08-23 18:16:36 +02:00
parent bfeb4f5eef
commit 9a5182816f
1 changed files with 15 additions and 6 deletions

View File

@ -15,18 +15,28 @@
die(); die();
} }
if(!isset($_REQUEST['code'])) function displayError(string $message) {
die("MISSING INVITE CODE!"); $HTML = new HTML();
$HTML->importHTML("error.html");
$HTML->ReplaceLayoutInhalt("%%MESSAGE%%", $message);
$HTML->build();
echo $HTML->ausgabe();
die();
}
if(!isset($_REQUEST['code'])) {
displayError("Du benötigst einen Einladungscode, um dich bei 4Creative zu registrieren.");
}
if(strlen($_REQUEST['code']) != 32 || !preg_match('/^[a-f0-9]+$/', $_REQUEST['code'])) { if(strlen($_REQUEST['code']) != 32 || !preg_match('/^[a-f0-9]+$/', $_REQUEST['code'])) {
die("INVALID INVITE CODE!"); displayError("Der angegebene Einladungscode ist nicht gültig. Nutze genau den Link, der dir zugeschickt wurde.");
} }
$statementInviteCode = $RUNTIME['PDO']->prepare("SELECT 1 FROM InviteCodes WHERE InviteCode = ? LIMIT 1"); $statementInviteCode = $RUNTIME['PDO']->prepare("SELECT 1 FROM InviteCodes WHERE InviteCode = ? LIMIT 1");
$statementInviteCode->execute([$_REQUEST['code']]); $statementInviteCode->execute([$_REQUEST['code']]);
if($statementInviteCode->rowCount() == 0) { if($statementInviteCode->rowCount() == 0) {
die("INVALID INVITE CODE!"); displayError("Der angegebene Einladungscode ist nicht gültig. Nutze genau den Link, der dir zugeschickt wurde.");
} }
if($_SERVER['REQUEST_METHOD'] != 'POST') { if($_SERVER['REQUEST_METHOD'] != 'POST') {
@ -95,8 +105,7 @@
$statementInviteDeleter = $RUNTIME['PDO']->prepare('DELETE FROM InviteCodes WHERE InviteCode = :code'); $statementInviteDeleter = $RUNTIME['PDO']->prepare('DELETE FROM InviteCodes WHERE InviteCode = :code');
$statementInviteDeleter->execute(['code' => $_REQUEST['code']]); $statementInviteDeleter->execute(['code' => $_REQUEST['code']]);
if($statementInviteDeleter->rowCount() == 0) { if($statementInviteDeleter->rowCount() == 0) {
header('Location: index.php'); displayError("Der angegebene Einladungscode ist nicht mehr gültig.");
die();
} }
try { try {