Code: Select all
'username' => 'username'
'user_password' => 'password'
'user_email' => 'email'
'group_id' => 2
'user_lang' => 'en'
'user_type' => 0
'user_regdate' => ''
Code: Select all
$users_rows[] = array(
'username' => 'username',
'user_password' => 'password',
'user_email' => 'email',
'group_id' => 2,
'user_lang' => 'en',
'user_type' => 0,
'user_regdate' => '',
);
Code: Select all
<?php
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include_once($phpbb_root_path . 'includes/functions_user.' . $phpEx);
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();
include($phpbb_root_path . 'users_to_add.php');
$users_list = '';
for ($i = 0; $i < count($users); $i++)
{
$users[$i]['user_regdate'] = time();
$users[$i]['password'] = phpbb_hash($users[$i]['password']);
$user_id = user_add($users[$i]);
if ($user_id !== false)
{
$users_list .= (($users_list == '') ? '' : ', ') . $users[$i]['username'];
}
}
$template->assign_vars(array(
'MESSAGE_TITLE' => 'ADDING USERS',
'MESSAGE_TEXT' => $users_list . '<br /><br />Have been added!'
)
);
page_header('ADDING USERS');
$template->set_filenames(array('body' => 'message_body.html'));
page_footer();
?>
Code: Select all
<?php
$file_handle = fopen("forum_users_test.csv", "rb");
while (!feof($file_handle) ) {
$line_of_text = fgets($file_handle);
$parts = explode(',', $line_of_text);
$users = array(
'username' => $parts[0],
'user_password' => $parts[1],
'user_email' => $parts[2],
'group_id' => 2,
'user_lang' => 'en',
'user_type' => 0,
'user_regdate' => '',
);
fclose($file_handle);
?>
Code: Select all
<?php
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();
//echo $phpbb_root_path;
include($phpbb_root_path . 'users_to_add.php');
$users_list = '';
for ($i = 0; $i < count($users); $i++)
{
$users[$i]['user_regdate'] = time();
$users[$i]['password'] = phpbb_hash($users[$i]['password']);
$user_id = user_add($users[$i]);
if ($user_id !== false)
{
$users_list .= (($users_list == '') ? '' : ', ') . $users[$i]['username'];
}
}
$template->assign_vars(array(
'MESSAGE_TITLE' => 'ADDING USERS',
'MESSAGE_TEXT' => $users_list . '<br /><br />Have been added!'
)
);
page_header('ADDING USERS');
$template->set_filenames(array('body' => 'message_body.html'));
page_footer();
?>
Code: Select all
<html><body>
<?php
$file_handle = fopen("forum_users_test.csv", "rb");
while (!feof($file_handle) ) {
$line_of_text = fgets($file_handle);
$parts = explode(',', $line_of_text);
$users_rows = array(
'username' => $parts[0],
'user_password' => $parts[1],
'user_email' => $parts[2],
'group_id' => 2,
'user_lang' => 'en',
'user_type' => 0,
'user_regdate' => '',
);
echo $users_rows['username'] . "|" . $users_rows['user_password'] . "|" . $users_rows['user_email'] . "<BR>";
}
fclose($file_handle);
?>
</body></html>
Did you solve this?harley1979fxe wrote:I get error "Fatal error: Call to undefined function: user_add() in G:\Inetpub\vhosts\sitename.com\httpdocs\members\get-connected\forum\addem.php on line 20"
The files forum_users.php, users_to_add.php, and addem.php are in the root of phpBB directory (renamed forum).
Any ideas what the problem might be? Is the session/php setup in this correct?
Code: Select all
include_once($phpbb_root_path . 'includes/functions_user.' . $phpEx);
Code: Select all
if (PHP_VERSION >= 5)
{
$hash = md5($salt . $password, true);
do
{
$hash = md5($hash . $password, true);
}
while (--$count);
}
else
{
$hash = pack('H*', md5($salt . $password));
do
{
$hash = pack('H*', md5($hash . $password));
}
while (--$count);
}
$output = substr($setting, 0, 12);
$output .= _hash_encode64($hash, 16, $itoa64);
return $output;
}
Code: Select all
@set_time_limit(0);