diff options
Diffstat (limited to 'phpBB/includes')
36 files changed, 358 insertions, 241 deletions
diff --git a/phpBB/includes/acp/acp_attachments.php b/phpBB/includes/acp/acp_attachments.php index 6c2df8d999..5b1db5c31b 100644 --- a/phpBB/includes/acp/acp_attachments.php +++ b/phpBB/includes/acp/acp_attachments.php @@ -164,7 +164,6 @@ class acp_attachments 'img_create_thumbnail' => array('lang' => 'CREATE_THUMBNAIL', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 'img_max_thumb_width' => array('lang' => 'MAX_THUMB_WIDTH', 'validate' => 'int:0:999999999999999', 'type' => 'number:0:999999999999999', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']), 'img_min_thumb_filesize' => array('lang' => 'MIN_THUMB_FILESIZE', 'validate' => 'int:0:999999999999999', 'type' => 'number:0:999999999999999', 'explain' => true, 'append' => ' ' . $user->lang['BYTES']), - 'img_imagick' => array('lang' => 'IMAGICK_PATH', 'validate' => 'absolute_path', 'type' => 'text:20:200', 'explain' => true, 'append' => ' <span>[ <a href="' . $this->u_action . '&action=imgmagick">' . $user->lang['SEARCH_IMAGICK'] . '</a> ]</span>'), 'img_max' => array('lang' => 'MAX_IMAGE_SIZE', 'validate' => 'int:0:9999', 'type' => 'dimension:0:9999', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']), 'img_link' => array('lang' => 'IMAGE_LINK_SIZE', 'validate' => 'int:0:9999', 'type' => 'dimension:0:9999', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']), ) @@ -234,38 +233,6 @@ class acp_attachments $template->assign_var('S_ATTACHMENT_SETTINGS', true); - if ($action == 'imgmagick') - { - $this->new_config['img_imagick'] = $this->search_imagemagick(); - } - - // We strip eventually manual added convert program, we only want the patch - if ($this->new_config['img_imagick']) - { - // Change path separator - $this->new_config['img_imagick'] = str_replace('\\', '/', $this->new_config['img_imagick']); - $this->new_config['img_imagick'] = str_replace(array('convert', '.exe'), array('', ''), $this->new_config['img_imagick']); - - // Check for trailing slash - if (substr($this->new_config['img_imagick'], -1) !== '/') - { - $this->new_config['img_imagick'] .= '/'; - } - } - - $supported_types = get_supported_image_types(); - - // Check Thumbnail Support - if (!$this->new_config['img_imagick'] && (!isset($supported_types['format']) || !count($supported_types['format']))) - { - $this->new_config['img_create_thumbnail'] = 0; - } - - $template->assign_vars(array( - 'U_SEARCH_IMAGICK' => $this->u_action . '&action=imgmagick', - 'S_THUMBNAIL_SUPPORT' => (!$this->new_config['img_imagick'] && (!isset($supported_types['format']) || !count($supported_types['format']))) ? false : true) - ); - // Secure Download Options - Same procedure as with banning $allow_deny = ($this->new_config['secure_allow_deny']) ? 'ALLOWED' : 'DISALLOWED'; @@ -1496,47 +1463,6 @@ class acp_attachments } /** - * Search Imagick - */ - function search_imagemagick() - { - $imagick = ''; - - $exe = ((defined('PHP_OS')) && (preg_match('#^win#i', PHP_OS))) ? '.exe' : ''; - - $magic_home = getenv('MAGICK_HOME'); - - if (empty($magic_home)) - { - $locations = array('C:/WINDOWS/', 'C:/WINNT/', 'C:/WINDOWS/SYSTEM/', 'C:/WINNT/SYSTEM/', 'C:/WINDOWS/SYSTEM32/', 'C:/WINNT/SYSTEM32/', '/usr/bin/', '/usr/sbin/', '/usr/local/bin/', '/usr/local/sbin/', '/opt/', '/usr/imagemagick/', '/usr/bin/imagemagick/'); - $path_locations = str_replace('\\', '/', (explode(($exe) ? ';' : ':', getenv('PATH')))); - - $locations = array_merge($path_locations, $locations); - - foreach ($locations as $location) - { - // The path might not end properly, fudge it - if (substr($location, -1) !== '/') - { - $location .= '/'; - } - - if (@file_exists($location) && @is_readable($location . 'mogrify' . $exe) && @filesize($location . 'mogrify' . $exe) > 3000) - { - $imagick = str_replace('\\', '/', $location); - continue; - } - } - } - else - { - $imagick = str_replace('\\', '/', $magic_home); - } - - return $imagick; - } - - /** * Test Settings */ function test_upload(&$error, $upload_dir, $create_directory = false) diff --git a/phpBB/includes/acp/acp_database.php b/phpBB/includes/acp/acp_database.php index b98756a34b..19c4f6e4f1 100644 --- a/phpBB/includes/acp/acp_database.php +++ b/phpBB/includes/acp/acp_database.php @@ -203,7 +203,7 @@ class acp_database $file = $request->variable('file', ''); $download = $request->variable('download', ''); - if (!preg_match('#^backup_\d{10,}_[a-z\d]{16}\.(sql(?:\.(?:gz|bz2))?)$#', $file, $matches)) + if (!preg_match('#^backup_\d{10,}_(?:[a-z\d]{16}|[a-z\d]{32})\.(sql(?:\.(?:gz|bz2))?)$#i', $file, $matches)) { trigger_error($user->lang['BACKUP_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING); } @@ -402,7 +402,7 @@ class acp_database { while (($file = readdir($dh)) !== false) { - if (preg_match('#^backup_(\d{10,})_[a-z\d]{16}\.(sql(?:\.(?:gz|bz2))?)$#', $file, $matches)) + if (preg_match('#^backup_(\d{10,})_(?:[a-z\d]{16}|[a-z\d]{32})\.(sql(?:\.(?:gz|bz2))?)$#i', $file, $matches)) { if (in_array($matches[2], $methods)) { diff --git a/phpBB/includes/acp/acp_extensions.php b/phpBB/includes/acp/acp_extensions.php index 6f65dc9fa0..a1cb2108e7 100644 --- a/phpBB/includes/acp/acp_extensions.php +++ b/phpBB/includes/acp/acp_extensions.php @@ -35,11 +35,13 @@ class acp_extensions private $request; private $phpbb_dispatcher; private $ext_manager; + private $phpbb_container; + private $php_ini; function main() { // Start the page - global $config, $user, $template, $request, $phpbb_extension_manager, $phpbb_root_path, $phpbb_log, $phpbb_dispatcher; + global $config, $user, $template, $request, $phpbb_extension_manager, $phpbb_root_path, $phpbb_log, $phpbb_dispatcher, $phpbb_container; $this->config = $config; $this->template = $template; @@ -48,6 +50,8 @@ class acp_extensions $this->log = $phpbb_log; $this->phpbb_dispatcher = $phpbb_dispatcher; $this->ext_manager = $phpbb_extension_manager; + $this->phpbb_container = $phpbb_container; + $this->php_ini = $this->phpbb_container->get('php_ini'); $this->user->add_lang(array('install', 'acp/extensions', 'migrator')); @@ -57,7 +61,7 @@ class acp_extensions $ext_name = $this->request->variable('ext_name', ''); // What is a safe limit of execution time? Half the max execution time should be safe. - $safe_time_limit = (ini_get('max_execution_time') / 2); + $safe_time_limit = ($this->php_ini->getNumeric('max_execution_time') / 2); $start_time = time(); // Cancel action diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index 13d74f0811..be5a7a2f26 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -1541,6 +1541,16 @@ class acp_forums $table_ary = array(LOG_TABLE, POSTS_TABLE, TOPICS_TABLE, DRAFTS_TABLE, TOPICS_TRACK_TABLE); + /** + * Perform additional actions before move forum content + * + * @event core.acp_manage_forums_move_content_sql_before + * @var array table_ary Array of tables from which forum_id will be updated + * @since 3.2.4-RC1 + */ + $vars = array('table_ary'); + extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_move_content_sql_before', compact($vars))); + foreach ($table_ary as $table) { $sql = "UPDATE $table diff --git a/phpBB/includes/acp/acp_inactive.php b/phpBB/includes/acp/acp_inactive.php index 6026f44ede..66f0d2116c 100644 --- a/phpBB/includes/acp/acp_inactive.php +++ b/phpBB/includes/acp/acp_inactive.php @@ -24,7 +24,7 @@ class acp_inactive var $u_action; var $p_master; - function acp_inactive(&$p_master) + function __construct(&$p_master) { $this->p_master = &$p_master; } diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php index 60afccdc22..b74fe535ee 100644 --- a/phpBB/includes/acp/acp_users.php +++ b/phpBB/includes/acp/acp_users.php @@ -24,7 +24,7 @@ class acp_users var $u_action; var $p_master; - function acp_users(&$p_master) + function __construct(&$p_master) { $this->p_master = &$p_master; } @@ -1883,6 +1883,17 @@ class acp_users 'user_avatar_height' => $result['avatar_height'], ); + /** + * Modify users preferences data before assigning it to the template + * + * @event core.acp_users_avatar_sql + * @var array user_row Array with user data + * @var array result Array with user avatar data to be updated in the DB + * @since 3.2.4-RC1 + */ + $vars = array('user_row', 'result'); + extract($phpbb_dispatcher->trigger_event('core.acp_users_avatar_sql', compact($vars))); + $sql = 'UPDATE ' . USERS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $result) . ' WHERE user_id = ' . (int) $user_id; @@ -2085,6 +2096,17 @@ class acp_users 'user_sig_bbcode_bitfield' => $bbcode_bitfield, ); + /** + * Modify user signature before it is stored in the DB + * + * @event core.acp_users_modify_signature_sql_ary + * @var array user_row Array with user data + * @var array sql_ary Array with user signature data to be updated in the DB + * @since 3.2.4-RC1 + */ + $vars = array('user_row', 'sql_ary'); + extract($phpbb_dispatcher->trigger_event('core.acp_users_modify_signature_sql_ary', compact($vars))); + $sql = 'UPDATE ' . USERS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' WHERE user_id = ' . $user_id; diff --git a/phpBB/includes/acp/auth.php b/phpBB/includes/acp/auth.php index 58da3b922f..b414a3121a 100644 --- a/phpBB/includes/acp/auth.php +++ b/phpBB/includes/acp/auth.php @@ -27,7 +27,7 @@ class auth_admin extends \phpbb\auth\auth /** * Init auth settings */ - function auth_admin() + function __construct() { global $db, $cache; @@ -819,7 +819,7 @@ class auth_admin extends \phpbb\auth\auth // Because we just changed the options and also purged the options cache, we instantly update/regenerate it for later calls to succeed. $this->acl_options = array(); - $this->auth_admin(); + $this->__construct(); return true; } diff --git a/phpBB/includes/bbcode.php b/phpBB/includes/bbcode.php index 239e5c8ad6..c31b63a403 100644 --- a/phpBB/includes/bbcode.php +++ b/phpBB/includes/bbcode.php @@ -35,9 +35,18 @@ class bbcode /** * Constructor + */ + function __construct($bitfield = '') + { + $this->bbcode_set_bitfield($bitfield); + } + + /** * Init bbcode cache entries if bitfield is specified + * + * @param string $bbcode_bitfield The bbcode bitfield */ - function bbcode($bitfield = '') + function bbcode_set_bitfield($bitfield = '') { if ($bitfield) { diff --git a/phpBB/includes/constants.php b/phpBB/includes/constants.php index 29ca6959c8..70ceed1036 100644 --- a/phpBB/includes/constants.php +++ b/phpBB/includes/constants.php @@ -28,7 +28,7 @@ if (!defined('IN_PHPBB')) */ // phpBB Version -@define('PHPBB_VERSION', '3.2.4-dev'); +@define('PHPBB_VERSION', '3.2.5-dev'); // QA-related // define('PHPBB_QA', 1); diff --git a/phpBB/includes/diff/diff.php b/phpBB/includes/diff/diff.php index 68c6c6e6a8..d8ae9d77ac 100644 --- a/phpBB/includes/diff/diff.php +++ b/phpBB/includes/diff/diff.php @@ -50,7 +50,7 @@ class diff * @param array &$to_content An array of strings. * @param bool $preserve_cr If true, \r is replaced by a new line in the diff output */ - function diff(&$from_content, &$to_content, $preserve_cr = true) + function __construct(&$from_content, &$to_content, $preserve_cr = true) { $diff_engine = new diff_engine(); $this->_edits = $diff_engine->diff($from_content, $to_content, $preserve_cr); @@ -330,14 +330,14 @@ class mapped_diff extends diff * compared when computing the diff. * @param array $mapped_to_lines This array should have the same number of elements as $to_lines. */ - function mapped_diff(&$from_lines, &$to_lines, &$mapped_from_lines, &$mapped_to_lines) + function __construct(&$from_lines, &$to_lines, &$mapped_from_lines, &$mapped_to_lines) { if (count($from_lines) != count($mapped_from_lines) || count($to_lines) != count($mapped_to_lines)) { return false; } - parent::diff($mapped_from_lines, $mapped_to_lines); + parent::__construct($mapped_from_lines, $mapped_to_lines); $xi = $yi = 0; for ($i = 0; $i < count($this->_edits); $i++) @@ -394,7 +394,7 @@ class diff_op */ class diff_op_copy extends diff_op { - function diff_op_copy($orig, $final = false) + function __construct($orig, $final = false) { if (!is_array($final)) { @@ -419,7 +419,7 @@ class diff_op_copy extends diff_op */ class diff_op_delete extends diff_op { - function diff_op_delete($lines) + function __construct($lines) { $this->orig = $lines; $this->final = false; @@ -440,7 +440,7 @@ class diff_op_delete extends diff_op */ class diff_op_add extends diff_op { - function diff_op_add($lines) + function __construct($lines) { $this->final = $lines; $this->orig = false; @@ -461,7 +461,7 @@ class diff_op_add extends diff_op */ class diff_op_change extends diff_op { - function diff_op_change($orig, $final) + function __construct($orig, $final) { $this->orig = $orig; $this->final = $final; @@ -498,7 +498,7 @@ class diff3 extends diff * @param bool $preserve_cr If true, \r\n and bare \r are replaced by a new line * in the diff output */ - function diff3(&$orig, &$final1, &$final2, $preserve_cr = true) + function __construct(&$orig, &$final1, &$final2, $preserve_cr = true) { $diff_engine = new diff_engine(); @@ -754,7 +754,7 @@ class diff3 extends diff */ class diff3_op { - function diff3_op($orig = false, $final1 = false, $final2 = false) + function __construct($orig = false, $final1 = false, $final2 = false) { $this->orig = $orig ? $orig : array(); $this->final1 = $final1 ? $final1 : array(); @@ -1066,7 +1066,7 @@ class diff3_op */ class diff3_op_copy extends diff3_op { - function diff3_op_copy($lines = false) + function __construct($lines = false) { $this->orig = $lines ? $lines : array(); $this->final1 = &$this->orig; @@ -1092,7 +1092,7 @@ class diff3_op_copy extends diff3_op */ class diff3_block_builder { - function diff3_block_builder() + function __construct() { $this->_init(); } diff --git a/phpBB/includes/diff/renderer.php b/phpBB/includes/diff/renderer.php index c12ff3b7d5..8a8b0c295e 100644 --- a/phpBB/includes/diff/renderer.php +++ b/phpBB/includes/diff/renderer.php @@ -56,7 +56,7 @@ class diff_renderer /** * Constructor. */ - function diff_renderer($params = array()) + function __construct($params = array()) { foreach ($params as $param => $value) { diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 3fec88a354..99f65a0e92 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -115,7 +115,7 @@ function gen_rand_string_friendly($num_chars = 8) */ function unique_id() { - return gen_rand_string(32); + return strtolower(gen_rand_string(16)); } /** diff --git a/phpBB/includes/functions_acp.php b/phpBB/includes/functions_acp.php index 8bf42aa36e..9b7491305c 100644 --- a/phpBB/includes/functions_acp.php +++ b/phpBB/includes/functions_acp.php @@ -564,9 +564,6 @@ function validate_config_vars($config_vars, &$cfg_array, &$error) $cfg_array[$config_name] = trim($destination); - // Absolute file path - case 'absolute_path': - case 'absolute_path_writable': // Path being relative (still prefixed by phpbb_root_path), but with the ability to escape the root dir... case 'path': case 'wpath': @@ -585,7 +582,7 @@ function validate_config_vars($config_vars, &$cfg_array, &$error) break; } - $path = in_array($config_definition['validate'], array('wpath', 'path', 'rpath', 'rwpath')) ? $phpbb_root_path . $cfg_array[$config_name] : $cfg_array[$config_name]; + $path = $phpbb_root_path . $cfg_array[$config_name]; if (!file_exists($path)) { @@ -598,7 +595,7 @@ function validate_config_vars($config_vars, &$cfg_array, &$error) } // Check if the path is writable - if ($config_definition['validate'] == 'wpath' || $config_definition['validate'] == 'rwpath' || $config_definition['validate'] === 'absolute_path_writable') + if ($config_definition['validate'] == 'wpath' || $config_definition['validate'] == 'rwpath') { if (file_exists($path) && !$phpbb_filesystem->is_writable($path)) { diff --git a/phpBB/includes/functions_compress.php b/phpBB/includes/functions_compress.php index 77e03ee449..e86da77b38 100644 --- a/phpBB/includes/functions_compress.php +++ b/phpBB/includes/functions_compress.php @@ -210,7 +210,7 @@ class compress_zip extends compress /** * Constructor */ - function compress_zip($mode, $file) + function __construct($mode, $file) { global $phpbb_filesystem; @@ -569,7 +569,7 @@ class compress_tar extends compress /** * Constructor */ - function compress_tar($mode, $file, $type = '') + function __construct($mode, $file, $type = '') { global $phpbb_filesystem; diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php index e124bd46e6..8284aab6a4 100644 --- a/phpBB/includes/functions_content.php +++ b/phpBB/includes/functions_content.php @@ -627,7 +627,7 @@ function generate_text_for_display($text, $uid, $bitfield, $flags, $censor_text } else { - $bbcode->bbcode($bitfield); + $bbcode->bbcode_set_bitfield($bitfield); } $bbcode->bbcode_second_pass($text, $uid); @@ -1672,7 +1672,7 @@ class bitfield { var $data; - function bitfield($bitfield = '') + function __construct($bitfield = '') { $this->data = base64_decode($bitfield); } diff --git a/phpBB/includes/functions_messenger.php b/phpBB/includes/functions_messenger.php index 75c15657b0..4f0d40031d 100644 --- a/phpBB/includes/functions_messenger.php +++ b/phpBB/includes/functions_messenger.php @@ -37,7 +37,7 @@ class messenger /** * Constructor */ - function messenger($use_queue = true) + function __construct($use_queue = true) { global $config; @@ -326,10 +326,26 @@ class messenger )); $subject = $this->subject; - $message = $this->msg; - $template = $this->template; + $template = $this->template; /** - * Event to modify notification message text before parsing + * Event to modify the template before parsing + * + * @event core.modify_notification_template + * @var int method User notification method NOTIFY_EMAIL|NOTIFY_IM|NOTIFY_BOTH + * @var bool break Flag indicating if the function only formats the subject + * and the message without sending it + * @var string subject The message subject + * @var \phpbb\template\template template The (readonly) template object + * @since 3.2.4-RC1 + */ + $vars = array('method', 'break', 'subject', 'template'); + extract($phpbb_dispatcher->trigger_event('core.modify_notification_template', compact($vars))); + + // Parse message through template + $message = trim($this->template->assign_display('body')); + + /** + * Event to modify notification message text after parsing * * @event core.modify_notification_message * @var int method User notification method NOTIFY_EMAIL|NOTIFY_IM|NOTIFY_BOTH @@ -337,24 +353,14 @@ class messenger * and the message without sending it * @var string subject The message subject * @var string message The message text - * @var \phpbb\template\template template Template object * @since 3.1.11-RC1 - * @changed 3.2.4-RC1 Added template */ - $vars = array( - 'method', - 'break', - 'subject', - 'message', - 'template', - ); + $vars = array('method', 'break', 'subject', 'message'); extract($phpbb_dispatcher->trigger_event('core.modify_notification_message', compact($vars))); + $this->subject = $subject; $this->msg = $message; - unset($subject, $message); - - // Parse message through template - $this->msg = trim($this->template->assign_display('body')); + unset($subject, $message, $template); // Because we use \n for newlines in the body message we need to fix line encoding errors for those admins who uploaded email template files in the wrong encoding $this->msg = str_replace("\r\n", "\n", $this->msg); @@ -373,6 +379,12 @@ class messenger $this->subject = (($this->subject != '') ? $this->subject : $user->lang['NO_EMAIL_SUBJECT']); } + if (preg_match('#^(List-Unsubscribe:(.*?))$#m', $this->msg, $match)) + { + $this->extra_headers[] = $match[1]; + $drop_header .= '[\r\n]*?' . preg_quote($match[1], '#'); + } + if ($drop_header) { $this->msg = trim(preg_replace('#' . $drop_header . '#s', '', $this->msg)); @@ -781,7 +793,7 @@ class queue /** * constructor */ - function queue() + function __construct() { global $phpEx, $phpbb_root_path, $phpbb_filesystem, $phpbb_container; @@ -1317,7 +1329,7 @@ class smtp_class var $backtrace = false; var $backtrace_log = array(); - function smtp_class() + function __construct() { // Always create a backtrace for admins to identify SMTP problems $this->backtrace = true; diff --git a/phpBB/includes/functions_module.php b/phpBB/includes/functions_module.php index 3563a646e8..88dafc4300 100644 --- a/phpBB/includes/functions_module.php +++ b/phpBB/includes/functions_module.php @@ -40,7 +40,7 @@ class p_master * Constuctor * Set module include path */ - function p_master($include_path = false) + function __construct($include_path = false) { global $phpbb_root_path; diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 1e8f1ad00d..c7d691287c 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -519,7 +519,7 @@ function get_supported_image_types($type = false) */ function create_thumbnail($source, $destination, $mimetype) { - global $config, $phpbb_filesystem; + global $config, $phpbb_filesystem, $phpbb_dispatcher; $min_filesize = (int) $config['img_min_thumb_filesize']; $img_filesize = (file_exists($source)) ? @filesize($source) : false; @@ -551,25 +551,31 @@ function create_thumbnail($source, $destination, $mimetype) return false; } - $used_imagick = false; + $thumbnail_created = false; - // Only use ImageMagick if defined and the passthru function not disabled - if ($config['img_imagick'] && function_exists('passthru')) - { - if (substr($config['img_imagick'], -1) !== '/') - { - $config['img_imagick'] .= '/'; - } - - @passthru(escapeshellcmd($config['img_imagick']) . 'convert' . ((defined('PHP_OS') && preg_match('#^win#i', PHP_OS)) ? '.exe' : '') . ' -quality 85 -geometry ' . $new_width . 'x' . $new_height . ' "' . str_replace('\\', '/', $source) . '" "' . str_replace('\\', '/', $destination) . '"'); - - if (file_exists($destination)) - { - $used_imagick = true; - } - } + /** + * Create thumbnail event to replace GD thumbnail creation with for example ImageMagick + * + * @event core.thumbnail_create_before + * @var string source Image source path + * @var string destination Thumbnail destination path + * @var string mimetype Image mime type + * @var float new_width Calculated thumbnail width + * @var float new_height Calculated thumbnail height + * @var bool thumbnail_created Set to true to skip default GD thumbnail creation + * @since 3.2.4 + */ + $vars = array( + 'source', + 'destination', + 'mimetype', + 'new_width', + 'new_height', + 'thumbnail_created', + ); + extract($phpbb_dispatcher->trigger_event('core.thumbnail_create_before', compact($vars))); - if (!$used_imagick) + if (!$thumbnail_created) { $type = get_supported_image_types($type); diff --git a/phpBB/includes/functions_transfer.php b/phpBB/includes/functions_transfer.php index 67ce2211e7..7427b89917 100644 --- a/phpBB/includes/functions_transfer.php +++ b/phpBB/includes/functions_transfer.php @@ -38,7 +38,7 @@ class transfer /** * Constructor - init some basic values */ - function transfer() + function __construct() { global $phpbb_root_path; @@ -264,7 +264,7 @@ class ftp extends transfer /** * Standard parameters for FTP session */ - function ftp($host, $username, $password, $root_path, $port = 21, $timeout = 10) + function __construct($host, $username, $password, $root_path, $port = 21, $timeout = 10) { $this->host = $host; $this->port = $port; @@ -512,7 +512,7 @@ class ftp_fsock extends transfer /** * Standard parameters for FTP session */ - function ftp_fsock($host, $username, $password, $root_path, $port = 21, $timeout = 10) + function __construct($host, $username, $password, $root_path, $port = 21, $timeout = 10) { $this->host = $host; $this->port = $port; @@ -529,7 +529,7 @@ class ftp_fsock extends transfer } // Init some needed values - $this->transfer(); + parent::__construct(); return; } diff --git a/phpBB/includes/hooks/index.php b/phpBB/includes/hooks/index.php index 805e0eea1a..821242cbf4 100644 --- a/phpBB/includes/hooks/index.php +++ b/phpBB/includes/hooks/index.php @@ -44,7 +44,7 @@ class phpbb_hook * * @param array $valid_hooks array containing the hookable functions/methods */ - function phpbb_hook($valid_hooks) + function __construct($valid_hooks) { foreach ($valid_hooks as $_null => $method) { diff --git a/phpBB/includes/mcp/mcp_logs.php b/phpBB/includes/mcp/mcp_logs.php index cbc84e8c64..049f24b262 100644 --- a/phpBB/includes/mcp/mcp_logs.php +++ b/phpBB/includes/mcp/mcp_logs.php @@ -28,7 +28,7 @@ class mcp_logs var $u_action; var $p_master; - function mcp_logs(&$p_master) + function __construct(&$p_master) { $this->p_master = &$p_master; } diff --git a/phpBB/includes/mcp/mcp_main.php b/phpBB/includes/mcp/mcp_main.php index 2133bd9a19..196d2f995f 100644 --- a/phpBB/includes/mcp/mcp_main.php +++ b/phpBB/includes/mcp/mcp_main.php @@ -28,7 +28,7 @@ class mcp_main var $p_master; var $u_action; - function mcp_main(&$p_master) + function __construct(&$p_master) { $this->p_master = &$p_master; } @@ -1458,6 +1458,24 @@ function mcp_fork_topic($topic_ids) $db->sql_query('INSERT INTO ' . POSTS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary)); $new_post_id = $db->sql_nextid(); + /** + * Perform actions after forked topic is created. + * + * @event core.mcp_main_fork_sql_after + * @var int new_topic_id The newly created topic ID + * @var int to_forum_id The forum ID where the forked topic has been moved to + * @var int new_post_id The newly created post ID + * @var array row Post data + * @since 3.2.4-RC1 + */ + $vars = array( + 'new_topic_id', + 'to_forum_id', + 'new_post_id', + 'row', + ); + extract($phpbb_dispatcher->trigger_event('core.mcp_main_fork_sql_after', compact($vars))); + switch ($row['post_visibility']) { case ITEM_APPROVED: diff --git a/phpBB/includes/mcp/mcp_notes.php b/phpBB/includes/mcp/mcp_notes.php index 67f59bd618..12b116e495 100644 --- a/phpBB/includes/mcp/mcp_notes.php +++ b/phpBB/includes/mcp/mcp_notes.php @@ -28,7 +28,7 @@ class mcp_notes var $p_master; var $u_action; - function mcp_notes(&$p_master) + function __construct(&$p_master) { $this->p_master = &$p_master; } diff --git a/phpBB/includes/mcp/mcp_pm_reports.php b/phpBB/includes/mcp/mcp_pm_reports.php index c17b9985af..ba89733bfe 100644 --- a/phpBB/includes/mcp/mcp_pm_reports.php +++ b/phpBB/includes/mcp/mcp_pm_reports.php @@ -28,7 +28,7 @@ class mcp_pm_reports var $p_master; var $u_action; - function mcp_pm_reports(&$p_master) + function __construct(&$p_master) { $this->p_master = &$p_master; } diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index 4f1f9bb990..a95c8fad44 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -28,7 +28,7 @@ class mcp_queue var $p_master; var $u_action; - public function mcp_queue(&$p_master) + public function __construct(&$p_master) { $this->p_master = &$p_master; } diff --git a/phpBB/includes/mcp/mcp_reports.php b/phpBB/includes/mcp/mcp_reports.php index 78f497c275..b4018184a7 100644 --- a/phpBB/includes/mcp/mcp_reports.php +++ b/phpBB/includes/mcp/mcp_reports.php @@ -28,7 +28,7 @@ class mcp_reports var $p_master; var $u_action; - function mcp_reports(&$p_master) + function __construct(&$p_master) { $this->p_master = &$p_master; } @@ -246,7 +246,10 @@ class mcp_reports $parse_flags = ($post_info['user_sig_bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES; $post_info['user_sig'] = generate_text_for_display($post_info['user_sig'], $post_info['user_sig_bbcode_uid'], $post_info['user_sig_bbcode_bitfield'], $parse_flags, true); - $template->assign_vars(array( + $topic_id = (int) $post_info['topic_id']; + + // So it can be sent through the event below. + $report_template = array( 'S_MCP_REPORT' => true, 'S_CLOSE_ACTION' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&mode=report_details&f=' . $post_info['forum_id'] . '&p=' . $post_id), 'S_CAN_VIEWIP' => $auth->acl_get('m_info', $post_info['forum_id']), @@ -298,7 +301,33 @@ class mcp_reports 'SIGNATURE' => $post_info['user_sig'], 'U_LOOKUP_IP' => ($auth->acl_get('m_info', $post_info['forum_id'])) ? $this->u_action . '&r=' . $report_id . '&p=' . $post_id . '&f=' . $forum_id . '&lookup=' . $post_info['poster_ip'] . '#ip' : '', - )); + ); + + /** + * Event to add/modify MCP report details template data. + * + * @event core.mcp_report_template_data + * @var int forum_id The forum_id, the number in the f GET parameter + * @var int topic_id The topic_id of the report being viewed + * @var int post_id The post_id of the report being viewed (if 0, it is meaningless) + * @var int report_id The report_id of the report being viewed + * @var array report Array with the report data + * @var array report_template Array with the report template data + * @var array post_info Array with the reported post data + * @since 3.2.5-RC1 + */ + $vars = array( + 'forum_id', + 'topic_id', + 'post_id', + 'report_id', + 'report', + 'report_template', + 'post_info', + ); + extract($phpbb_dispatcher->trigger_event('core.mcp_report_template_data', compact($vars))); + + $template->assign_vars($report_template); $this->tpl_name = 'mcp_post'; diff --git a/phpBB/includes/mcp/mcp_warn.php b/phpBB/includes/mcp/mcp_warn.php index 0e80372f43..888069ef5d 100644 --- a/phpBB/includes/mcp/mcp_warn.php +++ b/phpBB/includes/mcp/mcp_warn.php @@ -28,7 +28,7 @@ class mcp_warn var $p_master; var $u_action; - function mcp_warn(&$p_master) + function __construct(&$p_master) { $this->p_master = &$p_master; } diff --git a/phpBB/includes/message_parser.php b/phpBB/includes/message_parser.php index d67bc69591..c12f2ab1aa 100644 --- a/phpBB/includes/message_parser.php +++ b/phpBB/includes/message_parser.php @@ -1139,7 +1139,7 @@ class parse_message extends bbcode_firstpass /** * Init - give message here or manually */ - function parse_message($message = '') + function __construct($message = '') { // Init BBCode UID $this->bbcode_uid = substr(base_convert(unique_id(), 16, 36), 0, BBCODE_UID_LEN); diff --git a/phpBB/includes/questionnaire/questionnaire.php b/phpBB/includes/questionnaire/questionnaire.php index ee6d0ee2a6..2f80582918 100644 --- a/phpBB/includes/questionnaire/questionnaire.php +++ b/phpBB/includes/questionnaire/questionnaire.php @@ -40,7 +40,7 @@ class phpbb_questionnaire_data_collector * * @param string */ - function phpbb_questionnaire_data_collector($install_id) + function __construct($install_id) { $this->install_id = $install_id; $this->providers = array(); @@ -223,7 +223,7 @@ class phpbb_questionnaire_phpbb_data_provider * * @param array $config */ - function phpbb_questionnaire_phpbb_data_provider($config) + function __construct($config) { // generate a unique id if necessary if (empty($config['questionnaire_unique_id'])) @@ -369,7 +369,6 @@ class phpbb_questionnaire_phpbb_data_provider 'hot_threshold' => true, 'img_create_thumbnail' => true, 'img_display_inlined' => true, - 'img_imagick' => true, 'img_link_height' => true, 'img_link_width' => true, 'img_max_height' => true, diff --git a/phpBB/includes/sphinxapi.php b/phpBB/includes/sphinxapi.php index 5e1f131ac2..b63a85a90f 100644 --- a/phpBB/includes/sphinxapi.php +++ b/phpBB/includes/sphinxapi.php @@ -126,7 +126,7 @@ define ( "SPH_GROUPBY_ATTRPAIR", 5 ); function sphPackI64 ( $v ) { assert ( is_numeric($v) ); - + // x64 if ( PHP_INT_SIZE>=8 ) { @@ -138,7 +138,7 @@ function sphPackI64 ( $v ) if ( is_int($v) ) return pack ( "NN", $v < 0 ? -1 : 0, $v ); - // x32, bcmath + // x32, bcmath if ( function_exists("bcmul") ) { if ( bccomp ( $v, 0 ) == -1 ) @@ -175,16 +175,16 @@ function sphPackI64 ( $v ) function sphPackU64 ( $v ) { assert ( is_numeric($v) ); - + // x64 if ( PHP_INT_SIZE>=8 ) { assert ( $v>=0 ); - + // x64, int if ( is_int($v) ) return pack ( "NN", $v>>32, $v&0xFFFFFFFF ); - + // x64, bcmath if ( function_exists("bcmul") ) { @@ -192,12 +192,12 @@ function sphPackU64 ( $v ) $l = bcmod ( $v, 4294967296 ); return pack ( "NN", $h, $l ); } - + // x64, no-bcmath $p = max ( 0, strlen($v) - 13 ); $lo = (int)substr ( $v, $p ); $hi = (int)substr ( $v, 0, $p ); - + $m = $lo + $hi*1316134912; $l = $m % 4294967296; $h = $hi*2328 + (int)($m/4294967296); @@ -208,7 +208,7 @@ function sphPackU64 ( $v ) // x32, int if ( is_int($v) ) return pack ( "NN", 0, $v ); - + // x32, bcmath if ( function_exists("bcmul") ) { @@ -221,7 +221,7 @@ function sphPackU64 ( $v ) $p = max(0, strlen($v) - 13); $lo = (float)substr($v, $p); $hi = (float)substr($v, 0, $p); - + $m = $lo + $hi*1316134912.0; $q = floor($m / 4294967296.0); $l = $m - ($q * 4294967296.0); @@ -277,11 +277,11 @@ function sphUnpackU64 ( $v ) // x32, bcmath if ( function_exists("bcmul") ) return bcadd ( $lo, bcmul ( $hi, "4294967296" ) ); - + // x32, no-bcmath $hi = (float)$hi; $lo = (float)$lo; - + $q = floor($hi/10000000.0); $r = $hi - $q*10000000.0; $m = $lo + $r*4967296.0; @@ -324,7 +324,7 @@ function sphUnpackI64 ( $v ) return $lo; return sprintf ( "%.0f", $lo - 4294967296.0 ); } - + $neg = ""; $c = 0; if ( $hi<0 ) @@ -333,7 +333,7 @@ function sphUnpackI64 ( $v ) $lo = ~$lo; $c = 1; $neg = "-"; - } + } $hi = sprintf ( "%u", $hi ); $lo = sprintf ( "%u", $lo ); @@ -345,7 +345,7 @@ function sphUnpackI64 ( $v ) // x32, no-bcmath $hi = (float)$hi; $lo = (float)$lo; - + $q = floor($hi/10000000.0); $r = $hi - $q*10000000.0; $m = $lo + $r*4967296.0; @@ -427,7 +427,7 @@ class SphinxClient ///////////////////////////////////////////////////////////////////////////// /// create a new client object and fill defaults - function SphinxClient () + function __construct () { // per-client-object settings $this->_host = "localhost"; @@ -510,7 +510,7 @@ class SphinxClient $this->_path = $host; return; } - + assert ( is_int($port) ); $this->_host = $host; $this->_port = $port; @@ -590,14 +590,14 @@ class SphinxClient $fp = @fsockopen ( $host, $port, $errno, $errstr ); else $fp = @fsockopen ( $host, $port, $errno, $errstr, $this->_timeout ); - + if ( !$fp ) { if ( $this->_path ) $location = $this->_path; else $location = "{$this->_host}:{$this->_port}"; - + $errstr = trim ( $errstr ); $this->_error = "connection to $location failed (errno=$errno, msg=$errstr)"; $this->_connerror = true; @@ -1236,7 +1236,7 @@ class SphinxClient if ( $type==SPH_ATTR_FLOAT ) { list(,$uval) = unpack ( "N*", substr ( $response, $p, 4 ) ); $p += 4; - list(,$fval) = unpack ( "f*", pack ( "L", $uval ) ); + list(,$fval) = unpack ( "f*", pack ( "L", $uval ) ); $attrvals[$attr] = $fval; continue; } @@ -1264,7 +1264,7 @@ class SphinxClient } else if ( $type==SPH_ATTR_STRING ) { $attrvals[$attr] = substr ( $response, $p, $val ); - $p += $val; + $p += $val; } else { $attrvals[$attr] = sphFixUint($val); @@ -1345,7 +1345,7 @@ class SphinxClient if ( !isset($opts["passage_boundary"]) ) $opts["passage_boundary"] = "none"; if ( !isset($opts["emit_zones"]) ) $opts["emit_zones"] = false; if ( !isset($opts["load_files_scattered"]) ) $opts["load_files_scattered"] = false; - + ///////////////// // build request @@ -1634,7 +1634,7 @@ class SphinxClient fclose ( $this->_socket ); $this->_socket = false; - + return true; } diff --git a/phpBB/includes/ucp/ucp_activate.php b/phpBB/includes/ucp/ucp_activate.php index 1e54c18dc1..7a90f2e3b1 100644 --- a/phpBB/includes/ucp/ucp_activate.php +++ b/phpBB/includes/ucp/ucp_activate.php @@ -87,6 +87,8 @@ class ucp_activate WHERE user_id = ' . $user_row['user_id']; $db->sql_query($sql); + $user->reset_login_keys($user_row['user_id']); + $phpbb_log->add('user', $user->data['user_id'], $user->ip, 'LOG_USER_NEW_PASSWORD', false, array( 'reportee_id' => $user_row['user_id'], $user_row['username'] diff --git a/phpBB/includes/ucp/ucp_login_link.php b/phpBB/includes/ucp/ucp_login_link.php index f4d47e30bb..c1f307eeb5 100644 --- a/phpBB/includes/ucp/ucp_login_link.php +++ b/phpBB/includes/ucp/ucp_login_link.php @@ -39,7 +39,7 @@ class ucp_login_link */ function main($id, $mode) { - global $phpbb_container, $request, $template, $user; + global $phpbb_container, $request, $template, $user, $phpbb_dispatcher; global $phpbb_root_path, $phpEx; // Initialize necessary variables @@ -108,7 +108,7 @@ class ucp_login_link } } - $template->assign_vars(array( + $tpl_ary = array( // Common template elements 'LOGIN_LINK_ERROR' => $login_link_error, 'PASSWORD_CREDENTIAL' => 'login_password', @@ -121,7 +121,24 @@ class ucp_login_link // Login elements 'LOGIN_ERROR' => $login_error, 'LOGIN_USERNAME' => $login_username, - )); + ); + + /** + * Event to perform additional actions before ucp_login_link is displayed + * + * @event core.ucp_login_link_template_after + * @var array data Login link data + * @var \phpbb\auth\provider_interface auth_provider Auth provider + * @var string login_link_error Login link error + * @var string login_error Login error + * @var string login_username Login username + * @var array tpl_ary Template variables + * @since 3.2.4-RC1 + */ + $vars = array('data', 'auth_provider', 'login_link_error', 'login_error', 'login_username', 'tpl_ary'); + extract($phpbb_dispatcher->trigger_event('core.ucp_login_link_template_after', compact($vars))); + + $template->assign_vars($tpl_ary); $this->tpl_name = 'ucp_login_link'; $this->page_title = 'UCP_LOGIN_LINK'; diff --git a/phpBB/includes/ucp/ucp_main.php b/phpBB/includes/ucp/ucp_main.php index f8a80b3324..ec652a5e45 100644 --- a/phpBB/includes/ucp/ucp_main.php +++ b/phpBB/includes/ucp/ucp_main.php @@ -28,7 +28,7 @@ class ucp_main var $p_master; var $u_action; - function ucp_main(&$p_master) + function __construct(&$p_master) { $this->p_master = &$p_master; } diff --git a/phpBB/includes/ucp/ucp_pm.php b/phpBB/includes/ucp/ucp_pm.php index d145d66f59..fa374c15c8 100644 --- a/phpBB/includes/ucp/ucp_pm.php +++ b/phpBB/includes/ucp/ucp_pm.php @@ -170,6 +170,12 @@ class ucp_pm trigger_error('NO_AUTH_READ_MESSAGE'); } + if ($view == 'print' && (!$config['print_pm'] || !$auth->acl_get('u_pm_printpm'))) + { + send_status_line(403, 'Forbidden'); + trigger_error('NO_AUTH_PRINT_MESSAGE'); + } + // Do not allow hold messages to be seen if ($folder_id == PRIVMSGS_HOLD_BOX) { diff --git a/phpBB/includes/ucp/ucp_register.php b/phpBB/includes/ucp/ucp_register.php index 3c5f4e2826..0e673cb692 100644 --- a/phpBB/includes/ucp/ucp_register.php +++ b/phpBB/includes/ucp/ucp_register.php @@ -481,6 +481,32 @@ class ucp_register ); } + /** + * Modify messenger data before welcome mail is sent + * + * @event core.ucp_register_welcome_email_before + * @var array user_row Array with user registration data + * @var array cp_data Array with custom profile fields data + * @var array data Array with current ucp registration data + * @var string message Message to be displayed to the user after registration + * @var string server_url Server URL + * @var int user_id New user ID + * @var string user_actkey User activation key + * @var messenger messenger phpBB Messenger + * @since 3.2.4-RC1 + */ + $vars = array( + 'user_row', + 'cp_data', + 'data', + 'message', + 'server_url', + 'user_id', + 'user_actkey', + 'messenger', + ); + extract($phpbb_dispatcher->trigger_event('core.ucp_register_welcome_email_before', compact($vars))); + $messenger->send(NOTIFY_EMAIL); } @@ -508,6 +534,30 @@ class ucp_register } } + /** + * Perform additional actions after user registration + * + * @event core.ucp_register_register_after + * @var array user_row Array with user registration data + * @var array cp_data Array with custom profile fields data + * @var array data Array with current ucp registration data + * @var string message Message to be displayed to the user after registration + * @var string server_url Server URL + * @var int user_id New user ID + * @var string user_actkey User activation key + * @since 3.2.4-RC1 + */ + $vars = array( + 'user_row', + 'cp_data', + 'data', + 'message', + 'server_url', + 'user_id', + 'user_actkey', + ); + extract($phpbb_dispatcher->trigger_event('core.ucp_register_register_after', compact($vars))); + $message = $message . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . append_sid("{$phpbb_root_path}index.$phpEx") . '">', '</a>'); trigger_error($message); } diff --git a/phpBB/includes/ucp/ucp_remind.php b/phpBB/includes/ucp/ucp_remind.php index f46df99edb..e50428bfea 100644 --- a/phpBB/includes/ucp/ucp_remind.php +++ b/phpBB/includes/ucp/ucp_remind.php @@ -50,11 +50,16 @@ class ucp_remind trigger_error('FORM_INVALID'); } + if (empty($email)) + { + trigger_error('NO_EMAIL_USER'); + } + $sql_array = array( 'SELECT' => 'user_id, username, user_permissions, user_email, user_jabber, user_notify_type, user_type, user_lang, user_inactive_reason', 'FROM' => array(USERS_TABLE => 'u'), - 'WHERE' => "user_email_hash = '" . $db->sql_escape(phpbb_email_hash($email)) . "' - AND username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'" + 'WHERE' => "user_email_hash = '" . $db->sql_escape(phpbb_email_hash($email)) . "'" . + (!empty($username) ? " AND username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'" : ''), ); /** @@ -74,82 +79,87 @@ class ucp_remind extract($phpbb_dispatcher->trigger_event('core.ucp_remind_modify_select_sql', compact($vars))); $sql = $db->sql_build_query('SELECT', $sql_array); - $result = $db->sql_query($sql); - $user_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); + $result = $db->sql_query_limit($sql, 2); // don't waste resources on more rows than we need + $rowset = $db->sql_fetchrowset($result); - if (!$user_row) + if (count($rowset) > 1) { - trigger_error('NO_EMAIL_USER'); - } + $db->sql_freeresult($result); - if ($user_row['user_type'] == USER_IGNORE) - { - trigger_error('NO_USER'); + $template->assign_vars(array( + 'USERNAME_REQUIRED' => true, + 'EMAIL' => $email, + )); } - - if ($user_row['user_type'] == USER_INACTIVE) + else { - if ($user_row['user_inactive_reason'] == INACTIVE_MANUAL) + $message = $user->lang['PASSWORD_UPDATED_IF_EXISTED'] . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . append_sid("{$phpbb_root_path}index.$phpEx") . '">', '</a>'); + + if (empty($rowset)) { - trigger_error('ACCOUNT_DEACTIVATED'); + trigger_error($message); } - else + + $user_row = $rowset[0]; + $db->sql_freeresult($result); + + if (!$user_row) { - trigger_error('ACCOUNT_NOT_ACTIVATED'); + trigger_error($message); } - } - // Check users permissions - $auth2 = new \phpbb\auth\auth(); - $auth2->acl($user_row); + if ($user_row['user_type'] == USER_IGNORE || $user_row['user_type'] == USER_INACTIVE) + { + trigger_error($message); + } - if (!$auth2->acl_get('u_chgpasswd')) - { - send_status_line(403, 'Forbidden'); - trigger_error('NO_AUTH_PASSWORD_REMINDER'); - } + // Check users permissions + $auth2 = new \phpbb\auth\auth(); + $auth2->acl($user_row); - $server_url = generate_board_url(); + if (!$auth2->acl_get('u_chgpasswd')) + { + trigger_error($message); + } - // Make password at least 8 characters long, make it longer if admin wants to. - // gen_rand_string() however has a limit of 12 or 13. - $user_password = gen_rand_string_friendly(max(8, mt_rand((int) $config['min_pass_chars'], (int) $config['max_pass_chars']))); + $server_url = generate_board_url(); - // For the activation key a random length between 6 and 10 will do. - $user_actkey = gen_rand_string(mt_rand(6, 10)); + // Make password at least 8 characters long, make it longer if admin wants to. + // gen_rand_string() however has a limit of 12 or 13. + $user_password = gen_rand_string_friendly(max(8, mt_rand((int) $config['min_pass_chars'], (int) $config['max_pass_chars']))); - // Instantiate passwords manager - /* @var $manager \phpbb\passwords\manager */ - $passwords_manager = $phpbb_container->get('passwords.manager'); + // For the activation key a random length between 6 and 10 will do. + $user_actkey = gen_rand_string(mt_rand(6, 10)); - $sql = 'UPDATE ' . USERS_TABLE . " - SET user_newpasswd = '" . $db->sql_escape($passwords_manager->hash($user_password)) . "', user_actkey = '" . $db->sql_escape($user_actkey) . "' - WHERE user_id = " . $user_row['user_id']; - $db->sql_query($sql); + // Instantiate passwords manager + /* @var $manager \phpbb\passwords\manager */ + $passwords_manager = $phpbb_container->get('passwords.manager'); - include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx); + $sql = 'UPDATE ' . USERS_TABLE . " + SET user_newpasswd = '" . $db->sql_escape($passwords_manager->hash($user_password)) . "', user_actkey = '" . $db->sql_escape($user_actkey) . "' + WHERE user_id = " . $user_row['user_id']; + $db->sql_query($sql); - $messenger = new messenger(false); + include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx); - $messenger->template('user_activate_passwd', $user_row['user_lang']); + $messenger = new messenger(false); - $messenger->set_addresses($user_row); + $messenger->template('user_activate_passwd', $user_row['user_lang']); - $messenger->anti_abuse_headers($config, $user); + $messenger->set_addresses($user_row); - $messenger->assign_vars(array( - 'USERNAME' => htmlspecialchars_decode($user_row['username']), - 'PASSWORD' => htmlspecialchars_decode($user_password), - 'U_ACTIVATE' => "$server_url/ucp.$phpEx?mode=activate&u={$user_row['user_id']}&k=$user_actkey") - ); + $messenger->anti_abuse_headers($config, $user); - $messenger->send($user_row['user_notify_type']); + $messenger->assign_vars(array( + 'USERNAME' => htmlspecialchars_decode($user_row['username']), + 'PASSWORD' => htmlspecialchars_decode($user_password), + 'U_ACTIVATE' => "$server_url/ucp.$phpEx?mode=activate&u={$user_row['user_id']}&k=$user_actkey") + ); - meta_refresh(3, append_sid("{$phpbb_root_path}index.$phpEx")); + $messenger->send($user_row['user_notify_type']); - $message = $user->lang['PASSWORD_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . append_sid("{$phpbb_root_path}index.$phpEx") . '">', '</a>'); - trigger_error($message); + trigger_error($message); + } } $template->assign_vars(array( |