diff options
Diffstat (limited to 'phpBB/install/convertors/functions_phpbb20.php')
-rw-r--r-- | phpBB/install/convertors/functions_phpbb20.php | 120 |
1 files changed, 60 insertions, 60 deletions
diff --git a/phpBB/install/convertors/functions_phpbb20.php b/phpBB/install/convertors/functions_phpbb20.php index 29e5f7ab09..e8de7ef3e1 100644 --- a/phpBB/install/convertors/functions_phpbb20.php +++ b/phpBB/install/convertors/functions_phpbb20.php @@ -1,9 +1,13 @@ <?php /** * -* @package install -* @copyright (c) 2006 phpBB Group -* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. * */ @@ -50,7 +54,7 @@ function phpbb_forum_flags() */ function phpbb_insert_forums() { - global $db, $src_db, $same_db, $convert, $user, $config; + global $db, $src_db, $same_db, $convert, $user; $db->sql_query($convert->truncate_statement . FORUMS_TABLE); @@ -71,7 +75,6 @@ function phpbb_insert_forums() $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 @@ -89,7 +92,7 @@ function phpbb_insert_forums() $src_db->sql_query("SET NAMES 'utf8'"); } - switch ($db->sql_layer) + switch ($db->get_sql_layer()) { case 'mssql': case 'mssql_odbc': @@ -176,7 +179,6 @@ function phpbb_insert_forums() $db->sql_query($sql); $cats_added[$unknown_cat_id] = $max_forum_id; - $max_forum_id++; } // Now insert the forums @@ -220,7 +222,7 @@ function phpbb_insert_forums() '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, + '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, @@ -286,7 +288,7 @@ function phpbb_insert_forums() } $src_db->sql_freeresult($result); - switch ($db->sql_layer) + 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 . '));'); @@ -419,8 +421,6 @@ function phpbb_set_encoding($text, $grab_user_lang = true) } } - $encoding = $lang_enc_array[$get_lang]; - return utf8_recode($text, $lang_enc_array[$get_lang]); } @@ -511,12 +511,12 @@ function phpbb_user_id($user_id) // If there is a user id 1, we need to increment user ids. :/ if ($id === 1) { - set_config('increment_user_id', ($max_id + 1), true); + $config->set('increment_user_id', ($max_id + 1), false); $config['increment_user_id'] = $max_id + 1; } else { - set_config('increment_user_id', 0, true); + $config->set('increment_user_id', 0, false); $config['increment_user_id'] = 0; } } @@ -561,7 +561,7 @@ function phpbb_copy_table_fields() */ function phpbb_convert_authentication($mode) { - global $db, $src_db, $same_db, $convert, $user, $config, $cache; + global $db, $src_db, $same_db, $convert, $config; if ($mode == 'start') { @@ -571,7 +571,6 @@ function phpbb_convert_authentication($mode) // 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 @@ -659,7 +658,7 @@ function phpbb_convert_authentication($mode) 'auth_delete' => 'f_delete', 'auth_pollcreate' => 'f_poll', 'auth_vote' => 'f_vote', - 'auth_announce' => 'f_announce', + 'auth_announce' => array('f_announce', 'f_announce_global'), 'auth_sticky' => 'f_sticky', 'auth_attachments' => array('f_attach', 'f_download'), 'auth_download' => 'f_download', @@ -988,7 +987,7 @@ function phpbb_convert_authentication($mode) // 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' => 'f_announce', + 'auth_announce' => array('f_announce', 'f_announce_global'), 'auth_sticky' => 'f_sticky' ); @@ -1219,7 +1218,7 @@ function phpbb_replace_size($matches) */ function phpbb_prepare_message($message) { - global $phpbb_root_path, $phpEx, $db, $convert, $user, $config, $cache, $convert_row, $message_parser; + global $convert, $user, $convert_row, $message_parser; if (!$message) { @@ -1249,9 +1248,6 @@ function phpbb_prepare_message($message) $message = str_replace('\"', '"', $message); } - // Already the new user id ;) - $user_id = $convert->row['poster_id']; - $message = str_replace('<br />', "\n", $message); $message = str_replace('<', '<', $message); $message = str_replace('>', '>', $message); @@ -1303,7 +1299,7 @@ function get_bbcode_bitfield() */ function phpbb_post_edit_user() { - global $convert_row, $config; + global $convert_row; if (isset($convert_row['post_edit_count'])) { @@ -1324,7 +1320,7 @@ function phpbb_get_files_dir() return; } - global $src_db, $same_db, $convert, $user, $config, $cache; + global $src_db, $same_db, $convert, $user; if ($convert->mysql_convert && $same_db) { @@ -1363,7 +1359,7 @@ function phpbb_get_files_dir() */ function phpbb_copy_thumbnails() { - global $db, $convert, $user, $config, $cache, $phpbb_root_path; + global $convert, $config, $phpbb_root_path; $src_path = $convert->options['forum_path'] . '/' . phpbb_get_files_dir() . '/thumbs/'; @@ -1609,8 +1605,6 @@ function phpbb_get_avatar_width($user_avatar) */ function phpbb_privmsgs_to_userid($to_userid) { - global $config; - return 'u_' . phpbb_user_id($to_userid); } @@ -1657,7 +1651,7 @@ function phpbb_get_savebox_id($user_id) */ function phpbb_import_attach_config() { - global $db, $src_db, $same_db, $convert, $config; + global $src_db, $same_db, $convert, $config; if ($convert->mysql_convert && $same_db) { @@ -1680,29 +1674,29 @@ function phpbb_import_attach_config() } $src_db->sql_freeresult($result); - set_config('allow_attachments', 1); + $config->set('allow_attachments', 1); // old attachment mod? Must be very old if this entry do not exist... if (!empty($attach_config['display_order'])) { - set_config('display_order', $attach_config['display_order']); - } - set_config('max_filesize', $attach_config['max_filesize']); - set_config('max_filesize_pm', $attach_config['max_filesize_pm']); - set_config('attachment_quota', $attach_config['attachment_quota']); - set_config('max_attachments', $attach_config['max_attachments']); - set_config('max_attachments_pm', $attach_config['max_attachments_pm']); - set_config('allow_pm_attach', $attach_config['allow_pm_attach']); - - set_config('img_display_inlined', $attach_config['img_display_inlined']); - set_config('img_max_width', $attach_config['img_max_width']); - set_config('img_max_height', $attach_config['img_max_height']); - set_config('img_link_width', $attach_config['img_link_width']); - set_config('img_link_height', $attach_config['img_link_height']); - set_config('img_create_thumbnail', $attach_config['img_create_thumbnail']); - set_config('img_max_thumb_width', 400); - set_config('img_min_thumb_filesize', $attach_config['img_min_thumb_filesize']); - set_config('img_imagick', $attach_config['img_imagick']); + $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_link_width', $attach_config['img_link_width']); + $config->set('img_link_height', $attach_config['img_link_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']); + $config->set('img_imagick', $attach_config['img_imagick']); } /** @@ -1763,10 +1757,9 @@ function phpbb_disallowed_username($username) */ function phpbb_create_userconv_table() { - global $db, $src_db, $convert, $table_prefix, $user, $lang; + global $db; - $map_dbms = ''; - switch ($db->sql_layer) + switch ($db->get_sql_layer()) { case 'mysql': $map_dbms = 'mysql_40'; @@ -1794,7 +1787,7 @@ function phpbb_create_userconv_table() break; default: - $map_dbms = $db->sql_layer; + $map_dbms = $db->get_sql_layer(); break; } @@ -1802,13 +1795,6 @@ function phpbb_create_userconv_table() $drop_sql = 'DROP TABLE ' . USERCONV_TABLE; switch ($map_dbms) { - case 'firebird': - $create_sql = 'CREATE TABLE ' . USERCONV_TABLE . ' ( - user_id INTEGER NOT NULL, - username_clean VARCHAR(255) CHARACTER SET UTF8 DEFAULT \'\' NOT NULL COLLATE UNICODE - )'; - break; - case 'mssql': $create_sql = 'CREATE TABLE [' . USERCONV_TABLE . '] ( [user_id] [int] NOT NULL , @@ -1845,6 +1831,7 @@ function phpbb_create_userconv_table() break; case 'sqlite': + case 'sqlite3': $create_sql = 'CREATE TABLE ' . USERCONV_TABLE . ' ( user_id INTEGER NOT NULL DEFAULT \'0\', username_clean varchar(255) NOT NULL DEFAULT \'\' @@ -1860,7 +1847,7 @@ function phpbb_create_userconv_table() function phpbb_check_username_collisions() { - global $db, $src_db, $convert, $table_prefix, $user, $lang; + global $db, $src_db, $convert, $user, $lang; // now find the clean version of the usernames that collide $sql = 'SELECT username_clean @@ -1930,7 +1917,9 @@ function phpbb_check_username_collisions() function phpbb_convert_timezone($timezone) { global $config, $db, $phpbb_root_path, $phpEx, $table_prefix; - $timezone_migration = new \phpbb\db\migration\data\v310\timezone($config, $db, new \phpbb\db\tools($db), $phpbb_root_path, $phpEx, $table_prefix); + + $factory = new \phpbb\db\tools\factory(); + $timezone_migration = new \phpbb\db\migration\data\v310\timezone($config, $db, $factory->get($db), $phpbb_root_path, $phpEx, $table_prefix); return $timezone_migration->convert_phpbb30_timezone($timezone, 0); } @@ -1971,5 +1960,16 @@ function phpbb_add_notification_options($user_notify_pm) ); } - $sql = $db->sql_multi_insert(USER_NOTIFICATIONS_TABLE, $rows); + $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; } |