phpBB

Code Changes

File: includes/functions.php

  Unmodified   Added   Modified   Removed
Line 1812Line 1812
	// Behave as per HTTP/1.1 spec for others
header('Location: ' . $url);
exit;

	// Behave as per HTTP/1.1 spec for others
header('Location: ' . $url);
exit;

 
}

/**
* Returns the install redirect path for phpBB.
*
* @param string $phpbb_root_path The root path of the phpBB installation.
* @param string $phpEx The file extension of php files, e.g., "php".
* @return string The install redirect path.
*/
function phpbb_get_install_redirect(string $phpbb_root_path, string $phpEx): string
{
$script_name = (!empty($_SERVER['REQUEST_URI'])) ? $_SERVER['REQUEST_URI'] : getenv('REQUEST_URI');
if (!$script_name)
{
$script_name = (!empty($_SERVER['PHP_SELF'])) ? $_SERVER['PHP_SELF'] : getenv('PHP_SELF');
}

// Add trailing dot to prevent dirname() from returning parent directory if $script_name is a directory
$script_name = substr($script_name, -1) === '/' ? $script_name . '.' : $script_name;

// $phpbb_root_path accounts for redirects from e.g. /adm
$script_path = trim(dirname($script_name)) . '/' . $phpbb_root_path . 'install/app.' . $phpEx;
// Replace any number of consecutive backslashes and/or slashes with a single slash
// (could happen on some proxy setups and/or Windows servers)
return preg_replace('#[\\\\/]{2,}#', '/', $script_path);

}

/**

}

/**

Line 2918Line 2943

/**
* Returns the first block of the specified IPv6 address and as many additional


/**
* Returns the first block of the specified IPv6 address and as many additional

* ones as specified in the length paramater.

* ones as specified in the length parameter.

* If length is zero, then an empty string is returned.
* If length is greater than 3 the complete IP will be returned
*/

* If length is zero, then an empty string is returned.
* If length is greater than 3 the complete IP will be returned
*/

Line 2927Line 2952
	if ($length < 1)
{
return '';

	if ($length < 1)
{
return '';

 
	}

// Handle IPv4 embedded IPv6 addresses
if (preg_match('/(?:\d{1,3}\.){3}\d{1,3}$/i', $ip))
{
$binary_ip = inet_pton($ip);
$ip_v6 = $binary_ip ? inet_ntop($binary_ip) : $ip;
$ip = $ip_v6 ?: $ip;

	}

// extend IPv6 addresses

	}

// extend IPv6 addresses

Line 2994Line 3027
	global $cache, $db, $auth, $template, $config, $user, $request;
global $phpbb_root_path, $msg_title, $msg_long_text, $phpbb_log;
global $phpbb_container;

	global $cache, $db, $auth, $template, $config, $user, $request;
global $phpbb_root_path, $msg_title, $msg_long_text, $phpbb_log;
global $phpbb_container;

 

// https://www.php.net/manual/en/language.operators.errorcontrol.php
// error_reporting() return a different error code inside the error handler after php 8.0
$suppresed = E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR | E_USER_ERROR | E_RECOVERABLE_ERROR | E_PARSE;
if (PHP_VERSION_ID < 80000)
{
$suppresed = 0;
}


// Do not display notices if we suppress them via @


// Do not display notices if we suppress them via @

	if (error_reporting() == 0 && $errno != E_USER_ERROR && $errno != E_USER_WARNING && $errno != E_USER_NOTICE)

	if (error_reporting() == $suppresed && $errno != E_USER_ERROR && $errno != E_USER_WARNING && $errno != E_USER_NOTICE)

	{
return;
}

	{
return;
}

