I have one question, how to encrypt password from my site to work with phpbb3 password?
Asked
Active
Viewed 916 times
1 Answers
0
This will allow you to set up a basic user.
define('IN_PHPBB', true);
global $db;
global $config;
global $user;
global $auth;
global $cache;
global $template;
global $phpbb_root_path;
global $phpEx;
include('forums/common.php'); // THIS NEEDS TO BE CHANGED TO MATCH YOUR PHPBB3 INSTALL LOCATION;
// Currently, I am assuming you have this page at the root of your domain
// and PHPBB3 is install in the 'forums' subdirectory
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();
require($phpbb_root_path .'includes/functions_user.php');
$username = $_POST['user'];
$password = $_POST['password']; // Do not encrypt this password, it is handled later by an MD5 function and PHPBB3's own code
$email = $_POST['email'];
// You should add in a check to verify that the username is unique to your PHPBB3 install, otherwise you'll get errors
// I left this as an exercise for you so that you can handle it how you want (reload the page, fail completely, offer suggestions, etc)
$user_row = array(
'username' => $username,
'user_password' => md5($password), 'user_email' => $email,
'group_id' => 2, // This is the 'Registered Users' group. Change this as you feel is appropriate
'user_timezone' => '0.00', // GMT
'user_dst' => 0, // No Day Light Saving
'user_lang' => 'en',
'user_type' => '0', // This means 'Normal User'
'user_actkey' => '',
'user_dateformat' => 'd M Y H:i',
'user_style' => 1,
'user_regdate' => time(),
);
$id = user_add($user_row); // Returns the ID of the new user
Assumptions:
- This file is in the root of your domain and the forums are in the
forums
subdirectory. If this is not the case, I added comments to show what needs to be changed - No error checking was performed for duplicate user names. It is assumed that you have a method to handle this or can modify this script appropriately

Andy
- 49,085
- 60
- 166
- 233
-
PHPBB3 uses a `salt` when users are created. This means users that have the same password have different hash values. Are you able to sign into your forum using '123456789' with the new user from the code above? – Andy Jun 11 '12 at 17:45