diff options
Diffstat (limited to 'phpBB/includes')
31 files changed, 283 insertions, 138 deletions
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_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..c00f9bd207 100644 --- a/phpBB/includes/bbcode.php +++ b/phpBB/includes/bbcode.php @@ -37,7 +37,7 @@ class bbcode * Constructor * Init bbcode cache entries if bitfield is specified */ - function bbcode($bitfield = '') + function __construct($bitfield = '') { if ($bitfield) { diff --git a/phpBB/includes/constants.php b/phpBB/includes/constants.php index 29ca6959c8..8938e23cfe 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.4-RC1'); // 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_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..43dce036a3 100644 --- a/phpBB/includes/functions_content.php +++ b/phpBB/includes/functions_content.php @@ -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_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..a1386e5d7e 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; } 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 5e7aca6a55..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'])) 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_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( |