rxu писал(а):Odina
Не занимайтесь самодеятельностью, тем более, что в phpBB3 хэш собственный, а не чистый md5.
includes/functions_user.php
function user_add
Я бы рада, но функция user_add тащит за собой приличное количество классов и других функций
Предложенный вариант вполне рабочий, после небольшой модернизации. В результате регистрация происходит, пользователь успешно аутентифицируется форумом.
Добавлено спустя 2 часа 8 минут 31 секунду:
Попробовала воспользоваться функцией user_add
- Код: Выделить всё
<?php
define('IN_PHPBB', true);
$phpbb_root_path='forum/';
$phpEx="php";
// Include files
include ("forum/config.php");
require($phpbb_root_path . 'includes/acm/acm_file.' . $phpEx);
require($phpbb_root_path . 'includes/cache.' . $phpEx);
//require($phpbb_root_path . 'includes/template.' . $phpEx);
require($phpbb_root_path . 'includes/session.' . $phpEx);
require($phpbb_root_path . 'includes/auth.' . $phpEx);
require($phpbb_root_path . 'includes/functions.' . $phpEx);
require($phpbb_root_path . 'includes/functions_content.' . $phpEx);
require($phpbb_root_path . 'includes/functions_user.' . $phpEx);
require($phpbb_root_path . 'includes/constants.' . $phpEx);
require($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx);
require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx);
// Set PHP error handler to ours
set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler');
// Instantiate some basic classes
$user = new user();
$auth = new auth();
//$template = new template();
$cache = new cache();
$db = new $sql_db();
// Connect to DB
$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, defined('PHPBB_DB_NEW_LINK') ? PHPBB_DB_NEW_LINK : false);
// We do not need this any longer, unset for safety purposes
unset($dbpasswd);
// Grab global variables, re-cache if necessary
$config = $cache->obtain_config();
// Add own hook handler
//require($phpbb_root_path . 'includes/hooks/index.' . $phpEx);
//$phpbb_hook = new phpbb_hook(array('exit_handler', 'phpbb_user_session_handler', 'append_sid', array('template', 'display')));
//foreach ($cache->obtain_hooks() as $hook)
//{
// @include($phpbb_root_path . 'includes/hooks/' . $hook . '.' . $phpEx);
//}
$user_row['username'] = "qwerty";
$user_row['user_password'] = phpbb_hash("qwerty");
$user_row['group_id'] = 2;
$user_row['user_email'] = "qwerty@qwerty.ru";
$user_row['user_type'] = 0;
user_add($user_row,false);
?>
Все Ok, пользователь регистрируется. Осталось только убрать ненужное для регистрации.
Добавлено спустя 2 минуты 6 секунд:Перед отправкой данных, надо обязательно проверить наличие пользователя с таким логином или email, а то вылетает глобальная ошибка MySql.
Добавлено спустя 48 минут 18 секунд:Начала раскручивать клубок, собирая все функции, запрашиваемые скриптом. Набрала на 1500 строк, плюнула, пускай будет так, как есть.
- Код: Выделить всё
<?php
define('IN_PHPBB', true);
$phpbb_root_path='forum/';
$phpEx="php";
// Include files
require("forum/config.php");
require($phpbb_root_path . 'includes/utf/utf_normalizer.' . $phpEx);
require($phpbb_root_path . 'includes/acm/acm_file.' . $phpEx);
require($phpbb_root_path . 'includes/cache.' . $phpEx);
require($phpbb_root_path . 'includes/session.' . $phpEx);
require($phpbb_root_path . 'includes/auth.' . $phpEx);
require($phpbb_root_path . 'includes/functions.' . $phpEx);
require($phpbb_root_path . 'includes/functions_user.' . $phpEx);
require($phpbb_root_path . 'includes/constants.' . $phpEx);
require($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx);
require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx);
// Set PHP error handler to ours
set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler');
// Instantiate some basic classes
$user = new user();
$auth = new auth();
$cache = new cache();
$db = new $sql_db();
// Connect to DB
$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, defined('PHPBB_DB_NEW_LINK') ? PHPBB_DB_NEW_LINK : false);
// We do not need this any longer, unset for safety purposes
unset($dbpasswd);
// Grab global variables, re-cache if necessary
$config = $cache->obtain_config();
$user_row['username'] = "qwerty";
$user_row['user_password'] = phpbb_hash("qwerty");
$user_row['group_id'] = 2;
$user_row['user_email'] = "qwerty@qwerty.ru";
$user_row['user_type'] = 0;
user_add($user_row,false);
?>
Если толкнуть кувшин, из него плеснет тем, чем он наполнен...