forum/common.php => forum/common_kohana.php
forum/includes/session.php => forum/includes/session_kohana.php
class session // => class session_kohana
class user extends session // => class user_kohana extends session_kohana
require($phpbb_root_path . 'includes/session.' . $phpEx);
require($phpbb_root_path . 'includes/session_kohana.' . $phpEx);
// Set PHP error handler to ours set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler');
// 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();
$user = new user_kohana();
$GLOBALS['user'] = $user; $GLOBALS['auth'] = $auth; $GLOBALS['template'] = $template; $GLOBALS['cache'] = $cache; $GLOBALS['db'] = $db;
// Grab global variables, re-cache if necessary $config = $cache->obtain_config();
$GLOBALS['config'] = $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); }
public static function include_libs() { // if (self::$libs_included) return TRUE; define('IN_PHPBB', true); define('PHPBB_DB_NEW_LINK', 1); $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './forum/'; $phpEx = substr(strrchr(__FILE__, '.'), 1); $GLOBALS['phpbb_root_path'] = $phpbb_root_path; $GLOBALS['phpEx'] = $phpEx; require_once($phpbb_root_path . 'common_kohana.' . $phpEx); require_once($phpbb_root_path . 'includes/functions_user.' . $phpEx); require_once($phpbb_root_path . 'includes/acp/auth.' . $phpEx); // Start session management $user->session_begin(); self::$libs_included = TRUE; return TRUE; }
define('PHPBB_DB_NEW_LINK', 1);
$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, defined('PHPBB_DB_NEW_LINK') ? PHPBB_DB_NEW_LINK : false);
If the second function call occurred with the same arguments mysql_connect () , the new connection will not be established. Instead, the function will return a link to an already established connection. The new_link parameter can cause the mysql_connect () function to open another connection, even if the connection with the same parameters is already open.
public static function register_user($username, $password, $email) { global $user; self::include_libs(); $user_row = array( 'username' => $username, 'user_password' => phpbb_hash($password), 'user_email' => $email, 'group_id' => 2, 'user_timezone' => 10.00, 'user_dst' => 1, 'user_lang' => 'ru', 'user_type' => 0, 'user_actkey' => '', 'user_ip' => Request::$client_ip, 'user_regdate' => time(), 'user_inactive_reason' => 0, 'user_inactive_time' => 0, ); try { $user_id = user_add($user_row, FALSE); return $user_id ? $user_id : FALSE; } catch (Exception $e) { return FALSE; } }
public static function login($user_id, $persist_login = FALSE) { global $user; self::include_libs(); $user->session_create($user_id, false, $persist_login, true); } public static function logout() { global $user; self::include_libs(); $user->session_kill(FALSE); return TRUE; }
public function logged_in() { global $user; $this->include_libs(); return ($user->data['user_id'] == ANONYMOUS) ? FALSE : TRUE; }
function forum_open($forum_id, $user_id) { $this->include_libs(); $role_id = 14; // Full access $auth_admin = new auth_admin(); $q = DB::query(Database::SELECT, "SELECT o.auth_option, r.auth_setting FROM `bazar_acl_roles_data` AS r, `bazar_acl_options` AS o WHERE o.auth_option_id = r.auth_option_id AND r.role_id = :role_id") ->param(':role_id', $role_id) ->as_object() ->execute('forum'); $auth_settings = array(); foreach ($q as $row) { if ($row->auth_option != 'f_') { $auth_settings[$row->auth_option] = $row->auth_setting; } } $auth_admin->acl_set('user', $forum_id, $user_id, $auth_settings, $role_id, true); }
Source: https://habr.com/ru/post/110884/
All Articles