From 7a831c3e2844c94feb5fea2a4710816c5024623a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Bartus?= Date: Wed, 6 Apr 2016 21:01:41 +0200 Subject: [ticket/14548] Move deprecated globals and functions PHPBB3-14584 --- phpBB/includes/functions_compatibility.php | 90 ++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) (limited to 'phpBB/includes/functions_compatibility.php') diff --git a/phpBB/includes/functions_compatibility.php b/phpBB/includes/functions_compatibility.php index e95fa40a58..51d9402558 100644 --- a/phpBB/includes/functions_compatibility.php +++ b/phpBB/includes/functions_compatibility.php @@ -511,3 +511,93 @@ function phpbb_pcre_utf8_support() { return true; } + +/** + * Casts a variable to the given type. + * + * @deprecated 3.3.0-dev (To be removed 3.4.0) + */ +function set_var(&$result, $var, $type, $multibyte = false) +{ + // no need for dependency injection here, if you have the object, call the method yourself! + $type_cast_helper = new \phpbb\request\type_cast_helper(); + $type_cast_helper->set_var($result, $var, $type, $multibyte); +} + +/** + * Delete Attachments + * + * @deprecated 3.2.0-a1 (To be removed: 3.4.0) + * + * @param string $mode can be: post|message|topic|attach|user + * @param mixed $ids can be: post_ids, message_ids, topic_ids, attach_ids, user_ids + * @param bool $resync set this to false if you are deleting posts or topics + */ +function delete_attachments($mode, $ids, $resync = true) +{ + global $phpbb_container; + + /** @var \phpbb\attachment\manager $attachment_manager */ + $attachment_manager = $phpbb_container->get('attachment.manager'); + $num_deleted = $attachment_manager->delete($mode, $ids, $resync); + + unset($attachment_manager); + + return $num_deleted; +} + +/** + * Delete attached file + * + * @deprecated 3.2.0-a1 (To be removed: 3.4.0) + */ +function phpbb_unlink($filename, $mode = 'file', $entry_removed = false) +{ + global $phpbb_container; + + /** @var \phpbb\attachment\manager $attachment_manager */ + $attachment_manager = $phpbb_container->get('attachment.manager'); + $unlink = $attachment_manager->unlink($filename, $mode, $entry_removed); + unset($attachment_manager); + + return $unlink; +} + +/** + * Display reasons + * + * @deprecated 3.2.0-dev (To be removed: 3.4.0) + */ +function display_reasons($reason_id = 0) +{ + global $phpbb_container; + + $phpbb_container->get('phpbb.report.report_reason_list_provider')->display_reasons($reason_id); +} + +/** + * Upload Attachment - filedata is generated here + * Uses upload class + * + * @deprecated 3.2.0-a1 (To be removed: 3.4.0) + * + * @param string $form_name The form name of the file upload input + * @param int $forum_id The id of the forum + * @param bool $local Whether the file is local or not + * @param string $local_storage The path to the local file + * @param bool $is_message Whether it is a PM or not + * @param array $local_filedata A filespec object created for the local file + * + * @return array File data array + */ +function upload_attachment($form_name, $forum_id, $local = false, $local_storage = '', $is_message = false, $local_filedata = false) +{ + global $phpbb_container; + + /** @var \phpbb\attachment\manager $attachment_manager */ + $attachment_manager = $phpbb_container->get('attachment.manager'); + $file = $attachment_manager->upload($form_name, $forum_id, $local, $local_storage, $is_message, $local_filedata); + unset($attachment_manager); + + return $file; +} -- cgit v1.2.1 From cfaf24bd451afa717b92a409c71ca97f8a3bf0f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Bartus?= Date: Wed, 6 Apr 2016 22:44:31 +0200 Subject: [ticket/14584] Change all to be removed tags to 4.0 PHPBB3-14584 --- phpBB/includes/functions_compatibility.php | 38 +++++++++++++++--------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'phpBB/includes/functions_compatibility.php') diff --git a/phpBB/includes/functions_compatibility.php b/phpBB/includes/functions_compatibility.php index 51d9402558..b5b60e118e 100644 --- a/phpBB/includes/functions_compatibility.php +++ b/phpBB/includes/functions_compatibility.php @@ -22,7 +22,7 @@ if (!defined('IN_PHPBB')) /** * Get user avatar * -* @deprecated 3.1.0-a1 (To be removed: 3.3.0) +* @deprecated 3.1.0-a1 (To be removed: 4.0.0) * * @param string $avatar Users assigned avatar name * @param int $avatar_type Type of avatar @@ -50,7 +50,7 @@ function get_user_avatar($avatar, $avatar_type, $avatar_width, $avatar_height, $ /** * Hash the password * -* @deprecated 3.1.0-a2 (To be removed: 3.3.0) +* @deprecated 3.1.0-a2 (To be removed: 4.0.0) * * @param string $password Password to be hashed * @@ -68,7 +68,7 @@ function phpbb_hash($password) /** * Check for correct password * -* @deprecated 3.1.0-a2 (To be removed: 3.3.0) +* @deprecated 3.1.0-a2 (To be removed: 4.0.0) * * @param string $password The password in plain text * @param string $hash The stored password hash @@ -92,7 +92,7 @@ function phpbb_check_hash($password, $hash) * @param string $path Path to clean * @return string Cleaned path * -* @deprecated 3.1.0 (To be removed: 3.3.0) +* @deprecated 3.1.0 (To be removed: 4.0.0) */ function phpbb_clean_path($path) { @@ -136,7 +136,7 @@ function phpbb_clean_path($path) * * @return string Returns the options for timezone selector only * -* @deprecated 3.1.0 (To be removed: 3.3.0) +* @deprecated 3.1.0 (To be removed: 4.0.0) */ function tz_select($default = '', $truncate = false) { @@ -150,7 +150,7 @@ function tz_select($default = '', $truncate = false) * via admin_permissions. Changes of usernames and group names * must be carried through for the moderators table. * -* @deprecated 3.1.0 (To be removed: 3.3.0) +* @deprecated 3.1.0 (To be removed: 4.0.0) * @return null */ function cache_moderators() @@ -162,7 +162,7 @@ function cache_moderators() /** * Removes moderators and administrators from foe lists. * -* @deprecated 3.1.0 (To be removed: 3.3.0) +* @deprecated 3.1.0 (To be removed: 4.0.0) * @param array|bool $group_id If an array, remove all members of this group from foe lists, or false to ignore * @param array|bool $user_id If an array, remove this user from foe lists, or false to ignore * @return null @@ -182,7 +182,7 @@ function update_foes($group_id = false, $user_id = false) * @param string &$rank_img the rank image as full img tag is stored here after execution * @param string &$rank_img_src the rank image source is stored here after execution * -* @deprecated 3.1.0-RC5 (To be removed: 3.3.0) +* @deprecated 3.1.0-RC5 (To be removed: 4.0.0) * * Note: since we do not want to break backwards-compatibility, this function will only properly assign ranks to guests if you call it for them with user_posts == false */ @@ -232,7 +232,7 @@ function get_remote_file($host, $directory, $filename, &$errstr, &$errno, $port * * @return int|bool Returns the log_id, if the entry was added to the database, false otherwise. * - * @deprecated 3.1.0 (To be removed: 3.3.0) + * @deprecated 3.1.0 (To be removed: 4.0.0) */ function add_log() { @@ -280,7 +280,7 @@ function add_log() * * @return null * - * @deprecated 3.1.0 (To be removed: 3.3.0) + * @deprecated 3.1.0 (To be removed: 4.0.0) */ function set_config($config_name, $config_value, $is_dynamic = false, \phpbb\config\config $set_config = null) { @@ -310,7 +310,7 @@ function set_config($config_name, $config_value, $is_dynamic = false, \phpbb\con * * @return null * - * @deprecated 3.1.0 (To be removed: 3.3.0) + * @deprecated 3.1.0 (To be removed: 4.0.0) */ function set_config_count($config_name, $increment, $is_dynamic = false, \phpbb\config\config $set_config = null) { @@ -331,7 +331,7 @@ function set_config_count($config_name, $increment, $is_dynamic = false, \phpbb\ * See {@link \phpbb\request\request_interface::variable \phpbb\request\request_interface::variable} for * documentation of this function's use. * - * @deprecated 3.1.0 (To be removed: 3.3.0) + * @deprecated 3.1.0 (To be removed: 4.0.0) * @param mixed $var_name The form variable's name from which data shall be retrieved. * If the value is an array this may be an array of indizes which will give * direct access to a value at any depth. E.g. if the value of "var" is array(1 => "a") @@ -389,7 +389,7 @@ function request_var($var_name, $default, $multibyte = false, $cookie = false, $ /** * Get tables of a database * - * @deprecated 3.1.0 (To be removed: 3.3.0) + * @deprecated 3.1.0 (To be removed: 4.0.0) */ function get_tables($db) { @@ -492,7 +492,7 @@ function phpbb_realpath($path) * @param $number int|float The number we want to get the plural case for. Float numbers are floored. * @return int The plural-case we need to use for the number plural-rule combination * - * @deprecated 3.2.0-dev (To be removed: 3.3.0) + * @deprecated 3.2.0-dev (To be removed: 4.0.0) */ function phpbb_get_plural_form($rule, $number) { @@ -515,7 +515,7 @@ function phpbb_pcre_utf8_support() /** * Casts a variable to the given type. * - * @deprecated 3.3.0-dev (To be removed 3.4.0) + * @deprecated 3.1 (To be removed 4.0.0) */ function set_var(&$result, $var, $type, $multibyte = false) { @@ -527,7 +527,7 @@ function set_var(&$result, $var, $type, $multibyte = false) /** * Delete Attachments * - * @deprecated 3.2.0-a1 (To be removed: 3.4.0) + * @deprecated 3.2.0-a1 (To be removed: 4.0.0) * * @param string $mode can be: post|message|topic|attach|user * @param mixed $ids can be: post_ids, message_ids, topic_ids, attach_ids, user_ids @@ -549,7 +549,7 @@ function delete_attachments($mode, $ids, $resync = true) /** * Delete attached file * - * @deprecated 3.2.0-a1 (To be removed: 3.4.0) + * @deprecated 3.2.0-a1 (To be removed: 4.0.0) */ function phpbb_unlink($filename, $mode = 'file', $entry_removed = false) { @@ -566,7 +566,7 @@ function phpbb_unlink($filename, $mode = 'file', $entry_removed = false) /** * Display reasons * - * @deprecated 3.2.0-dev (To be removed: 3.4.0) + * @deprecated 3.2.0-dev (To be removed: 4.0.0) */ function display_reasons($reason_id = 0) { @@ -579,7 +579,7 @@ function display_reasons($reason_id = 0) * Upload Attachment - filedata is generated here * Uses upload class * - * @deprecated 3.2.0-a1 (To be removed: 3.4.0) + * @deprecated 3.2.0-a1 (To be removed: 4.0.0) * * @param string $form_name The form name of the file upload input * @param int $forum_id The id of the forum -- cgit v1.2.1 From 163aac74dbe500eac223ea2ebdbce0a76c1d6ab4 Mon Sep 17 00:00:00 2001 From: rubencm Date: Thu, 31 Oct 2019 20:54:21 +0000 Subject: [ticket/16190] Deprecate phpbb's checkdnsrr wrapper PHPBB3-16190 --- phpBB/includes/functions_compatibility.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'phpBB/includes/functions_compatibility.php') diff --git a/phpBB/includes/functions_compatibility.php b/phpBB/includes/functions_compatibility.php index b5b60e118e..1f9131c9c0 100644 --- a/phpBB/includes/functions_compatibility.php +++ b/phpBB/includes/functions_compatibility.php @@ -601,3 +601,25 @@ function upload_attachment($form_name, $forum_id, $local = false, $local_storage return $file; } + +/** +* Wrapper for php's checkdnsrr function. +* +* @param string $host Fully-Qualified Domain Name +* @param string $type Resource record type to lookup +* Supported types are: MX (default), A, AAAA, NS, TXT, CNAME +* Other types may work or may not work +* +* @return mixed true if entry found, +* false if entry not found, +* null if this function is not supported by this environment +* +* Since null can also be returned, you probably want to compare the result +* with === true or === false, +* +* @deprecated 3.3.0-b2 (To be removed: 4.0.0) +*/ +function phpbb_checkdnsrr($host, $type = 'MX') +{ + return checkdnsrr($host, $type); +} -- cgit v1.2.1 From f09f5bc51c15eef526374105d6443270dc1172bf Mon Sep 17 00:00:00 2001 From: rubencm Date: Thu, 24 Oct 2019 19:32:47 +0000 Subject: [ticket/16189] Deprecate inet_ntop and inet_pton wrappers PHPBB3-16189 --- phpBB/includes/functions_compatibility.php | 148 +++++++++++++++++++++++++++++ 1 file changed, 148 insertions(+) (limited to 'phpBB/includes/functions_compatibility.php') diff --git a/phpBB/includes/functions_compatibility.php b/phpBB/includes/functions_compatibility.php index 1f9131c9c0..e93523914f 100644 --- a/phpBB/includes/functions_compatibility.php +++ b/phpBB/includes/functions_compatibility.php @@ -623,3 +623,151 @@ function phpbb_checkdnsrr($host, $type = 'MX') { return checkdnsrr($host, $type); } + +/* + * Wrapper for inet_ntop() + * + * Converts a packed internet address to a human readable representation + * inet_ntop() is supported by PHP since 5.1.0, since 5.3.0 also on Windows. + * + * @param string $in_addr A 32bit IPv4, or 128bit IPv6 address. + * + * @return mixed false on failure, + * string otherwise + * + * @deprecated 3.2.9 (To be removed: 4.0.0) + */ +function phpbb_inet_ntop($in_addr) +{ + $in_addr = bin2hex($in_addr); + + switch (strlen($in_addr)) + { + case 8: + return implode('.', array_map('hexdec', str_split($in_addr, 2))); + + case 32: + if (substr($in_addr, 0, 24) === '00000000000000000000ffff') + { + return phpbb_inet_ntop(pack('H*', substr($in_addr, 24))); + } + + $parts = str_split($in_addr, 4); + $parts = preg_replace('/^0+(?!$)/', '', $parts); + $ret = implode(':', $parts); + + $matches = array(); + preg_match_all('/(?<=:|^)(?::?0){2,}/', $ret, $matches, PREG_OFFSET_CAPTURE); + $matches = $matches[0]; + + if (empty($matches)) + { + return $ret; + } + + $longest_match = ''; + $longest_match_offset = 0; + foreach ($matches as $match) + { + if (strlen($match[0]) > strlen($longest_match)) + { + $longest_match = $match[0]; + $longest_match_offset = $match[1]; + } + } + + $ret = substr_replace($ret, '', $longest_match_offset, strlen($longest_match)); + + if ($longest_match_offset == strlen($ret)) + { + $ret .= ':'; + } + + if ($longest_match_offset == 0) + { + $ret = ':' . $ret; + } + + return $ret; + + default: + return false; + } +} + +/** + * Wrapper for inet_pton() + * + * Converts a human readable IP address to its packed in_addr representation + * inet_pton() is supported by PHP since 5.1.0, since 5.3.0 also on Windows. + * + * @param string $address A human readable IPv4 or IPv6 address. + * + * @return mixed false if address is invalid, + * in_addr representation of the given address otherwise (string) + * + * @deprecated 3.2.9 (To be removed: 4.0.0) + */ +function phpbb_inet_pton($address) +{ + $ret = ''; + if (preg_match(get_preg_expression('ipv4'), $address)) + { + foreach (explode('.', $address) as $part) + { + $ret .= ($part <= 0xF ? '0' : '') . dechex($part); + } + + return pack('H*', $ret); + } + + if (preg_match(get_preg_expression('ipv6'), $address)) + { + $parts = explode(':', $address); + $missing_parts = 8 - count($parts) + 1; + + if (substr($address, 0, 2) === '::') + { + ++$missing_parts; + } + + if (substr($address, -2) === '::') + { + ++$missing_parts; + } + + $embedded_ipv4 = false; + $last_part = end($parts); + + if (preg_match(get_preg_expression('ipv4'), $last_part)) + { + $parts[count($parts) - 1] = ''; + $last_part = phpbb_inet_pton($last_part); + $embedded_ipv4 = true; + --$missing_parts; + } + + foreach ($parts as $i => $part) + { + if (strlen($part)) + { + $ret .= str_pad($part, 4, '0', STR_PAD_LEFT); + } + else if ($i && $i < count($parts) - 1) + { + $ret .= str_repeat('0000', $missing_parts); + } + } + + $ret = pack('H*', $ret); + + if ($embedded_ipv4) + { + $ret .= $last_part; + } + + return $ret; + } + + return false; +} -- cgit v1.2.1 From 0a7e98951b27e63fa94d28f4a836f7b55f4b9bd7 Mon Sep 17 00:00:00 2001 From: rubencm Date: Thu, 24 Oct 2019 20:31:16 +0000 Subject: [ticket/16189] Update version PHPBB3-16189 --- phpBB/includes/functions_compatibility.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/functions_compatibility.php') diff --git a/phpBB/includes/functions_compatibility.php b/phpBB/includes/functions_compatibility.php index e93523914f..1c9b26d8f3 100644 --- a/phpBB/includes/functions_compatibility.php +++ b/phpBB/includes/functions_compatibility.php @@ -635,7 +635,7 @@ function phpbb_checkdnsrr($host, $type = 'MX') * @return mixed false on failure, * string otherwise * - * @deprecated 3.2.9 (To be removed: 4.0.0) + * @deprecated 3.3.0-b2 (To be removed: 4.0.0) */ function phpbb_inet_ntop($in_addr) { @@ -706,7 +706,7 @@ function phpbb_inet_ntop($in_addr) * @return mixed false if address is invalid, * in_addr representation of the given address otherwise (string) * - * @deprecated 3.2.9 (To be removed: 4.0.0) + * @deprecated 3.3.0-b2 (To be removed: 4.0.0) */ function phpbb_inet_pton($address) { -- cgit v1.2.1 From 00682db8a625e40f720c513c72267395c4354766 Mon Sep 17 00:00:00 2001 From: rubencm Date: Wed, 30 Oct 2019 22:40:01 +0000 Subject: [ticket/16189] Make wrappers call native functions PHPBB3-16189 --- phpBB/includes/functions_compatibility.php | 116 +---------------------------- 1 file changed, 2 insertions(+), 114 deletions(-) (limited to 'phpBB/includes/functions_compatibility.php') diff --git a/phpBB/includes/functions_compatibility.php b/phpBB/includes/functions_compatibility.php index 1c9b26d8f3..2578290875 100644 --- a/phpBB/includes/functions_compatibility.php +++ b/phpBB/includes/functions_compatibility.php @@ -639,60 +639,7 @@ function phpbb_checkdnsrr($host, $type = 'MX') */ function phpbb_inet_ntop($in_addr) { - $in_addr = bin2hex($in_addr); - - switch (strlen($in_addr)) - { - case 8: - return implode('.', array_map('hexdec', str_split($in_addr, 2))); - - case 32: - if (substr($in_addr, 0, 24) === '00000000000000000000ffff') - { - return phpbb_inet_ntop(pack('H*', substr($in_addr, 24))); - } - - $parts = str_split($in_addr, 4); - $parts = preg_replace('/^0+(?!$)/', '', $parts); - $ret = implode(':', $parts); - - $matches = array(); - preg_match_all('/(?<=:|^)(?::?0){2,}/', $ret, $matches, PREG_OFFSET_CAPTURE); - $matches = $matches[0]; - - if (empty($matches)) - { - return $ret; - } - - $longest_match = ''; - $longest_match_offset = 0; - foreach ($matches as $match) - { - if (strlen($match[0]) > strlen($longest_match)) - { - $longest_match = $match[0]; - $longest_match_offset = $match[1]; - } - } - - $ret = substr_replace($ret, '', $longest_match_offset, strlen($longest_match)); - - if ($longest_match_offset == strlen($ret)) - { - $ret .= ':'; - } - - if ($longest_match_offset == 0) - { - $ret = ':' . $ret; - } - - return $ret; - - default: - return false; - } + return inet_ntop($in_addr); } /** @@ -710,64 +657,5 @@ function phpbb_inet_ntop($in_addr) */ function phpbb_inet_pton($address) { - $ret = ''; - if (preg_match(get_preg_expression('ipv4'), $address)) - { - foreach (explode('.', $address) as $part) - { - $ret .= ($part <= 0xF ? '0' : '') . dechex($part); - } - - return pack('H*', $ret); - } - - if (preg_match(get_preg_expression('ipv6'), $address)) - { - $parts = explode(':', $address); - $missing_parts = 8 - count($parts) + 1; - - if (substr($address, 0, 2) === '::') - { - ++$missing_parts; - } - - if (substr($address, -2) === '::') - { - ++$missing_parts; - } - - $embedded_ipv4 = false; - $last_part = end($parts); - - if (preg_match(get_preg_expression('ipv4'), $last_part)) - { - $parts[count($parts) - 1] = ''; - $last_part = phpbb_inet_pton($last_part); - $embedded_ipv4 = true; - --$missing_parts; - } - - foreach ($parts as $i => $part) - { - if (strlen($part)) - { - $ret .= str_pad($part, 4, '0', STR_PAD_LEFT); - } - else if ($i && $i < count($parts) - 1) - { - $ret .= str_repeat('0000', $missing_parts); - } - } - - $ret = pack('H*', $ret); - - if ($embedded_ipv4) - { - $ret .= $last_part; - } - - return $ret; - } - - return false; + return inet_pton($address); } -- cgit v1.2.1 From c628cd7e151a09e25ca0d980620b5fa3fe36a763 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 19 Nov 2019 21:15:21 +0100 Subject: [ticket/16167] Deprecate phpbb_email_hash() and remove gen_email_hash() The latter one has been deprecated for 10 years now. PHPBB3-16167 --- phpBB/includes/functions_compatibility.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'phpBB/includes/functions_compatibility.php') diff --git a/phpBB/includes/functions_compatibility.php b/phpBB/includes/functions_compatibility.php index 2578290875..92e24c055c 100644 --- a/phpBB/includes/functions_compatibility.php +++ b/phpBB/includes/functions_compatibility.php @@ -659,3 +659,17 @@ function phpbb_inet_pton($address) { return inet_pton($address); } + +/** + * Hashes an email address to a big integer + * + * @param string $email Email address + * + * @return string Unsigned Big Integer + * + * @deprecated 3.3.0-b2 (To be removed: 4.0.0) + */ +function phpbb_email_hash($email) +{ + return sprintf('%u', crc32(strtolower($email))) . strlen($email); +} -- cgit v1.2.1