0 Replies - 189 Views - Last Post: 21 April 2013 - 05:59 PM Rate Topic: -----

#1 Logik22  Icon User is offline

  • D.I.C Head

Reputation: 9
  • View blog
  • Posts: 163
  • Joined: 12-December 11

How do you sync web login with PHPBB3 forums? (hashing trouble)

Posted 21 April 2013 - 05:59 PM

I'd like to have the web page login be the same as the PHPBB3 forums. The problem I'm running in to is I'm unable to hash it. Sorry if my code is a little messy, I've been playing in to several methods to try to get around this so some stuff is commented out. With this code when I hit submit it reloads the page but it's blank. Can someone point me in the right direction?

 <?php
 // Connects to your Database 
$con = mysql_connect("IP","username","pass");
if (!$con)
 {
 die('Could not connect: ' . mysql_error());
echo "Can't connect to DB";
 }
mysql_select_db("moosestats", $con);

//Stuff to try to make this a PHPBB page *********************

define('IN_PHPBB', true);
/*include('includes/functions.php');
//include('common.php');
//include('startup.php'); 

$password = $_POST['pass'];

$hash = phpbb_hash($password);

echo($hash); 

if (phpbb_check_hash($password, $hash))
{
   echo(' => $password matches $hash');
}
*/
//End PHPBB Stuff****************

 //Checks if there is a login cookie

 if(isset($_COOKIE['ID_my_site']))


 //if there is, it logs you in and directes you to the members page

 { 
 	$username = $_COOKIE['ID_my_site']; 

 	$pass = $_COOKIE['Key_my_site'];

 	 	$dbpassword = mysql_query("SELECT user_password FROM zzforums_users WHERE username = '$username'")or die(mysql_error());

 	while($info = mysql_fetch_array( $check )) 	

 		{
		//Password hash stuff ****************
/*include "PasswordHash.php";
$t_hasher = new PasswordHash(8, TRUE);
$hash = dbpassword; //from database
$pass=$_POST['pass'];
$check = $t_hasher->CheckPassword($pass, $hash);
//$check will be true or false if the passwords match
unset($t_hasher); //cleanup
*/
//END Password hash stuff ****************

 		if ($pass != $info['password']) 

 			{

 			 			}

 		else

 			{ 
			header("Location: http://www.google.com");


 			}

 		}

 }


 //if the login form is submitted 

 if (isset($_POST['submit'])) { // if form has been submitted



 // makes sure they filled it in

 	if(!$_POST['username'] | !$_POST['pass']) {

 		die('You did not fill in a required field.');

 	}
 	// checks it against the database



 	if (!get_magic_quotes_gpc()) {

 		$_POST['email'] = addslashes($_POST['email']);

 	}

 	$check = mysql_query("SELECT * FROM zzforums_users WHERE username = '".$_POST['username']."'")or die(mysql_error());



 //Gives error if user dosen't exist

 $check2 = mysql_num_rows($check);

 if ($check2 == 0) {

 		die('That user does not exist in our database. <a href=http://www.moosehockeyleague.com/..brentstats/phpBB3/ucp.php?mode=register>Click Here to Register</a>');

 				}

 while($info = mysql_fetch_array( $check )) 	

 {

 $_POST['pass'] = stripslashes($_POST['pass']);
 $pass=$_POST['pass'];
 $info['password'] = stripslashes($info['password']);

 //gives error if the password is wrong
 $query = mysql_query("SELECT user_password FROM zzforums_users WHERE username = '$username'");
$dbpassword = mysql_fetch_array($query)or die(mysql_error());
echo $dbpassword;
 	if ($pass != $dbpassword) {
	error_reporting(E_ALL);
 		die("password: ". $pass."..Hash:".$dbpassword."Incorrect password, please try again.");

 	}

	 else 

 { 

 // if login is ok then we add a cookie 

 	 $_POST['username'] = stripslashes($_POST['username']); 

 	 $hour = time() + 3600; 

 //setcookie(ID_my_site, $_POST['username'], $hour); 

 //setcookie(Key_my_site, $pass, $hour);	 
echo $password;
 //then redirect them to the members area 
 //header("Location: http://www.google.com");
?>  

 <?php 
// header("Location: http://www.google.com"); <html><meta http-equiv="refresh" content="0;url=http://moosehockeyleague.com/..brentstats/chris/general.php" /></html>  

 } 

 } 

 } 

 else 

{	 


 // if they are not logged in 

 ?> 

 <form action="<?php echo $_SERVER['PHP_SELF']?>" method="post"> 

 <table border="0"> 

 <tr><td colspan=2><h1>Login</h1></td></tr> 

 <tr><td>Username:</td><td> 

 <input type="text" name="username" maxlength="40"> 

 </td></tr> 

 <tr><td>Password:</td><td> 

 <input type="password" name="pass" maxlength="50"> 

 </td></tr> 

 <tr><td colspan="2" align="right"> 

 <input type="submit" name="submit" value="Login"> 

 </td></tr> 

 </table> 

 </form> 

 <?php 

 } 

 

 ?>


Is This A Good Question/Topic? 0
  • +

Page 1 of 1