Line 3695Line 3736
	{
if ($lazy)
{

	{
if ($lazy)
{

			// Determine board url - we may need it later
$board_url = generate_board_url() . '/';

 
			// This path is sent with the base template paths in the assign_vars()
// call below. We need to correct it in case we are accessing from a
// controller because the web paths will be incorrect otherwise.
$phpbb_path_helper = $phpbb_container->get('path_helper');

			// This path is sent with the base template paths in the assign_vars()
// call below. We need to correct it in case we are accessing from a
// controller because the web paths will be incorrect otherwise.
$phpbb_path_helper = $phpbb_container->get('path_helper');

			$corrected_path = $phpbb_path_helper->get_web_root_path();

$web_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? $board_url : $corrected_path;

			$web_path = $phpbb_path_helper->get_web_root_path();




$theme = "{$web_path}styles/" . rawurlencode($user->style['style_path']) . '/theme';



$theme = "{$web_path}styles/" . rawurlencode($user->style['style_path']) . '/theme';


Line 3891Line 3928
		$db->sql_freeresult($result);
}


		$db->sql_freeresult($result);
}


	// Determine board url - we may need it later
$board_url = generate_board_url() . '/';

 
	// This path is sent with the base template paths in the assign_vars()
// call below. We need to correct it in case we are accessing from a
// controller because the web paths will be incorrect otherwise.
/* @var $phpbb_path_helper \phpbb\path_helper */
$phpbb_path_helper = $phpbb_container->get('path_helper');

	// This path is sent with the base template paths in the assign_vars()
// call below. We need to correct it in case we are accessing from a
// controller because the web paths will be incorrect otherwise.
/* @var $phpbb_path_helper \phpbb\path_helper */
$phpbb_path_helper = $phpbb_container->get('path_helper');

	$corrected_path = $phpbb_path_helper->get_web_root_path();
$web_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? $board_url : $corrected_path;

	$web_path = $phpbb_path_helper->get_web_root_path();



// Send a proper content-language to the output
$user_lang = $user->lang['USER_LANG'];


// Send a proper content-language to the output
$user_lang = $user->lang['USER_LANG'];

Line 4002Line 4036
		'_SID'				=> $_SID,
'SESSION_ID' => $user->session_id,
'ROOT_PATH' => $web_path,

		'_SID'				=> $_SID,
'SESSION_ID' => $user->session_id,
'ROOT_PATH' => $web_path,

		'BOARD_URL'			=> $board_url,

		'BOARD_URL'			=> generate_board_url() . '/',


'L_LOGIN_LOGOUT' => $l_login_logout,
'L_INDEX' => ($config['board_index_text'] !== '') ? $config['board_index_text'] : $user->lang['FORUM_INDEX'],


'L_LOGIN_LOGOUT' => $l_login_logout,
'L_INDEX' => ($config['board_index_text'] !== '') ? $config['board_index_text'] : $user->lang['FORUM_INDEX'],

Line 4027Line 4061
		'U_SEARCH_UNANSWERED'	=> append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=unanswered'),
'U_SEARCH_UNREAD' => append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=unreadposts'),
'U_SEARCH_ACTIVE_TOPICS'=> append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=active_topics'),

		'U_SEARCH_UNANSWERED'	=> append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=unanswered'),
'U_SEARCH_UNREAD' => append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=unreadposts'),
'U_SEARCH_ACTIVE_TOPICS'=> append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=active_topics'),

		'U_DELETE_COOKIES'		=> append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=delete_cookies'),

		'U_DELETE_COOKIES'		=> $controller_helper->route('phpbb_ucp_delete_cookies_controller'),

		'U_CONTACT_US'			=> ($config['contact_admin_form_enable'] && $config['email_enable']) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contactadmin') : '',
'U_TEAM' => (!$auth->acl_get('u_viewprofile')) ? '' : append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=team'),
'U_TERMS_USE' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=terms'),

		'U_CONTACT_US'			=> ($config['contact_admin_form_enable'] && $config['email_enable']) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contactadmin') : '',
'U_TEAM' => (!$auth->acl_get('u_viewprofile')) ? '' : append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=team'),
'U_TERMS_USE' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=terms'),

Line 4089Line 4123

'T_FONT_AWESOME_LINK' => !empty($config['allow_cdn']) && !empty($config['load_font_awesome_url']) ? $config['load_font_awesome_url'] : "{$web_path}assets/css/font-awesome.min.css?assets_version=" . $config['assets_version'],



'T_FONT_AWESOME_LINK' => !empty($config['allow_cdn']) && !empty($config['load_font_awesome_url']) ? $config['load_font_awesome_url'] : "{$web_path}assets/css/font-awesome.min.css?assets_version=" . $config['assets_version'],


		'T_JQUERY_LINK'			=> !empty($config['allow_cdn']) && !empty($config['load_jquery_url']) ? $config['load_jquery_url'] : "{$web_path}assets/javascript/jquery-3.6.0.min.js?assets_version=" . $config['assets_version'],

		'T_JQUERY_LINK'			=> !empty($config['allow_cdn']) && !empty($config['load_jquery_url']) ? $config['load_jquery_url'] : "{$web_path}assets/javascript/jquery-3.7.1.min.js?assets_version=" . $config['assets_version'],

		'S_ALLOW_CDN'			=> !empty($config['allow_cdn']),
'S_COOKIE_NOTICE' => !empty($config['cookie_notice']),


		'S_ALLOW_CDN'			=> !empty($config['allow_cdn']),
'S_COOKIE_NOTICE' => !empty($config['cookie_notice']),