Passwort Verschlüsslung im eigenen Login Formular
Verfasst: 09.12.2010 13:32
Morgen, ich sitze jetzt seit 1 Woche an meinen Problem und komme einfach nicht weiter...
Ich habe jetzt schon so viel über die PHPbb Passwort Verschlüsslung gelesen und habe immer noch keine Ahnung wie ich die Verschlüsselung ein mein Loginformular einbaue.
Ich will einfach nur überprüfen ob das eingegebene Passwort mit dem gespeicherten übereinstimmt.
Ich habe immer wieder gelesen das diese Codefragmente aus der functions.php erklären wie es geht
Hier der code von meiner Loginseite:
Diese Frage wurde auch schon mal hier
viewtopic.php?f=93&t=156897 und hier
http://www.phpbb.com/community/viewtopi ... &t=2109105 gestellt ,
aber werd einfach nicht schlau daraus... Ich bitte um einen Denkanstoß
Ich habe jetzt schon so viel über die PHPbb Passwort Verschlüsslung gelesen und habe immer noch keine Ahnung wie ich die Verschlüsselung ein mein Loginformular einbaue.
Ich will einfach nur überprüfen ob das eingegebene Passwort mit dem gespeicherten übereinstimmt.
Ich habe immer wieder gelesen das diese Codefragmente aus der functions.php erklären wie es geht
Code: Alles auswählen
<?php
/**
* Hash the password
*/
function phpbb_hash($password)
{
$itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
$random_state = unique_id();
$random = '';
$count = 6;
if (($fh = @fopen('/dev/urandom', 'rb')))
{
$random = fread($fh, $count);
fclose($fh);
}
if (strlen($random) < $count)
{
$random = '';
for ($i = 0; $i < $count; $i += 16)
{
$random_state = md5(unique_id() . $random_state);
$random .= pack('H*', md5($random_state));
}
$random = substr($random, 0, $count);
}
$hash = _hash_crypt_private($password, _hash_gensalt_private($random, $itoa64), $itoa64);
if (strlen($hash) == 34)
{
return $hash;
}
return md5($password);
}
/**
* Check for correct password
*
* @param string $password The password in plain text
* @param string $hash The stored password hash
*
* @return bool Returns true if the password is correct, false if not.
*/
function phpbb_check_hash($password, $hash)
{
$itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
if (strlen($hash) == 34)
{
return (_hash_crypt_private($password, $hash, $itoa64) === $hash) ? true : false;
}
return (md5($password) === $hash) ? true : false;
}
?>
Hier der code von meiner Loginseite:
Code: Alles auswählen
<?php require_once('Connections/dbconnect.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
?>
<?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
session_start();
}
$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
$_SESSION['PrevUrl'] = $_GET['accesscheck'];
}
if (isset($_POST['benutzer'])) {
$loginUsername= strtolower($_POST['benutzer']);
$password=$_POST['Kennwort'];
$MM_fldUserAuthorization = "group_id";
$MM_redirectLoginSuccess = "selection.php";
$MM_redirectLoginFailed = "login.php";
$MM_redirecttoReferrer = false;
mysql_select_db($database_dbconnect, $dbconnect);
$LoginRS__query=sprintf("SELECT username_clean, user_password, group_id FROM phpbb_users WHERE username_clean=%s AND user_password=%s",
GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
$LoginRS = mysql_query($LoginRS__query, $dbconnect) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = mysql_result($LoginRS,0,'group_id');
if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
//declare two session variables and assign them
$_SESSION['MM_Username'] = $loginUsername;
$_SESSION['MM_UserGroup'] = $loginStrGroup;
if (isset($_SESSION['PrevUrl']) && false) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
header("Location: " . $MM_redirectLoginSuccess );
}
else {
header("Location: ". $MM_redirectLoginFailed );
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Unbenanntes Dokument</title>
</head>
<body>
<table border="1" align="center">
<tr>
<th>Login</th>
</tr>
<tr>
<td>
<form ACTION="<?php echo $loginFormAction; ?>" id="loginform" name="loginform" method="POST">
<table>
<tr>
<td>Benutzername: </td>
<td><input name="benutzer" type="text" id="benutzer" size="20" maxlength="20" /></td>
<td> </td>
</tr>
<tr>
<td>Passwort: </td>
<td><input name="Kennwort" type="text" id="Kennwort" size="20" maxlength="20" /></td>
<td><input type="submit" name="button" id="button" value="Senden" /></td>
</tr>
</table>
</form>
</td>
</tr>
<tr>
<td> </td>
</tr>
</table>
</body>
</html>
Diese Frage wurde auch schon mal hier
viewtopic.php?f=93&t=156897 und hier
http://www.phpbb.com/community/viewtopi ... &t=2109105 gestellt ,
aber werd einfach nicht schlau daraus... Ich bitte um einen Denkanstoß
