107 lines
3.7 KiB
PHP
107 lines
3.7 KiB
PHP
<?php
|
|
|
|
// Zuvor einegebenes Passwort und Code werden geholt
|
|
$code = htmlentities(substr($_POST["code"], 0, 30));
|
|
$password = htmlentities(substr($_POST["password"], 0, 256));
|
|
|
|
// Passwort wird gehasht
|
|
$password = hash('sha512',$password);
|
|
|
|
// Seite mit der fortgefahren werden soll wird geholt
|
|
$verify_identity = $_SESSION["verify-identity"];
|
|
|
|
// E-Mail wird geholt
|
|
$sql = "SELECT
|
|
*
|
|
FROM
|
|
`VokabelBox2Users`
|
|
WHERE
|
|
`userid` = '$userid'";
|
|
$result_articles = $conn->query($sql);
|
|
while ($articleDb = mysqli_fetch_object($result_articles))
|
|
{
|
|
$email = $articleDb->email;
|
|
}
|
|
|
|
// Code (der Seite "verify") wird überprüft
|
|
if($code != $_SESSION["verify-code"]) {
|
|
$_SESSION["verify-codeFails"] = $_SESSION["verify-codeFails"] + 1;
|
|
|
|
// Wenn öfter als drei Mal falsch eingegeben
|
|
if($_SESSION["verify-codeFails"] >= 3) {
|
|
echo "codeFailsLimit";
|
|
|
|
// Neuer Code, usw...
|
|
$code = '';
|
|
$string = "0123456789";
|
|
for ($i = 1; $i <= 4; $i++)
|
|
{
|
|
$zufallszahl = rand(0, 9);
|
|
$zufallszahl = substr($string, $zufallszahl, 1);
|
|
$code = $code . $zufallszahl;
|
|
}
|
|
|
|
// Neuer Code wird als Session gesetzt
|
|
$_SESSION["verify-code"] = $code;
|
|
// Anzahl d. Fehlversuche wird zurückgesetzt
|
|
$_SESSION["verify-codeFails"] = 0;
|
|
|
|
$betreff = "Kontosicherheit Ihrer VokSpace";
|
|
$from = "VokSpace";
|
|
$text = '
|
|
<html">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
|
<title>Bitte bestätigen Sie Ihr Konto</title>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
|
</head>
|
|
<body style="background-color: #3d434b;padding: 20px;">
|
|
<div style="margin-top: 50px;position:relative;overflow:hidden;background-color: #212529;border-radius: 30px;">
|
|
<div style="width: 50px;float:right;display:block;background-color: rgba(249,130,72,1);height:200px">
|
|
</div>
|
|
<div style="width: auto;float:left;display:block;padding:20px">
|
|
<h2 style="font-family: Arial;color:#fff;margin: 5px 0;font-size:40px">Ihr neuer Code: ' . $code . '</h2>
|
|
<h5 style="font-family: Arial;color:#fff;margin: 5px 0;font-size:15px">Die Bestätigung Ihrer Identität ist erforderlich, um sicherheitsrelevante Informationen Ihrer Kontos zu ändern.<br>Wenn Ihnen diese Aktivität nicht bekannt vorkommt, ändern Sie bitte SOFORT Ihr Passwort, um Ihr Konto zu schützen.</h5>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html>';
|
|
|
|
$header = "MIME-Version: 1.0\r\n";
|
|
$header .= "Content-type: text/html; charset=utf-8\r\n";
|
|
|
|
$header .= "From: VokSpace\r\n";
|
|
$header .= "Reply-To: tim@timvandenboom.de\r\n";
|
|
// $header .= "Cc: $cc\r\n"; // falls an CC gesendet werden soll
|
|
$header .= "X-Mailer: PHP ". phpversion();
|
|
|
|
mail($email, $betreff, $text, $header);
|
|
|
|
|
|
}
|
|
else {
|
|
echo "wrongCode";
|
|
}
|
|
die();
|
|
}
|
|
|
|
// Überprüfung des Passworts
|
|
$sql = "SELECT * FROM `VokabelBox2Users` WHERE `userid` = '$userid' AND `password` = '$password'";
|
|
$result_articles = $conn->query($sql);
|
|
if(!mysqli_num_rows($result_articles))
|
|
{
|
|
print("wrongPassword");
|
|
die();
|
|
}
|
|
|
|
// Nutzereingaben werden ebenfalls als Session gespeichert. Das ist enorm wichtig, da sonst Seiten übersprungen werden können.
|
|
// Im letzen Schritt werden alle Nutzer-Sessions noch einmal mit den tatsächlichen Sessions abgeglichen.
|
|
$_SESSION["verify-password-user"] = $password;
|
|
$_SESSION["verify-code-user"] = $code;
|
|
|
|
// Gib aus, mit welcher Seite JS forfahren soll
|
|
print($verify_identity);
|
|
|
|
|
|
?>
|