script based phpBB user add
For a customer I had to implement a script based user management for phpBB (add/delete) called from within a Java web app using existing login data. After evaluating and merging a lot of non-working suggestions/examples I managed to build a working script (tested with phpBB 3.0.4). Maybe it saves you some time.
<?php
if (isset($_REQUEST['forum_username']) && isset($_REQUEST['forum_password']) && isset($_REQUEST['forum_email'])) {
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : '../forum/';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/ucp/ucp_register.php');
include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
$username = $_REQUEST['forum_username'];
$username_clean = strtolower($username_clean);
$password = $_REQUEST['forum_password'];
$email = $_REQUEST['forum_email'];
$user_row = array(
'username' => $username,
'username_clean' => $username_clean,
'user_password' => phpbb_hash($password),
'user_pass_convert' => 0,
'user_email' => $email,
'user_email_hash' => crc32(strtolower($email)) . strlen($email),
'group_id' => 7,
'user_type' => 0,
);
user_add($user_row);
}
?>

0 Kommentare:
Kommentar veröffentlichen
Abonnieren Kommentare zum Post [Atom]
Links zu diesem Post:
Link erstellen
<< Startseite