From aa674a42a04cad6d2ae1d2e18a23f12e81df3eaf Mon Sep 17 00:00:00 2001 From: rubencm Date: Sun, 11 Apr 2021 06:18:23 +0200 Subject: [PATCH 1/2] [ticket/16005] Remove phpbb2 converter PHPBB3-16005 --- phpBB/install/convertors/convert_phpbb20.php | 984 --------- .../install/convertors/functions_phpbb20.php | 1929 ----------------- phpBB/install/convertors/index.htm | 10 + 3 files changed, 10 insertions(+), 2913 deletions(-) delete mode 100644 phpBB/install/convertors/convert_phpbb20.php delete mode 100644 phpBB/install/convertors/functions_phpbb20.php create mode 100644 phpBB/install/convertors/index.htm diff --git a/phpBB/install/convertors/convert_phpbb20.php b/phpBB/install/convertors/convert_phpbb20.php deleted file mode 100644 index 84b31feac6..0000000000 --- a/phpBB/install/convertors/convert_phpbb20.php +++ /dev/null @@ -1,984 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -use phpbb\messenger\method\messenger_interface; - -/** -* NOTE to potential convertor authors. Please use this file to get -* familiar with the structure since we added some bare explanations here. -* -* Since this file gets included more than once on one page you are not able to add functions to it. -* Instead use a functions_ file. -* -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -$phpbb_config_php_file = new \phpbb\config_php_file($phpbb_root_path, $phpEx); -extract($phpbb_config_php_file->get_all()); -unset($dbpasswd); - -$dbms = \phpbb\config_php_file::convert_30_dbms_to_31($dbms); - -/** -* $convertor_data provides some basic information about this convertor which is -* used on the initial list of convertors and to populate the default settings -*/ -$convertor_data = array( - 'forum_name' => 'phpBB 2.0.x', - 'version' => '1.0.3', - 'phpbb_version' => '4.0.0', - 'author' => 'phpBB Limited', - 'dbms' => $dbms, - 'dbhost' => $dbhost, - 'dbport' => $dbport, - 'dbuser' => $dbuser, - 'dbpasswd' => '', - 'dbname' => $dbname, - 'table_prefix' => 'phpbb_', - 'forum_path' => '../forums', - 'author_notes' => '', -); - -/** -* $tables is a list of the tables (minus prefix) which we expect to find in the -* source forum. It is used to guess the prefix if the specified prefix is incorrect -*/ -$tables = array( - 'auth_access', - 'banlist', - 'categories', - 'disallow', - 'forum_prune', - 'forums', - 'groups', - 'posts', - 'posts_text', - 'privmsgs', - 'privmsgs_text', - 'ranks', - 'smilies', - 'topics', - 'topics_watch', - 'user_group', - 'users', - 'vote_desc', - 'vote_results', - 'vote_voters', - 'words' -); - -/** -* $config_schema details how the board configuration information is stored in the source forum. -* -* 'table_format' can take the value 'file' to indicate a config file. In this case array_name -* is set to indicate the name of the array the config values are stored in -* Example of using a file: -* $config_schema = array( -* 'table_format' => 'file', -* 'filename' => 'NAME OF FILE', // If the file is not in the root directory, the path needs to be added with no leading slash -* 'array_name' => 'NAME OF ARRAY', // Only used if the configuration file stores the setting in an array. -* 'settings' => array( -* 'board_email' => 'SUPPORT_EMAIL', // target config name => source target name -* ) -* ); -* 'table_format' can be an array if the values are stored in a table which is an assosciative array -* (as per phpBB 2.0.x) -* If left empty, values are assumed to be stored in a table where each config setting is -* a column (as per phpBB 1.x) -* -* In either of the latter cases 'table_name' indicates the name of the table in the database -* -* 'settings' is an array which maps the name of the config directive in the source forum -* to the config directive in phpBB. It can either be a direct mapping or use a function. -* Please note that the contents of the old config value are passed to the function, therefore -* an in-built function requiring the variable passed by reference is not able to be used. Since -* empty() is such a function we created the function is_empty() to be used instead. -*/ -$config_schema = array( - 'table_name' => 'config', - 'table_format' => array('config_name' => 'config_value'), - 'settings' => array( - 'allow_bbcode' => 'allow_bbcode', - 'allow_smilies' => 'allow_smilies', - 'allow_sig' => 'allow_sig', - 'allow_namechange' => 'allow_namechange', - 'allow_avatar_local' => 'allow_avatar_local', - 'allow_avatar_upload' => 'allow_avatar_upload', - 'board_disable' => 'board_disable', - 'sitename' => 'phpbb_set_encoding(sitename)', - 'site_desc' => 'phpbb_set_encoding(site_desc)', - 'session_length' => 'session_length', - 'board_email_sig' => 'phpbb_set_encoding(board_email_sig)', - 'posts_per_page' => 'posts_per_page', - 'topics_per_page' => 'topics_per_page', - 'enable_confirm' => 'enable_confirm', - 'board_email_form' => 'board_email_form', - 'override_user_style' => 'override_user_style', - 'hot_threshold' => 'hot_threshold', - 'max_poll_options' => 'max_poll_options', - 'max_sig_chars' => 'max_sig_chars', - 'pm_max_msgs' => 'max_inbox_privmsgs', - 'smtp_delivery' => 'smtp_delivery', - 'smtp_host' => 'smtp_host', - 'smtp_username' => 'smtp_username', - 'smtp_password' => 'smtp_password', - 'require_activation' => 'require_activation', - 'flood_interval' => 'flood_interval', - 'avatar_filesize' => 'avatar_filesize', - 'avatar_max_width' => 'avatar_max_width', - 'avatar_max_height' => 'avatar_max_height', - 'default_dateformat' => 'phpbb_set_encoding(default_dateformat)', - 'board_timezone' => 'phpbb_convert_timezone(board_timezone)', - 'allow_privmsg' => 'not(privmsg_disable)', - 'gzip_compress' => 'gzip_compress', - 'coppa_enable' => '!is_empty(coppa_mail)', - 'coppa_fax' => 'coppa_fax', - 'coppa_mail' => 'coppa_mail', - 'record_online_users' => 'record_online_users', - 'record_online_date' => 'record_online_date', - 'board_startdate' => 'board_startdate', - ) -); - -/** -* $test_file is the name of a file which is present on the source -* forum which can be used to check that the path specified by the -* user was correct -*/ -$test_file = 'modcp.php'; - -/** -* If this is set then we are not generating the first page of information but getting the conversion information. -*/ -if (!$get_info) -{ - // Test to see if the birthday MOD is installed on the source forum - // Niels' birthday mod - if (get_config_value('birthday_required') !== false || get_config_value('bday_require') !== false) - { - define('MOD_BIRTHDAY', true); - } - - // TerraFrost's validated birthday mod - if (get_config_value('bday_require') !== false) - { - define('MOD_BIRTHDAY_TERRA', true); - } - - // Test to see if the attachment MOD is installed on the source forum - // If it is, we will convert this data as well - $src_db->sql_return_on_error(true); - - $sql = "SELECT config_value - FROM {$convert->src_table_prefix}attachments_config - WHERE config_name = 'upload_dir'"; - $result = $src_db->sql_query($sql); - - if ($result && $row = $src_db->sql_fetchrow($result)) - { - // Here the constant is defined - define('MOD_ATTACHMENT', true); - - // Here i add more tables to be checked in the old forum - $tables += array( - 'attachments', - 'attachments_desc', - 'extensions', - 'extension_groups' - ); - - $src_db->sql_freeresult($result); - } - else if ($result) - { - $src_db->sql_freeresult($result); - } - - - /** - * Tests for further MODs can be included here. - * Please use constants for this, prefixing them with MOD_ - */ - - $src_db->sql_return_on_error(false); - - // Now let us set a temporary config variable for user id incrementing - $sql = "SELECT user_id - FROM {$convert->src_table_prefix}users - WHERE user_id = 1"; - $result = $src_db->sql_query($sql); - $user_id = (int) $src_db->sql_fetchfield('user_id'); - $src_db->sql_freeresult($result); - - // If there is a user id 1, we need to increment user ids. :/ - if ($user_id === 1) - { - // Try to get the maximum user id possible... - $sql = "SELECT MAX(user_id) AS max_user_id - FROM {$convert->src_table_prefix}users"; - $result = $src_db->sql_query($sql); - $user_id = (int) $src_db->sql_fetchfield('max_user_id'); - $src_db->sql_freeresult($result); - - $config->set('increment_user_id', ($user_id + 1), false); - } - else - { - $config->set('increment_user_id', 0, false); - } - - // Overwrite maximum avatar width/height - @define('DEFAULT_AVATAR_X_CUSTOM', get_config_value('avatar_max_width')); - @define('DEFAULT_AVATAR_Y_CUSTOM', get_config_value('avatar_max_height')); - - // additional table used only during conversion - @define('USERCONV_TABLE', $table_prefix . 'userconv'); - -/** -* Description on how to use the convertor framework. -* -* 'schema' Syntax Description -* -> 'target' => Target Table. If not specified the next table will be handled -* -> 'primary' => Primary Key. If this is specified then this table is processed in batches -* -> 'query_first' => array('target' or 'src', Query to execute before beginning the process -* (if more than one then specified as array)) -* -> 'function_first' => Function to execute before beginning the process (if more than one then specified as array) -* (This is mostly useful if variables need to be given to the converting process) -* -> 'test_file' => This is not used at the moment but should be filled with a file from the old installation -* -* // DB Functions -* 'distinct' => Add DISTINCT to the select query -* 'where' => Add WHERE to the select query -* 'group_by' => Add GROUP BY to the select query -* 'left_join' => Add LEFT JOIN to the select query (if more than one joins specified as array) -* 'having' => Add HAVING to the select query -* -* // DB INSERT array -* This one consist of three parameters -* First Parameter: -* The key need to be filled within the target table -* If this is empty, the target table gets not assigned the source value -* Second Parameter: -* Source value. If the first parameter is specified, it will be assigned this value. -* If the first parameter is empty, this only gets added to the select query -* Third Parameter: -* Custom Function. Function to execute while storing source value into target table. -* The functions return value get stored. -* The function parameter consist of the value of the second parameter. -* -* types: -* - empty string == execute nothing -* - string == function to execute -* - array == complex execution instructions -* -* Complex execution instructions: -* @todo test complex execution instructions - in theory they will work fine -* -* By defining an array as the third parameter you are able to define some statements to be executed. The key -* is defining what to execute, numbers can be appended... -* -* 'function' => execute function -* 'execute' => run code, whereby all occurrences of {VALUE} get replaced by the last returned value. -* The result *must* be assigned/stored to {RESULT}. -* 'typecast' => typecast value -* -* The returned variables will be made always available to the next function to continue to work with. -* -* example (variable inputted is an integer of 1): -* -* array( -* 'function1' => 'increment_by_one', // returned variable is 2 -* 'typecast' => 'string', // typecast variable to be a string -* 'execute' => '{RESULT} = {VALUE} . ' is good';', // returned variable is '2 is good' -* 'function2' => 'replace_good_with_bad', // returned variable is '2 is bad' -* ), -* -*/ - - $convertor = array( - 'test_file' => 'viewtopic.php', - - 'avatar_path' => get_config_value('avatar_path') . '/', - 'avatar_gallery_path' => get_config_value('avatar_gallery_path') . '/', - 'smilies_path' => get_config_value('smilies_path') . '/', - 'upload_path' => (defined('MOD_ATTACHMENT')) ? phpbb_get_files_dir() . '/' : '', - 'thumbnails' => (defined('MOD_ATTACHMENT')) ? array('thumbs/', 't_') : '', - 'ranks_path' => false, // phpBB 2.0.x had no config value for a ranks path - - // We empty some tables to have clean data available - 'query_first' => array( - array('target', $convert->truncate_statement . SEARCH_RESULTS_TABLE), - array('target', $convert->truncate_statement . SEARCH_WORDLIST_TABLE), - array('target', $convert->truncate_statement . SEARCH_WORDMATCH_TABLE), - array('target', $convert->truncate_statement . LOG_TABLE), - ), - -// with this you are able to import all attachment files on the fly. For large boards this is not an option, therefore commented out by default. -// Instead every file gets copied while processing the corresponding attachment entry. -// if (defined("MOD_ATTACHMENT")) { import_attachment_files(); phpbb_copy_thumbnails(); } - - // phpBB2 allowed some similar usernames to coexist which would have the same - // username_clean in phpBB which is not possible, so we'll give the admin a list - // of user ids and usernames and let him deicde what he wants to do with them - 'execute_first' => ' - phpbb_create_userconv_table(); - import_avatar_gallery(); - if (defined("MOD_ATTACHMENT")) phpbb_import_attach_config(); - phpbb_insert_forums(); - ', - - 'execute_last' => array(' - add_bots(); - ', ' - update_folder_pm_count(); - ', ' - update_unread_count(); - ', (defined('MOD_ATTACHMENT')) ? ' - phpbb_attachment_extension_group_name(); - ' : ' - ', ' - phpbb_convert_authentication(\'start\'); - ', ' - phpbb_convert_authentication(\'first\'); - ', ' - phpbb_convert_authentication(\'second\'); - ', ' - phpbb_convert_authentication(\'third\'); - '), - - 'schema' => array( - array( - 'target' => USERCONV_TABLE, - 'query_first' => array('target', $convert->truncate_statement . USERCONV_TABLE), - - - array('user_id', 'users.user_id', ''), - array('username_clean', 'users.username', array('function1' => 'phpbb_set_encoding', 'function2' => 'utf8_clean_string')), - ), - - array( - 'target' => (defined('MOD_ATTACHMENT')) ? ATTACHMENTS_TABLE : '', - 'primary' => 'attachments.attach_id', - 'query_first' => (defined('MOD_ATTACHMENT')) ? array('target', $convert->truncate_statement . ATTACHMENTS_TABLE) : '', - 'autoincrement' => 'attach_id', - - array('attach_id', 'attachments.attach_id', ''), - array('post_msg_id', 'attachments.post_id', ''), - array('topic_id', 'posts.topic_id', ''), - array('in_message', 0, ''), - array('is_orphan', 0, ''), - array('poster_id', 'attachments.user_id_1 AS poster_id', 'phpbb_user_id'), - array('physical_filename', 'attachments_desc.physical_filename', 'import_attachment'), - array('real_filename', 'attachments_desc.real_filename', 'phpbb_set_encoding'), - array('download_count', 'attachments_desc.download_count', ''), - array('attach_comment', 'attachments_desc.comment', array('function1' => 'phpbb_set_encoding', 'function2' => 'utf8_htmlspecialchars')), - array('extension', 'attachments_desc.extension', ''), - array('mimetype', 'attachments_desc.mimetype', ''), - array('filesize', 'attachments_desc.filesize', ''), - array('filetime', 'attachments_desc.filetime', ''), - array('thumbnail', 'attachments_desc.thumbnail', ''), - - 'where' => 'attachments_desc.attach_id = attachments.attach_id AND attachments.privmsgs_id = 0 AND posts.post_id = attachments.post_id', - 'group_by' => 'attachments.attach_id' - ), - - array( - 'target' => (defined('MOD_ATTACHMENT')) ? ATTACHMENTS_TABLE : '', - 'primary' => 'attachments.attach_id', - 'autoincrement' => 'attach_id', - - array('attach_id', 'attachments.attach_id', ''), - array('post_msg_id', 'attachments.privmsgs_id', ''), - array('topic_id', 0, ''), - array('in_message', 1, ''), - array('is_orphan', 0, ''), - array('poster_id', 'attachments.user_id_1 AS poster_id', 'phpbb_user_id'), - array('physical_filename', 'attachments_desc.physical_filename', 'import_attachment'), - array('real_filename', 'attachments_desc.real_filename', 'phpbb_set_encoding'), - array('download_count', 'attachments_desc.download_count', ''), - array('attach_comment', 'attachments_desc.comment', array('function1' => 'phpbb_set_encoding', 'function2' => 'utf8_htmlspecialchars')), - array('extension', 'attachments_desc.extension', ''), - array('mimetype', 'attachments_desc.mimetype', ''), - array('filesize', 'attachments_desc.filesize', ''), - array('filetime', 'attachments_desc.filetime', ''), - array('thumbnail', 'attachments_desc.thumbnail', ''), - - 'where' => 'attachments_desc.attach_id = attachments.attach_id AND attachments.post_id = 0', - 'group_by' => 'attachments.attach_id' - ), - - array( - 'target' => (defined('MOD_ATTACHMENT')) ? EXTENSIONS_TABLE : '', - 'query_first' => (defined('MOD_ATTACHMENT')) ? array('target', $convert->truncate_statement . EXTENSIONS_TABLE) : '', - 'autoincrement' => 'extension_id', - - array('extension_id', 'extensions.ext_id', ''), - array('group_id', 'extensions.group_id', ''), - array('extension', 'extensions.extension', ''), - ), - - array( - 'target' => (defined('MOD_ATTACHMENT')) ? EXTENSION_GROUPS_TABLE : '', - 'query_first' => (defined('MOD_ATTACHMENT')) ? array('target', $convert->truncate_statement . EXTENSION_GROUPS_TABLE) : '', - 'autoincrement' => 'group_id', - - array('group_id', 'extension_groups.group_id', ''), - array('group_name', 'extension_groups.group_name', array('function1' => 'phpbb_set_encoding', 'function2' => 'utf8_htmlspecialchars')), - array('cat_id', 'extension_groups.cat_id', 'phpbb_attachment_category'), - array('allow_group', 'extension_groups.allow_group', ''), - array('upload_icon', '', ''), - array('max_filesize', 'extension_groups.max_filesize', ''), - array('allowed_forums', 'extension_groups.forum_permissions', 'phpbb_attachment_forum_perms'), - array('allow_in_pm', 1, ''), - ), - - array( - 'target' => BANS_TABLE, - 'execute_first' => 'phpbb_check_username_collisions();', - 'query_first' => array('target', $convert->truncate_statement . BANS_TABLE), - - array('ban_mode', 'user', ''), - array('ban_item', 'banlist.ban_userid', 'phpbb_user_id'), - array('ban_userid', 'banlist.ban_userid', 'phpbb_user_id'), - array('ban_reason', '', ''), - array('ban_reason_display', '', ''), - - 'where' => "banlist.ban_ip NOT LIKE '%.%' - AND banlist.ban_userid <> 0", - ), - - array( - 'target' => BANS_TABLE, - - array('ban_mode', 'email', ''), - array('ban_item', 'banlist.ban_email', ''), - array('ban_reason', '', ''), - array('ban_reason_display', '', ''), - - 'where' => "banlist.ban_ip NOT LIKE '%.%' - AND banlist.ban_email <> ''", - ), - - array( - 'target' => BANS_TABLE, - - array('ban_mode', 'ip', ''), - array('ban_item', 'banlist.ban_ip', 'decode_ban_ip'), - array('ban_reason', '', ''), - array('ban_reason_display', '', ''), - - 'where' => "banlist.ban_userid = 0 - AND banlist.ban_ip <> ''", - ), - - array( - 'target' => DISALLOW_TABLE, - 'query_first' => array('target', $convert->truncate_statement . DISALLOW_TABLE), - - array('disallow_username', 'disallow.disallow_username', 'phpbb_disallowed_username'), - ), - - array( - 'target' => RANKS_TABLE, - 'query_first' => array('target', $convert->truncate_statement . RANKS_TABLE), - 'autoincrement' => 'rank_id', - - array('rank_id', 'ranks.rank_id', ''), - array('rank_title', 'ranks.rank_title', array('function1' => 'phpbb_set_default_encoding', 'function2' => 'utf8_htmlspecialchars')), - array('rank_min', 'ranks.rank_min', array('typecast' => 'int', 'execute' => '{RESULT} = ({VALUE}[0] < 0) ? 0 : {VALUE}[0];')), - array('rank_special', 'ranks.rank_special', ''), - array('rank_image', 'ranks.rank_image', 'import_rank'), - ), - - array( - 'target' => TOPICS_TABLE, - 'query_first' => array('target', $convert->truncate_statement . TOPICS_TABLE), - 'primary' => 'topics.topic_id', - 'autoincrement' => 'topic_id', - - array('topic_id', 'topics.topic_id', ''), - array('forum_id', 'topics.forum_id', ''), - array('icon_id', 0, ''), - array('topic_poster', 'topics.topic_poster AS poster_id', 'phpbb_user_id'), - array('topic_attachment', ((defined('MOD_ATTACHMENT')) ? 'topics.topic_attachment' : 0), ''), - array('topic_title', 'topics.topic_title', 'phpbb_set_encoding'), - array('topic_time', 'topics.topic_time', ''), - array('topic_views', 'topics.topic_views', ''), - array('topic_posts_approved', 'topics.topic_replies', 'phpbb_topic_replies_to_posts'), - array('topic_posts_unapproved', 0, ''), - array('topic_posts_softdeleted',0, ''), - array('topic_last_post_id', 'topics.topic_last_post_id', ''), - array('topic_status', 'topics.topic_status', 'is_topic_locked'), - array('topic_moved_id', 0, ''), - array('topic_type', 'topics.topic_type', 'phpbb_convert_topic_type'), - array('topic_first_post_id', 'topics.topic_first_post_id', ''), - array('topic_last_view_time', 'posts.post_time', 'intval'), - array('topic_visibility', ITEM_APPROVED, ''), - - array('poll_title', 'vote_desc.vote_text', array('function1' => 'null_to_str', 'function2' => 'phpbb_set_encoding', 'function3' => 'htmlspecialchars_decode', 'function4' => 'utf8_htmlspecialchars')), - array('poll_start', 'vote_desc.vote_start', 'null_to_zero'), - array('poll_length', 'vote_desc.vote_length', 'null_to_zero'), - array('poll_max_options', 1, ''), - array('poll_vote_change', 0, ''), - - 'left_join' => array ( 'topics LEFT JOIN vote_desc ON topics.topic_id = vote_desc.topic_id AND topics.topic_vote = 1', - 'topics LEFT JOIN posts ON topics.topic_last_post_id = posts.post_id', - ), - 'where' => 'topics.topic_moved_id = 0', - ), - - array( - 'target' => TOPICS_TABLE, - 'primary' => 'topics.topic_id', - 'autoincrement' => 'topic_id', - - array('topic_id', 'topics.topic_id', ''), - array('forum_id', 'topics.forum_id', ''), - array('icon_id', 0, ''), - array('topic_poster', 'topics.topic_poster AS poster_id', 'phpbb_user_id'), - array('topic_attachment', ((defined('MOD_ATTACHMENT')) ? 'topics.topic_attachment' : 0), ''), - array('topic_title', 'topics.topic_title', 'phpbb_set_encoding'), - array('topic_time', 'topics.topic_time', ''), - array('topic_views', 'topics.topic_views', ''), - array('topic_posts_approved', 'topics.topic_replies', 'phpbb_topic_replies_to_posts'), - array('topic_posts_unapproved', 0, ''), - array('topic_posts_softdeleted',0, ''), - array('topic_last_post_id', 'topics.topic_last_post_id', ''), - array('topic_status', ITEM_MOVED, ''), - array('topic_moved_id', 'topics.topic_moved_id', ''), - array('topic_type', 'topics.topic_type', 'phpbb_convert_topic_type'), - array('topic_first_post_id', 'topics.topic_first_post_id', ''), - array('topic_visibility', ITEM_APPROVED, ''), - - array('poll_title', 'vote_desc.vote_text', array('function1' => 'null_to_str', 'function2' => 'phpbb_set_encoding', 'function3' => 'htmlspecialchars_decode', 'function4' => 'utf8_htmlspecialchars')), - array('poll_start', 'vote_desc.vote_start', 'null_to_zero'), - array('poll_length', 'vote_desc.vote_length', 'null_to_zero'), - array('poll_max_options', 1, ''), - array('poll_vote_change', 0, ''), - - 'left_join' => 'topics LEFT JOIN vote_desc ON topics.topic_id = vote_desc.topic_id AND topics.topic_vote = 1', - 'where' => 'topics.topic_moved_id <> 0', - ), - - array( - 'target' => TOPICS_WATCH_TABLE, - 'primary' => 'topics_watch.topic_id', - 'query_first' => array('target', $convert->truncate_statement . TOPICS_WATCH_TABLE), - - array('topic_id', 'topics_watch.topic_id', ''), - array('user_id', 'topics_watch.user_id', 'phpbb_user_id'), - array('notify_status', 'topics_watch.notify_status', ''), - ), - - array( - 'target' => SMILIES_TABLE, - 'query_first' => array('target', $convert->truncate_statement . SMILIES_TABLE), - 'autoincrement' => 'smiley_id', - - array('smiley_id', 'smilies.smilies_id', ''), - array('code', 'smilies.code', array('function1' => 'phpbb_smilie_html_decode', 'function2' => 'phpbb_set_encoding', 'function3' => 'utf8_htmlspecialchars')), - array('emotion', 'smilies.emoticon', 'phpbb_set_encoding'), - array('smiley_url', 'smilies.smile_url', 'import_smiley'), - array('smiley_width', 'smilies.smile_url', 'get_smiley_width'), - array('smiley_height', 'smilies.smile_url', 'get_smiley_height'), - array('smiley_order', 'smilies.smilies_id', ''), - array('display_on_posting', 'smilies.smilies_id', 'get_smiley_display'), - - 'order_by' => 'smilies.smilies_id ASC', - ), - - array( - 'target' => POLL_OPTIONS_TABLE, - 'primary' => 'vote_results.vote_option_id', - 'query_first' => array('target', $convert->truncate_statement . POLL_OPTIONS_TABLE), - - array('poll_option_id', 'vote_results.vote_option_id', ''), - array('topic_id', 'vote_desc.topic_id', ''), - array('', 'topics.topic_poster AS poster_id', 'phpbb_user_id'), - array('poll_option_text', 'vote_results.vote_option_text', array('function1' => 'phpbb_set_encoding', 'function2' => 'htmlspecialchars_decode', 'function3' => 'utf8_htmlspecialchars')), - array('poll_option_total', 'vote_results.vote_result', ''), - - 'where' => 'vote_results.vote_id = vote_desc.vote_id', - 'left_join' => 'vote_desc LEFT JOIN topics ON topics.topic_id = vote_desc.topic_id', - ), - - array( - 'target' => POLL_VOTES_TABLE, - 'primary' => 'vote_desc.topic_id', - 'query_first' => array('target', $convert->truncate_statement . POLL_VOTES_TABLE), - - array('poll_option_id', VOTE_CONVERTED, ''), - array('topic_id', 'vote_desc.topic_id', ''), - array('vote_user_id', 'vote_voters.vote_user_id', 'phpbb_user_id'), - array('vote_user_ip', 'vote_voters.vote_user_ip', 'decode_ip'), - - 'where' => 'vote_voters.vote_id = vote_desc.vote_id', - ), - - array( - 'target' => WORDS_TABLE, - 'primary' => 'words.word_id', - 'query_first' => array('target', $convert->truncate_statement . WORDS_TABLE), - 'autoincrement' => 'word_id', - - array('word_id', 'words.word_id', ''), - array('word', 'words.word', 'phpbb_set_encoding'), - array('replacement', 'words.replacement', 'phpbb_set_encoding'), - ), - - array( - 'target' => POSTS_TABLE, - 'primary' => 'posts.post_id', - 'autoincrement' => 'post_id', - 'query_first' => array('target', $convert->truncate_statement . POSTS_TABLE), - 'execute_first' => ' - $config["max_post_chars"] = 0; - $config["min_post_chars"] = 0; - $config["max_quote_depth"] = 0; - ', - - array('post_id', 'posts.post_id', ''), - array('topic_id', 'posts.topic_id', ''), - array('forum_id', 'posts.forum_id', ''), - array('poster_id', 'posts.poster_id', 'phpbb_user_id'), - array('icon_id', 0, ''), - array('poster_ip', 'posts.poster_ip', 'decode_ip'), - array('post_time', 'posts.post_time', ''), - array('enable_bbcode', 'posts.enable_bbcode', ''), - array('', 'posts.enable_html', ''), - array('enable_smilies', 'posts.enable_smilies', ''), - array('enable_sig', 'posts.enable_sig', ''), - array('enable_magic_url', 1, ''), - array('post_username', 'posts.post_username', 'phpbb_set_encoding'), - array('post_subject', 'posts_text.post_subject', 'phpbb_set_encoding'), - array('post_attachment', ((defined('MOD_ATTACHMENT')) ? 'posts.post_attachment' : 0), ''), - array('post_edit_time', 'posts.post_edit_time', array('typecast' => 'int')), - array('post_edit_count', 'posts.post_edit_count', ''), - array('post_edit_reason', '', ''), - array('post_edit_user', '', 'phpbb_post_edit_user'), - array('post_visibility', ITEM_APPROVED, ''), - - array('bbcode_uid', 'posts.post_time', 'make_uid'), - array('post_text', 'posts_text.post_text', 'phpbb_prepare_message'), - array('', 'posts_text.bbcode_uid AS old_bbcode_uid', ''), - array('bbcode_bitfield', '', 'get_bbcode_bitfield'), - array('post_checksum', '', ''), - - // Commented out inline search indexing, this takes up a LOT of time. :D - // @todo We either need to enable this or call the rebuild search functionality post convert -/* array('', '', 'search_indexing'), - array('', 'posts_text.post_text AS message', ''), - array('', 'posts_text.post_subject AS title', ''),*/ - - 'where' => 'posts.post_id = posts_text.post_id' - ), - - array( - 'target' => PRIVMSGS_TABLE, - 'primary' => 'privmsgs.privmsgs_id', - 'autoincrement' => 'msg_id', - 'query_first' => array( - array('target', $convert->truncate_statement . PRIVMSGS_TABLE), - array('target', $convert->truncate_statement . PRIVMSGS_RULES_TABLE), - ), - - 'execute_first' => ' - $config["max_post_chars"] = 0; - $config["min_post_chars"] = 0; - $config["max_quote_depth"] = 0; - ', - - array('msg_id', 'privmsgs.privmsgs_id', ''), - array('root_level', 0, ''), - array('author_id', 'privmsgs.privmsgs_from_userid AS poster_id', 'phpbb_user_id'), - array('icon_id', 0, ''), - array('author_ip', 'privmsgs.privmsgs_ip', 'decode_ip'), - array('message_time', 'privmsgs.privmsgs_date', ''), - array('enable_bbcode', 'privmsgs.privmsgs_enable_bbcode AS enable_bbcode', ''), - array('', 'privmsgs.privmsgs_enable_html AS enable_html', ''), - array('enable_smilies', 'privmsgs.privmsgs_enable_smilies AS enable_smilies', ''), - array('enable_magic_url', 1, ''), - array('enable_sig', 'privmsgs.privmsgs_attach_sig', ''), - array('message_subject', 'privmsgs.privmsgs_subject', 'phpbb_set_encoding'), // Already specialchared in 2.0.x - array('message_attachment', ((defined('MOD_ATTACHMENT')) ? 'privmsgs.privmsgs_attachment' : 0), ''), - array('message_edit_reason', '', ''), - array('message_edit_user', 0, ''), - array('message_edit_time', 0, ''), - array('message_edit_count', 0, ''), - - array('bbcode_uid', 'privmsgs.privmsgs_date AS post_time', 'make_uid'), - array('message_text', 'privmsgs_text.privmsgs_text', 'phpbb_prepare_message'), - array('', 'privmsgs_text.privmsgs_bbcode_uid AS old_bbcode_uid', ''), - array('bbcode_bitfield', '', 'get_bbcode_bitfield'), - array('to_address', 'privmsgs.privmsgs_to_userid', 'phpbb_privmsgs_to_userid'), - array('bcc_address', '', ''), - - 'where' => 'privmsgs.privmsgs_id = privmsgs_text.privmsgs_text_id' - ), - - array( - 'target' => PRIVMSGS_FOLDER_TABLE, - 'primary' => 'users.user_id', - 'query_first' => array('target', $convert->truncate_statement . PRIVMSGS_FOLDER_TABLE), - - array('user_id', 'users.user_id', 'phpbb_user_id'), - array('folder_name', $user->lang['CONV_SAVED_MESSAGES'], ''), - array('pm_count', 0, ''), - - 'where' => 'users.user_id <> -1', - ), - - // Inbox - array( - 'target' => PRIVMSGS_TO_TABLE, - 'primary' => 'privmsgs.privmsgs_id', - 'query_first' => array('target', $convert->truncate_statement . PRIVMSGS_TO_TABLE), - - array('msg_id', 'privmsgs.privmsgs_id', ''), - array('user_id', 'privmsgs.privmsgs_to_userid', 'phpbb_user_id'), - array('author_id', 'privmsgs.privmsgs_from_userid', 'phpbb_user_id'), - array('pm_deleted', 0, ''), - array('pm_new', 'privmsgs.privmsgs_type', 'phpbb_new_pm'), - array('pm_unread', 'privmsgs.privmsgs_type', 'phpbb_unread_pm'), - array('pm_replied', 0, ''), - array('pm_marked', 0, ''), - array('pm_forwarded', 0, ''), - array('folder_id', PRIVMSGS_INBOX, ''), - - 'where' => 'privmsgs.privmsgs_id = privmsgs_text.privmsgs_text_id - AND (privmsgs.privmsgs_type = 0 OR privmsgs.privmsgs_type = 1 OR privmsgs.privmsgs_type = 5)', - ), - - // Outbox - array( - 'target' => PRIVMSGS_TO_TABLE, - 'primary' => 'privmsgs.privmsgs_id', - - array('msg_id', 'privmsgs.privmsgs_id', ''), - array('user_id', 'privmsgs.privmsgs_from_userid', 'phpbb_user_id'), - array('author_id', 'privmsgs.privmsgs_from_userid', 'phpbb_user_id'), - array('pm_deleted', 0, ''), - array('pm_new', 0, ''), - array('pm_unread', 0, ''), - array('pm_replied', 0, ''), - array('pm_marked', 0, ''), - array('pm_forwarded', 0, ''), - array('folder_id', PRIVMSGS_OUTBOX, ''), - - 'where' => 'privmsgs.privmsgs_id = privmsgs_text.privmsgs_text_id - AND (privmsgs.privmsgs_type = 1 OR privmsgs.privmsgs_type = 5)', - ), - - // Sentbox - array( - 'target' => PRIVMSGS_TO_TABLE, - 'primary' => 'privmsgs.privmsgs_id', - - array('msg_id', 'privmsgs.privmsgs_id', ''), - array('user_id', 'privmsgs.privmsgs_from_userid', 'phpbb_user_id'), - array('author_id', 'privmsgs.privmsgs_from_userid', 'phpbb_user_id'), - array('pm_deleted', 0, ''), - array('pm_new', 'privmsgs.privmsgs_type', 'phpbb_new_pm'), - array('pm_unread', 'privmsgs.privmsgs_type', 'phpbb_unread_pm'), - array('pm_replied', 0, ''), - array('pm_marked', 0, ''), - array('pm_forwarded', 0, ''), - array('folder_id', PRIVMSGS_SENTBOX, ''), - - 'where' => 'privmsgs.privmsgs_id = privmsgs_text.privmsgs_text_id - AND privmsgs.privmsgs_type = 2', - ), - - // Savebox (SAVED IN) - array( - 'target' => PRIVMSGS_TO_TABLE, - 'primary' => 'privmsgs.privmsgs_id', - - array('msg_id', 'privmsgs.privmsgs_id', ''), - array('user_id', 'privmsgs.privmsgs_to_userid', 'phpbb_user_id'), - array('author_id', 'privmsgs.privmsgs_from_userid', 'phpbb_user_id'), - array('pm_deleted', 0, ''), - array('pm_new', 'privmsgs.privmsgs_type', 'phpbb_new_pm'), - array('pm_unread', 'privmsgs.privmsgs_type', 'phpbb_unread_pm'), - array('pm_replied', 0, ''), - array('pm_marked', 0, ''), - array('pm_forwarded', 0, ''), - array('folder_id', 'privmsgs.privmsgs_to_userid', 'phpbb_get_savebox_id'), - - 'where' => 'privmsgs.privmsgs_id = privmsgs_text.privmsgs_text_id - AND privmsgs.privmsgs_type = 3', - ), - - // Savebox (SAVED OUT) - array( - 'target' => PRIVMSGS_TO_TABLE, - 'primary' => 'privmsgs.privmsgs_id', - - array('msg_id', 'privmsgs.privmsgs_id', ''), - array('user_id', 'privmsgs.privmsgs_from_userid', 'phpbb_user_id'), - array('author_id', 'privmsgs.privmsgs_from_userid', 'phpbb_user_id'), - array('pm_deleted', 0, ''), - array('pm_new', 'privmsgs.privmsgs_type', 'phpbb_new_pm'), - array('pm_unread', 'privmsgs.privmsgs_type', 'phpbb_unread_pm'), - array('pm_replied', 0, ''), - array('pm_marked', 0, ''), - array('pm_forwarded', 0, ''), - array('folder_id', 'privmsgs.privmsgs_from_userid', 'phpbb_get_savebox_id'), - - 'where' => 'privmsgs.privmsgs_id = privmsgs_text.privmsgs_text_id - AND privmsgs.privmsgs_type = 4', - ), - - array( - 'target' => GROUPS_TABLE, - 'autoincrement' => 'group_id', - 'query_first' => array( - array('target', $convert->truncate_statement . GROUPS_TABLE), - array('target', $convert->truncate_statement . TEAMPAGE_TABLE), - ), - - array('group_id', 'groups.group_id', ''), - array('group_type', 'groups.group_type', 'phpbb_convert_group_type'), - array('group_display', 0, ''), - array('group_legend', 0, ''), - array('group_name', 'groups.group_name', 'phpbb_convert_group_name'), // phpbb_set_encoding called in phpbb_convert_group_name - array('group_desc', 'groups.group_description', 'phpbb_set_encoding'), - - 'where' => 'groups.group_single_user = 0', - ), - - array( - 'target' => USER_GROUP_TABLE, - 'query_first' => array('target', $convert->truncate_statement . USER_GROUP_TABLE), - 'execute_first' => ' - add_default_groups(); - add_groups_to_teampage(); - ', - - array('group_id', 'groups.group_id', ''), - array('user_id', 'groups.group_moderator', 'phpbb_user_id'), - array('group_leader', 1, ''), - array('user_pending', 0, ''), - - 'where' => 'groups.group_single_user = 0 AND groups.group_moderator <> 0', - ), - - array( - 'target' => USER_GROUP_TABLE, - - array('group_id', 'user_group.group_id', ''), - array('user_id', 'user_group.user_id', 'phpbb_user_id'), - array('group_leader', 0, ''), - array('user_pending', 'user_group.user_pending', ''), - - 'where' => 'user_group.group_id = groups.group_id AND groups.group_single_user = 0 AND groups.group_moderator <> user_group.user_id', - ), - - array( - 'target' => USERS_TABLE, - 'primary' => 'users.user_id', - 'autoincrement' => 'user_id', - 'query_first' => array( - array('target', 'DELETE FROM ' . USERS_TABLE . ' WHERE user_id <> ' . ANONYMOUS), - array('target', $convert->truncate_statement . BOTS_TABLE), - array('target', $convert->truncate_statement . USER_NOTIFICATIONS_TABLE), - ), - - 'execute_last' => ' - remove_invalid_users(); - ', - - array('user_id', 'users.user_id', 'phpbb_user_id'), - array('', 'users.user_id AS poster_id', 'phpbb_user_id'), - array('user_type', 'users.user_active', 'set_user_type'), - array('group_id', 'users.user_level', 'phpbb_set_primary_group'), - array('user_regdate', 'users.user_regdate', ''), - array('username', 'users.username', 'phpbb_set_default_encoding'), // recode to utf8 with default lang - array('username_clean', 'users.username', array('function1' => 'phpbb_set_default_encoding', 'function2' => 'utf8_clean_string')), - array('user_password', 'users.user_password', 'phpbb_convert_password_hash'), - array('user_posts', 'users.user_posts', 'intval'), - array('user_email', 'users.user_email', 'strtolower'), - array('user_birthday', ((defined('MOD_BIRTHDAY')) ? 'users.user_birthday' : ''), 'phpbb_get_birthday'), - array('user_lastvisit', 'users.user_lastvisit', 'intval'), - array('user_last_active', 'users.user_lastvisit', 'intval'), - array('user_lastmark', 'users.user_lastvisit', 'intval'), - array('user_lang', $config['default_lang'], ''), - array('', 'users.user_lang', ''), - array('user_timezone', 'users.user_timezone', 'phpbb_convert_timezone'), - array('user_dateformat', 'users.user_dateformat', array('function1' => 'phpbb_set_encoding', 'function2' => 'fill_dateformat')), - array('user_inactive_reason', '', 'phpbb_inactive_reason'), - array('user_inactive_time', '', 'phpbb_inactive_time'), - - array('user_rank', 'users.user_rank', 'intval'), - array('user_permissions', '', ''), - - array('user_avatar', 'users.user_avatar', 'phpbb_import_avatar'), - array('user_avatar_type', 'users.user_avatar_type', 'phpbb_avatar_type'), - array('user_avatar_width', 'users.user_avatar', 'phpbb_get_avatar_width'), - array('user_avatar_height', 'users.user_avatar', 'phpbb_get_avatar_height'), - - array('user_new_privmsg', 'users.user_new_privmsg', ''), - array('user_unread_privmsg', 0, ''), //'users.user_unread_privmsg' - array('user_last_privmsg', 'users.user_last_privmsg', 'intval'), - array('user_emailtime', 'users.user_emailtime', 'null_to_zero'), - array('user_notify', 'users.user_notify', 'intval'), - array('user_notify_pm', 'users.user_notify_pm', 'intval'), - array('user_allow_pm', 'users.user_allow_pm', 'intval'), - array('user_allow_viewonline', 'users.user_allow_viewonline', 'intval'), - array('user_allow_viewemail', 'users.user_viewemail', 'intval'), - array('user_actkey', 'users.user_actkey', ''), - array('user_newpasswd', '', ''), // Users need to re-request their password... - array('user_style', $config['default_style'], ''), - - array('user_options', '', 'set_user_options'), - array('', 'users.user_popup_pm AS popuppm', ''), - array('', 'users.user_allowhtml AS html', ''), - array('', 'users.user_allowbbcode AS bbcode', ''), - array('', 'users.user_allowsmile AS smile', ''), - array('', 'users.user_attachsig AS attachsig',''), - - array('user_sig_bbcode_uid', 'users.user_regdate', 'make_uid'), - array('user_sig', 'users.user_sig', 'phpbb_prepare_message'), - array('', 'users.user_sig_bbcode_uid AS old_bbcode_uid', ''), - array('user_sig_bbcode_bitfield', '', 'get_bbcode_bitfield'), - array('', 'users.user_regdate AS post_time', ''), - - array('', 'users.user_notify_pm', 'phpbb_add_notification_options'), - - 'where' => 'users.user_id <> -1', - ), - - array( - 'target' => PROFILE_FIELDS_DATA_TABLE, - 'primary' => 'users.user_id', - 'query_first' => array( - array('target', $convert->truncate_statement . PROFILE_FIELDS_DATA_TABLE), - ), - - array('user_id', 'users.user_id', 'phpbb_user_id'), - array('pf_phpbb_occupation', 'users.user_occ', array('function1' => 'phpbb_set_encoding')), - array('pf_phpbb_interests', 'users.user_interests', array('function1' => 'phpbb_set_encoding')), - array('pf_phpbb_location', 'users.user_from', array('function1' => 'phpbb_set_encoding')), - array('pf_phpbb_icq', 'users.user_icq', array('function1' => 'phpbb_set_encoding')), - array('pf_phpbb_yahoo', 'users.user_yim', array('function1' => 'phpbb_set_encoding')), - array('pf_phpbb_website', 'users.user_website', 'validate_website'), - - 'where' => 'users.user_id <> -1', - ), - ), - ); -} diff --git a/phpBB/install/convertors/functions_phpbb20.php b/phpBB/install/convertors/functions_phpbb20.php deleted file mode 100644 index 450800c314..0000000000 --- a/phpBB/install/convertors/functions_phpbb20.php +++ /dev/null @@ -1,1929 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -use phpbb\attachment\attachment_category; - -if (!defined('IN_PHPBB')) -{ - exit; -} - -/** -* Helper functions for phpBB 2.0.x to phpBB 3.1.x conversion -*/ - -/** -* Set forum flags - only prune old polls by default -*/ -function phpbb_forum_flags() -{ - // Set forum flags - $forum_flags = 0; - - // FORUM_FLAG_LINK_TRACK - $forum_flags += 0; - - // FORUM_FLAG_PRUNE_POLL - $forum_flags += FORUM_FLAG_PRUNE_POLL; - - // FORUM_FLAG_PRUNE_ANNOUNCE - $forum_flags += 0; - - // FORUM_FLAG_PRUNE_STICKY - $forum_flags += 0; - - // FORUM_FLAG_ACTIVE_TOPICS - $forum_flags += 0; - - // FORUM_FLAG_POST_REVIEW - $forum_flags += FORUM_FLAG_POST_REVIEW; - - return $forum_flags; -} - -/** -* Insert/Convert forums -*/ -function phpbb_insert_forums() -{ - global $db, $src_db, $same_db, $convert, $user; - - $db->sql_query($convert->truncate_statement . FORUMS_TABLE); - - // Determine the highest id used within the old forums table (we add the categories after the forum ids) - $sql = 'SELECT MAX(forum_id) AS max_forum_id - FROM ' . $convert->src_table_prefix . 'forums'; - $result = $src_db->sql_query($sql); - $max_forum_id = (int) $src_db->sql_fetchfield('max_forum_id'); - $src_db->sql_freeresult($result); - - $max_forum_id++; - - // pruning disabled globally? - $sql = "SELECT config_value - FROM {$convert->src_table_prefix}config - WHERE config_name = 'prune_enable'"; - $result = $src_db->sql_query($sql); - $prune_enabled = (int) $src_db->sql_fetchfield('config_value'); - $src_db->sql_freeresult($result); - - // Insert categories - $sql = 'SELECT cat_id, cat_title - FROM ' . $convert->src_table_prefix . 'categories - ORDER BY cat_order'; - - if ($convert->mysql_convert && $same_db) - { - $src_db->sql_query("SET NAMES 'binary'"); - } - - $result = $src_db->sql_query($sql); - - if ($convert->mysql_convert && $same_db) - { - $src_db->sql_query("SET NAMES 'utf8'"); - } - - switch ($db->get_sql_layer()) - { - case 'mssql_odbc': - case 'mssqlnative': - $db->sql_query('SET IDENTITY_INSERT ' . FORUMS_TABLE . ' ON'); - break; - } - - $cats_added = array(); - while ($row = $src_db->sql_fetchrow($result)) - { - $sql_ary = array( - 'forum_id' => (int) $max_forum_id, - 'forum_name' => ($row['cat_title']) ? htmlspecialchars(phpbb_set_default_encoding($row['cat_title']), ENT_COMPAT, 'UTF-8') : $user->lang['CATEGORY'], - 'parent_id' => 0, - 'forum_parents' => '', - 'forum_desc' => '', - 'forum_type' => FORUM_CAT, - 'forum_status' => ITEM_UNLOCKED, - 'forum_rules' => '', - ); - - $sql = 'SELECT MAX(right_id) AS right_id - FROM ' . FORUMS_TABLE; - $_result = $db->sql_query($sql); - $cat_row = $db->sql_fetchrow($_result); - $db->sql_freeresult($_result); - - $sql_ary['left_id'] = (int) ($cat_row['right_id'] + 1); - $sql_ary['right_id'] = (int) ($cat_row['right_id'] + 2); - - $sql = 'INSERT INTO ' . FORUMS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary); - $db->sql_query($sql); - - $cats_added[$row['cat_id']] = $max_forum_id; - $max_forum_id++; - } - $src_db->sql_freeresult($result); - - // There may be installations having forums with non-existant category ids. - // We try to catch them and add them to an "unknown" category instead of leaving them out. - $sql = 'SELECT cat_id - FROM ' . $convert->src_table_prefix . 'forums - GROUP BY cat_id'; - $result = $src_db->sql_query($sql); - - $unknown_cat_id = false; - while ($row = $src_db->sql_fetchrow($result)) - { - // Catch those categories not been added before - if (!isset($cats_added[$row['cat_id']])) - { - $unknown_cat_id = true; - } - } - $src_db->sql_freeresult($result); - - // Is there at least one category not known? - if ($unknown_cat_id === true) - { - $unknown_cat_id = 'ghost'; - - $sql_ary = array( - 'forum_id' => (int) $max_forum_id, - 'forum_name' => (string) $user->lang['CATEGORY'], - 'parent_id' => 0, - 'forum_parents' => '', - 'forum_desc' => '', - 'forum_type' => FORUM_CAT, - 'forum_status' => ITEM_UNLOCKED, - 'forum_rules' => '', - ); - - $sql = 'SELECT MAX(right_id) AS right_id - FROM ' . FORUMS_TABLE; - $_result = $db->sql_query($sql); - $cat_row = $db->sql_fetchrow($_result); - $db->sql_freeresult($_result); - - $sql_ary['left_id'] = (int) ($cat_row['right_id'] + 1); - $sql_ary['right_id'] = (int) ($cat_row['right_id'] + 2); - - $sql = 'INSERT INTO ' . FORUMS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary); - $db->sql_query($sql); - - $cats_added[$unknown_cat_id] = $max_forum_id; - } - - // Now insert the forums - $sql = 'SELECT f.forum_id, f.forum_name, f.cat_id, f.forum_desc, f.forum_status, f.prune_enable, f.prune_next, fp.prune_days, fp.prune_freq FROM ' . $convert->src_table_prefix . 'forums f - LEFT JOIN ' . $convert->src_table_prefix . 'forum_prune fp ON f.forum_id = fp.forum_id - GROUP BY f.forum_id, f.forum_name, f.cat_id, f.forum_desc, f.forum_status, f.prune_enable, f.prune_next, f.forum_order, fp.prune_days, fp.prune_freq - ORDER BY f.cat_id, f.forum_order'; - - if ($convert->mysql_convert && $same_db) - { - $src_db->sql_query("SET NAMES 'binary'"); - } - - $result = $src_db->sql_query($sql); - - if ($convert->mysql_convert && $same_db) - { - $src_db->sql_query("SET NAMES 'utf8'"); - } - - while ($row = $src_db->sql_fetchrow($result)) - { - // Some might have forums here with an id not being "possible"... - // To be somewhat friendly we "change" the category id for those to a previously created ghost category - if (!isset($cats_added[$row['cat_id']]) && $unknown_cat_id !== false) - { - $row['cat_id'] = $unknown_cat_id; - } - - if (!isset($cats_added[$row['cat_id']])) - { - continue; - } - - // Define the new forums sql ary - $sql_ary = array( - 'forum_id' => (int) $row['forum_id'], - 'forum_name' => htmlspecialchars(phpbb_set_default_encoding($row['forum_name']), ENT_COMPAT, 'UTF-8'), - 'parent_id' => (int) $cats_added[$row['cat_id']], - 'forum_parents' => '', - 'forum_desc' => htmlspecialchars(phpbb_set_default_encoding($row['forum_desc']), ENT_COMPAT, 'UTF-8'), - 'forum_type' => FORUM_POST, - 'forum_status' => is_item_locked($row['forum_status']), - 'enable_prune' => ($prune_enabled) ? (int) $row['prune_enable'] : 0, - 'prune_next' => (int) null_to_zero($row['prune_next']), - 'prune_days' => (int) null_to_zero($row['prune_days']), - 'prune_viewed' => 0, - 'prune_freq' => (int) null_to_zero($row['prune_freq']), - - 'forum_flags' => phpbb_forum_flags(), - 'forum_options' => 0, - - // Default values - 'forum_desc_bitfield' => '', - 'forum_desc_options' => 7, - 'forum_desc_uid' => '', - 'forum_link' => '', - 'forum_password' => '', - 'forum_style' => 0, - 'forum_image' => '', - 'forum_rules' => '', - 'forum_rules_link' => '', - 'forum_rules_bitfield' => '', - 'forum_rules_options' => 7, - 'forum_rules_uid' => '', - 'forum_topics_per_page' => 0, - 'forum_posts_approved' => 0, - 'forum_posts_unapproved' => 0, - 'forum_posts_softdeleted' => 0, - 'forum_topics_approved' => 0, - 'forum_topics_unapproved' => 0, - 'forum_topics_softdeleted' => 0, - 'forum_last_post_id' => 0, - 'forum_last_poster_id' => 0, - 'forum_last_post_subject' => '', - 'forum_last_post_time' => 0, - 'forum_last_poster_name' => '', - 'forum_last_poster_colour' => '', - 'display_on_index' => 1, - 'enable_indexing' => 1, - 'enable_icons' => 0, - ); - - // Now add the forums with proper left/right ids - $sql = 'SELECT left_id, right_id - FROM ' . FORUMS_TABLE . ' - WHERE forum_id = ' . $cats_added[$row['cat_id']]; - $_result = $db->sql_query($sql); - $cat_row = $db->sql_fetchrow($_result); - $db->sql_freeresult($_result); - - $sql = 'UPDATE ' . FORUMS_TABLE . ' - SET left_id = left_id + 2, right_id = right_id + 2 - WHERE left_id > ' . $cat_row['right_id']; - $db->sql_query($sql); - - $sql = 'UPDATE ' . FORUMS_TABLE . ' - SET right_id = right_id + 2 - WHERE ' . $cat_row['left_id'] . ' BETWEEN left_id AND right_id'; - $db->sql_query($sql); - - $sql_ary['left_id'] = (int) $cat_row['right_id']; - $sql_ary['right_id'] = (int) ($cat_row['right_id'] + 1); - - $sql = 'INSERT INTO ' . FORUMS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary); - $db->sql_query($sql); - } - $src_db->sql_freeresult($result); - - switch ($db->get_sql_layer()) - { - case 'postgres': - $db->sql_query("SELECT SETVAL('" . FORUMS_TABLE . "_seq',(select case when max(forum_id)>0 then max(forum_id)+1 else 1 end from " . FORUMS_TABLE . '));'); - break; - - case 'mssql_odbc': - case 'mssqlnative': - $db->sql_query('SET IDENTITY_INSERT ' . FORUMS_TABLE . ' OFF'); - break; - - case 'oracle': - $result = $db->sql_query('SELECT MAX(forum_id) as max_id FROM ' . FORUMS_TABLE); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $largest_id = (int) $row['max_id']; - - if ($largest_id) - { - $db->sql_query('DROP SEQUENCE ' . FORUMS_TABLE . '_seq'); - $db->sql_query('CREATE SEQUENCE ' . FORUMS_TABLE . '_seq START WITH ' . ($largest_id + 1)); - } - break; - } -} - -/** -* Function for recoding text with the default language -* -* @param string $text text to recode to utf8 -* @param bool $grab_user_lang if set to true the function tries to use $convert_row['user_lang'] (and falls back to $convert_row['poster_id']) instead of the boards default language -*/ -function phpbb_set_encoding($text, $grab_user_lang = true) -{ - global $lang_enc_array, $convert_row; - global $convert, $phpEx; - - /*static $lang_enc_array = array( - 'korean' => 'euc-kr', - 'serbian' => 'windows-1250', - 'polish' => 'iso-8859-2', - 'kurdish' => 'windows-1254', - 'slovak' => 'Windows-1250', - 'russian' => 'windows-1251', - 'estonian' => 'iso-8859-4', - 'chinese_simplified' => 'gb2312', - 'macedonian' => 'windows-1251', - 'azerbaijani' => 'UTF-8', - 'romanian' => 'iso-8859-2', - 'romanian_diacritice' => 'iso-8859-2', - 'lithuanian' => 'windows-1257', - 'turkish' => 'iso-8859-9', - 'ukrainian' => 'windows-1251', - 'japanese' => 'shift_jis', - 'hungarian' => 'ISO-8859-2', - 'romanian_no_diacritics' => 'iso-8859-2', - 'mongolian' => 'UTF-8', - 'slovenian' => 'windows-1250', - 'bosnian' => 'windows-1250', - 'czech' => 'Windows-1250', - 'farsi' => 'Windows-1256', - 'croatian' => 'windows-1250', - 'greek' => 'iso-8859-7', - 'russian_tu' => 'windows-1251', - 'sakha' => 'UTF-8', - 'serbian_cyrillic' => 'windows-1251', - 'bulgarian' => 'windows-1251', - 'chinese_traditional_taiwan' => 'big5', - 'chinese_traditional' => 'big5', - 'arabic' => 'windows-1256', - 'hebrew' => 'WINDOWS-1255', - 'thai' => 'windows-874', - //'chinese_traditional_taiwan' => 'utf-8' // custom modified, we may have to do an include :-( - );*/ - - if (empty($lang_enc_array)) - { - $lang_enc_array = array(); - } - - $get_lang = trim(get_config_value('default_lang')); - - // Do we need the users language encoding? - if ($grab_user_lang && !empty($convert_row)) - { - if (!empty($convert_row['user_lang'])) - { - $get_lang = trim($convert_row['user_lang']); - } - else if (!empty($convert_row['poster_id'])) - { - global $src_db, $same_db; - - if ($convert->mysql_convert && $same_db) - { - $src_db->sql_query("SET NAMES 'binary'"); - } - - $sql = 'SELECT user_lang - FROM ' . $convert->src_table_prefix . 'users - WHERE user_id = ' . (int) $convert_row['poster_id']; - $result = $src_db->sql_query($sql); - $get_lang = (string) $src_db->sql_fetchfield('user_lang'); - $src_db->sql_freeresult($result); - - if ($convert->mysql_convert && $same_db) - { - $src_db->sql_query("SET NAMES 'utf8'"); - } - - $get_lang = (!trim($get_lang)) ? trim(get_config_value('default_lang')) : trim($get_lang); - } - } - - if (!isset($lang_enc_array[$get_lang])) - { - $filename = $convert->options['forum_path'] . '/language/lang_' . $get_lang . '/lang_main.' . $phpEx; - - if (!file_exists($filename)) - { - $get_lang = trim(get_config_value('default_lang')); - } - - if (!isset($lang_enc_array[$get_lang])) - { - include($convert->options['forum_path'] . '/language/lang_' . $get_lang . '/lang_main.' . $phpEx); - $lang_enc_array[$get_lang] = $lang['ENCODING']; - unset($lang); - } - } - - return utf8_recode($text, $lang_enc_array[$get_lang]); -} - -/** -* Same as phpbb_set_encoding, but forcing boards default language -*/ -function phpbb_set_default_encoding($text) -{ - return phpbb_set_encoding($text, false); -} - -/** -* Convert Birthday from Birthday MOD to phpBB Format -*/ -function phpbb_get_birthday($birthday = '') -{ - if (defined('MOD_BIRTHDAY_TERRA')) - { - $birthday = (string) $birthday; - - // stored as month, day, year - if (!$birthday) - { - return ' 0- 0- 0'; - } - - // We use the original mod code to retrieve the birthday (not ideal) - preg_match('/(..)(..)(....)/', sprintf('%08d', $birthday), $birthday_parts); - - $month = $birthday_parts[1]; - $day = $birthday_parts[2]; - $year = $birthday_parts[3]; - - return sprintf('%2d-%2d-%4d', $day, $month, $year); - } - else - { - $birthday = (int) $birthday; - - if (!$birthday || $birthday == 999999) - { - return ' 0- 0- 0'; - } - - // The birthday mod from niels is using this code to transform to day/month/year - return sprintf('%2d-%2d-%4d', gmdate('j', $birthday * 86400 + 1), gmdate('n', $birthday * 86400 + 1), gmdate('Y', $birthday * 86400 + 1)); - } -} - -/** -* Return correct user id value -* Everyone's id will be one higher to allow the guest/anonymous user to have a positive id as well -*/ -function phpbb_user_id($user_id) -{ - global $config; - - // Increment user id if the old forum is having a user with the id 1 - if (!isset($config['increment_user_id'])) - { - global $src_db, $same_db, $convert; - - if ($convert->mysql_convert && $same_db) - { - $src_db->sql_query("SET NAMES 'binary'"); - } - - // Now let us set a temporary config variable for user id incrementing - $sql = "SELECT user_id - FROM {$convert->src_table_prefix}users - WHERE user_id = 1"; - $result = $src_db->sql_query($sql); - $id = (int) $src_db->sql_fetchfield('user_id'); - $src_db->sql_freeresult($result); - - // Try to get the maximum user id possible... - $sql = "SELECT MAX(user_id) AS max_user_id - FROM {$convert->src_table_prefix}users"; - $result = $src_db->sql_query($sql); - $max_id = (int) $src_db->sql_fetchfield('max_user_id'); - $src_db->sql_freeresult($result); - - if ($convert->mysql_convert && $same_db) - { - $src_db->sql_query("SET NAMES 'utf8'"); - } - - // If there is a user id 1, we need to increment user ids. :/ - if ($id === 1) - { - $config->set('increment_user_id', ($max_id + 1), false); - $config['increment_user_id'] = $max_id + 1; - } - else - { - $config->set('increment_user_id', 0, false); - $config['increment_user_id'] = 0; - } - } - - // If the old user id is -1 in 2.0.x it is the anonymous user... - if ($user_id == -1) - { - return ANONYMOUS; - } - - if (!empty($config['increment_user_id']) && $user_id == 1) - { - return $config['increment_user_id']; - } - - // A user id of 0 can happen, for example within the ban table if no user is banned... - // Within the posts and topics table this can be "dangerous" but is the fault of the user - // having mods installed (a poster id of 0 is not possible in 2.0.x). - // Therefore, we return the user id "as is". - - return (int) $user_id; -} - -/** -* Return correct user id value -* Everyone's id will be one higher to allow the guest/anonymous user to have a positive id as well -*/ -function phpbb_topic_replies_to_posts($num_replies) -{ - return (int) $num_replies + 1; -} - -/* Copy additional table fields from old forum to new forum if user wants this (for Mod compatibility for example) -function phpbb_copy_table_fields() -{ -} -*/ - -/** -* Convert authentication -* user, group and forum table has to be filled in order to work -*/ -function phpbb_convert_authentication($mode) -{ - global $db, $src_db, $same_db, $convert, $config; - - if ($mode == 'start') - { - $db->sql_query($convert->truncate_statement . ACL_USERS_TABLE); - $db->sql_query($convert->truncate_statement . ACL_GROUPS_TABLE); - - // What we will do is handling all 2.0.x admins as founder to replicate what is common in 2.0.x. - // After conversion the main admin need to make sure he is removing permissions and the founder status if wanted. - - // Grab user ids of users with user_level of ADMIN - $sql = "SELECT user_id - FROM {$convert->src_table_prefix}users - WHERE user_level = 1 - ORDER BY user_regdate ASC"; - $result = $src_db->sql_query($sql); - - while ($row = $src_db->sql_fetchrow($result)) - { - $user_id = (int) phpbb_user_id($row['user_id']); - // Set founder admin... - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_type = ' . USER_FOUNDER . " - WHERE user_id = $user_id"; - $db->sql_query($sql); - } - $src_db->sql_freeresult($result); - - $sql = 'SELECT group_id - FROM ' . GROUPS_TABLE . " - WHERE group_name = '" . $db->sql_escape('BOTS') . "'"; - $result = $db->sql_query($sql); - $bot_group_id = (int) $db->sql_fetchfield('group_id'); - $db->sql_freeresult($result); - } - - // Grab forum auth information - $sql = "SELECT * - FROM {$convert->src_table_prefix}forums"; - $result = $src_db->sql_query($sql); - - $forum_access = array(); - while ($row = $src_db->sql_fetchrow($result)) - { - $forum_access[$row['forum_id']] = $row; - } - $src_db->sql_freeresult($result); - - if ($convert->mysql_convert && $same_db) - { - $src_db->sql_query("SET NAMES 'binary'"); - } - // Grab user auth information from 2.0.x board - $sql = "SELECT ug.user_id, aa.* - FROM {$convert->src_table_prefix}auth_access aa, {$convert->src_table_prefix}user_group ug, {$convert->src_table_prefix}groups g, {$convert->src_table_prefix}forums f - WHERE g.group_id = aa.group_id - AND g.group_single_user = 1 - AND ug.group_id = g.group_id - AND f.forum_id = aa.forum_id"; - $result = $src_db->sql_query($sql); - - $user_access = array(); - while ($row = $src_db->sql_fetchrow($result)) - { - $user_access[$row['forum_id']][] = $row; - } - $src_db->sql_freeresult($result); - - // Grab group auth information - $sql = "SELECT g.group_id, aa.* - FROM {$convert->src_table_prefix}auth_access aa, {$convert->src_table_prefix}groups g - WHERE g.group_id = aa.group_id - AND g.group_single_user <> 1"; - $result = $src_db->sql_query($sql); - - $group_access = array(); - while ($row = $src_db->sql_fetchrow($result)) - { - $group_access[$row['forum_id']][] = $row; - } - $src_db->sql_freeresult($result); - - if ($convert->mysql_convert && $same_db) - { - $src_db->sql_query("SET NAMES 'utf8'"); - } - - // Add Forum Access List - $auth_map = array( - 'auth_view' => array('f_', 'f_list'), - 'auth_read' => array('f_read', 'f_search'), - 'auth_post' => array('f_post', 'f_bbcode', 'f_smilies', 'f_img', 'f_sigs', 'f_postcount', 'f_report', 'f_subscribe', 'f_print', 'f_email'), - 'auth_reply' => 'f_reply', - 'auth_edit' => 'f_edit', - 'auth_delete' => 'f_delete', - 'auth_pollcreate' => 'f_poll', - 'auth_vote' => 'f_vote', - 'auth_announce' => array('f_announce', 'f_announce_global'), - 'auth_sticky' => 'f_sticky', - 'auth_attachments' => array('f_attach', 'f_download'), - 'auth_download' => 'f_download', - ); - - // Define the ACL constants used in 2.0 to make the code slightly more readable - define('AUTH_ALL', 0); - define('AUTH_REG', 1); - define('AUTH_ACL', 2); - define('AUTH_MOD', 3); - define('AUTH_ADMIN', 5); - - // A mapping of the simple permissions used by 2.0 - $simple_auth_ary = array( - 'public' => array( - 'auth_view' => AUTH_ALL, - 'auth_read' => AUTH_ALL, - 'auth_post' => AUTH_ALL, - 'auth_reply' => AUTH_ALL, - 'auth_edit' => AUTH_REG, - 'auth_delete' => AUTH_REG, - 'auth_sticky' => AUTH_MOD, - 'auth_announce' => AUTH_MOD, - 'auth_vote' => AUTH_REG, - 'auth_pollcreate' => AUTH_REG, - ), - 'registered' => array( - 'auth_view' => AUTH_ALL, - 'auth_read' => AUTH_ALL, - 'auth_post' => AUTH_REG, - 'auth_reply' => AUTH_REG, - 'auth_edit' => AUTH_REG, - 'auth_delete' => AUTH_REG, - 'auth_sticky' => AUTH_MOD, - 'auth_announce' => AUTH_MOD, - 'auth_vote' => AUTH_REG, - 'auth_pollcreate' => AUTH_REG, - ), - 'registered_hidden' => array( - 'auth_view' => AUTH_REG, - 'auth_read' => AUTH_REG, - 'auth_post' => AUTH_REG, - 'auth_reply' => AUTH_REG, - 'auth_edit' => AUTH_REG, - 'auth_delete' => AUTH_REG, - 'auth_sticky' => AUTH_MOD, - 'auth_announce' => AUTH_MOD, - 'auth_vote' => AUTH_REG, - 'auth_pollcreate' => AUTH_REG, - ), - 'private' => array( - 'auth_view' => AUTH_ALL, - 'auth_read' => AUTH_ACL, - 'auth_post' => AUTH_ACL, - 'auth_reply' => AUTH_ACL, - 'auth_edit' => AUTH_ACL, - 'auth_delete' => AUTH_ACL, - 'auth_sticky' => AUTH_ACL, - 'auth_announce' => AUTH_MOD, - 'auth_vote' => AUTH_ACL, - 'auth_pollcreate' => AUTH_ACL, - ), - 'private_hidden' => array( - 'auth_view' => AUTH_ACL, - 'auth_read' => AUTH_ACL, - 'auth_post' => AUTH_ACL, - 'auth_reply' => AUTH_ACL, - 'auth_edit' => AUTH_ACL, - 'auth_delete' => AUTH_ACL, - 'auth_sticky' => AUTH_ACL, - 'auth_announce' => AUTH_MOD, - 'auth_vote' => AUTH_ACL, - 'auth_pollcreate' => AUTH_ACL, - ), - 'moderator' => array( - 'auth_view' => AUTH_ALL, - 'auth_read' => AUTH_MOD, - 'auth_post' => AUTH_MOD, - 'auth_reply' => AUTH_MOD, - 'auth_edit' => AUTH_MOD, - 'auth_delete' => AUTH_MOD, - 'auth_sticky' => AUTH_MOD, - 'auth_announce' => AUTH_MOD, - 'auth_vote' => AUTH_MOD, - 'auth_pollcreate' => AUTH_MOD, - ), - 'moderator_hidden' => array( - 'auth_view' => AUTH_MOD, - 'auth_read' => AUTH_MOD, - 'auth_post' => AUTH_MOD, - 'auth_reply' => AUTH_MOD, - 'auth_edit' => AUTH_MOD, - 'auth_delete' => AUTH_MOD, - 'auth_sticky' => AUTH_MOD, - 'auth_announce' => AUTH_MOD, - 'auth_vote' => AUTH_MOD, - 'auth_pollcreate' => AUTH_MOD, - ), - ); - - if ($mode == 'start') - { - user_group_auth('guests', 'SELECT user_id, {GUESTS} FROM ' . USERS_TABLE . ' WHERE user_id = ' . ANONYMOUS, false); - user_group_auth('registered', 'SELECT user_id, {REGISTERED} FROM ' . USERS_TABLE . ' WHERE user_id <> ' . ANONYMOUS . " AND group_id <> $bot_group_id", false); - - // Selecting from old table - if (!empty($config['increment_user_id'])) - { - $auth_sql = 'SELECT user_id, {ADMINISTRATORS} FROM ' . $convert->src_table_prefix . 'users WHERE user_level = 1 AND user_id <> 1'; - user_group_auth('administrators', $auth_sql, true); - - $auth_sql = 'SELECT ' . $config['increment_user_id'] . ' as user_id, {ADMINISTRATORS} FROM ' . $convert->src_table_prefix . 'users WHERE user_level = 1 AND user_id = 1'; - user_group_auth('administrators', $auth_sql, true); - } - else - { - $auth_sql = 'SELECT user_id, {ADMINISTRATORS} FROM ' . $convert->src_table_prefix . 'users WHERE user_level = 1'; - user_group_auth('administrators', $auth_sql, true); - } - - if (!empty($config['increment_user_id'])) - { - $auth_sql = 'SELECT user_id, {GLOBAL_MODERATORS} FROM ' . $convert->src_table_prefix . 'users WHERE user_level = 1 AND user_id <> 1'; - user_group_auth('global_moderators', $auth_sql, true); - - $auth_sql = 'SELECT ' . $config['increment_user_id'] . ' as user_id, {GLOBAL_MODERATORS} FROM ' . $convert->src_table_prefix . 'users WHERE user_level = 1 AND user_id = 1'; - user_group_auth('global_moderators', $auth_sql, true); - } - else - { - $auth_sql = 'SELECT user_id, {GLOBAL_MODERATORS} FROM ' . $convert->src_table_prefix . 'users WHERE user_level = 1'; - user_group_auth('global_moderators', $auth_sql, true); - } - } - else if ($mode == 'first') - { - // Go through all 2.0.x forums - foreach ($forum_access as $forum) - { - $new_forum_id = (int) $forum['forum_id']; - - // Administrators have full access to all forums whatever happens - mass_auth('group_role', $new_forum_id, 'administrators', 'FORUM_FULL'); - - $matched_type = ''; - foreach ($simple_auth_ary as $key => $auth_levels) - { - $matched = 1; - foreach ($auth_levels as $k => $level) - { - if ($forum[$k] != $auth_levels[$k]) - { - $matched = 0; - } - } - - if ($matched) - { - $matched_type = $key; - break; - } - } - - switch ($matched_type) - { - case 'public': - mass_auth('group_role', $new_forum_id, 'guests', 'FORUM_LIMITED'); - mass_auth('group_role', $new_forum_id, 'registered', 'FORUM_LIMITED_POLLS'); - mass_auth('group_role', $new_forum_id, 'bots', 'FORUM_BOT'); - break; - - case 'registered': - mass_auth('group_role', $new_forum_id, 'guests', 'FORUM_READONLY'); - mass_auth('group_role', $new_forum_id, 'bots', 'FORUM_BOT'); - - // no break; - - case 'registered_hidden': - mass_auth('group_role', $new_forum_id, 'registered', 'FORUM_POLLS'); - break; - - case 'private': - case 'private_hidden': - case 'moderator': - case 'moderator_hidden': - default: - // The permissions don't match a simple set, so we're going to have to map them directly - - // No post approval for all, in 2.0.x this feature does not exist - mass_auth('group', $new_forum_id, 'guests', 'f_noapprove', ACL_YES); - mass_auth('group', $new_forum_id, 'registered', 'f_noapprove', ACL_YES); - - // Go through authentication map - foreach ($auth_map as $old_auth_key => $new_acl) - { - // If old authentication key does not exist we continue - // This is helpful for mods adding additional authentication fields, we need to add them to the auth_map array - if (!isset($forum[$old_auth_key])) - { - continue; - } - - // Now set the new ACL correctly - switch ($forum[$old_auth_key]) - { - // AUTH_ALL - case AUTH_ALL: - mass_auth('group', $new_forum_id, 'guests', $new_acl, ACL_YES); - mass_auth('group', $new_forum_id, 'bots', $new_acl, ACL_YES); - mass_auth('group', $new_forum_id, 'registered', $new_acl, ACL_YES); - break; - - // AUTH_REG - case AUTH_REG: - mass_auth('group', $new_forum_id, 'registered', $new_acl, ACL_YES); - break; - - // AUTH_ACL - case AUTH_ACL: - // Go through the old group access list for this forum - if (isset($group_access[$forum['forum_id']])) - { - foreach ($group_access[$forum['forum_id']] as $index => $access) - { - // We only check for ACL_YES equivalence entry - if (isset($access[$old_auth_key]) && $access[$old_auth_key] == 1) - { - mass_auth('group', $new_forum_id, (int) $access['group_id'], $new_acl, ACL_YES); - } - } - } - - if (isset($user_access[$forum['forum_id']])) - { - foreach ($user_access[$forum['forum_id']] as $index => $access) - { - // We only check for ACL_YES equivalence entry - if (isset($access[$old_auth_key]) && $access[$old_auth_key] == 1) - { - mass_auth('user', $new_forum_id, (int) phpbb_user_id($access['user_id']), $new_acl, ACL_YES); - } - } - } - break; - - // AUTH_MOD - case AUTH_MOD: - if (isset($group_access[$forum['forum_id']])) - { - foreach ($group_access[$forum['forum_id']] as $index => $access) - { - // We only check for ACL_YES equivalence entry - if (isset($access[$old_auth_key]) && $access[$old_auth_key] == 1) - { - mass_auth('group', $new_forum_id, (int) $access['group_id'], $new_acl, ACL_YES); - } - } - } - - if (isset($user_access[$forum['forum_id']])) - { - foreach ($user_access[$forum['forum_id']] as $index => $access) - { - // We only check for ACL_YES equivalence entry - if (isset($access[$old_auth_key]) && $access[$old_auth_key] == 1) - { - mass_auth('user', $new_forum_id, (int) phpbb_user_id($access['user_id']), $new_acl, ACL_YES); - } - } - } - break; - } - } - break; - } - } - } - else if ($mode == 'second') - { - // Assign permission roles and other default permissions - - // guests having u_download and u_search ability - $db->sql_query('INSERT INTO ' . ACL_GROUPS_TABLE . ' (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) SELECT ' . get_group_id('guests') . ', 0, auth_option_id, 0, 1 FROM ' . ACL_OPTIONS_TABLE . " WHERE auth_option IN ('u_', 'u_download', 'u_search')"); - - // administrators/global mods having full user features - mass_auth('group_role', 0, 'administrators', 'USER_FULL'); - mass_auth('group_role', 0, 'global_moderators', 'USER_FULL'); - - // By default all converted administrators are given full access - mass_auth('group_role', 0, 'administrators', 'ADMIN_FULL'); - - // All registered users are assigned the standard user role - mass_auth('group_role', 0, 'registered', 'USER_STANDARD'); - mass_auth('group_role', 0, 'registered_coppa', 'USER_STANDARD'); - - // Instead of administrators being global moderators we give the MOD_FULL role to global mods (admins already assigned to this group) - mass_auth('group_role', 0, 'global_moderators', 'MOD_FULL'); - - // And now those who have had their avatar rights removed get assigned a more restrictive role - $sql = 'SELECT user_id FROM ' . $convert->src_table_prefix . 'users - WHERE user_allowavatar = 0 - AND user_id > 0'; - $result = $src_db->sql_query($sql); - - while ($row = $src_db->sql_fetchrow($result)) - { - mass_auth('user_role', 0, (int) phpbb_user_id($row['user_id']), 'USER_NOAVATAR'); - } - $src_db->sql_freeresult($result); - - // And the same for those who have had their PM rights removed - $sql = 'SELECT user_id FROM ' . $convert->src_table_prefix . 'users - WHERE user_allow_pm = 0 - AND user_id > 0'; - $result = $src_db->sql_query($sql); - - while ($row = $src_db->sql_fetchrow($result)) - { - mass_auth('user_role', 0, (int) phpbb_user_id($row['user_id']), 'USER_NOPM'); - } - $src_db->sql_freeresult($result); - } - else if ($mode == 'third') - { - // And now the moderators - // We make sure that they have at least standard access to the forums they moderate in addition to the moderating permissions - - $mod_post_map = array( - 'auth_announce' => array('f_announce', 'f_announce_global'), - 'auth_sticky' => 'f_sticky' - ); - - foreach ($user_access as $forum_id => $access_map) - { - $forum_id = (int) $forum_id; - - foreach ($access_map as $access) - { - if (isset($access['auth_mod']) && $access['auth_mod'] == 1) - { - mass_auth('user_role', $forum_id, (int) phpbb_user_id($access['user_id']), 'MOD_STANDARD'); - mass_auth('user_role', $forum_id, (int) phpbb_user_id($access['user_id']), 'FORUM_STANDARD'); - foreach ($mod_post_map as $old => $new) - { - if (isset($forum_access[$forum_id]) && isset($forum_access[$forum_id][$old]) && $forum_access[$forum_id][$old] == AUTH_MOD) - { - mass_auth('user', $forum_id, (int) phpbb_user_id($access['user_id']), $new, ACL_YES); - } - } - } - } - } - - foreach ($group_access as $forum_id => $access_map) - { - $forum_id = (int) $forum_id; - - foreach ($access_map as $access) - { - if (isset($access['auth_mod']) && $access['auth_mod'] == 1) - { - mass_auth('group_role', $forum_id, (int) $access['group_id'], 'MOD_STANDARD'); - mass_auth('group_role', $forum_id, (int) $access['group_id'], 'FORUM_STANDARD'); - foreach ($mod_post_map as $old => $new) - { - if (isset($forum_access[$forum_id]) && isset($forum_access[$forum_id][$old]) && $forum_access[$forum_id][$old] == AUTH_MOD) - { - mass_auth('group', $forum_id, (int) $access['group_id'], $new, ACL_YES); - } - } - } - } - } - - // We grant everyone readonly access to the categories to ensure that the forums are visible - $sql = 'SELECT forum_id, forum_name, parent_id, left_id, right_id - FROM ' . FORUMS_TABLE . ' - ORDER BY left_id ASC'; - $result = $db->sql_query($sql); - - $parent_forums = $forums = array(); - while ($row = $db->sql_fetchrow($result)) - { - if ($row['parent_id'] == 0) - { - mass_auth('group_role', $row['forum_id'], 'administrators', 'FORUM_FULL'); - mass_auth('group_role', $row['forum_id'], 'global_moderators', 'FORUM_FULL'); - $parent_forums[] = $row; - } - else - { - $forums[] = $row; - } - } - $db->sql_freeresult($result); - - global $auth; - - // Let us see which groups have access to these forums... - foreach ($parent_forums as $row) - { - // Get the children - $branch = $forum_ids = array(); - - foreach ($forums as $key => $_row) - { - if ($_row['left_id'] > $row['left_id'] && $_row['left_id'] < $row['right_id']) - { - $branch[] = $_row; - $forum_ids[] = $_row['forum_id']; - continue; - } - } - - if (count($forum_ids)) - { - // Now make sure the user is able to read these forums - $hold_ary = $auth->acl_group_raw_data(false, 'f_list', $forum_ids); - - if (empty($hold_ary)) - { - continue; - } - - foreach ($hold_ary as $g_id => $f_id_ary) - { - $set_group = false; - - foreach ($f_id_ary as $f_id => $auth_ary) - { - foreach ($auth_ary as $auth_option => $setting) - { - if ($setting == ACL_YES) - { - $set_group = true; - break 2; - } - } - } - - if ($set_group) - { - mass_auth('group', $row['forum_id'], $g_id, 'f_list', ACL_YES); - } - } - } - } - } -} - -/** -* Set primary group. -* Really simple and only based on user_level (remaining groups will be assigned later) -*/ -function phpbb_set_primary_group($user_level) -{ - global $convert_row; - - if ($user_level == 1) - { - return get_group_id('administrators'); - } -/* else if ($user_level == 2) - { - return get_group_id('global_moderators'); - } - else if ($user_level == 0 && $convert_row['user_active'])*/ - else if ($convert_row['user_active']) - { - return get_group_id('registered'); - } - - return 0; -} - -/** -* Convert the group name, making sure to avoid conflicts with 3.0 special groups -*/ -function phpbb_convert_group_name($group_name) -{ - $default_groups = array( - 'GUESTS', - 'REGISTERED', - 'REGISTERED_COPPA', - 'GLOBAL_MODERATORS', - 'ADMINISTRATORS', - 'BOTS', - ); - - if (in_array(strtoupper($group_name), $default_groups)) - { - return 'phpBB2 - ' . $group_name; - } - - return phpbb_set_default_encoding($group_name); -} - -/** -* Convert the group type constants -*/ -function phpbb_convert_group_type($group_type) -{ - switch ($group_type) - { - case 0: - return GROUP_OPEN; - break; - - case 1: - return GROUP_CLOSED; - break; - - case 2: - return GROUP_HIDDEN; - break; - } - - // Never return GROUP_SPECIAL here, because only phpBB's default groups are allowed to have this type set. - return GROUP_HIDDEN; -} - -/** -* Convert the topic type constants -*/ -function phpbb_convert_topic_type($topic_type) -{ - switch ($topic_type) - { - case 0: - return POST_NORMAL; - break; - - case 1: - return POST_STICKY; - break; - - case 2: - return POST_ANNOUNCE; - break; - - case 3: - return POST_GLOBAL; - break; - } - - return POST_NORMAL; -} - -function phpbb_replace_size($matches) -{ - return '[size=' . min(200, ceil(100.0 * (((double) $matches[1])/12.0))) . ':' . $matches[2] . ']'; -} - -/** -* Reparse the message stripping out the bbcode_uid values and adding new ones and setting the bitfield -* @todo What do we want to do about HTML in messages - currently it gets converted to the entities, but there may be some objections to this -*/ -function phpbb_prepare_message($message) -{ - global $convert, $user, $convert_row, $message_parser; - - if (!$message) - { - $convert->row['mp_bbcode_bitfield'] = $convert_row['mp_bbcode_bitfield'] = 0; - return ''; - } - - // Decode phpBB 2.0.x Message - if (isset($convert->row['old_bbcode_uid']) && $convert->row['old_bbcode_uid'] != '') - { - // Adjust size... - if (strpos($message, '[size=') !== false) - { - $message = preg_replace_callback('/\[size=(\d*):(' . $convert->row['old_bbcode_uid'] . ')\]/', 'phpbb_replace_size', $message); - } - - $message = preg_replace('/\:(([a-z0-9]:)?)' . $convert->row['old_bbcode_uid'] . '/s', '', $message); - } - - if (strpos($message, '[quote=') !== false) - { - $message = preg_replace('/\[quote="(.*?)"\]/s', '[quote="\1"]', $message); - $message = preg_replace('/\[quote=\\\"(.*?)\\\"\]/s', '[quote="\1"]', $message); - - // let's hope that this solves more problems than it causes. Deal with escaped quotes. - $message = str_replace('\"', '"', $message); - $message = str_replace('\"', '"', $message); - } - - $message = str_replace('
', "\n", $message); - $message = str_replace('<', '<', $message); - $message = str_replace('>', '>', $message); - - // make the post UTF-8 - $message = phpbb_set_encoding($message); - - $message_parser->warn_msg = array(); // Reset the errors from the previous message - $message_parser->bbcode_uid = make_uid($convert->row['post_time']); - $message_parser->message = $message; - unset($message); - - // Make sure options are set. -// $enable_html = (!isset($row['enable_html'])) ? false : $row['enable_html']; - $enable_bbcode = (!isset($convert->row['enable_bbcode'])) ? true : $convert->row['enable_bbcode']; - $enable_smilies = (!isset($convert->row['enable_smilies'])) ? true : $convert->row['enable_smilies']; - $enable_magic_url = (!isset($convert->row['enable_magic_url'])) ? true : $convert->row['enable_magic_url']; - - // parse($allow_bbcode, $allow_magic_url, $allow_smilies, $allow_img_bbcode = true, $allow_quote_bbcode = true, $allow_url_bbcode = true, $update_this_message = true, $mode = 'post') - $message_parser->parse($enable_bbcode, $enable_magic_url, $enable_smilies); - - if (count($message_parser->warn_msg)) - { - $msg_id = isset($convert->row['post_id']) ? $convert->row['post_id'] : $convert->row['privmsgs_id']; - $convert->p_master->error('' . $user->lang['POST_ID'] . ': ' . $msg_id . ' ' . $user->lang['CONV_ERROR_MESSAGE_PARSER'] . ':

' . implode('
', $message_parser->warn_msg), __LINE__, __FILE__, true); - } - - $convert->row['mp_bbcode_bitfield'] = $convert_row['mp_bbcode_bitfield'] = $message_parser->bbcode_bitfield; - - $message = $message_parser->message; - unset($message_parser->message); - - return $message; -} - -/** -* Return the bitfield calculated by the previous function -*/ -function get_bbcode_bitfield() -{ - global $convert_row; - - return $convert_row['mp_bbcode_bitfield']; -} - -/** -* Determine the last user to edit a post -* In practice we only tracked edits by the original poster in 2.0.x so this will only be set if they had edited their own post -*/ -function phpbb_post_edit_user() -{ - global $convert_row; - - if (isset($convert_row['post_edit_count'])) - { - return phpbb_user_id($convert_row['poster_id']); - } - - return 0; -} - -/** -* Obtain the path to uploaded files on the 2.0.x forum -* This is only used if the Attachment MOD was installed -*/ -function phpbb_get_files_dir() -{ - if (!defined('MOD_ATTACHMENT')) - { - return ''; - } - - global $src_db, $same_db, $convert, $user; - - if ($convert->mysql_convert && $same_db) - { - $src_db->sql_query("SET NAMES 'binary'"); - } - $sql = 'SELECT config_value AS upload_dir - FROM ' . $convert->src_table_prefix . "attachments_config - WHERE config_name = 'upload_dir'"; - $result = $src_db->sql_query($sql); - $upload_path = $src_db->sql_fetchfield('upload_dir'); - $src_db->sql_freeresult($result); - - $sql = 'SELECT config_value AS ftp_upload - FROM ' . $convert->src_table_prefix . "attachments_config - WHERE config_name = 'allow_ftp_upload'"; - $result = $src_db->sql_query($sql); - $ftp_upload = (int) $src_db->sql_fetchfield('ftp_upload'); - $src_db->sql_freeresult($result); - - if ($convert->mysql_convert && $same_db) - { - $src_db->sql_query("SET NAMES 'utf8'"); - } - - if ($ftp_upload) - { - $convert->p_master->error($user->lang['CONV_ERROR_ATTACH_FTP_DIR'], __LINE__, __FILE__); - } - - return $upload_path; -} - -/** -* Copy thumbnails of uploaded images from the 2.0.x forum -* This is only used if the Attachment MOD was installed -*/ -function phpbb_copy_thumbnails() -{ - global $convert, $config, $phpbb_root_path; - - $src_path = $convert->options['forum_path'] . '/' . phpbb_get_files_dir() . '/thumbs/'; - - if ($handle = @opendir($src_path)) - { - while ($entry = readdir($handle)) - { - if ($entry[0] == '.') - { - continue; - } - - if (is_dir($src_path . $entry)) - { - continue; - } - else - { - copy_file($src_path . $entry, $config['upload_path'] . '/' . preg_replace('/^t_/', 'thumb_', $entry)); - @unlink($phpbb_root_path . $config['upload_path'] . '/thumbs/' . $entry); - } - } - closedir($handle); - } -} - -/** -* Convert the attachment category constants -* This is only used if the Attachment MOD was installed -*/ -function phpbb_attachment_category($cat_id) -{ - switch ($cat_id) - { - case 1: - return attachment_category::IMAGE; - break; - - case 2: - return ATTACHMENT_CATEGORY_WM; - break; - } - - return attachment_category::NONE; -} - -/** -* Convert the attachment extension names -* This is only used if the Attachment MOD was installed -*/ -function phpbb_attachment_extension_group_name() -{ - global $db, $phpbb_root_path, $phpEx; - - // Update file extension group names to use language strings. - $sql = 'SELECT lang_dir - FROM ' . LANG_TABLE; - $result = $db->sql_query($sql); - - $extension_groups_updated = array(); - while ($row = $db->sql_fetchrow($result)) - { - $lang_dir = basename($row['lang_dir']); - $lang_file = $phpbb_root_path . 'language/' . $lang_dir . '/acp/attachments.' . $phpEx; - - if (!file_exists($lang_file)) - { - continue; - } - - $lang = array(); - include($lang_file); - - foreach ($lang as $lang_key => $lang_val) - { - if (isset($extension_groups_updated[$lang_key]) || strpos($lang_key, 'EXT_GROUP_') !== 0) - { - continue; - } - - $sql_ary = array( - 'group_name' => substr($lang_key, 10), // Strip off 'EXT_GROUP_' - ); - - $sql = 'UPDATE ' . EXTENSION_GROUPS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $sql_ary) . " - WHERE group_name = '" . $db->sql_escape($lang_val) . "'"; - $db->sql_query($sql); - - $extension_groups_updated[$lang_key] = true; - } - } - $db->sql_freeresult($result); -} - -/** -* Obtain list of forums in which different attachment categories can be used -*/ -function phpbb_attachment_forum_perms($forum_permissions) -{ - if (empty($forum_permissions)) - { - return ''; - } - - // Decode forum permissions - $forum_ids = array(); - - $one_char_encoding = '#'; - $two_char_encoding = '.'; - - $auth_len = 1; - for ($pos = 0; $pos < strlen($forum_permissions); $pos += $auth_len) - { - $forum_auth = substr($forum_permissions, $pos, 1); - if ($forum_auth == $one_char_encoding) - { - $auth_len = 1; - continue; - } - else if ($forum_auth == $two_char_encoding) - { - $auth_len = 2; - $pos--; - continue; - } - - $forum_auth = substr($forum_permissions, $pos, $auth_len); - $forum_id = base64_unpack($forum_auth); - - $forum_ids[] = (int) $forum_id; - } - - if (count($forum_ids)) - { - return attachment_forum_perms($forum_ids); - } - - return ''; -} - -/** -* Convert the avatar type constants -*/ -function phpbb_avatar_type($type) -{ - switch ($type) - { - case 1: - return AVATAR_UPLOAD; - - case 3: - return AVATAR_GALLERY; - } - - return 0; -} - - -/** -* Just undos the replacing of '<' and '>' -*/ -function phpbb_smilie_html_decode($code) -{ - $code = str_replace('<', '<', $code); - return str_replace('>', '>', $code); -} - -/** -* Transfer avatars, copying the image if it was uploaded -*/ -function phpbb_import_avatar($user_avatar) -{ - global $convert_row; - - if (!$convert_row['user_avatar_type']) - { - return ''; - } - else if ($convert_row['user_avatar_type'] == 1) - { - // Uploaded avatar - return import_avatar($user_avatar, false, $convert_row['user_id']); - } - else if ($convert_row['user_avatar_type'] == 3) - { - // Gallery avatar - return $user_avatar; - } - - return ''; -} - - -/** -* Find out about the avatar's dimensions -*/ -function phpbb_get_avatar_height($user_avatar) -{ - global $convert_row; - - if (empty($convert_row['user_avatar_type'])) - { - return 0; - } - return get_avatar_height($user_avatar, 'phpbb_avatar_type', $convert_row['user_avatar_type']); -} - - -/** -* Find out about the avatar's dimensions -*/ -function phpbb_get_avatar_width($user_avatar) -{ - global $convert_row; - - if (empty($convert_row['user_avatar_type'])) - { - return 0; - } - - return get_avatar_width($user_avatar, 'phpbb_avatar_type', $convert_row['user_avatar_type']); -} - - -/** -* Calculate the correct to_address field for private messages -*/ -function phpbb_privmsgs_to_userid($to_userid) -{ - return 'u_' . phpbb_user_id($to_userid); -} - -/** -* Calculate whether a private message was unread using the bitfield -*/ -function phpbb_unread_pm($pm_type) -{ - return ($pm_type == 5) ? 1 : 0; -} - -/** -* Calculate whether a private message was new using the bitfield -*/ -function phpbb_new_pm($pm_type) -{ - return ($pm_type == 1) ? 1 : 0; -} - -/** -* Obtain the folder_id for the custom folder created to replace the savebox from 2.0.x (used to store saved private messages) -*/ -function phpbb_get_savebox_id($user_id) -{ - global $db; - - $user_id = phpbb_user_id($user_id); - - // Only one custom folder, check only one - $sql = 'SELECT folder_id - FROM ' . PRIVMSGS_FOLDER_TABLE . ' - WHERE user_id = ' . $user_id; - $result = $db->sql_query_limit($sql, 1); - $folder_id = (int) $db->sql_fetchfield('folder_id'); - $db->sql_freeresult($result); - - return $folder_id; -} - -/** -* Transfer attachment specific configuration options -* These were not stored in the main config table on 2.0.x -* This is only used if the Attachment MOD was installed -*/ -function phpbb_import_attach_config() -{ - global $src_db, $same_db, $convert, $config; - - if ($convert->mysql_convert && $same_db) - { - $src_db->sql_query("SET NAMES 'binary'"); - } - - $sql = 'SELECT * - FROM ' . $convert->src_table_prefix . 'attachments_config'; - $result = $src_db->sql_query($sql); - - if ($convert->mysql_convert && $same_db) - { - $src_db->sql_query("SET NAMES 'utf8'"); - } - - $attach_config = array(); - while ($row = $src_db->sql_fetchrow($result)) - { - $attach_config[$row['config_name']] = $row['config_value']; - } - $src_db->sql_freeresult($result); - - $config->set('allow_attachments', 1); - - // old attachment mod? Must be very old if this entry do not exist... - if (!empty($attach_config['display_order'])) - { - $config->set('display_order', $attach_config['display_order']); - } - $config->set('max_filesize', $attach_config['max_filesize']); - $config->set('max_filesize_pm', $attach_config['max_filesize_pm']); - $config->set('attachment_quota', $attach_config['attachment_quota']); - $config->set('max_attachments', $attach_config['max_attachments']); - $config->set('max_attachments_pm', $attach_config['max_attachments_pm']); - $config->set('allow_pm_attach', $attach_config['allow_pm_attach']); - - $config->set('img_display_inlined', $attach_config['img_display_inlined']); - $config->set('img_max_width', $attach_config['img_max_width']); - $config->set('img_max_height', $attach_config['img_max_height']); - $config->set('img_create_thumbnail', $attach_config['img_create_thumbnail']); - $config->set('img_max_thumb_width', 400); - $config->set('img_min_thumb_filesize', $attach_config['img_min_thumb_filesize']); -} - -/** -* Calculate the date a user became inactive -*/ -function phpbb_inactive_time() -{ - global $convert_row; - - if ($convert_row['user_active']) - { - return 0; - } - - if ($convert_row['user_lastvisit']) - { - return $convert_row['user_lastvisit']; - } - - return $convert_row['user_regdate']; -} - -/** -* Calculate the reason a user became inactive -* We can't actually tell the difference between a manual deactivation and one for profile changes -* from the data available to assume the latter -*/ -function phpbb_inactive_reason() -{ - global $convert_row; - - if ($convert_row['user_active']) - { - return 0; - } - - if ($convert_row['user_lastvisit']) - { - return INACTIVE_PROFILE; - } - - return INACTIVE_REGISTER; -} - -/** -* Adjust 2.0.x disallowed names to 3.0.x format -*/ -function phpbb_disallowed_username($username) -{ - // Replace * with % - $username = phpbb_set_default_encoding(str_replace('*', '%', $username)); - return utf8_htmlspecialchars($username); -} - -/** -* Checks whether there are any usernames on the old board that would map to the same -* username_clean on phpBB. Prints out a list if any exist and exits. -*/ -function phpbb_create_userconv_table() -{ - global $db; - - switch ($db->get_sql_layer()) - { - case 'mysqli': - $map_dbms = 'mysql_41'; - break; - - case 'mssql_odbc': - case 'mssqlnative': - $map_dbms = 'mssql'; - break; - - default: - $map_dbms = $db->get_sql_layer(); - break; - } - - // create a temporary table in which we store the clean usernames - $drop_sql = 'DROP TABLE ' . USERCONV_TABLE; - switch ($map_dbms) - { - case 'mssql': - $create_sql = 'CREATE TABLE [' . USERCONV_TABLE . '] ( - [user_id] [int] NOT NULL , - [username_clean] [varchar] (255) DEFAULT (\'\') NOT NULL - )'; - break; - - case 'mysql_41': - $create_sql = 'CREATE TABLE ' . USERCONV_TABLE . ' ( - user_id mediumint(8) NOT NULL, - username_clean varchar(255) DEFAULT \'\' NOT NULL - ) CHARACTER SET `utf8` COLLATE `utf8_bin`'; - break; - - case 'oracle': - $create_sql = 'CREATE TABLE ' . USERCONV_TABLE . ' ( - user_id number(8) NOT NULL, - username_clean varchar2(255) DEFAULT \'\' - )'; - break; - - case 'postgres': - $create_sql = 'CREATE TABLE ' . USERCONV_TABLE . ' ( - user_id INT4 DEFAULT \'0\', - username_clean varchar_ci DEFAULT \'\' NOT NULL - )'; - break; - - case 'sqlite3': - $create_sql = 'CREATE TABLE ' . USERCONV_TABLE . ' ( - user_id INTEGER NOT NULL DEFAULT \'0\', - username_clean varchar(255) NOT NULL DEFAULT \'\' - )'; - break; - } - - $db->sql_return_on_error(true); - $db->sql_query($drop_sql); - $db->sql_return_on_error(false); - $db->sql_query($create_sql); -} - -function phpbb_check_username_collisions() -{ - global $db, $src_db, $convert, $user, $lang; - - // now find the clean version of the usernames that collide - $sql = 'SELECT username_clean - FROM ' . USERCONV_TABLE .' - GROUP BY username_clean - HAVING COUNT(user_id) > 1'; - $result = $db->sql_query($sql); - - $colliding_names = array(); - while ($row = $db->sql_fetchrow($result)) - { - $colliding_names[] = $row['username_clean']; - } - $db->sql_freeresult($result); - - // there was at least one collision, the admin will have to solve it before conversion can continue - if (count($colliding_names)) - { - $sql = 'SELECT user_id, username_clean - FROM ' . USERCONV_TABLE . ' - WHERE ' . $db->sql_in_set('username_clean', $colliding_names); - $result = $db->sql_query($sql); - unset($colliding_names); - - $colliding_user_ids = array(); - while ($row = $db->sql_fetchrow($result)) - { - $colliding_user_ids[(int) $row['user_id']] = $row['username_clean']; - } - $db->sql_freeresult($result); - - $sql = 'SELECT username, user_id, user_posts - FROM ' . $convert->src_table_prefix . 'users - WHERE ' . $src_db->sql_in_set('user_id', array_keys($colliding_user_ids)); - $result = $src_db->sql_query($sql); - - $colliding_users = array(); - while ($row = $src_db->sql_fetchrow($result)) - { - $row['user_id'] = (int) $row['user_id']; - if (isset($colliding_user_ids[$row['user_id']])) - { - $colliding_users[$colliding_user_ids[$row['user_id']]][] = $row; - } - } - $src_db->sql_freeresult($result); - unset($colliding_user_ids); - - $list = ''; - foreach ($colliding_users as $username_clean => $users) - { - $list .= sprintf($user->lang['COLLIDING_CLEAN_USERNAME'], $username_clean) . "
\n"; - foreach ($users as $i => $row) - { - $list .= sprintf($user->lang['COLLIDING_USER'], $row['user_id'], phpbb_set_default_encoding($row['username']), $row['user_posts']) . "
\n"; - } - } - - $lang['INST_ERR_FATAL'] = $user->lang['CONV_ERR_FATAL']; - $convert->p_master->error('' . $user->lang['COLLIDING_USERNAMES_FOUND'] . '

' . $list . '', __LINE__, __FILE__); - } - - $drop_sql = 'DROP TABLE ' . USERCONV_TABLE; - $db->sql_query($drop_sql); -} - -function phpbb_convert_timezone($timezone) -{ - return \phpbb\db\migration\data\v310\timezone::convert_phpbb30_timezone($timezone, 0); -} - -function phpbb_add_notification_options($user_notify_pm) -{ - global $convert_row, $db; - - $user_id = phpbb_user_id($convert_row['user_id']); - if ($user_id == ANONYMOUS) - { - return; - } - - $rows = array(); - - $rows[] = array( - 'item_type' => 'post', - 'item_id' => 0, - 'user_id' => (int) $user_id, - 'notify' => 1, - 'method' => 'email', - ); - $rows[] = array( - 'item_type' => 'topic', - 'item_id' => 0, - 'user_id' => (int) $user_id, - 'notify' => 1, - 'method' => 'email', - ); - if ($user_notify_pm) - { - $rows[] = array( - 'item_type' => 'pm', - 'item_id' => 0, - 'user_id' => (int) $user_id, - 'notify' => 1, - 'method' => 'email', - ); - } - - $db->sql_multi_insert(USER_NOTIFICATIONS_TABLE, $rows); -} - -function phpbb_convert_password_hash($hash) -{ - global $phpbb_container; - - /* @var $manager \phpbb\passwords\manager */ - $manager = $phpbb_container->get('passwords.manager'); - $hash = $manager->hash($hash, '$H$'); - - return '$CP$' . $hash; -} diff --git a/phpBB/install/convertors/index.htm b/phpBB/install/convertors/index.htm new file mode 100644 index 0000000000..ee1f723a7d --- /dev/null +++ b/phpBB/install/convertors/index.htm @@ -0,0 +1,10 @@ + + + + + + + + + + From 391bda011e9985b799608ecab89e807fc4314875 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 26 Sep 2025 15:38:13 +0200 Subject: [PATCH 2/2] [ticket/16005] Remove references that don't make sense anymore PHPBB-16005 --- phpBB/includes/functions_convert.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/functions_convert.php b/phpBB/includes/functions_convert.php index 8a161edfa7..9292281c1f 100644 --- a/phpBB/includes/functions_convert.php +++ b/phpBB/includes/functions_convert.php @@ -1022,7 +1022,7 @@ function user_group_auth($group, $select_query, $use_src_db) /** * Retrieves configuration information from the source forum and caches it as an array * Both database and file driven configuration formats can be handled -* (the type used is specified in $config_schema, see convert_phpbb20.php for more details) +* (the type used is specified in $config_schema) */ function get_config() { @@ -1110,7 +1110,7 @@ function get_config() /** * Transfers the relevant configuration information from the source forum -* The mapping of fields is specified in $config_schema, see convert_phpbb20.php for more details +* The mapping of fields is specified in $config_schema */ function restore_config($schema) {