mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-09 02:06:32 +02:00
Merge branch 'develop' of git://github.com/phpbb/phpbb3 into ticket/11786
This commit is contained in:
@@ -328,6 +328,7 @@ class acp_board
|
||||
'session_length' => array('lang' => 'SESSION_LENGTH', 'validate' => 'int:60:9999999999', 'type' => 'number:60:9999999999', 'explain' => true, 'append' => ' ' . $user->lang['SECONDS']),
|
||||
'active_sessions' => array('lang' => 'LIMIT_SESSIONS', 'validate' => 'int:0:9999', 'type' => 'number:0:9999', 'explain' => true),
|
||||
'load_online_time' => array('lang' => 'ONLINE_LENGTH', 'validate' => 'int:0:999', 'type' => 'number:0:999', 'explain' => true, 'append' => ' ' . $user->lang['MINUTES']),
|
||||
'read_notification_expire_days' => array('lang' => 'READ_NOTIFICATION_EXPIRE_DAYS', 'validate' => 'int:0', 'type' => 'number:0', 'explain' => true, 'append' => ' ' . $user->lang['DAYS']),
|
||||
|
||||
'legend2' => 'GENERAL_OPTIONS',
|
||||
'load_notifications' => array('lang' => 'LOAD_NOTIFICATIONS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
|
||||
@@ -375,6 +376,7 @@ class acp_board
|
||||
'use_system_cron' => array('lang' => 'USE_SYSTEM_CRON', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
|
||||
|
||||
'legend2' => 'PATH_SETTINGS',
|
||||
'enable_mod_rewrite' => array('lang' => 'MOD_REWRITE_ENABLE', 'validate' => 'bool', 'type' => 'custom', 'method' => 'enable_mod_rewrite', 'explain' => true),
|
||||
'smilies_path' => array('lang' => 'SMILIES_PATH', 'validate' => 'rpath', 'type' => 'text:20:255', 'explain' => true),
|
||||
'icons_path' => array('lang' => 'ICONS_PATH', 'validate' => 'rpath', 'type' => 'text:20:255', 'explain' => true),
|
||||
'upload_icons_path' => array('lang' => 'UPLOAD_ICONS_PATH', 'validate' => 'rpath', 'type' => 'text:20:255', 'explain' => true),
|
||||
@@ -658,6 +660,13 @@ class acp_board
|
||||
$auth_tpl = $provider->get_acp_template($this->new_config);
|
||||
if ($auth_tpl)
|
||||
{
|
||||
if (array_key_exists('BLOCK_VAR_NAME', $auth_tpl))
|
||||
{
|
||||
foreach ($auth_tpl['BLOCK_VARS'] as $block_vars)
|
||||
{
|
||||
$template->assign_block_vars($auth_tpl['BLOCK_VAR_NAME'], $block_vars);
|
||||
}
|
||||
}
|
||||
$template->assign_vars($auth_tpl['TEMPLATE_VARS']);
|
||||
$template->assign_block_vars('auth_tpl', array(
|
||||
'TEMPLATE_FILE' => $auth_tpl['TEMPLATE_FILE'],
|
||||
@@ -994,4 +1003,51 @@ class acp_board
|
||||
$cache->destroy('sql', FORUMS_TABLE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Option to enable/disable removal of 'app.php' from URLs
|
||||
*
|
||||
* Note that if mod_rewrite is on, URLs without app.php will still work,
|
||||
* but any paths generated by the controller helper url() method will not
|
||||
* contain app.php.
|
||||
*
|
||||
* @param int $value The current config value
|
||||
* @param string $key The config key
|
||||
* @return string The HTML for the form field
|
||||
*/
|
||||
function enable_mod_rewrite($value, $key)
|
||||
{
|
||||
global $user, $config;
|
||||
|
||||
// Determine whether mod_rewrite is enabled on the server
|
||||
// NOTE: This only works on Apache servers on which PHP is NOT
|
||||
// installed as CGI. In that case, there is no way for PHP to
|
||||
// determine whether or not the Apache module is enabled.
|
||||
//
|
||||
// To be clear on the value of $mod_rewite:
|
||||
// null = Cannot determine whether or not the server has mod_rewrite
|
||||
// enabled
|
||||
// false = Can determine that the server does NOT have mod_rewrite
|
||||
// enabled
|
||||
// true = Can determine that the server DOES have mod_rewrite_enabled
|
||||
$mod_rewrite = null;
|
||||
if (function_exists('apache_get_modules'))
|
||||
{
|
||||
$mod_rewrite = (bool) in_array('mod_rewrite', apache_get_modules());
|
||||
}
|
||||
|
||||
// If $message is false, mod_rewrite is enabled.
|
||||
// Otherwise, it is not and we need to:
|
||||
// 1) disable the form field
|
||||
// 2) make sure the config value is set to 0
|
||||
// 3) append the message to the return
|
||||
$value = ($mod_rewrite === false) ? 0 : $value;
|
||||
$message = $mod_rewrite === null ? 'MOD_REWRITE_INFORMATION_UNAVAILABLE' : ($mod_rewrite === false ? 'MOD_REWRITE_DISABLED' : false);
|
||||
|
||||
// Let's do some friendly HTML injection if we want to disable the
|
||||
// form field because h_radio() has no pretty way of doing so
|
||||
$field_name = 'config[enable_mod_rewrite]' . ($message === 'MOD_REWRITE_DISABLED' ? '" disabled="disabled' : '');
|
||||
|
||||
return h_radio($field_name, array(1 => 'YES', 0 => 'NO'), $value) .
|
||||
($message !== false ? '<br /><span>' . $user->lang($message) . '</span>' : '');
|
||||
}
|
||||
}
|
||||
|
@@ -126,17 +126,14 @@ class bbcode
|
||||
*/
|
||||
function bbcode_cache_init()
|
||||
{
|
||||
global $phpbb_root_path, $phpEx, $config, $user, $phpbb_extension_manager;
|
||||
global $phpbb_root_path, $phpEx, $config, $user, $phpbb_extension_manager, $phpbb_filesystem;
|
||||
|
||||
if (empty($this->template_filename))
|
||||
{
|
||||
$this->template_bitfield = new bitfield($user->style['bbcode_bitfield']);
|
||||
|
||||
$style_resource_locator = new phpbb_style_resource_locator();
|
||||
$style_path_provider = new phpbb_style_extension_path_provider($phpbb_extension_manager, new phpbb_style_path_provider(), $phpbb_root_path);
|
||||
$template = new phpbb_template_twig($phpbb_root_path, $phpEx, $config, $user, new phpbb_template_context(), $phpbb_extension_manager);
|
||||
$style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $style_resource_locator, $style_path_provider, $template);
|
||||
$style->set_style();
|
||||
$template = new phpbb_template_twig($phpbb_filesystem, $config, $user, new phpbb_template_context(), $phpbb_extension_manager);
|
||||
$template->set_style();
|
||||
$template->set_filenames(array('bbcode.html' => 'bbcode.html'));
|
||||
$this->template_filename = $template->get_source_file_for_handle('bbcode.html');
|
||||
}
|
||||
|
@@ -61,6 +61,7 @@ define('LOGIN_CONTINUE', 1);
|
||||
define('LOGIN_BREAK', 2);
|
||||
define('LOGIN_SUCCESS', 3);
|
||||
define('LOGIN_SUCCESS_CREATE_PROFILE', 20);
|
||||
define('LOGIN_SUCCESS_LINK_PROFILE', 21);
|
||||
define('LOGIN_ERROR_USERNAME', 10);
|
||||
define('LOGIN_ERROR_PASSWORD', 11);
|
||||
define('LOGIN_ERROR_ACTIVE', 12);
|
||||
|
1219
phpBB/includes/db/schema_data.php
Normal file
1219
phpBB/includes/db/schema_data.php
Normal file
File diff suppressed because it is too large
Load Diff
@@ -7,8 +7,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
@@ -1072,7 +1070,14 @@ function phpbb_clean_path($path)
|
||||
global $phpbb_root_path, $phpEx;
|
||||
require($phpbb_root_path . 'includes/filesystem.' . $phpEx);
|
||||
}
|
||||
$phpbb_filesystem = new phpbb_filesystem();
|
||||
|
||||
$phpbb_filesystem = new phpbb_filesystem(
|
||||
new phpbb_symfony_request(
|
||||
new phpbb_request()
|
||||
),
|
||||
$phpbb_root_path,
|
||||
$phpEx
|
||||
);
|
||||
}
|
||||
|
||||
return $phpbb_filesystem->clean_path($path);
|
||||
@@ -2343,7 +2348,6 @@ function phpbb_generate_template_pagination($template, $base_url, $block_var_nam
|
||||
|
||||
$template_array = array(
|
||||
$tpl_prefix . 'BASE_URL' => $base_url,
|
||||
'A_' . $tpl_prefix . 'BASE_URL' => addslashes($base_url),
|
||||
$tpl_prefix . 'PER_PAGE' => $per_page,
|
||||
'U_' . $tpl_prefix . 'PREVIOUS_PAGE' => $previous_page,
|
||||
'U_' . $tpl_prefix . 'NEXT_PAGE' => ($on_page != $total_pages) ? $base_url . $url_delim . $start_name . '=' . ($on_page * $per_page) : '',
|
||||
@@ -2383,7 +2387,7 @@ function phpbb_on_page($template, $user, $base_url, $num_items, $per_page, $star
|
||||
$template->assign_vars(array(
|
||||
'PER_PAGE' => $per_page,
|
||||
'ON_PAGE' => $on_page,
|
||||
'A_BASE_URL' => addslashes($base_url),
|
||||
'BASE_URL' => $base_url,
|
||||
));
|
||||
|
||||
return sprintf($user->lang['PAGE_OF'], $on_page, max(ceil($num_items / $per_page), 1));
|
||||
@@ -2411,7 +2415,7 @@ function phpbb_on_page($template, $user, $base_url, $num_items, $per_page, $star
|
||||
*/
|
||||
function append_sid($url, $params = false, $is_amp = true, $session_id = false)
|
||||
{
|
||||
global $_SID, $_EXTRA_URL, $phpbb_hook;
|
||||
global $_SID, $_EXTRA_URL, $phpbb_hook, $phpbb_filesystem;
|
||||
global $phpbb_dispatcher;
|
||||
|
||||
if ($params === '' || (is_array($params) && empty($params)))
|
||||
@@ -2420,6 +2424,12 @@ function append_sid($url, $params = false, $is_amp = true, $session_id = false)
|
||||
$params = false;
|
||||
}
|
||||
|
||||
// Update the root path with the correct relative web path
|
||||
if ($phpbb_filesystem instanceof phpbb_filesystem)
|
||||
{
|
||||
$url = $phpbb_filesystem->update_web_root_path($url);
|
||||
}
|
||||
|
||||
$append_sid_overwrite = false;
|
||||
|
||||
/**
|
||||
@@ -2809,8 +2819,22 @@ function build_url($strip_vars = false)
|
||||
{
|
||||
global $user, $phpbb_root_path;
|
||||
|
||||
$page = $user->page['page'];
|
||||
|
||||
// We need to be cautious here.
|
||||
// On some situations, the redirect path is an absolute URL, sometimes a relative path
|
||||
// For a relative path, let's prefix it with $phpbb_root_path to point to the correct location,
|
||||
// else we use the URL directly.
|
||||
$url_parts = parse_url($page);
|
||||
|
||||
// URL
|
||||
if ($url_parts !== false && !empty($url_parts['scheme']) && !empty($url_parts['host']))
|
||||
{
|
||||
$page = $phpbb_root_path . $page;
|
||||
}
|
||||
|
||||
// Append SID
|
||||
$redirect = append_sid($user->page['page'], false, false);
|
||||
$redirect = append_sid($page, false, false);
|
||||
|
||||
// Add delimiter if not there...
|
||||
if (strpos($redirect, '?') === false)
|
||||
@@ -2865,19 +2889,7 @@ function build_url($strip_vars = false)
|
||||
$redirect .= ($query) ? '?' . $query : '';
|
||||
}
|
||||
|
||||
// We need to be cautious here.
|
||||
// On some situations, the redirect path is an absolute URL, sometimes a relative path
|
||||
// For a relative path, let's prefix it with $phpbb_root_path to point to the correct location,
|
||||
// else we use the URL directly.
|
||||
$url_parts = @parse_url($redirect);
|
||||
|
||||
// URL
|
||||
if ($url_parts !== false && !empty($url_parts['scheme']) && !empty($url_parts['host']))
|
||||
{
|
||||
return str_replace('&', '&', $redirect);
|
||||
}
|
||||
|
||||
return $phpbb_root_path . str_replace('&', '&', $redirect);
|
||||
return str_replace('&', '&', $redirect);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3199,7 +3211,7 @@ function confirm_box($check, $title = '', $hidden = '', $html_body = 'confirm_bo
|
||||
function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = false, $s_display = true)
|
||||
{
|
||||
global $db, $user, $template, $auth, $phpEx, $phpbb_root_path, $config;
|
||||
global $request;
|
||||
global $request, $phpbb_container;
|
||||
|
||||
if (!class_exists('phpbb_captcha_factory', false))
|
||||
{
|
||||
@@ -3226,7 +3238,7 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa
|
||||
trigger_error('NO_AUTH_ADMIN');
|
||||
}
|
||||
|
||||
if (isset($_POST['login']))
|
||||
if ($request->is_set_post('login') || ($request->is_set('login') && $request->variable('login', '') == 'external'))
|
||||
{
|
||||
// Get credential
|
||||
if ($admin)
|
||||
@@ -3367,6 +3379,29 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa
|
||||
$s_hidden_fields['credential'] = $credential;
|
||||
}
|
||||
|
||||
$auth_provider = $phpbb_container->get('auth.provider.' . $config['auth_method']);
|
||||
|
||||
$auth_provider_data = $auth_provider->get_login_data();
|
||||
if ($auth_provider_data)
|
||||
{
|
||||
if (isset($auth_provider_data['VARS']))
|
||||
{
|
||||
$template->assign_vars($auth_provider_data['VARS']);
|
||||
}
|
||||
|
||||
if (isset($auth_provider_data['BLOCK_VAR_NAME']))
|
||||
{
|
||||
foreach ($auth_provider_data['BLOCK_VARS'] as $block_vars)
|
||||
{
|
||||
$template->assign_block_vars($auth_provider_data['BLOCK_VAR_NAME'], $block_vars);
|
||||
}
|
||||
}
|
||||
|
||||
$template->assign_vars(array(
|
||||
'PROVIDER_TEMPLATE_FILE' => $auth_provider_data['TEMPLATE_FILE'],
|
||||
));
|
||||
}
|
||||
|
||||
$s_hidden_fields = build_hidden_fields($s_hidden_fields);
|
||||
|
||||
$template->assign_vars(array(
|
||||
@@ -5051,7 +5086,7 @@ function phpbb_build_hidden_fields_for_query_params($request, $exclude = null)
|
||||
function page_header($page_title = '', $display_online_list = true, $item_id = 0, $item = 'forum')
|
||||
{
|
||||
global $db, $config, $template, $SID, $_SID, $_EXTRA_URL, $user, $auth, $phpEx, $phpbb_root_path;
|
||||
global $phpbb_dispatcher, $request, $phpbb_container;
|
||||
global $phpbb_dispatcher, $request, $phpbb_container, $adm_relative_path;
|
||||
|
||||
if (defined('HEADER_INC'))
|
||||
{
|
||||
@@ -5208,7 +5243,12 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0
|
||||
|
||||
// Determine board url - we may need it later
|
||||
$board_url = generate_board_url() . '/';
|
||||
$web_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? $board_url : $phpbb_root_path;
|
||||
// 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_filesystem = $phpbb_container->get('filesystem');
|
||||
$corrected_path = $phpbb_filesystem->get_web_root_path();
|
||||
$web_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? $board_url : $corrected_path;
|
||||
|
||||
// Send a proper content-language to the output
|
||||
$user_lang = $user->lang['USER_LANG'];
|
||||
@@ -5289,7 +5329,7 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0
|
||||
'SID' => $SID,
|
||||
'_SID' => $_SID,
|
||||
'SESSION_ID' => $user->session_id,
|
||||
'ROOT_PATH' => $phpbb_root_path,
|
||||
'ROOT_PATH' => $web_path,
|
||||
'BOARD_URL' => $board_url,
|
||||
|
||||
'L_LOGIN_LOGOUT' => $l_login_logout,
|
||||
@@ -5300,7 +5340,6 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0
|
||||
'U_PRIVATEMSGS' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&folder=inbox'),
|
||||
'U_RETURN_INBOX' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&folder=inbox'),
|
||||
'U_POPUP_PM' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&mode=popup'),
|
||||
'UA_POPUP_PM' => addslashes(append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&mode=popup')),
|
||||
'U_MEMBERLIST' => append_sid("{$phpbb_root_path}memberlist.$phpEx"),
|
||||
'U_VIEWONLINE' => ($auth->acl_gets('u_viewprofile', 'a_user', 'a_useradd', 'a_userdel')) ? append_sid("{$phpbb_root_path}viewonline.$phpEx") : '',
|
||||
'U_LOGIN_LOGOUT' => $u_login_logout,
|
||||
@@ -5346,7 +5385,7 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0
|
||||
'S_FORUM_ID' => $forum_id,
|
||||
'S_TOPIC_ID' => $topic_id,
|
||||
|
||||
'S_LOGIN_ACTION' => ((!defined('ADMIN_START')) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login') : append_sid("index.$phpEx", false, true, $user->session_id)),
|
||||
'S_LOGIN_ACTION' => ((!defined('ADMIN_START')) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login') : append_sid("{$phpbb_root_path}{$adm_relative_path}index.$phpEx", false, true, $user->session_id)),
|
||||
'S_LOGIN_REDIRECT' => build_hidden_fields(array('redirect' => build_url())),
|
||||
|
||||
'S_ENABLE_FEEDS' => ($config['feed_enable']) ? true : false,
|
||||
@@ -5390,8 +5429,6 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0
|
||||
'T_UPLOAD' => $config['upload_path'],
|
||||
|
||||
'SITE_LOGO_IMG' => $user->img('site_logo'),
|
||||
|
||||
'A_COOKIE_SETTINGS' => addslashes('; path=' . $config['cookie_path'] . ((!$config['cookie_domain'] || $config['cookie_domain'] == 'localhost' || $config['cookie_domain'] == '127.0.0.1') ? '' : '; domain=' . $config['cookie_domain']) . ((!$config['cookie_secure']) ? '' : '; secure')),
|
||||
));
|
||||
|
||||
// application/xhtml+xml not used because of IE
|
||||
@@ -5675,49 +5712,3 @@ function phpbb_convert_30_dbms_to_31($dbms)
|
||||
|
||||
throw new \RuntimeException("You have specified an invalid dbms driver: $dbms");
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a Symfony Request object from phpbb_request object
|
||||
*
|
||||
* @param phpbb_request $request Request object
|
||||
* @return Request A Symfony Request object
|
||||
*/
|
||||
function phpbb_create_symfony_request(phpbb_request $request)
|
||||
{
|
||||
// This function is meant to sanitize the global input arrays
|
||||
$sanitizer = function(&$value, $key) {
|
||||
$type_cast_helper = new phpbb_request_type_cast_helper();
|
||||
$type_cast_helper->set_var($value, $value, gettype($value), true);
|
||||
};
|
||||
|
||||
// We need to re-enable the super globals so we can access them here
|
||||
$request->enable_super_globals();
|
||||
$get_parameters = $_GET;
|
||||
$post_parameters = $_POST;
|
||||
$server_parameters = $_SERVER;
|
||||
$files_parameters = $_FILES;
|
||||
$cookie_parameters = $_COOKIE;
|
||||
// And now disable them again for security
|
||||
$request->disable_super_globals();
|
||||
|
||||
array_walk_recursive($get_parameters, $sanitizer);
|
||||
array_walk_recursive($post_parameters, $sanitizer);
|
||||
|
||||
// Until we fix the issue with relative paths, we have to fake path info
|
||||
// to allow urls like app.php?controller=foo/bar
|
||||
$controller = $request->variable('controller', '');
|
||||
$path_info = '/' . $controller;
|
||||
$request_uri = $server_parameters['REQUEST_URI'];
|
||||
|
||||
// Remove the query string from REQUEST_URI
|
||||
if ($pos = strpos($request_uri, '?'))
|
||||
{
|
||||
$request_uri = substr($request_uri, 0, $pos);
|
||||
}
|
||||
|
||||
// Add the path info (i.e. controller route) to the REQUEST_URI
|
||||
$server_parameters['REQUEST_URI'] = $request_uri . $path_info;
|
||||
$server_parameters['SCRIPT_NAME'] = '';
|
||||
|
||||
return new Request($get_parameters, $post_parameters, array(), $cookie_parameters, $files_parameters, $server_parameters);
|
||||
}
|
||||
|
@@ -727,37 +727,58 @@ function make_clickable($text, $server_url = false, $class = 'postlink')
|
||||
$server_url = generate_board_url();
|
||||
}
|
||||
|
||||
static $magic_url_match;
|
||||
static $magic_url_replace;
|
||||
static $static_class;
|
||||
static $magic_url_match_args;
|
||||
|
||||
if (!is_array($magic_url_match) || $static_class != $class)
|
||||
if (!is_array($magic_url_match_args) || $static_class != $class)
|
||||
{
|
||||
$static_class = $class;
|
||||
$class = ($static_class) ? ' class="' . $static_class . '"' : '';
|
||||
$local_class = ($static_class) ? ' class="' . $static_class . '-local"' : '';
|
||||
|
||||
$magic_url_match = $magic_url_replace = array();
|
||||
// Be sure to not let the matches cross over. ;)
|
||||
$magic_url_match_args = array();
|
||||
|
||||
// relative urls for this board
|
||||
$magic_url_match[] = '#(^|[\n\t (>.])(' . preg_quote($server_url, '#') . ')/(' . get_preg_expression('relative_url_inline') . ')#ie';
|
||||
$magic_url_replace[] = "make_clickable_callback(MAGIC_URL_LOCAL, '\$1', '\$2', '\$3', '$local_class')";
|
||||
$magic_url_match_args[] = array(
|
||||
'#(^|[\n\t (>.])(' . preg_quote($server_url, '#') . ')/(' . get_preg_expression('relative_url_inline') . ')#i',
|
||||
MAGIC_URL_LOCAL,
|
||||
$local_class,
|
||||
);
|
||||
|
||||
// matches a xxxx://aaaaa.bbb.cccc. ...
|
||||
$magic_url_match[] = '#(^|[\n\t (>.])(' . get_preg_expression('url_inline') . ')#ie';
|
||||
$magic_url_replace[] = "make_clickable_callback(MAGIC_URL_FULL, '\$1', '\$2', '', '$class')";
|
||||
$magic_url_match_args[] = array(
|
||||
'#(^|[\n\t (>.])(' . get_preg_expression('url_inline') . ')#i',
|
||||
MAGIC_URL_FULL,
|
||||
$class,
|
||||
);
|
||||
|
||||
// matches a "www.xxxx.yyyy[/zzzz]" kinda lazy URL thing
|
||||
$magic_url_match[] = '#(^|[\n\t (>])(' . get_preg_expression('www_url_inline') . ')#ie';
|
||||
$magic_url_replace[] = "make_clickable_callback(MAGIC_URL_WWW, '\$1', '\$2', '', '$class')";
|
||||
$magic_url_match_args[] = array(
|
||||
'#(^|[\n\t (>])(' . get_preg_expression('www_url_inline') . ')#i',
|
||||
MAGIC_URL_WWW,
|
||||
$class,
|
||||
);
|
||||
|
||||
// matches an email@domain type address at the start of a line, or after a space or after what might be a BBCode.
|
||||
$magic_url_match[] = '/(^|[\n\t (>])(' . get_preg_expression('email') . ')/ie';
|
||||
$magic_url_replace[] = "make_clickable_callback(MAGIC_URL_EMAIL, '\$1', '\$2', '', '')";
|
||||
$magic_url_match_args[] = array(
|
||||
'/(^|[\n\t (>])(' . get_preg_expression('email') . ')/i',
|
||||
MAGIC_URL_EMAIL,
|
||||
'',
|
||||
);
|
||||
}
|
||||
|
||||
return preg_replace($magic_url_match, $magic_url_replace, $text);
|
||||
foreach ($magic_url_match_args as $magic_args)
|
||||
{
|
||||
if (preg_match($magic_args[0], $text, $matches))
|
||||
{
|
||||
$text = preg_replace_callback($magic_args[0], function($matches) use ($magic_args)
|
||||
{
|
||||
return make_clickable_callback($magic_args[1], $matches[1], $matches[2], $matches[3], $magic_args[2]);
|
||||
}, $text);
|
||||
}
|
||||
}
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -813,7 +834,7 @@ function bbcode_nl2br($text)
|
||||
*/
|
||||
function smiley_text($text, $force_option = false)
|
||||
{
|
||||
global $config, $user, $phpbb_root_path;
|
||||
global $config, $user, $phpbb_filesystem;
|
||||
|
||||
if ($force_option || !$config['allow_smilies'] || !$user->optionget('viewsmilies'))
|
||||
{
|
||||
@@ -821,7 +842,7 @@ function smiley_text($text, $force_option = false)
|
||||
}
|
||||
else
|
||||
{
|
||||
$root_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? generate_board_url() . '/' : $phpbb_root_path;
|
||||
$root_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? generate_board_url() . '/' : $phpbb_filesystem->get_web_root_path();
|
||||
return preg_replace('#<!\-\- s(.*?) \-\-><img src="\{SMILIES_PATH\}\/(.*?) \/><!\-\- s\1 \-\->#', '<img class="smilies" src="' . $root_path . $config['smilies_path'] . '/\2 />', $text);
|
||||
}
|
||||
}
|
||||
|
@@ -21,7 +21,7 @@ if (!defined('IN_PHPBB'))
|
||||
*/
|
||||
class messenger
|
||||
{
|
||||
var $vars, $msg, $extra_headers, $replyto, $from, $subject;
|
||||
var $msg, $extra_headers, $replyto, $from, $subject;
|
||||
var $addresses = array();
|
||||
|
||||
var $mail_priority = MAIL_NORMAL_PRIORITY;
|
||||
@@ -53,7 +53,7 @@ class messenger
|
||||
function reset()
|
||||
{
|
||||
$this->addresses = $this->extra_headers = array();
|
||||
$this->vars = $this->msg = $this->replyto = $this->from = '';
|
||||
$this->msg = $this->replyto = $this->from = '';
|
||||
$this->mail_priority = MAIL_NORMAL_PRIORITY;
|
||||
}
|
||||
|
||||
@@ -258,8 +258,6 @@ class messenger
|
||||
'body' => $template_file . '.txt',
|
||||
));
|
||||
|
||||
$this->vars = $this->template->get_template_vars();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -288,26 +286,11 @@ class messenger
|
||||
global $config, $user;
|
||||
|
||||
// We add some standard variables we always use, no need to specify them always
|
||||
if (!isset($this->vars['U_BOARD']))
|
||||
{
|
||||
$this->assign_vars(array(
|
||||
'U_BOARD' => generate_board_url(),
|
||||
));
|
||||
}
|
||||
|
||||
if (!isset($this->vars['EMAIL_SIG']))
|
||||
{
|
||||
$this->assign_vars(array(
|
||||
'EMAIL_SIG' => str_replace('<br />', "\n", "-- \n" . htmlspecialchars_decode($config['board_email_sig'])),
|
||||
));
|
||||
}
|
||||
|
||||
if (!isset($this->vars['SITENAME']))
|
||||
{
|
||||
$this->assign_vars(array(
|
||||
'SITENAME' => htmlspecialchars_decode($config['sitename']),
|
||||
));
|
||||
}
|
||||
$this->assign_vars(array(
|
||||
'U_BOARD' => generate_board_url(),
|
||||
'EMAIL_SIG' => str_replace('<br />', "\n", "-- \n" . htmlspecialchars_decode($config['board_email_sig'])),
|
||||
'SITENAME' => htmlspecialchars_decode($config['sitename']),
|
||||
));
|
||||
|
||||
// Parse message through template
|
||||
$this->msg = trim($this->template->assign_display('body'));
|
||||
@@ -643,14 +626,14 @@ class messenger
|
||||
*/
|
||||
protected function setup_template()
|
||||
{
|
||||
global $config, $phpbb_root_path, $phpEx, $user, $phpbb_extension_manager;
|
||||
global $config, $phpbb_filesystem, $user, $phpbb_extension_manager;
|
||||
|
||||
if ($this->template instanceof phpbb_template)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$this->template = new phpbb_template_twig($phpbb_root_path, $phpEx, $config, $user, new phpbb_template_context(), $phpbb_extension_manager);
|
||||
$this->template = new phpbb_template_twig($phpbb_filesystem, $config, $user, new phpbb_template_context(), $phpbb_extension_manager);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -660,7 +643,7 @@ class messenger
|
||||
{
|
||||
$this->setup_template();
|
||||
|
||||
$this->template->set_style_names(array($path_name), $paths);
|
||||
$this->template->set_custom_style($path_name, $paths);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -455,7 +455,7 @@ class p_master
|
||||
*/
|
||||
function load_active($mode = false, $module_url = false, $execute_module = true)
|
||||
{
|
||||
global $phpbb_root_path, $phpbb_admin_path, $phpEx, $user, $phpbb_style;
|
||||
global $phpbb_root_path, $phpbb_admin_path, $phpEx, $user, $template;
|
||||
|
||||
$module_path = $this->include_path . $this->p_class;
|
||||
$icat = request_var('icat', '');
|
||||
@@ -508,7 +508,7 @@ class p_master
|
||||
|
||||
if (is_dir($module_style_dir))
|
||||
{
|
||||
$phpbb_style->set_custom_style('admin', array($module_style_dir, $phpbb_admin_path . 'style'), array(), '');
|
||||
$template->set_custom_style('adm', array($module_style_dir, $phpbb_admin_path . 'style'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -537,7 +537,7 @@ class p_master
|
||||
|
||||
if (is_dir($phpbb_root_path . $module_style_dir))
|
||||
{
|
||||
$phpbb_style->set_style(array($module_style_dir, 'styles'));
|
||||
$template->set_style(array($module_style_dir, 'styles'));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -2166,6 +2166,11 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
|
||||
update_forum_tracking_info($data['forum_id'], $forum_last_post_time, $f_mark_time, false);
|
||||
}
|
||||
|
||||
// If a username was supplied or the poster is a guest, we will use the supplied username.
|
||||
// Doing it this way we can use "...post by guest-username..." in notifications when
|
||||
// "guest-username" is supplied or ommit the username if it is not.
|
||||
$username = ($username !== '' || !$user->data['is_registered']) ? $username : $user->data['username'];
|
||||
|
||||
// Send Notifications
|
||||
$notification_data = array_merge($data, array(
|
||||
'topic_title' => (isset($data['topic_title'])) ? $data['topic_title'] : $subject,
|
||||
|
@@ -2534,7 +2534,7 @@ function group_delete($group_id, $group_name = false)
|
||||
*/
|
||||
function group_user_add($group_id, $user_id_ary = false, $username_ary = false, $group_name = false, $default = false, $leader = 0, $pending = 0, $group_attributes = false)
|
||||
{
|
||||
global $db, $auth;
|
||||
global $db, $auth, $phpbb_container;
|
||||
|
||||
// We need both username and user_id info
|
||||
$result = user_get_id_name($user_id_ary, $username_ary);
|
||||
@@ -2622,6 +2622,20 @@ function group_user_add($group_id, $user_id_ary = false, $username_ary = false,
|
||||
|
||||
group_update_listings($group_id);
|
||||
|
||||
if ($pending)
|
||||
{
|
||||
$phpbb_notifications = $phpbb_container->get('notification_manager');
|
||||
|
||||
foreach ($add_id_ary as $user_id)
|
||||
{
|
||||
$phpbb_notifications->add_notifications('group_request', array(
|
||||
'group_id' => $group_id,
|
||||
'user_id' => $user_id,
|
||||
'group_name' => $group_name,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
// Return false - no error
|
||||
return false;
|
||||
}
|
||||
@@ -2635,7 +2649,7 @@ function group_user_add($group_id, $user_id_ary = false, $username_ary = false,
|
||||
*/
|
||||
function group_user_del($group_id, $user_id_ary = false, $username_ary = false, $group_name = false)
|
||||
{
|
||||
global $db, $auth, $config, $phpbb_dispatcher;
|
||||
global $db, $auth, $config, $phpbb_dispatcher, $phpbb_container;
|
||||
|
||||
if ($config['coppa_enable'])
|
||||
{
|
||||
@@ -2769,6 +2783,10 @@ function group_user_del($group_id, $user_id_ary = false, $username_ary = false,
|
||||
|
||||
group_update_listings($group_id);
|
||||
|
||||
$phpbb_notifications = $phpbb_container->get('notification_manager');
|
||||
|
||||
$phpbb_notifications->delete_notifications('group_request', $user_id_ary, $group_id);
|
||||
|
||||
// Return false - no error
|
||||
return false;
|
||||
}
|
||||
@@ -2858,7 +2876,7 @@ function remove_default_rank($group_id, $user_ids)
|
||||
*/
|
||||
function group_user_attributes($action, $group_id, $user_id_ary = false, $username_ary = false, $group_name = false, $group_attributes = false)
|
||||
{
|
||||
global $db, $auth, $phpbb_root_path, $phpEx, $config;
|
||||
global $db, $auth, $phpbb_root_path, $phpEx, $config, $phpbb_container;
|
||||
|
||||
// We need both username and user_id info
|
||||
$result = user_get_id_name($user_id_ary, $username_ary);
|
||||
@@ -2911,11 +2929,10 @@ function group_user_attributes($action, $group_id, $user_id_ary = false, $userna
|
||||
AND ' . $db->sql_in_set('ug.user_id', $user_id_ary);
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$user_id_ary = $email_users = array();
|
||||
$user_id_ary = array();
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$user_id_ary[] = $row['user_id'];
|
||||
$email_users[] = $row;
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
@@ -2930,26 +2947,14 @@ function group_user_attributes($action, $group_id, $user_id_ary = false, $userna
|
||||
AND " . $db->sql_in_set('user_id', $user_id_ary);
|
||||
$db->sql_query($sql);
|
||||
|
||||
// Send approved email to users...
|
||||
include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
|
||||
$messenger = new messenger();
|
||||
$phpbb_notifications = $phpbb_container->get('notification_manager');
|
||||
|
||||
foreach ($email_users as $row)
|
||||
{
|
||||
$messenger->template('group_approved', $row['user_lang']);
|
||||
|
||||
$messenger->set_addresses($row);
|
||||
|
||||
$messenger->assign_vars(array(
|
||||
'USERNAME' => htmlspecialchars_decode($row['username']),
|
||||
'GROUP_NAME' => htmlspecialchars_decode($group_name),
|
||||
'U_GROUP' => generate_board_url() . "/ucp.$phpEx?i=groups&mode=membership")
|
||||
);
|
||||
|
||||
$messenger->send($row['user_notify_type']);
|
||||
}
|
||||
|
||||
$messenger->save_queue();
|
||||
$phpbb_notifications->add_notifications('group_request_approved', array(
|
||||
'user_ids' => $user_id_ary,
|
||||
'group_id' => $group_id,
|
||||
'group_name' => $group_name,
|
||||
));
|
||||
$phpbb_notifications->delete_notifications('group_request', $user_id_ary, $group_id);
|
||||
|
||||
$log = 'LOG_USERS_APPROVED';
|
||||
break;
|
||||
|
@@ -161,6 +161,7 @@ class mcp_pm_reports
|
||||
'S_CLOSE_ACTION' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=pm_reports&mode=pm_report_details&r=' . $report_id),
|
||||
'S_CAN_VIEWIP' => $auth->acl_getf_global('m_info'),
|
||||
'S_POST_REPORTED' => $pm_info['message_reported'],
|
||||
'S_REPORT_CLOSED' => $report['report_closed'],
|
||||
'S_USER_NOTES' => true,
|
||||
|
||||
'U_MCP_REPORT' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=pm_reports&mode=pm_report_details&r=' . $report_id),
|
||||
|
@@ -189,6 +189,7 @@ class mcp_reports
|
||||
'S_POST_REPORTED' => $post_info['post_reported'],
|
||||
'S_POST_UNAPPROVED' => ($post_info['post_visibility'] == ITEM_UNAPPROVED),
|
||||
'S_POST_LOCKED' => $post_info['post_edit_locked'],
|
||||
'S_REPORT_CLOSED' => $report['report_closed'],
|
||||
'S_USER_NOTES' => true,
|
||||
|
||||
'U_EDIT' => ($auth->acl_get('m_edit', $post_info['forum_id'])) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=edit&f={$post_info['forum_id']}&p={$post_info['post_id']}") : '',
|
||||
|
@@ -669,10 +669,10 @@ function merge_posts($topic_id, $to_topic_id)
|
||||
}
|
||||
|
||||
// If the topic no longer exist, we will update the topic watch table.
|
||||
phpbb_update_rows_avoiding_duplicates_notify_status($db, TOPICS_WATCH_TABLE, 'topic_id', $topic_ids, $to_topic_id);
|
||||
phpbb_update_rows_avoiding_duplicates_notify_status($db, TOPICS_WATCH_TABLE, 'topic_id', array($topic_id), $to_topic_id);
|
||||
|
||||
// If the topic no longer exist, we will update the bookmarks table.
|
||||
phpbb_update_rows_avoiding_duplicates($db, BOOKMARKS_TABLE, 'topic_id', $topic_id, $to_topic_id);
|
||||
phpbb_update_rows_avoiding_duplicates($db, BOOKMARKS_TABLE, 'topic_id', array($topic_id), $to_topic_id);
|
||||
}
|
||||
|
||||
// Link to the new topic
|
||||
|
34
phpBB/includes/ucp/info/ucp_auth_link.php
Normal file
34
phpBB/includes/ucp/info/ucp_auth_link.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package ucp
|
||||
* @copyright (c) 2013 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @package module_install
|
||||
*/
|
||||
class ucp_auth_link_info
|
||||
{
|
||||
function module()
|
||||
{
|
||||
return array(
|
||||
'filename' => 'ucp_auth_link',
|
||||
'title' => 'UCP_AUTH_LINK',
|
||||
'version' => '1.0.0',
|
||||
'modes' => array(
|
||||
'auth_link' => array('title' => 'UCP_AUTH_LINK_MANAGE', 'auth' => '', 'cat' => array('UCP_PROFILE')),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
function install()
|
||||
{
|
||||
}
|
||||
|
||||
function uninstall()
|
||||
{
|
||||
}
|
||||
}
|
142
phpBB/includes/ucp/ucp_auth_link.php
Normal file
142
phpBB/includes/ucp/ucp_auth_link.php
Normal file
@@ -0,0 +1,142 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package ucp
|
||||
* @copyright (c) 2013 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
class ucp_auth_link
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $u_action;
|
||||
|
||||
/**
|
||||
* Generates the ucp_auth_link page and handles the auth link process
|
||||
*
|
||||
* @param int $id
|
||||
* @param string $mode
|
||||
*/
|
||||
public function main($id, $mode)
|
||||
{
|
||||
global $config, $request, $template, $phpbb_container, $user;
|
||||
|
||||
$error = array();
|
||||
|
||||
$auth_provider = $phpbb_container->get('auth.provider.' . $config['auth_method']);
|
||||
|
||||
// confirm that the auth provider supports this page
|
||||
$provider_data = $auth_provider->get_auth_link_data();
|
||||
if ($provider_data === null)
|
||||
{
|
||||
$error[] = 'UCP_AUTH_LINK_NOT_SUPPORTED';
|
||||
}
|
||||
|
||||
$s_hidden_fields = array();
|
||||
add_form_key('ucp_auth_link');
|
||||
|
||||
$submit = $request->variable('submit', false, false, phpbb_request_interface::POST);
|
||||
|
||||
// This path is only for primary actions
|
||||
if (!sizeof($error) && $submit)
|
||||
{
|
||||
if (!check_form_key('ucp_auth_link'))
|
||||
{
|
||||
$error[] = 'FORM_INVALID';
|
||||
}
|
||||
|
||||
if (!sizeof($error))
|
||||
{
|
||||
// Any post data could be necessary for auth (un)linking
|
||||
$link_data = $request->get_super_global(phpbb_request_interface::POST);
|
||||
|
||||
// The current user_id is also necessary
|
||||
$link_data['user_id'] = $user->data['user_id'];
|
||||
|
||||
// Tell the provider that the method is auth_link not login_link
|
||||
$link_data['link_method'] = 'auth_link';
|
||||
|
||||
if ($request->variable('link', 0, false, phpbb_request_interface::POST))
|
||||
{
|
||||
$error[] = $auth_provider->link_account($link_data);
|
||||
}
|
||||
else
|
||||
{
|
||||
$error[] = $auth_provider->unlink_account($link_data);
|
||||
}
|
||||
|
||||
// Template data may have changed, get new data
|
||||
$provider_data = $auth_provider->get_auth_link_data();
|
||||
}
|
||||
}
|
||||
|
||||
// In some cases, a request to an external server may be required. In
|
||||
// these cases, the GET parameter 'link' should exist and should be true
|
||||
if ($request->variable('link', false))
|
||||
{
|
||||
// In this case the link data should only be populated with the
|
||||
// link_method as the provider dictates how data is returned to it.
|
||||
$link_data = array('link_method' => 'auth_link');
|
||||
|
||||
$error[] = $auth_provider->link_account($link_data);
|
||||
|
||||
// Template data may have changed, get new data
|
||||
$provider_data = $auth_provider->get_auth_link_data();
|
||||
}
|
||||
|
||||
if (isset($provider_data['VARS']))
|
||||
{
|
||||
// Handle hidden fields separately
|
||||
if (isset($provider_data['VARS']['HIDDEN_FIELDS']))
|
||||
{
|
||||
$s_hidden_fields = array_merge($s_hidden_fields, $provider_data['VARS']['HIDDEN_FIELDS']);
|
||||
unset($provider_data['VARS']['HIDDEN_FIELDS']);
|
||||
}
|
||||
|
||||
$template->assign_vars($provider_data['VARS']);
|
||||
}
|
||||
|
||||
if (isset($provider_data['BLOCK_VAR_NAME']))
|
||||
{
|
||||
foreach ($provider_data['BLOCK_VARS'] as $block_vars)
|
||||
{
|
||||
// See if there are additional hidden fields. This should be an associative array
|
||||
if (isset($block_vars['HIDDEN_FIELDS']))
|
||||
{
|
||||
$block_vars['HIDDEN_FIELDS'] = build_hidden_fields($block_vars['HIDDEN_FIELDS']);
|
||||
}
|
||||
|
||||
$template->assign_block_vars($provider_data['BLOCK_VAR_NAME'], $block_vars);
|
||||
}
|
||||
}
|
||||
|
||||
$s_hidden_fields = build_hidden_fields($s_hidden_fields);
|
||||
|
||||
// Replace "error" strings with their real, localised form
|
||||
$error = array_map(array($user, 'lang'), $error);
|
||||
$error = implode('<br />', $error);
|
||||
|
||||
$template->assign_vars(array(
|
||||
'ERROR' => $error,
|
||||
|
||||
'PROVIDER_TEMPLATE_FILE' => $provider_data['TEMPLATE_FILE'],
|
||||
|
||||
'S_HIDDEN_FIELDS' => $s_hidden_fields,
|
||||
'S_UCP_ACTION' => $this->u_action,
|
||||
));
|
||||
|
||||
$this->tpl_name = 'ucp_auth_link';
|
||||
$this->page_title = 'UCP_AUTH_LINK';
|
||||
}
|
||||
}
|
@@ -197,37 +197,6 @@ class ucp_groups
|
||||
else
|
||||
{
|
||||
group_user_add($group_id, $user->data['user_id'], false, false, false, 0, 1);
|
||||
|
||||
include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
|
||||
$messenger = new messenger();
|
||||
|
||||
$sql = 'SELECT u.username, u.username_clean, u.user_email, u.user_notify_type, u.user_jabber, u.user_lang
|
||||
FROM ' . USER_GROUP_TABLE . ' ug, ' . USERS_TABLE . " u
|
||||
WHERE ug.user_id = u.user_id
|
||||
AND ug.group_leader = 1
|
||||
AND ug.group_id = $group_id";
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$messenger->template('group_request', $row['user_lang']);
|
||||
|
||||
$messenger->set_addresses($row);
|
||||
|
||||
$messenger->assign_vars(array(
|
||||
'USERNAME' => htmlspecialchars_decode($row['username']),
|
||||
'GROUP_NAME' => htmlspecialchars_decode($group_row[$group_id]['group_name']),
|
||||
'REQUEST_USERNAME' => $user->data['username'],
|
||||
|
||||
'U_PENDING' => generate_board_url() . "/ucp.$phpEx?i=groups&mode=manage&action=list&g=$group_id",
|
||||
'U_GROUP' => generate_board_url() . "/memberlist.$phpEx?mode=group&g=$group_id")
|
||||
);
|
||||
|
||||
$messenger->send($row['user_notify_type']);
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$messenger->save_queue();
|
||||
}
|
||||
|
||||
add_log('user', $user->data['user_id'], 'LOG_USER_GROUP_JOIN' . (($group_row[$group_id]['group_type'] == GROUP_FREE) ? '' : '_PENDING'), $group_row[$group_id]['group_name']);
|
||||
|
243
phpBB/includes/ucp/ucp_login_link.php
Normal file
243
phpBB/includes/ucp/ucp_login_link.php
Normal file
@@ -0,0 +1,243 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package ucp
|
||||
* @copyright (c) 2013 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* ucp_login_link
|
||||
* Allows users of external accounts link those accounts to their phpBB accounts
|
||||
* during an attempted login.
|
||||
* @package ucp
|
||||
*/
|
||||
class ucp_login_link
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $u_action;
|
||||
|
||||
/**
|
||||
* Generates the ucp_login_link page and handles login link process
|
||||
*
|
||||
* @param int $id
|
||||
* @param string $mode
|
||||
*/
|
||||
function main($id, $mode)
|
||||
{
|
||||
global $config, $phpbb_container, $request, $template, $user;
|
||||
global $phpbb_root_path, $phpEx;
|
||||
|
||||
// Initialize necessary variables
|
||||
$login_error = null;
|
||||
$login_link_error = null;
|
||||
$login_username = null;
|
||||
|
||||
// Build the data array
|
||||
$data = $this->get_login_link_data_array();
|
||||
|
||||
// Ensure the person was sent here with login_link data
|
||||
if (empty($data))
|
||||
{
|
||||
$login_link_error = $user->lang['LOGIN_LINK_NO_DATA_PROVIDED'];
|
||||
}
|
||||
|
||||
// Use the auth_provider requested even if different from configured
|
||||
$auth_provider = 'auth.provider.' . $request->variable('auth_provider', $config['auth_method']);
|
||||
$auth_provider = $phpbb_container->get($auth_provider);
|
||||
|
||||
// Set the link_method to login_link
|
||||
$data['link_method'] = 'login_link';
|
||||
|
||||
// Have the authentication provider check that all necessary data is available
|
||||
$result = $auth_provider->login_link_has_necessary_data($data);
|
||||
if ($result !== null)
|
||||
{
|
||||
$login_link_error = $user->lang[$result];
|
||||
}
|
||||
|
||||
// Perform link action if there is no error
|
||||
if (!$login_link_error)
|
||||
{
|
||||
if ($request->is_set_post('login'))
|
||||
{
|
||||
$login_username = $request->variable('login_username', '', false, phpbb_request_interface::POST);
|
||||
$login_password = $request->untrimmed_variable('login_password', '', true, phpbb_request_interface::POST);
|
||||
|
||||
$login_result = $auth_provider->login($login_username, $login_password);
|
||||
|
||||
// We only care if there is or is not an error
|
||||
$login_error = $this->process_login_result($login_result);
|
||||
|
||||
if (!$login_error)
|
||||
{
|
||||
// Give the user_id to the data
|
||||
$data['user_id'] = $login_result['user_row']['user_id'];
|
||||
|
||||
// The user is now logged in, attempt to link the user to the external account
|
||||
$result = $auth_provider->link_account($data);
|
||||
|
||||
if ($result)
|
||||
{
|
||||
$login_link_error = $user->lang[$result];
|
||||
}
|
||||
else
|
||||
{
|
||||
// Finish login
|
||||
$result = $user->session_create($login_result['user_row']['user_id'], false, false, true);
|
||||
|
||||
// Perform a redirect as the account has been linked
|
||||
$this->perform_redirect();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$template->assign_vars(array(
|
||||
// Common template elements
|
||||
'LOGIN_LINK_ERROR' => $login_link_error,
|
||||
'PASSWORD_CREDENTIAL' => 'login_password',
|
||||
'USERNAME_CREDENTIAL' => 'login_username',
|
||||
'S_HIDDEN_FIELDS' => $this->get_hidden_fields($data),
|
||||
|
||||
// Registration elements
|
||||
'REGISTER_ACTION' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=register'),
|
||||
|
||||
// Login elements
|
||||
'LOGIN_ERROR' => $login_error,
|
||||
'LOGIN_USERNAME' => $login_username,
|
||||
));
|
||||
|
||||
$this->tpl_name = 'ucp_login_link';
|
||||
$this->page_title = 'UCP_LOGIN_LINK';
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the hidden fields string from the data array.
|
||||
*
|
||||
* @param array $data This function only includes data in the array
|
||||
* that has a key that begins with 'login_link_'
|
||||
* @return string A string of hidden fields that can be included in the
|
||||
* template
|
||||
*/
|
||||
protected function get_hidden_fields($data)
|
||||
{
|
||||
$fields = array();
|
||||
|
||||
foreach ($data as $key => $value)
|
||||
{
|
||||
$fields['login_link_' . $key] = $value;
|
||||
}
|
||||
|
||||
return build_hidden_fields($fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the login_link data array
|
||||
*
|
||||
* @return array All login_link data. This is all GET data whose names
|
||||
* begin with 'login_link_'
|
||||
*/
|
||||
protected function get_login_link_data_array()
|
||||
{
|
||||
global $request;
|
||||
|
||||
$var_names = $request->variable_names(phpbb_request_interface::GET);
|
||||
$login_link_data = array();
|
||||
$string_start_length = strlen('login_link_');
|
||||
|
||||
foreach ($var_names as $var_name)
|
||||
{
|
||||
if (strpos($var_name, 'login_link_') === 0)
|
||||
{
|
||||
$key_name = substr($var_name, $string_start_length);
|
||||
$login_link_data[$key_name] = $request->variable($var_name, '', false, phpbb_request_interface::GET);
|
||||
}
|
||||
}
|
||||
|
||||
return $login_link_data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes the result array from the login process
|
||||
* @param array $result The login result array
|
||||
* @return string|null If there was an error in the process, a string is
|
||||
* returned. If the login was successful, then null is
|
||||
* returned.
|
||||
*/
|
||||
protected function process_login_result($result)
|
||||
{
|
||||
global $config, $request, $template, $user;
|
||||
|
||||
$login_error = null;
|
||||
|
||||
if ($result['status'] != LOGIN_SUCCESS)
|
||||
{
|
||||
// Handle all errors first
|
||||
if ($result['status'] == LOGIN_BREAK)
|
||||
{
|
||||
trigger_error($result['error_msg']);
|
||||
}
|
||||
|
||||
switch ($result['status'])
|
||||
{
|
||||
case LOGIN_ERROR_ATTEMPTS:
|
||||
|
||||
$captcha = phpbb_captcha_factory::get_instance($config['captcha_plugin']);
|
||||
$captcha->init(CONFIRM_LOGIN);
|
||||
|
||||
$template->assign_vars(array(
|
||||
'CAPTCHA_TEMPLATE' => $captcha->get_template(),
|
||||
));
|
||||
|
||||
$login_error = $user->lang[$result['error_msg']];
|
||||
break;
|
||||
|
||||
case LOGIN_ERROR_PASSWORD_CONVERT:
|
||||
$login_error = sprintf(
|
||||
$user->lang[$result['error_msg']],
|
||||
($config['email_enable']) ? '<a href="' . append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=sendpassword') . '">' : '',
|
||||
($config['email_enable']) ? '</a>' : '',
|
||||
($config['board_contact']) ? '<a href="mailto:' . htmlspecialchars($config['board_contact']) . '">' : '',
|
||||
($config['board_contact']) ? '</a>' : ''
|
||||
);
|
||||
break;
|
||||
|
||||
// Username, password, etc...
|
||||
default:
|
||||
$login_error = $user->lang[$result['error_msg']];
|
||||
|
||||
// Assign admin contact to some error messages
|
||||
if ($result['error_msg'] == 'LOGIN_ERROR_USERNAME' || $result['error_msg'] == 'LOGIN_ERROR_PASSWORD')
|
||||
{
|
||||
$login_error = (!$config['board_contact']) ? sprintf($user->lang[$result['error_msg']], '', '') : sprintf($user->lang[$result['error_msg']], '<a href="mailto:' . htmlspecialchars($config['board_contact']) . '">', '</a>');
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $login_error;
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a post login redirect
|
||||
*/
|
||||
protected function perform_redirect()
|
||||
{
|
||||
global $phpbb_root_path, $phpEx;
|
||||
$url = append_sid($phpbb_root_path . 'index.' . $phpEx);
|
||||
redirect($url);
|
||||
}
|
||||
}
|
@@ -26,7 +26,7 @@ class ucp_prefs
|
||||
|
||||
function main($id, $mode)
|
||||
{
|
||||
global $config, $db, $user, $auth, $template, $phpbb_root_path, $phpEx;
|
||||
global $config, $db, $user, $auth, $template, $phpbb_dispatcher, $phpbb_root_path, $phpEx;
|
||||
|
||||
$submit = (isset($_POST['submit'])) ? true : false;
|
||||
$error = $data = array();
|
||||
@@ -55,6 +55,20 @@ class ucp_prefs
|
||||
$data['notifymethod'] = NOTIFY_BOTH;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add UCP edit global settings data before they are assigned to the template or submitted
|
||||
*
|
||||
* To assign data to the template, use $template->assign_vars()
|
||||
*
|
||||
* @event core.ucp_prefs_personal_data
|
||||
* @var bool submit Do we display the form only
|
||||
* or did the user press submit
|
||||
* @var array data Array with current ucp options data
|
||||
* @since 3.1-A1
|
||||
*/
|
||||
$vars = array('submit', 'data');
|
||||
extract($phpbb_dispatcher->trigger_event('core.ucp_prefs_personal_data', compact($vars)));
|
||||
|
||||
if ($submit)
|
||||
{
|
||||
if ($config['override_user_style'])
|
||||
@@ -93,6 +107,17 @@ class ucp_prefs
|
||||
'user_style' => $data['style'],
|
||||
);
|
||||
|
||||
/**
|
||||
* Update UCP edit global settings data on form submit
|
||||
*
|
||||
* @event core.ucp_prefs_personal_update_data
|
||||
* @var array data Submitted display options data
|
||||
* @var array sql_ary Display options data we udpate
|
||||
* @since 3.1-A1
|
||||
*/
|
||||
$vars = array('data', 'sql_ary');
|
||||
extract($phpbb_dispatcher->trigger_event('core.ucp_prefs_personal_update_data', compact($vars)));
|
||||
|
||||
$sql = 'UPDATE ' . USERS_TABLE . '
|
||||
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
|
||||
WHERE user_id = ' . $user->data['user_id'];
|
||||
@@ -209,6 +234,20 @@ class ucp_prefs
|
||||
'wordcensor' => request_var('wordcensor', (bool) $user->optionget('viewcensors')),
|
||||
);
|
||||
|
||||
/**
|
||||
* Add UCP edit display options data before they are assigned to the template or submitted
|
||||
*
|
||||
* To assign data to the template, use $template->assign_vars()
|
||||
*
|
||||
* @event core.ucp_prefs_view_data
|
||||
* @var bool submit Do we display the form only
|
||||
* or did the user press submit
|
||||
* @var array data Array with current ucp options data
|
||||
* @since 3.1-A1
|
||||
*/
|
||||
$vars = array('submit', 'data');
|
||||
extract($phpbb_dispatcher->trigger_event('core.ucp_prefs_view_data', compact($vars)));
|
||||
|
||||
if ($submit)
|
||||
{
|
||||
$error = validate_data($data, array(
|
||||
@@ -247,6 +286,17 @@ class ucp_prefs
|
||||
'user_post_show_days' => $data['post_st'],
|
||||
);
|
||||
|
||||
/**
|
||||
* Update UCP edit display options data on form submit
|
||||
*
|
||||
* @event core.ucp_prefs_view_update_data
|
||||
* @var array data Submitted display options data
|
||||
* @var array sql_ary Display options data we udpate
|
||||
* @since 3.1-A1
|
||||
*/
|
||||
$vars = array('data', 'sql_ary');
|
||||
extract($phpbb_dispatcher->trigger_event('core.ucp_prefs_view_update_data', compact($vars)));
|
||||
|
||||
$sql = 'UPDATE ' . USERS_TABLE . '
|
||||
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
|
||||
WHERE user_id = ' . $user->data['user_id'];
|
||||
@@ -335,6 +385,20 @@ class ucp_prefs
|
||||
);
|
||||
add_form_key('ucp_prefs_post');
|
||||
|
||||
/**
|
||||
* Add UCP edit posting defaults data before they are assigned to the template or submitted
|
||||
*
|
||||
* To assign data to the template, use $template->assign_vars()
|
||||
*
|
||||
* @event core.ucp_prefs_post_data
|
||||
* @var bool submit Do we display the form only
|
||||
* or did the user press submit
|
||||
* @var array data Array with current ucp options data
|
||||
* @since 3.1-A1
|
||||
*/
|
||||
$vars = array('submit', 'data');
|
||||
extract($phpbb_dispatcher->trigger_event('core.ucp_prefs_post_data', compact($vars)));
|
||||
|
||||
if ($submit)
|
||||
{
|
||||
if (check_form_key('ucp_prefs_post'))
|
||||
@@ -348,6 +412,17 @@ class ucp_prefs
|
||||
'user_notify' => $data['notify'],
|
||||
);
|
||||
|
||||
/**
|
||||
* Update UCP edit posting defaults data on form submit
|
||||
*
|
||||
* @event core.ucp_prefs_post_update_data
|
||||
* @var array data Submitted display options data
|
||||
* @var array sql_ary Display options data we udpate
|
||||
* @since 3.1-A1
|
||||
*/
|
||||
$vars = array('data', 'sql_ary');
|
||||
extract($phpbb_dispatcher->trigger_event('core.ucp_prefs_post_update_data', compact($vars)));
|
||||
|
||||
$sql = 'UPDATE ' . USERS_TABLE . '
|
||||
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
|
||||
WHERE user_id = ' . $user->data['user_id'];
|
||||
|
@@ -27,7 +27,7 @@ class ucp_register
|
||||
function main($id, $mode)
|
||||
{
|
||||
global $config, $db, $user, $auth, $template, $phpbb_root_path, $phpEx;
|
||||
global $request;
|
||||
global $request, $phpbb_container;
|
||||
|
||||
//
|
||||
if ($config['require_activation'] == USER_ACTIVATION_DISABLE)
|
||||
@@ -78,19 +78,37 @@ class ucp_register
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$cp = new custom_profile();
|
||||
|
||||
$error = $cp_data = $cp_error = array();
|
||||
$s_hidden_fields = array();
|
||||
|
||||
// Handle login_link data added to $_hidden_fields
|
||||
$login_link_data = $this->get_login_link_data_array();
|
||||
|
||||
if (!empty($login_link_data))
|
||||
{
|
||||
// Confirm that we have all necessary data
|
||||
$auth_provider = 'auth.provider.' . $request->variable('auth_provider', $config['auth_method']);
|
||||
$auth_provider = $phpbb_container->get($auth_provider);
|
||||
|
||||
$result = $auth_provider->login_link_has_necessary_data($login_link_data);
|
||||
if ($result !== null)
|
||||
{
|
||||
$error[] = $user->lang[$result];
|
||||
}
|
||||
|
||||
$s_hidden_fields = array_merge($s_hidden_fields, $this->get_login_link_data_for_hidden_fields($login_link_data));
|
||||
}
|
||||
|
||||
if (!$agreed || ($coppa === false && $config['coppa_enable']) || ($coppa && !$config['coppa_enable']))
|
||||
{
|
||||
$add_lang = ($change_lang) ? '&change_lang=' . urlencode($change_lang) : '';
|
||||
$add_coppa = ($coppa !== false) ? '&coppa=' . $coppa : '';
|
||||
|
||||
$s_hidden_fields = array(
|
||||
$s_hidden_fields = array_merge($s_hidden_fields, array(
|
||||
'change_lang' => '',
|
||||
);
|
||||
));
|
||||
|
||||
// If we change the language, we want to pass on some more possible parameter.
|
||||
if ($change_lang)
|
||||
@@ -398,15 +416,28 @@ class ucp_register
|
||||
}
|
||||
}
|
||||
|
||||
// Perform account linking if necessary
|
||||
if (!empty($login_link_data))
|
||||
{
|
||||
$login_link_data['user_id'] = $user_id;
|
||||
|
||||
$result = $auth_provider->link_account($login_link_data);
|
||||
|
||||
if ($result)
|
||||
{
|
||||
$message = $message . '<br /><br />' . $user->lang[$result];
|
||||
}
|
||||
}
|
||||
|
||||
$message = $message . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . append_sid("{$phpbb_root_path}index.$phpEx") . '">', '</a>');
|
||||
trigger_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
$s_hidden_fields = array(
|
||||
$s_hidden_fields = array_merge($s_hidden_fields, array(
|
||||
'agreed' => 'true',
|
||||
'change_lang' => 0,
|
||||
);
|
||||
));
|
||||
|
||||
if ($config['coppa_enable'])
|
||||
{
|
||||
@@ -474,4 +505,49 @@ class ucp_register
|
||||
$this->tpl_name = 'ucp_register';
|
||||
$this->page_title = 'UCP_REGISTRATION';
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the login_link data array
|
||||
*
|
||||
* @return array Returns an array of all POST paramaters whose names
|
||||
* begin with 'login_link_'
|
||||
*/
|
||||
protected function get_login_link_data_array()
|
||||
{
|
||||
global $request;
|
||||
|
||||
$var_names = $request->variable_names(phpbb_request_interface::POST);
|
||||
$login_link_data = array();
|
||||
$string_start_length = strlen('login_link_');
|
||||
|
||||
foreach ($var_names as $var_name)
|
||||
{
|
||||
if (strpos($var_name, 'login_link_') === 0)
|
||||
{
|
||||
$key_name = substr($var_name, $string_start_length);
|
||||
$login_link_data[$key_name] = $request->variable($var_name, '', false, phpbb_request_interface::POST);
|
||||
}
|
||||
}
|
||||
|
||||
return $login_link_data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepends they key names of an associative array with 'login_link_' for
|
||||
* inclusion on the page as hidden fields.
|
||||
*
|
||||
* @param array $data The array to be modified
|
||||
* @return array The modified array
|
||||
*/
|
||||
protected function get_login_link_data_for_hidden_fields($data)
|
||||
{
|
||||
$new_data = array();
|
||||
|
||||
foreach ($data as $key => $value)
|
||||
{
|
||||
$new_data['login_link_' . $key] = $value;
|
||||
}
|
||||
|
||||
return $new_data;
|
||||
}
|
||||
}
|
||||
|
@@ -101,6 +101,8 @@ class ucp_remind
|
||||
|
||||
$messenger->set_addresses($user_row);
|
||||
|
||||
$messenger->anti_abuse_headers($config, $user);
|
||||
|
||||
$messenger->assign_vars(array(
|
||||
'USERNAME' => htmlspecialchars_decode($user_row['username']),
|
||||
'PASSWORD' => htmlspecialchars_decode($user_password),
|
||||
|
Reference in New Issue
Block a user