|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
*
|
|
|
4c79b5 |
* @package install
|
|
|
4c79b5 |
* @version $Id: functions_phpbb20.php 9113 2008-11-24 19:23:23Z naderman $
|
|
|
4c79b5 |
* @copyright (c) 2006 phpBB Group
|
|
|
4c79b5 |
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
|
|
4c79b5 |
*
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if (!defined('IN_PHPBB'))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
exit;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* Helper functions for phpBB 2.0.x to phpBB 3.0.x conversion
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* Set forum flags - only prune old polls by default
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
function phpbb_forum_flags()
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
// Set forum flags
|
|
|
4c79b5 |
$forum_flags = 0;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// FORUM_FLAG_LINK_TRACK
|
|
|
4c79b5 |
$forum_flags += 0;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// FORUM_FLAG_PRUNE_POLL
|
|
|
4c79b5 |
$forum_flags += FORUM_FLAG_PRUNE_POLL;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// FORUM_FLAG_PRUNE_ANNOUNCE
|
|
|
4c79b5 |
$forum_flags += 0;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// FORUM_FLAG_PRUNE_STICKY
|
|
|
4c79b5 |
$forum_flags += 0;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// FORUM_FLAG_ACTIVE_TOPICS
|
|
|
4c79b5 |
$forum_flags += 0;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// FORUM_FLAG_POST_REVIEW
|
|
|
4c79b5 |
$forum_flags += FORUM_FLAG_POST_REVIEW;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
return $forum_flags;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* Insert/Convert forums
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
function phpbb_insert_forums()
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
global $db, $src_db, $same_db, $convert, $user, $config;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$db->sql_query($convert->truncate_statement . FORUMS_TABLE);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Determine the highest id used within the old forums table (we add the categories after the forum ids)
|
|
|
4c79b5 |
$sql = 'SELECT MAX(forum_id) AS max_forum_id
|
|
|
4c79b5 |
FROM ' . $convert->src_table_prefix . 'forums';
|
|
|
4c79b5 |
$result = $src_db->sql_query($sql);
|
|
|
4c79b5 |
$max_forum_id = (int) $src_db->sql_fetchfield('max_forum_id');
|
|
|
4c79b5 |
$src_db->sql_freeresult($result);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$max_forum_id++;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// pruning disabled globally?
|
|
|
4c79b5 |
$sql = "SELECT config_value
|
|
|
4c79b5 |
FROM {$convert->src_table_prefix}config
|
|
|
4c79b5 |
WHERE config_name = 'prune_enable'";
|
|
|
4c79b5 |
$result = $src_db->sql_query($sql);
|
|
|
4c79b5 |
$prune_enabled = (int) $src_db->sql_fetchfield('config_value');
|
|
|
4c79b5 |
$src_db->sql_freeresult($result);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Insert categories
|
|
|
4c79b5 |
$sql = 'SELECT cat_id, cat_title
|
|
|
4c79b5 |
FROM ' . $convert->src_table_prefix . 'categories
|
|
|
4c79b5 |
ORDER BY cat_order';
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ($convert->mysql_convert && $same_db)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$src_db->sql_query("SET NAMES 'binary'");
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$result = $src_db->sql_query($sql);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ($convert->mysql_convert && $same_db)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$src_db->sql_query("SET NAMES 'utf8'");
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
switch ($db->sql_layer)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
case 'mssql':
|
|
|
4c79b5 |
case 'mssql_odbc':
|
|
|
4c79b5 |
$db->sql_query('SET IDENTITY_INSERT ' . FORUMS_TABLE . ' ON');
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$cats_added = array();
|
|
|
4c79b5 |
while ($row = $src_db->sql_fetchrow($result))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$sql_ary = array(
|
|
|
4c79b5 |
'forum_id' => (int) $max_forum_id,
|
|
|
4c79b5 |
'forum_name' => ($row['cat_title']) ? htmlspecialchars(phpbb_set_default_encoding($row['cat_title']), ENT_COMPAT, 'UTF-8') : $user->lang['CATEGORY'],
|
|
|
4c79b5 |
'parent_id' => 0,
|
|
|
4c79b5 |
'forum_parents' => '',
|
|
|
4c79b5 |
'forum_desc' => '',
|
|
|
4c79b5 |
'forum_type' => FORUM_CAT,
|
|
|
4c79b5 |
'forum_status' => ITEM_UNLOCKED,
|
|
|
4c79b5 |
'forum_rules' => '',
|
|
|
4c79b5 |
);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$sql = 'SELECT MAX(right_id) AS right_id
|
|
|
4c79b5 |
FROM ' . FORUMS_TABLE;
|
|
|
4c79b5 |
$_result = $db->sql_query($sql);
|
|
|
4c79b5 |
$cat_row = $db->sql_fetchrow($_result);
|
|
|
4c79b5 |
$db->sql_freeresult($_result);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$sql_ary['left_id'] = (int) ($cat_row['right_id'] + 1);
|
|
|
4c79b5 |
$sql_ary['right_id'] = (int) ($cat_row['right_id'] + 2);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$sql = 'INSERT INTO ' . FORUMS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
|
|
|
4c79b5 |
$db->sql_query($sql);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$cats_added[$row['cat_id']] = $max_forum_id;
|
|
|
4c79b5 |
$max_forum_id++;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
$src_db->sql_freeresult($result);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// There may be installations having forums with non-existant category ids.
|
|
|
4c79b5 |
// We try to catch them and add them to an "unknown" category instead of leaving them out.
|
|
|
4c79b5 |
$sql = 'SELECT cat_id
|
|
|
4c79b5 |
FROM ' . $convert->src_table_prefix . 'forums
|
|
|
4c79b5 |
GROUP BY cat_id';
|
|
|
4c79b5 |
$result = $src_db->sql_query($sql);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$unknown_cat_id = false;
|
|
|
4c79b5 |
while ($row = $src_db->sql_fetchrow($result))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
// Catch those categories not been added before
|
|
|
4c79b5 |
if (!isset($cats_added[$row['cat_id']]))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$unknown_cat_id = true;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
$src_db->sql_freeresult($result);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Is there at least one category not known?
|
|
|
4c79b5 |
if ($unknown_cat_id === true)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$unknown_cat_id = 'ghost';
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$sql_ary = array(
|
|
|
4c79b5 |
'forum_id' => (int) $max_forum_id,
|
|
|
4c79b5 |
'forum_name' => (string) $user->lang['CATEGORY'],
|
|
|
4c79b5 |
'parent_id' => 0,
|
|
|
4c79b5 |
'forum_parents' => '',
|
|
|
4c79b5 |
'forum_desc' => '',
|
|
|
4c79b5 |
'forum_type' => FORUM_CAT,
|
|
|
4c79b5 |
'forum_status' => ITEM_UNLOCKED,
|
|
|
4c79b5 |
'forum_rules' => '',
|
|
|
4c79b5 |
);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$sql = 'SELECT MAX(right_id) AS right_id
|
|
|
4c79b5 |
FROM ' . FORUMS_TABLE;
|
|
|
4c79b5 |
$_result = $db->sql_query($sql);
|
|
|
4c79b5 |
$cat_row = $db->sql_fetchrow($_result);
|
|
|
4c79b5 |
$db->sql_freeresult($_result);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$sql_ary['left_id'] = (int) ($cat_row['right_id'] + 1);
|
|
|
4c79b5 |
$sql_ary['right_id'] = (int) ($cat_row['right_id'] + 2);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$sql = 'INSERT INTO ' . FORUMS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
|
|
|
4c79b5 |
$db->sql_query($sql);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$cats_added[$unknown_cat_id] = $max_forum_id;
|
|
|
4c79b5 |
$max_forum_id++;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Now insert the forums
|
|
|
4c79b5 |
$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
|
|
|
4c79b5 |
LEFT JOIN ' . $convert->src_table_prefix . 'forum_prune fp ON f.forum_id = fp.forum_id
|
|
|
4c79b5 |
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
|
|
|
4c79b5 |
ORDER BY f.cat_id, f.forum_order';
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ($convert->mysql_convert && $same_db)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$src_db->sql_query("SET NAMES 'binary'");
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$result = $src_db->sql_query($sql);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ($convert->mysql_convert && $same_db)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$src_db->sql_query("SET NAMES 'utf8'");
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
while ($row = $src_db->sql_fetchrow($result))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
// Some might have forums here with an id not being "possible"...
|
|
|
4c79b5 |
// To be somewhat friendly we "change" the category id for those to a previously created ghost category
|
|
|
4c79b5 |
if (!isset($cats_added[$row['cat_id']]) && $unknown_cat_id !== false)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$row['cat_id'] = $unknown_cat_id;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if (!isset($cats_added[$row['cat_id']]))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
continue;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Define the new forums sql ary
|
|
|
4c79b5 |
$sql_ary = array(
|
|
|
4c79b5 |
'forum_id' => (int) $row['forum_id'],
|
|
|
4c79b5 |
'forum_name' => htmlspecialchars(phpbb_set_default_encoding($row['forum_name']), ENT_COMPAT, 'UTF-8'),
|
|
|
4c79b5 |
'parent_id' => (int) $cats_added[$row['cat_id']],
|
|
|
4c79b5 |
'forum_parents' => '',
|
|
|
4c79b5 |
'forum_desc' => htmlspecialchars(phpbb_set_default_encoding($row['forum_desc']), ENT_COMPAT, 'UTF-8'),
|
|
|
4c79b5 |
'forum_type' => FORUM_POST,
|
|
|
4c79b5 |
'forum_status' => is_item_locked($row['forum_status']),
|
|
|
4c79b5 |
'enable_prune' => ($prune_enabled) ? (int)$row['prune_enable'] : 0,
|
|
|
4c79b5 |
'prune_next' => (int) null_to_zero($row['prune_next']),
|
|
|
4c79b5 |
'prune_days' => (int) null_to_zero($row['prune_days']),
|
|
|
4c79b5 |
'prune_viewed' => 0,
|
|
|
4c79b5 |
'prune_freq' => (int) null_to_zero($row['prune_freq']),
|
|
|
4c79b5 |
|
|
|
4c79b5 |
'forum_flags' => phpbb_forum_flags(),
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Default values
|
|
|
4c79b5 |
'forum_desc_bitfield' => '',
|
|
|
4c79b5 |
'forum_desc_options' => 7,
|
|
|
4c79b5 |
'forum_desc_uid' => '',
|
|
|
4c79b5 |
'forum_link' => '',
|
|
|
4c79b5 |
'forum_password' => '',
|
|
|
4c79b5 |
'forum_style' => 0,
|
|
|
4c79b5 |
'forum_image' => '',
|
|
|
4c79b5 |
'forum_rules' => '',
|
|
|
4c79b5 |
'forum_rules_link' => '',
|
|
|
4c79b5 |
'forum_rules_bitfield' => '',
|
|
|
4c79b5 |
'forum_rules_options' => 7,
|
|
|
4c79b5 |
'forum_rules_uid' => '',
|
|
|
4c79b5 |
'forum_topics_per_page' => 0,
|
|
|
4c79b5 |
'forum_posts' => 0,
|
|
|
4c79b5 |
'forum_topics' => 0,
|
|
|
4c79b5 |
'forum_topics_real' => 0,
|
|
|
4c79b5 |
'forum_last_post_id' => 0,
|
|
|
4c79b5 |
'forum_last_poster_id' => 0,
|
|
|
4c79b5 |
'forum_last_post_subject' => '',
|
|
|
4c79b5 |
'forum_last_post_time' => 0,
|
|
|
4c79b5 |
'forum_last_poster_name' => '',
|
|
|
4c79b5 |
'forum_last_poster_colour' => '',
|
|
|
4c79b5 |
'display_on_index' => 1,
|
|
|
4c79b5 |
'enable_indexing' => 1,
|
|
|
4c79b5 |
'enable_icons' => 0,
|
|
|
4c79b5 |
);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Now add the forums with proper left/right ids
|
|
|
4c79b5 |
$sql = 'SELECT left_id, right_id
|
|
|
4c79b5 |
FROM ' . FORUMS_TABLE . '
|
|
|
4c79b5 |
WHERE forum_id = ' . $cats_added[$row['cat_id']];
|
|
|
4c79b5 |
$_result = $db->sql_query($sql);
|
|
|
4c79b5 |
$cat_row = $db->sql_fetchrow($_result);
|
|
|
4c79b5 |
$db->sql_freeresult($_result);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$sql = 'UPDATE ' . FORUMS_TABLE . '
|
|
|
4c79b5 |
SET left_id = left_id + 2, right_id = right_id + 2
|
|
|
4c79b5 |
WHERE left_id > ' . $cat_row['right_id'];
|
|
|
4c79b5 |
$db->sql_query($sql);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$sql = 'UPDATE ' . FORUMS_TABLE . '
|
|
|
4c79b5 |
SET right_id = right_id + 2
|
|
|
4c79b5 |
WHERE ' . $cat_row['left_id'] . ' BETWEEN left_id AND right_id';
|
|
|
4c79b5 |
$db->sql_query($sql);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$sql_ary['left_id'] = (int) $cat_row['right_id'];
|
|
|
4c79b5 |
$sql_ary['right_id'] = (int) ($cat_row['right_id'] + 1);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$sql = 'INSERT INTO ' . FORUMS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
|
|
|
4c79b5 |
$db->sql_query($sql);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
$src_db->sql_freeresult($result);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
switch ($db->sql_layer)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
case 'postgres':
|
|
|
4c79b5 |
$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 . '));');
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
case 'mssql':
|
|
|
4c79b5 |
case 'mssql_odbc':
|
|
|
4c79b5 |
$db->sql_query('SET IDENTITY_INSERT ' . FORUMS_TABLE . ' OFF');
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
case 'oracle':
|
|
|
4c79b5 |
$result = $db->sql_query('SELECT MAX(forum_id) as max_id FROM ' . FORUMS_TABLE);
|
|
|
4c79b5 |
$row = $db->sql_fetchrow($result);
|
|
|
4c79b5 |
$db->sql_freeresult($result);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$largest_id = (int) $row['max_id'];
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ($largest_id)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$db->sql_query('DROP SEQUENCE ' . FORUMS_TABLE . '_seq');
|
|
|
4c79b5 |
$db->sql_query('CREATE SEQUENCE ' . FORUMS_TABLE . '_seq START WITH ' . ($largest_id + 1));
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* Function for recoding text with the default language
|
|
|
4c79b5 |
*
|
|
|
4c79b5 |
* @param string $text text to recode to utf8
|
|
|
4c79b5 |
* @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
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
function phpbb_set_encoding($text, $grab_user_lang = true)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
global $lang_enc_array, $convert_row;
|
|
|
4c79b5 |
global $convert, $phpEx;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/*static $lang_enc_array = array(
|
|
|
4c79b5 |
'korean' => 'euc-kr',
|
|
|
4c79b5 |
'serbian' => 'windows-1250',
|
|
|
4c79b5 |
'polish' => 'iso-8859-2',
|
|
|
4c79b5 |
'kurdish' => 'windows-1254',
|
|
|
4c79b5 |
'slovak' => 'Windows-1250',
|
|
|
4c79b5 |
'russian' => 'windows-1251',
|
|
|
4c79b5 |
'estonian' => 'iso-8859-4',
|
|
|
4c79b5 |
'chinese_simplified' => 'gb2312',
|
|
|
4c79b5 |
'macedonian' => 'windows-1251',
|
|
|
4c79b5 |
'azerbaijani' => 'UTF-8',
|
|
|
4c79b5 |
'romanian' => 'iso-8859-2',
|
|
|
4c79b5 |
'romanian_diacritice' => 'iso-8859-2',
|
|
|
4c79b5 |
'lithuanian' => 'windows-1257',
|
|
|
4c79b5 |
'turkish' => 'iso-8859-9',
|
|
|
4c79b5 |
'ukrainian' => 'windows-1251',
|
|
|
4c79b5 |
'japanese' => 'shift_jis',
|
|
|
4c79b5 |
'hungarian' => 'ISO-8859-2',
|
|
|
4c79b5 |
'romanian_no_diacritics' => 'iso-8859-2',
|
|
|
4c79b5 |
'mongolian' => 'UTF-8',
|
|
|
4c79b5 |
'slovenian' => 'windows-1250',
|
|
|
4c79b5 |
'bosnian' => 'windows-1250',
|
|
|
4c79b5 |
'czech' => 'Windows-1250',
|
|
|
4c79b5 |
'farsi' => 'Windows-1256',
|
|
|
4c79b5 |
'croatian' => 'windows-1250',
|
|
|
4c79b5 |
'greek' => 'iso-8859-7',
|
|
|
4c79b5 |
'russian_tu' => 'windows-1251',
|
|
|
4c79b5 |
'sakha' => 'UTF-8',
|
|
|
4c79b5 |
'serbian_cyrillic' => 'windows-1251',
|
|
|
4c79b5 |
'bulgarian' => 'windows-1251',
|
|
|
4c79b5 |
'chinese_traditional_taiwan' => 'big5',
|
|
|
4c79b5 |
'chinese_traditional' => 'big5',
|
|
|
4c79b5 |
'arabic' => 'windows-1256',
|
|
|
4c79b5 |
'hebrew' => 'WINDOWS-1255',
|
|
|
4c79b5 |
'thai' => 'windows-874',
|
|
|
4c79b5 |
//'chinese_traditional_taiwan' => 'utf-8' // custom modified, we may have to do an include :-(
|
|
|
4c79b5 |
);*/
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if (empty($lang_enc_array))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$lang_enc_array = array();
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$get_lang = trim(get_config_value('default_lang'));
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Do we need the users language encoding?
|
|
|
4c79b5 |
if ($grab_user_lang && !empty($convert_row))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
if (!empty($convert_row['user_lang']))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$get_lang = trim($convert_row['user_lang']);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
else if (!empty($convert_row['poster_id']))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
global $src_db, $same_db;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ($convert->mysql_convert && $same_db)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$src_db->sql_query("SET NAMES 'binary'");
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$sql = 'SELECT user_lang
|
|
|
4c79b5 |
FROM ' . $convert->src_table_prefix . 'users
|
|
|
4c79b5 |
WHERE user_id = ' . (int) $convert_row['poster_id'];
|
|
|
4c79b5 |
$result = $src_db->sql_query($sql);
|
|
|
4c79b5 |
$get_lang = (string) $src_db->sql_fetchfield('user_lang');
|
|
|
4c79b5 |
$src_db->sql_freeresult($result);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ($convert->mysql_convert && $same_db)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$src_db->sql_query("SET NAMES 'utf8'");
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$get_lang = (!trim($get_lang)) ? trim(get_config_value('default_lang')) : trim($get_lang);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if (!isset($lang_enc_array[$get_lang]))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$filename = $convert->options['forum_path'] . '/language/lang_' . $get_lang . '/lang_main.' . $phpEx;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if (!file_exists($filename))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$get_lang = trim(get_config_value('default_lang'));
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if (!isset($lang_enc_array[$get_lang]))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
include($convert->options['forum_path'] . '/language/lang_' . $get_lang . '/lang_main.' . $phpEx);
|
|
|
4c79b5 |
$lang_enc_array[$get_lang] = $lang['ENCODING'];
|
|
|
4c79b5 |
unset($lang);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$encoding = $lang_enc_array[$get_lang];
|
|
|
4c79b5 |
|
|
|
4c79b5 |
return utf8_recode($text, $lang_enc_array[$get_lang]);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* Same as phpbb_set_encoding, but forcing boards default language
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
function phpbb_set_default_encoding($text)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
return phpbb_set_encoding($text, false);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* Convert Birthday from Birthday MOD to phpBB Format
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
function phpbb_get_birthday($birthday = '')
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
if (defined('MOD_BIRTHDAY_TERRA'))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$birthday = (string) $birthday;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// stored as month, day, year
|
|
|
4c79b5 |
if (!$birthday)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
return ' 0- 0- 0';
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// We use the original mod code to retrieve the birthday (not ideal)
|
|
|
4c79b5 |
preg_match('/(..)(..)(....)/', sprintf('%08d', $birthday), $birthday_parts);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$month = $birthday_parts[1];
|
|
|
4c79b5 |
$day = $birthday_parts[2];
|
|
|
4c79b5 |
$year = $birthday_parts[3];
|
|
|
4c79b5 |
|
|
|
4c79b5 |
return sprintf('%2d-%2d-%4d', $day, $month, $year);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
else
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$birthday = (int) $birthday;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if (!$birthday || $birthday == 999999 || ((version_compare(PHP_VERSION, '5.1.0') < 0) && $birthday < 0))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
return ' 0- 0- 0';
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// The birthday mod from niels is using this code to transform to day/month/year
|
|
|
4c79b5 |
return sprintf('%2d-%2d-%4d', gmdate('n', $birthday * 86400 + 1), gmdate('j', $birthday * 86400 + 1), gmdate('Y', $birthday * 86400 + 1));
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* Return correct user id value
|
|
|
4c79b5 |
* Everyone's id will be one higher to allow the guest/anonymous user to have a positive id as well
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
function phpbb_user_id($user_id)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
global $config;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Increment user id if the old forum is having a user with the id 1
|
|
|
4c79b5 |
if (!isset($config['increment_user_id']))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
global $src_db, $same_db, $convert;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ($convert->mysql_convert && $same_db)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$src_db->sql_query("SET NAMES 'binary'");
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Now let us set a temporary config variable for user id incrementing
|
|
|
4c79b5 |
$sql = "SELECT user_id
|
|
|
4c79b5 |
FROM {$convert->src_table_prefix}users
|
|
|
4c79b5 |
WHERE user_id = 1";
|
|
|
4c79b5 |
$result = $src_db->sql_query($sql);
|
|
|
4c79b5 |
$id = (int) $src_db->sql_fetchfield('user_id');
|
|
|
4c79b5 |
$src_db->sql_freeresult($result);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Try to get the maximum user id possible...
|
|
|
4c79b5 |
$sql = "SELECT MAX(user_id) AS max_user_id
|
|
|
4c79b5 |
FROM {$convert->src_table_prefix}users";
|
|
|
4c79b5 |
$result = $src_db->sql_query($sql);
|
|
|
4c79b5 |
$max_id = (int) $src_db->sql_fetchfield('max_user_id');
|
|
|
4c79b5 |
$src_db->sql_freeresult($result);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ($convert->mysql_convert && $same_db)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$src_db->sql_query("SET NAMES 'utf8'");
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// If there is a user id 1, we need to increment user ids. :/
|
|
|
4c79b5 |
if ($id === 1)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
set_config('increment_user_id', ($max_id + 1), true);
|
|
|
4c79b5 |
$config['increment_user_id'] = $max_id + 1;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
else
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
set_config('increment_user_id', 0, true);
|
|
|
4c79b5 |
$config['increment_user_id'] = 0;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// If the old user id is -1 in 2.0.x it is the anonymous user...
|
|
|
4c79b5 |
if ($user_id == -1)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
return ANONYMOUS;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if (!empty($config['increment_user_id']) && $user_id == 1)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
return $config['increment_user_id'];
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// A user id of 0 can happen, for example within the ban table if no user is banned...
|
|
|
4c79b5 |
// Within the posts and topics table this can be "dangerous" but is the fault of the user
|
|
|
4c79b5 |
// having mods installed (a poster id of 0 is not possible in 2.0.x).
|
|
|
4c79b5 |
// Therefore, we return the user id "as is".
|
|
|
4c79b5 |
|
|
|
4c79b5 |
return (int) $user_id;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/* Copy additional table fields from old forum to new forum if user wants this (for Mod compatibility for example)
|
|
|
4c79b5 |
function phpbb_copy_table_fields()
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* Convert authentication
|
|
|
4c79b5 |
* user, group and forum table has to be filled in order to work
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
function phpbb_convert_authentication($mode)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
global $db, $src_db, $same_db, $convert, $user, $config, $cache;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ($mode == 'start')
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$db->sql_query($convert->truncate_statement . ACL_USERS_TABLE);
|
|
|
4c79b5 |
$db->sql_query($convert->truncate_statement . ACL_GROUPS_TABLE);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// What we will do is handling all 2.0.x admins as founder to replicate what is common in 2.0.x.
|
|
|
4c79b5 |
// After conversion the main admin need to make sure he is removing permissions and the founder status if wanted.
|
|
|
4c79b5 |
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Grab user ids of users with user_level of ADMIN
|
|
|
4c79b5 |
$sql = "SELECT user_id
|
|
|
4c79b5 |
FROM {$convert->src_table_prefix}users
|
|
|
4c79b5 |
WHERE user_level = 1
|
|
|
4c79b5 |
ORDER BY user_regdate ASC";
|
|
|
4c79b5 |
$result = $src_db->sql_query($sql);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
while ($row = $src_db->sql_fetchrow($result))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$user_id = (int) phpbb_user_id($row['user_id']);
|
|
|
4c79b5 |
// Set founder admin...
|
|
|
4c79b5 |
$sql = 'UPDATE ' . USERS_TABLE . '
|
|
|
4c79b5 |
SET user_type = ' . USER_FOUNDER . "
|
|
|
4c79b5 |
WHERE user_id = $user_id";
|
|
|
4c79b5 |
$db->sql_query($sql);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
$src_db->sql_freeresult($result);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$sql = 'SELECT group_id
|
|
|
4c79b5 |
FROM ' . GROUPS_TABLE . "
|
|
|
4c79b5 |
WHERE group_name = '" . $db->sql_escape('BOTS') . "'";
|
|
|
4c79b5 |
$result = $db->sql_query($sql);
|
|
|
4c79b5 |
$bot_group_id = (int) $db->sql_fetchfield('group_id');
|
|
|
4c79b5 |
$db->sql_freeresult($result);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Grab forum auth information
|
|
|
4c79b5 |
$sql = "SELECT *
|
|
|
4c79b5 |
FROM {$convert->src_table_prefix}forums";
|
|
|
4c79b5 |
$result = $src_db->sql_query($sql);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$forum_access = array();
|
|
|
4c79b5 |
while ($row = $src_db->sql_fetchrow($result))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$forum_access[$row['forum_id']] = $row;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
$src_db->sql_freeresult($result);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ($convert->mysql_convert && $same_db)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$src_db->sql_query("SET NAMES 'binary'");
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
// Grab user auth information from 2.0.x board
|
|
|
4c79b5 |
$sql = "SELECT ug.user_id, aa.*
|
|
|
4c79b5 |
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
|
|
|
4c79b5 |
WHERE g.group_id = aa.group_id
|
|
|
4c79b5 |
AND g.group_single_user = 1
|
|
|
4c79b5 |
AND ug.group_id = g.group_id
|
|
|
4c79b5 |
AND f.forum_id = aa.forum_id";
|
|
|
4c79b5 |
$result = $src_db->sql_query($sql);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$user_access = array();
|
|
|
4c79b5 |
while ($row = $src_db->sql_fetchrow($result))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$user_access[$row['forum_id']][] = $row;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
$src_db->sql_freeresult($result);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Grab group auth information
|
|
|
4c79b5 |
$sql = "SELECT g.group_id, aa.*
|
|
|
4c79b5 |
FROM {$convert->src_table_prefix}auth_access aa, {$convert->src_table_prefix}groups g
|
|
|
4c79b5 |
WHERE g.group_id = aa.group_id
|
|
|
4c79b5 |
AND g.group_single_user <> 1";
|
|
|
4c79b5 |
$result = $src_db->sql_query($sql);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$group_access = array();
|
|
|
4c79b5 |
while ($row = $src_db->sql_fetchrow($result))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$group_access[$row['forum_id']][] = $row;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
$src_db->sql_freeresult($result);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ($convert->mysql_convert && $same_db)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$src_db->sql_query("SET NAMES 'utf8'");
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Add Forum Access List
|
|
|
4c79b5 |
$auth_map = array(
|
|
|
4c79b5 |
'auth_view' => array('f_', 'f_list'),
|
|
|
4c79b5 |
'auth_read' => array('f_read', 'f_search'),
|
|
|
4c79b5 |
'auth_post' => array('f_post', 'f_bbcode', 'f_smilies', 'f_img', 'f_sigs', 'f_postcount', 'f_report', 'f_subscribe', 'f_print', 'f_email'),
|
|
|
4c79b5 |
'auth_reply' => 'f_reply',
|
|
|
4c79b5 |
'auth_edit' => 'f_edit',
|
|
|
4c79b5 |
'auth_delete' => 'f_delete',
|
|
|
4c79b5 |
'auth_pollcreate' => 'f_poll',
|
|
|
4c79b5 |
'auth_vote' => 'f_vote',
|
|
|
4c79b5 |
'auth_announce' => 'f_announce',
|
|
|
4c79b5 |
'auth_sticky' => 'f_sticky',
|
|
|
4c79b5 |
'auth_attachments' => array('f_attach', 'f_download'),
|
|
|
4c79b5 |
'auth_download' => 'f_download',
|
|
|
4c79b5 |
);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Define the ACL constants used in 2.0 to make the code slightly more readable
|
|
|
4c79b5 |
define('AUTH_ALL', 0);
|
|
|
4c79b5 |
define('AUTH_REG', 1);
|
|
|
4c79b5 |
define('AUTH_ACL', 2);
|
|
|
4c79b5 |
define('AUTH_MOD', 3);
|
|
|
4c79b5 |
define('AUTH_ADMIN', 5);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// A mapping of the simple permissions used by 2.0
|
|
|
4c79b5 |
$simple_auth_ary = array(
|
|
|
4c79b5 |
'public' => array(
|
|
|
4c79b5 |
'auth_view' => AUTH_ALL,
|
|
|
4c79b5 |
'auth_read' => AUTH_ALL,
|
|
|
4c79b5 |
'auth_post' => AUTH_ALL,
|
|
|
4c79b5 |
'auth_reply' => AUTH_ALL,
|
|
|
4c79b5 |
'auth_edit' => AUTH_REG,
|
|
|
4c79b5 |
'auth_delete' => AUTH_REG,
|
|
|
4c79b5 |
'auth_sticky' => AUTH_MOD,
|
|
|
4c79b5 |
'auth_announce' => AUTH_MOD,
|
|
|
4c79b5 |
'auth_vote' => AUTH_REG,
|
|
|
4c79b5 |
'auth_pollcreate' => AUTH_REG,
|
|
|
4c79b5 |
),
|
|
|
4c79b5 |
'registered' => array(
|
|
|
4c79b5 |
'auth_view' => AUTH_ALL,
|
|
|
4c79b5 |
'auth_read' => AUTH_ALL,
|
|
|
4c79b5 |
'auth_post' => AUTH_REG,
|
|
|
4c79b5 |
'auth_reply' => AUTH_REG,
|
|
|
4c79b5 |
'auth_edit' => AUTH_REG,
|
|
|
4c79b5 |
'auth_delete' => AUTH_REG,
|
|
|
4c79b5 |
'auth_sticky' => AUTH_MOD,
|
|
|
4c79b5 |
'auth_announce' => AUTH_MOD,
|
|
|
4c79b5 |
'auth_vote' => AUTH_REG,
|
|
|
4c79b5 |
'auth_pollcreate' => AUTH_REG,
|
|
|
4c79b5 |
),
|
|
|
4c79b5 |
'registered_hidden' => array(
|
|
|
4c79b5 |
'auth_view' => AUTH_REG,
|
|
|
4c79b5 |
'auth_read' => AUTH_REG,
|
|
|
4c79b5 |
'auth_post' => AUTH_REG,
|
|
|
4c79b5 |
'auth_reply' => AUTH_REG,
|
|
|
4c79b5 |
'auth_edit' => AUTH_REG,
|
|
|
4c79b5 |
'auth_delete' => AUTH_REG,
|
|
|
4c79b5 |
'auth_sticky' => AUTH_MOD,
|
|
|
4c79b5 |
'auth_announce' => AUTH_MOD,
|
|
|
4c79b5 |
'auth_vote' => AUTH_REG,
|
|
|
4c79b5 |
'auth_pollcreate' => AUTH_REG,
|
|
|
4c79b5 |
),
|
|
|
4c79b5 |
'private' => array(
|
|
|
4c79b5 |
'auth_view' => AUTH_ALL,
|
|
|
4c79b5 |
'auth_read' => AUTH_ACL,
|
|
|
4c79b5 |
'auth_post' => AUTH_ACL,
|
|
|
4c79b5 |
'auth_reply' => AUTH_ACL,
|
|
|
4c79b5 |
'auth_edit' => AUTH_ACL,
|
|
|
4c79b5 |
'auth_delete' => AUTH_ACL,
|
|
|
4c79b5 |
'auth_sticky' => AUTH_ACL,
|
|
|
4c79b5 |
'auth_announce' => AUTH_MOD,
|
|
|
4c79b5 |
'auth_vote' => AUTH_ACL,
|
|
|
4c79b5 |
'auth_pollcreate' => AUTH_ACL,
|
|
|
4c79b5 |
),
|
|
|
4c79b5 |
'private_hidden' => array(
|
|
|
4c79b5 |
'auth_view' => AUTH_ACL,
|
|
|
4c79b5 |
'auth_read' => AUTH_ACL,
|
|
|
4c79b5 |
'auth_post' => AUTH_ACL,
|
|
|
4c79b5 |
'auth_reply' => AUTH_ACL,
|
|
|
4c79b5 |
'auth_edit' => AUTH_ACL,
|
|
|
4c79b5 |
'auth_delete' => AUTH_ACL,
|
|
|
4c79b5 |
'auth_sticky' => AUTH_ACL,
|
|
|
4c79b5 |
'auth_announce' => AUTH_MOD,
|
|
|
4c79b5 |
'auth_vote' => AUTH_ACL,
|
|
|
4c79b5 |
'auth_pollcreate' => AUTH_ACL,
|
|
|
4c79b5 |
),
|
|
|
4c79b5 |
'moderator' => array(
|
|
|
4c79b5 |
'auth_view' => AUTH_ALL,
|
|
|
4c79b5 |
'auth_read' => AUTH_MOD,
|
|
|
4c79b5 |
'auth_post' => AUTH_MOD,
|
|
|
4c79b5 |
'auth_reply' => AUTH_MOD,
|
|
|
4c79b5 |
'auth_edit' => AUTH_MOD,
|
|
|
4c79b5 |
'auth_delete' => AUTH_MOD,
|
|
|
4c79b5 |
'auth_sticky' => AUTH_MOD,
|
|
|
4c79b5 |
'auth_announce' => AUTH_MOD,
|
|
|
4c79b5 |
'auth_vote' => AUTH_MOD,
|
|
|
4c79b5 |
'auth_pollcreate' => AUTH_MOD,
|
|
|
4c79b5 |
),
|
|
|
4c79b5 |
'moderator_hidden' => array(
|
|
|
4c79b5 |
'auth_view' => AUTH_MOD,
|
|
|
4c79b5 |
'auth_read' => AUTH_MOD,
|
|
|
4c79b5 |
'auth_post' => AUTH_MOD,
|
|
|
4c79b5 |
'auth_reply' => AUTH_MOD,
|
|
|
4c79b5 |
'auth_edit' => AUTH_MOD,
|
|
|
4c79b5 |
'auth_delete' => AUTH_MOD,
|
|
|
4c79b5 |
'auth_sticky' => AUTH_MOD,
|
|
|
4c79b5 |
'auth_announce' => AUTH_MOD,
|
|
|
4c79b5 |
'auth_vote' => AUTH_MOD,
|
|
|
4c79b5 |
'auth_pollcreate' => AUTH_MOD,
|
|
|
4c79b5 |
),
|
|
|
4c79b5 |
);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ($mode == 'start')
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
user_group_auth('guests', 'SELECT user_id, {GUESTS} FROM ' . USERS_TABLE . ' WHERE user_id = ' . ANONYMOUS, false);
|
|
|
4c79b5 |
user_group_auth('registered', 'SELECT user_id, {REGISTERED} FROM ' . USERS_TABLE . ' WHERE user_id <> ' . ANONYMOUS . " AND group_id <> $bot_group_id", false);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Selecting from old table
|
|
|
4c79b5 |
if (!empty($config['increment_user_id']))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$auth_sql = 'SELECT user_id, {ADMINISTRATORS} FROM ' . $convert->src_table_prefix . 'users WHERE user_level = 1 AND user_id <> 1';
|
|
|
4c79b5 |
user_group_auth('administrators', $auth_sql, true);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$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';
|
|
|
4c79b5 |
user_group_auth('administrators', $auth_sql, true);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
else
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$auth_sql = 'SELECT user_id, {ADMINISTRATORS} FROM ' . $convert->src_table_prefix . 'users WHERE user_level = 1';
|
|
|
4c79b5 |
user_group_auth('administrators', $auth_sql, true);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if (!empty($config['increment_user_id']))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$auth_sql = 'SELECT user_id, {GLOBAL_MODERATORS} FROM ' . $convert->src_table_prefix . 'users WHERE user_level = 1 AND user_id <> 1';
|
|
|
4c79b5 |
user_group_auth('global_moderators', $auth_sql, true);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$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';
|
|
|
4c79b5 |
user_group_auth('global_moderators', $auth_sql, true);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
else
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$auth_sql = 'SELECT user_id, {GLOBAL_MODERATORS} FROM ' . $convert->src_table_prefix . 'users WHERE user_level = 1';
|
|
|
4c79b5 |
user_group_auth('global_moderators', $auth_sql, true);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
else if ($mode == 'first')
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
// Go through all 2.0.x forums
|
|
|
4c79b5 |
foreach ($forum_access as $forum)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$new_forum_id = (int) $forum['forum_id'];
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Administrators have full access to all forums whatever happens
|
|
|
4c79b5 |
mass_auth('group_role', $new_forum_id, 'administrators', 'FORUM_FULL');
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$matched_type = '';
|
|
|
4c79b5 |
foreach ($simple_auth_ary as $key => $auth_levels)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$matched = 1;
|
|
|
4c79b5 |
foreach ($auth_levels as $k => $level)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
if ($forum[$k] != $auth_levels[$k])
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$matched = 0;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ($matched)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$matched_type = $key;
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
switch ($matched_type)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
case 'public':
|
|
|
4c79b5 |
mass_auth('group_role', $new_forum_id, 'guests', 'FORUM_LIMITED');
|
|
|
4c79b5 |
mass_auth('group_role', $new_forum_id, 'registered', 'FORUM_LIMITED_POLLS');
|
|
|
4c79b5 |
mass_auth('group_role', $new_forum_id, 'bots', 'FORUM_BOT');
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
case 'registered':
|
|
|
4c79b5 |
mass_auth('group_role', $new_forum_id, 'guests', 'FORUM_READONLY');
|
|
|
4c79b5 |
mass_auth('group_role', $new_forum_id, 'bots', 'FORUM_BOT');
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// no break;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
case 'registered_hidden':
|
|
|
4c79b5 |
mass_auth('group_role', $new_forum_id, 'registered', 'FORUM_POLLS');
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
case 'private':
|
|
|
4c79b5 |
case 'private_hidden':
|
|
|
4c79b5 |
case 'moderator':
|
|
|
4c79b5 |
case 'moderator_hidden':
|
|
|
4c79b5 |
default:
|
|
|
4c79b5 |
// The permissions don't match a simple set, so we're going to have to map them directly
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// No post approval for all, in 2.0.x this feature does not exist
|
|
|
4c79b5 |
mass_auth('group', $new_forum_id, 'guests', 'f_noapprove', ACL_YES);
|
|
|
4c79b5 |
mass_auth('group', $new_forum_id, 'registered', 'f_noapprove', ACL_YES);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Go through authentication map
|
|
|
4c79b5 |
foreach ($auth_map as $old_auth_key => $new_acl)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
// If old authentication key does not exist we continue
|
|
|
4c79b5 |
// This is helpful for mods adding additional authentication fields, we need to add them to the auth_map array
|
|
|
4c79b5 |
if (!isset($forum[$old_auth_key]))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
continue;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Now set the new ACL correctly
|
|
|
4c79b5 |
switch ($forum[$old_auth_key])
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
// AUTH_ALL
|
|
|
4c79b5 |
case AUTH_ALL:
|
|
|
4c79b5 |
mass_auth('group', $new_forum_id, 'guests', $new_acl, ACL_YES);
|
|
|
4c79b5 |
mass_auth('group', $new_forum_id, 'bots', $new_acl, ACL_YES);
|
|
|
4c79b5 |
mass_auth('group', $new_forum_id, 'registered', $new_acl, ACL_YES);
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// AUTH_REG
|
|
|
4c79b5 |
case AUTH_REG:
|
|
|
4c79b5 |
mass_auth('group', $new_forum_id, 'registered', $new_acl, ACL_YES);
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// AUTH_ACL
|
|
|
4c79b5 |
case AUTH_ACL:
|
|
|
4c79b5 |
// Go through the old group access list for this forum
|
|
|
4c79b5 |
if (isset($group_access[$forum['forum_id']]))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
foreach ($group_access[$forum['forum_id']] as $index => $access)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
// We only check for ACL_YES equivalence entry
|
|
|
4c79b5 |
if (isset($access[$old_auth_key]) && $access[$old_auth_key] == 1)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
mass_auth('group', $new_forum_id, (int) $access['group_id'], $new_acl, ACL_YES);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if (isset($user_access[$forum['forum_id']]))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
foreach ($user_access[$forum['forum_id']] as $index => $access)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
// We only check for ACL_YES equivalence entry
|
|
|
4c79b5 |
if (isset($access[$old_auth_key]) && $access[$old_auth_key] == 1)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
mass_auth('user', $new_forum_id, (int) phpbb_user_id($access['user_id']), $new_acl, ACL_YES);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// AUTH_MOD
|
|
|
4c79b5 |
case AUTH_MOD:
|
|
|
4c79b5 |
if (isset($group_access[$forum['forum_id']]))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
foreach ($group_access[$forum['forum_id']] as $index => $access)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
// We only check for ACL_YES equivalence entry
|
|
|
4c79b5 |
if (isset($access[$old_auth_key]) && $access[$old_auth_key] == 1)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
mass_auth('group', $new_forum_id, (int) $access['group_id'], $new_acl, ACL_YES);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if (isset($user_access[$forum['forum_id']]))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
foreach ($user_access[$forum['forum_id']] as $index => $access)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
// We only check for ACL_YES equivalence entry
|
|
|
4c79b5 |
if (isset($access[$old_auth_key]) && $access[$old_auth_key] == 1)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
mass_auth('user', $new_forum_id, (int) phpbb_user_id($access['user_id']), $new_acl, ACL_YES);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
else if ($mode == 'second')
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
// Assign permission roles and other default permissions
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// guests having u_download and u_search ability
|
|
|
4c79b5 |
$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')");
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// administrators/global mods having full user features
|
|
|
4c79b5 |
mass_auth('group_role', 0, 'administrators', 'USER_FULL');
|
|
|
4c79b5 |
mass_auth('group_role', 0, 'global_moderators', 'USER_FULL');
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// By default all converted administrators are given full access
|
|
|
4c79b5 |
mass_auth('group_role', 0, 'administrators', 'ADMIN_FULL');
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// All registered users are assigned the standard user role
|
|
|
4c79b5 |
mass_auth('group_role', 0, 'registered', 'USER_STANDARD');
|
|
|
4c79b5 |
mass_auth('group_role', 0, 'registered_coppa', 'USER_STANDARD');
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Instead of administrators being global moderators we give the MOD_FULL role to global mods (admins already assigned to this group)
|
|
|
4c79b5 |
mass_auth('group_role', 0, 'global_moderators', 'MOD_FULL');
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// And now those who have had their avatar rights removed get assigned a more restrictive role
|
|
|
4c79b5 |
$sql = 'SELECT user_id FROM ' . $convert->src_table_prefix . 'users
|
|
|
4c79b5 |
WHERE user_allowavatar = 0
|
|
|
4c79b5 |
AND user_id > 0';
|
|
|
4c79b5 |
$result = $src_db->sql_query($sql);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
while ($row = $src_db->sql_fetchrow($result))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
mass_auth('user_role', 0, (int) phpbb_user_id($row['user_id']), 'USER_NOAVATAR');
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
$src_db->sql_freeresult($result);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// And the same for those who have had their PM rights removed
|
|
|
4c79b5 |
$sql = 'SELECT user_id FROM ' . $convert->src_table_prefix . 'users
|
|
|
4c79b5 |
WHERE user_allow_pm = 0
|
|
|
4c79b5 |
AND user_id > 0';
|
|
|
4c79b5 |
$result = $src_db->sql_query($sql);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
while ($row = $src_db->sql_fetchrow($result))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
mass_auth('user_role', 0, (int) phpbb_user_id($row['user_id']), 'USER_NOPM');
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
$src_db->sql_freeresult($result);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
else if ($mode == 'third')
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
// And now the moderators
|
|
|
4c79b5 |
// We make sure that they have at least standard access to the forums they moderate in addition to the moderating permissions
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$mod_post_map = array(
|
|
|
4c79b5 |
'auth_announce' => 'f_announce',
|
|
|
4c79b5 |
'auth_sticky' => 'f_sticky'
|
|
|
4c79b5 |
);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
foreach ($user_access as $forum_id => $access_map)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$forum_id = (int) $forum_id;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
foreach ($access_map as $access)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
if (isset($access['auth_mod']) && $access['auth_mod'] == 1)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
mass_auth('user_role', $forum_id, (int) phpbb_user_id($access['user_id']), 'MOD_STANDARD');
|
|
|
4c79b5 |
mass_auth('user_role', $forum_id, (int) phpbb_user_id($access['user_id']), 'FORUM_STANDARD');
|
|
|
4c79b5 |
foreach ($mod_post_map as $old => $new)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
if (isset($forum_access[$forum_id]) && isset($forum_access[$forum_id][$old]) && $forum_access[$forum_id][$old] == AUTH_MOD)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
mass_auth('user', $forum_id, (int) phpbb_user_id($access['user_id']), $new, ACL_YES);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
foreach ($group_access as $forum_id => $access_map)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$forum_id = (int) $forum_id;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
foreach ($access_map as $access)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
if (isset($access['auth_mod']) && $access['auth_mod'] == 1)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
mass_auth('group_role', $forum_id, (int) $access['group_id'], 'MOD_STANDARD');
|
|
|
4c79b5 |
mass_auth('group_role', $forum_id, (int) $access['group_id'], 'FORUM_STANDARD');
|
|
|
4c79b5 |
foreach ($mod_post_map as $old => $new)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
if (isset($forum_access[$forum_id]) && isset($forum_access[$forum_id][$old]) && $forum_access[$forum_id][$old] == AUTH_MOD)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
mass_auth('group', $forum_id, (int) $access['group_id'], $new, ACL_YES);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// We grant everyone readonly access to the categories to ensure that the forums are visible
|
|
|
4c79b5 |
$sql = 'SELECT forum_id, forum_name, parent_id, left_id, right_id
|
|
|
4c79b5 |
FROM ' . FORUMS_TABLE . '
|
|
|
4c79b5 |
ORDER BY left_id ASC';
|
|
|
4c79b5 |
$result = $db->sql_query($sql);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$parent_forums = $forums = array();
|
|
|
4c79b5 |
while ($row = $db->sql_fetchrow($result))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
if ($row['parent_id'] == 0)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
mass_auth('group_role', $row['forum_id'], 'administrators', 'FORUM_FULL');
|
|
|
4c79b5 |
mass_auth('group_role', $row['forum_id'], 'global_moderators', 'FORUM_FULL');
|
|
|
4c79b5 |
$parent_forums[] = $row;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
else
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$forums[] = $row;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
$db->sql_freeresult($result);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
global $auth;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Let us see which groups have access to these forums...
|
|
|
4c79b5 |
foreach ($parent_forums as $row)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
// Get the children
|
|
|
4c79b5 |
$branch = $forum_ids = array();
|
|
|
4c79b5 |
|
|
|
4c79b5 |
foreach ($forums as $key => $_row)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
if ($_row['left_id'] > $row['left_id'] && $_row['left_id'] < $row['right_id'])
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$branch[] = $_row;
|
|
|
4c79b5 |
$forum_ids[] = $_row['forum_id'];
|
|
|
4c79b5 |
continue;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if (sizeof($forum_ids))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
// Now make sure the user is able to read these forums
|
|
|
4c79b5 |
$hold_ary = $auth->acl_group_raw_data(false, 'f_list', $forum_ids);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if (empty($hold_ary))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
continue;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
foreach ($hold_ary as $g_id => $f_id_ary)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$set_group = false;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
foreach ($f_id_ary as $f_id => $auth_ary)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
foreach ($auth_ary as $auth_option => $setting)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
if ($setting == ACL_YES)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$set_group = true;
|
|
|
4c79b5 |
break 2;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ($set_group)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
mass_auth('group', $row['forum_id'], $g_id, 'f_list', ACL_YES);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* Set primary group.
|
|
|
4c79b5 |
* Really simple and only based on user_level (remaining groups will be assigned later)
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
function phpbb_set_primary_group($user_level)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
global $convert_row;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ($user_level == 1)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
return get_group_id('administrators');
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
/* else if ($user_level == 2)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
return get_group_id('global_moderators');
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
else if ($user_level == 0 && $convert_row['user_active'])*/
|
|
|
4c79b5 |
else if ($convert_row['user_active'])
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
return get_group_id('registered');
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
return 0;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* Convert the group name, making sure to avoid conflicts with 3.0 special groups
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
function phpbb_convert_group_name($group_name)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$default_groups = array(
|
|
|
4c79b5 |
'GUESTS',
|
|
|
4c79b5 |
'REGISTERED',
|
|
|
4c79b5 |
'REGISTERED_COPPA',
|
|
|
4c79b5 |
'GLOBAL_MODERATORS',
|
|
|
4c79b5 |
'ADMINISTRATORS',
|
|
|
4c79b5 |
'BOTS',
|
|
|
4c79b5 |
);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if (in_array(strtoupper($group_name), $default_groups))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
return 'phpBB2 - ' . $group_name;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
return phpbb_set_default_encoding($group_name);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* Convert the group type constants
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
function phpbb_convert_group_type($group_type)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
switch ($group_type)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
case 0:
|
|
|
4c79b5 |
return GROUP_OPEN;
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
case 1:
|
|
|
4c79b5 |
return GROUP_CLOSED;
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
case 2:
|
|
|
4c79b5 |
return GROUP_HIDDEN;
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Never return GROUP_SPECIAL here, because only phpBB3's default groups are allowed to have this type set.
|
|
|
4c79b5 |
return GROUP_HIDDEN;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* Convert the topic type constants
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
function phpbb_convert_topic_type($topic_type)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
switch ($topic_type)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
case 0:
|
|
|
4c79b5 |
return POST_NORMAL;
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
case 1:
|
|
|
4c79b5 |
return POST_STICKY;
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
case 2:
|
|
|
4c79b5 |
return POST_ANNOUNCE;
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
case 3:
|
|
|
4c79b5 |
return POST_GLOBAL;
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
return POST_NORMAL;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
function phpbb_replace_size($matches)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
return '[size=' . min(200, ceil(100.0 * (((double) $matches[1])/12.0))) . ':' . $matches[2] . ']';
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* Reparse the message stripping out the bbcode_uid values and adding new ones and setting the bitfield
|
|
|
4c79b5 |
* @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
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
function phpbb_prepare_message($message)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
global $phpbb_root_path, $phpEx, $db, $convert, $user, $config, $cache, $convert_row, $message_parser;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if (!$message)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$convert->row['mp_bbcode_bitfield'] = $convert_row['mp_bbcode_bitfield'] = 0;
|
|
|
4c79b5 |
return '';
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Decode phpBB 2.0.x Message
|
|
|
4c79b5 |
if (isset($convert->row['old_bbcode_uid']) && $convert->row['old_bbcode_uid'] != '')
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
// Adjust size...
|
|
|
4c79b5 |
if (strpos($message, '[size=') !== false)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$message = preg_replace_callback('/\[size=(\d*):(' . $convert->row['old_bbcode_uid'] . ')\]/', 'phpbb_replace_size', $message);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$message = preg_replace('/\:(([a-z0-9]:)?)' . $convert->row['old_bbcode_uid'] . '/s', '', $message);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if (strpos($message, '[quote=') !== false)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$message = preg_replace('/\[quote="(.*?)"\]/s', '[quote="\1"]', $message);
|
|
|
4c79b5 |
$message = preg_replace('/\[quote=\\\"(.*?)\\\"\]/s', '[quote="\1"]', $message);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// let's hope that this solves more problems than it causes. Deal with escaped quotes.
|
|
|
4c79b5 |
$message = str_replace('\"', '"', $message);
|
|
|
4c79b5 |
$message = str_replace('\"', '"', $message);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Already the new user id ;)
|
|
|
4c79b5 |
$user_id = $convert->row['poster_id'];
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$message = str_replace('<', '<', $message);
|
|
|
4c79b5 |
$message = str_replace('>', '>', $message);
|
|
|
4c79b5 |
$message = str_replace(' ', "\n", $message);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// make the post UTF-8
|
|
|
4c79b5 |
$message = phpbb_set_encoding($message);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$message_parser->warn_msg = array(); // Reset the errors from the previous message
|
|
|
4c79b5 |
$message_parser->bbcode_uid = make_uid($convert->row['post_time']);
|
|
|
4c79b5 |
$message_parser->message = $message;
|
|
|
4c79b5 |
unset($message);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Make sure options are set.
|
|
|
4c79b5 |
// $enable_html = (!isset($row['enable_html'])) ? false : $row['enable_html'];
|
|
|
4c79b5 |
$enable_bbcode = (!isset($convert->row['enable_bbcode'])) ? true : $convert->row['enable_bbcode'];
|
|
|
4c79b5 |
$enable_smilies = (!isset($convert->row['enable_smilies'])) ? true : $convert->row['enable_smilies'];
|
|
|
4c79b5 |
$enable_magic_url = (!isset($convert->row['enable_magic_url'])) ? true : $convert->row['enable_magic_url'];
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// parse($allow_bbcode, $allow_magic_url, $allow_smilies, $allow_img_bbcode = true, $allow_flash_bbcode = true, $allow_quote_bbcode = true, $allow_url_bbcode = true, $update_this_message = true, $mode = 'post')
|
|
|
4c79b5 |
$message_parser->parse($enable_bbcode, $enable_magic_url, $enable_smilies);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if (sizeof($message_parser->warn_msg))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$msg_id = isset($convert->row['post_id']) ? $convert->row['post_id'] : $convert->row['privmsgs_id'];
|
|
|
4c79b5 |
$convert->p_master->error('' . $user->lang['POST_ID'] . ': ' . $msg_id . ' ' . $user->lang['CONV_ERROR_MESSAGE_PARSER'] . ':
' . implode(' ', $message_parser->warn_msg), __LINE__, __FILE__, true);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$convert->row['mp_bbcode_bitfield'] = $convert_row['mp_bbcode_bitfield'] = $message_parser->bbcode_bitfield;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$message = $message_parser->message;
|
|
|
4c79b5 |
unset($message_parser->message);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
return $message;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* Return the bitfield calculated by the previous function
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
function get_bbcode_bitfield()
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
global $convert_row;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
return $convert_row['mp_bbcode_bitfield'];
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* Determine the last user to edit a post
|
|
|
4c79b5 |
* 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
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
function phpbb_post_edit_user()
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
global $convert_row, $config;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if (isset($convert_row['post_edit_count']))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
return phpbb_user_id($convert_row['poster_id']);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
return 0;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* Obtain the path to uploaded files on the 2.0.x forum
|
|
|
4c79b5 |
* This is only used if the Attachment MOD was installed
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
function phpbb_get_files_dir()
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
if (!defined('MOD_ATTACHMENT'))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
return;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
global $src_db, $same_db, $convert, $user, $config, $cache;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ($convert->mysql_convert && $same_db)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$src_db->sql_query("SET NAMES 'binary'");
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
$sql = 'SELECT config_value AS upload_dir
|
|
|
4c79b5 |
FROM ' . $convert->src_table_prefix . "attachments_config
|
|
|
4c79b5 |
WHERE config_name = 'upload_dir'";
|
|
|
4c79b5 |
$result = $src_db->sql_query($sql);
|
|
|
4c79b5 |
$upload_path = $src_db->sql_fetchfield('upload_dir');
|
|
|
4c79b5 |
$src_db->sql_freeresult($result);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$sql = 'SELECT config_value AS ftp_upload
|
|
|
4c79b5 |
FROM ' . $convert->src_table_prefix . "attachments_config
|
|
|
4c79b5 |
WHERE config_name = 'allow_ftp_upload'";
|
|
|
4c79b5 |
$result = $src_db->sql_query($sql);
|
|
|
4c79b5 |
$ftp_upload = (int) $src_db->sql_fetchfield('ftp_upload');
|
|
|
4c79b5 |
$src_db->sql_freeresult($result);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ($convert->mysql_convert && $same_db)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$src_db->sql_query("SET NAMES 'utf8'");
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ($ftp_upload)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$convert->p_master->error($user->lang['CONV_ERROR_ATTACH_FTP_DIR'], __LINE__, __FILE__);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
return $upload_path;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* Copy thumbnails of uploaded images from the 2.0.x forum
|
|
|
4c79b5 |
* This is only used if the Attachment MOD was installed
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
function phpbb_copy_thumbnails()
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
global $db, $convert, $user, $config, $cache, $phpbb_root_path;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$src_path = $convert->options['forum_path'] . '/' . phpbb_get_files_dir() . '/thumbs/';
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ($handle = @opendir($src_path))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
while ($entry = readdir($handle))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
if ($entry[0] == '.')
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
continue;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if (is_dir($src_path . $entry))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
continue;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
else
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
copy_file($src_path . $entry, $config['upload_path'] . '/' . preg_replace('/^t_/', 'thumb_', $entry));
|
|
|
4c79b5 |
@unlink($phpbb_root_path . $config['upload_path'] . '/thumbs/' . $entry);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
closedir($handle);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* Convert the attachment category constants
|
|
|
4c79b5 |
* This is only used if the Attachment MOD was installed
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
function phpbb_attachment_category($cat_id)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
switch ($cat_id)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
case 1:
|
|
|
4c79b5 |
return ATTACHMENT_CATEGORY_IMAGE;
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
case 2:
|
|
|
4c79b5 |
return ATTACHMENT_CATEGORY_WM;
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
case 3:
|
|
|
4c79b5 |
return ATTACHMENT_CATEGORY_FLASH;
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
return ATTACHMENT_CATEGORY_NONE;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* Obtain list of forums in which different attachment categories can be used
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
function phpbb_attachment_forum_perms($forum_permissions)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
if (empty($forum_permissions))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
return '';
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Decode forum permissions
|
|
|
4c79b5 |
$forum_ids = array();
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$one_char_encoding = '#';
|
|
|
4c79b5 |
$two_char_encoding = '.';
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$auth_len = 1;
|
|
|
4c79b5 |
for ($pos = 0; $pos < strlen($forum_permissions); $pos += $auth_len)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$forum_auth = substr($forum_permissions, $pos, 1);
|
|
|
4c79b5 |
if ($forum_auth == $one_char_encoding)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$auth_len = 1;
|
|
|
4c79b5 |
continue;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
else if ($forum_auth == $two_char_encoding)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$auth_len = 2;
|
|
|
4c79b5 |
$pos--;
|
|
|
4c79b5 |
continue;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$forum_auth = substr($forum_permissions, $pos, $auth_len);
|
|
|
4c79b5 |
$forum_id = base64_unpack($forum_auth);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$forum_ids[] = (int) $forum_id;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if (sizeof($forum_ids))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
return attachment_forum_perms($forum_ids);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
return '';
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* Convert the avatar type constants
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
function phpbb_avatar_type($type)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
switch ($type)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
case 1:
|
|
|
4c79b5 |
return AVATAR_UPLOAD;
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
case 2:
|
|
|
4c79b5 |
return AVATAR_REMOTE;
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
case 3:
|
|
|
4c79b5 |
return AVATAR_GALLERY;
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
return 0;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* Just undos the replacing of '<' and '>'
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
function phpbb_smilie_html_decode($code)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$code = str_replace('<', '<', $code);
|
|
|
4c79b5 |
return str_replace('>', '>', $code);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* Transfer avatars, copying the image if it was uploaded
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
function phpbb_import_avatar($user_avatar)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
global $convert_row;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if (!$convert_row['user_avatar_type'])
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
return '';
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
else if ($convert_row['user_avatar_type'] == 1)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
// Uploaded avatar
|
|
|
4c79b5 |
return import_avatar($user_avatar, false, $convert_row['user_id']);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
else if ($convert_row['user_avatar_type'] == 2)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
// Remote avatar
|
|
|
4c79b5 |
return $user_avatar;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
else if ($convert_row['user_avatar_type'] == 3)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
// Gallery avatar
|
|
|
4c79b5 |
return $user_avatar;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
return '';
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* Find out about the avatar's dimensions
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
function phpbb_get_avatar_height($user_avatar)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
global $convert_row;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if (empty($convert_row['user_avatar_type']))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
return 0;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
return get_avatar_height($user_avatar, 'phpbb_avatar_type', $convert_row['user_avatar_type']);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* Find out about the avatar's dimensions
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
function phpbb_get_avatar_width($user_avatar)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
global $convert_row;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if (empty($convert_row['user_avatar_type']))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
return 0;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
return get_avatar_width($user_avatar, 'phpbb_avatar_type', $convert_row['user_avatar_type']);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* Calculate the correct to_address field for private messages
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
function phpbb_privmsgs_to_userid($to_userid)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
global $config;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
return 'u_' . phpbb_user_id($to_userid);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* Calculate whether a private message was unread using the bitfield
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
function phpbb_unread_pm($pm_type)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
return ($pm_type == 5) ? 1 : 0;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* Calculate whether a private message was new using the bitfield
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
function phpbb_new_pm($pm_type)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
return ($pm_type == 1) ? 1 : 0;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* Obtain the folder_id for the custom folder created to replace the savebox from 2.0.x (used to store saved private messages)
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
function phpbb_get_savebox_id($user_id)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
global $db;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$user_id = phpbb_user_id($user_id);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Only one custom folder, check only one
|
|
|
4c79b5 |
$sql = 'SELECT folder_id
|
|
|
4c79b5 |
FROM ' . PRIVMSGS_FOLDER_TABLE . '
|
|
|
4c79b5 |
WHERE user_id = ' . $user_id;
|
|
|
4c79b5 |
$result = $db->sql_query_limit($sql, 1);
|
|
|
4c79b5 |
$folder_id = (int) $db->sql_fetchfield('folder_id');
|
|
|
4c79b5 |
$db->sql_freeresult($result);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
return $folder_id;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* Transfer attachment specific configuration options
|
|
|
4c79b5 |
* These were not stored in the main config table on 2.0.x
|
|
|
4c79b5 |
* This is only used if the Attachment MOD was installed
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
function phpbb_import_attach_config()
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
global $db, $src_db, $same_db, $convert, $config;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ($convert->mysql_convert && $same_db)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$src_db->sql_query("SET NAMES 'binary'");
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$sql = 'SELECT *
|
|
|
4c79b5 |
FROM ' . $convert->src_table_prefix . 'attachments_config';
|
|
|
4c79b5 |
$result = $src_db->sql_query($sql);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ($convert->mysql_convert && $same_db)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$src_db->sql_query("SET NAMES 'utf8'");
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$attach_config = array();
|
|
|
4c79b5 |
while ($row = $src_db->sql_fetchrow($result))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$attach_config[$row['config_name']] = $row['config_value'];
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
$src_db->sql_freeresult($result);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
set_config('allow_attachments', 1);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// old attachment mod? Must be very old if this entry do not exist...
|
|
|
4c79b5 |
if (!empty($attach_config['display_order']))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
set_config('display_order', $attach_config['display_order']);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
set_config('max_filesize', $attach_config['max_filesize']);
|
|
|
4c79b5 |
set_config('max_filesize_pm', $attach_config['max_filesize_pm']);
|
|
|
4c79b5 |
set_config('attachment_quota', $attach_config['attachment_quota']);
|
|
|
4c79b5 |
set_config('max_attachments', $attach_config['max_attachments']);
|
|
|
4c79b5 |
set_config('max_attachments_pm', $attach_config['max_attachments_pm']);
|
|
|
4c79b5 |
set_config('allow_pm_attach', $attach_config['allow_pm_attach']);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
set_config('img_display_inlined', $attach_config['img_display_inlined']);
|
|
|
4c79b5 |
set_config('img_max_width', $attach_config['img_max_width']);
|
|
|
4c79b5 |
set_config('img_max_height', $attach_config['img_max_height']);
|
|
|
4c79b5 |
set_config('img_link_width', $attach_config['img_link_width']);
|
|
|
4c79b5 |
set_config('img_link_height', $attach_config['img_link_height']);
|
|
|
4c79b5 |
set_config('img_create_thumbnail', $attach_config['img_create_thumbnail']);
|
|
|
4c79b5 |
set_config('img_max_thumb_width', 400);
|
|
|
4c79b5 |
set_config('img_min_thumb_filesize', $attach_config['img_min_thumb_filesize']);
|
|
|
4c79b5 |
set_config('img_imagick', $attach_config['img_imagick']);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* Calculate the date a user became inactive
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
function phpbb_inactive_time()
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
global $convert_row;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ($convert_row['user_active'])
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
return 0;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ($convert_row['user_lastvisit'])
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
return $convert_row['user_lastvisit'];
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
return $convert_row['user_regdate'];
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* Calculate the reason a user became inactive
|
|
|
4c79b5 |
* We can't actually tell the difference between a manual deactivation and one for profile changes
|
|
|
4c79b5 |
* from the data available to assume the latter
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
function phpbb_inactive_reason()
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
global $convert_row;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ($convert_row['user_active'])
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
return 0;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ($convert_row['user_lastvisit'])
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
return INACTIVE_PROFILE;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
return INACTIVE_REGISTER;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* Adjust 2.0.x disallowed names to 3.0.x format
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
function phpbb_disallowed_username($username)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
// Replace * with %
|
|
|
4c79b5 |
$username = phpbb_set_default_encoding(str_replace('*', '%', $username));
|
|
|
4c79b5 |
return utf8_htmlspecialchars($username);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* Checks whether there are any usernames on the old board that would map to the same
|
|
|
4c79b5 |
* username_clean on phpBB3. Prints out a list if any exist and exits.
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
function phpbb_create_userconv_table()
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
global $db, $src_db, $convert, $table_prefix, $user, $lang;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$map_dbms = '';
|
|
|
4c79b5 |
switch ($db->sql_layer)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
case 'mysql':
|
|
|
4c79b5 |
$map_dbms = 'mysql_40';
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
case 'mysql4':
|
|
|
4c79b5 |
if (version_compare($db->sql_server_info(true), '4.1.3', '>='))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$map_dbms = 'mysql_41';
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
else
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$map_dbms = 'mysql_40';
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
case 'mysqli':
|
|
|
4c79b5 |
$map_dbms = 'mysql_41';
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
case 'mssql':
|
|
|
4c79b5 |
case 'mssql_odbc':
|
|
|
4c79b5 |
$map_dbms = 'mssql';
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
default:
|
|
|
4c79b5 |
$map_dbms = $db->sql_layer;
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// create a temporary table in which we store the clean usernames
|
|
|
4c79b5 |
$drop_sql = 'DROP TABLE ' . USERCONV_TABLE;
|
|
|
4c79b5 |
switch ($map_dbms)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
case 'firebird':
|
|
|
4c79b5 |
$create_sql = 'CREATE TABLE ' . USERCONV_TABLE . ' (
|
|
|
4c79b5 |
user_id INTEGER NOT NULL,
|
|
|
4c79b5 |
username_clean VARCHAR(255) CHARACTER SET UTF8 DEFAULT \'\' NOT NULL COLLATE UNICODE
|
|
|
4c79b5 |
)';
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
case 'mssql':
|
|
|
4c79b5 |
$create_sql = 'CREATE TABLE [' . USERCONV_TABLE . '] (
|
|
|
4c79b5 |
[user_id] [int] NOT NULL ,
|
|
|
4c79b5 |
[username_clean] [varchar] (255) DEFAULT (\'\') NOT NULL
|
|
|
4c79b5 |
)';
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
case 'mysql_40':
|
|
|
4c79b5 |
$create_sql = 'CREATE TABLE ' . USERCONV_TABLE . ' (
|
|
|
4c79b5 |
user_id mediumint(8) NOT NULL,
|
|
|
4c79b5 |
username_clean blob NOT NULL
|
|
|
4c79b5 |
)';
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
case 'mysql_41':
|
|
|
4c79b5 |
$create_sql = 'CREATE TABLE ' . USERCONV_TABLE . ' (
|
|
|
4c79b5 |
user_id mediumint(8) NOT NULL,
|
|
|
4c79b5 |
username_clean varchar(255) DEFAULT \'\' NOT NULL
|
|
|
4c79b5 |
) CHARACTER SET `utf8` COLLATE `utf8_bin`';
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
case 'oracle':
|
|
|
4c79b5 |
$create_sql = 'CREATE TABLE ' . USERCONV_TABLE . ' (
|
|
|
4c79b5 |
user_id number(8) NOT NULL,
|
|
|
4c79b5 |
username_clean varchar2(255) DEFAULT \'\'
|
|
|
4c79b5 |
)';
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
case 'postgres':
|
|
|
4c79b5 |
$create_sql = 'CREATE TABLE ' . USERCONV_TABLE . ' (
|
|
|
4c79b5 |
user_id INT4 DEFAULT \'0\',
|
|
|
4c79b5 |
username_clean varchar_ci DEFAULT \'\' NOT NULL
|
|
|
4c79b5 |
)';
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
case 'sqlite':
|
|
|
4c79b5 |
$create_sql = 'CREATE TABLE ' . USERCONV_TABLE . ' (
|
|
|
4c79b5 |
user_id INTEGER NOT NULL DEFAULT \'0\',
|
|
|
4c79b5 |
username_clean varchar(255) NOT NULL DEFAULT \'\'
|
|
|
4c79b5 |
)';
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$db->sql_return_on_error(true);
|
|
|
4c79b5 |
$db->sql_query($drop_sql);
|
|
|
4c79b5 |
$db->sql_return_on_error(false);
|
|
|
4c79b5 |
$db->sql_query($create_sql);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
function phpbb_check_username_collisions()
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
global $db, $src_db, $convert, $table_prefix, $user, $lang;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// now find the clean version of the usernames that collide
|
|
|
4c79b5 |
$sql = 'SELECT username_clean
|
|
|
4c79b5 |
FROM ' . USERCONV_TABLE .'
|
|
|
4c79b5 |
GROUP BY username_clean
|
|
|
4c79b5 |
HAVING COUNT(user_id) > 1';
|
|
|
4c79b5 |
$result = $db->sql_query($sql);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$colliding_names = array();
|
|
|
4c79b5 |
while ($row = $db->sql_fetchrow($result))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$colliding_names[] = $row['username_clean'];
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
$db->sql_freeresult($result);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// there was at least one collision, the admin will have to solve it before conversion can continue
|
|
|
4c79b5 |
if (sizeof($colliding_names))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$sql = 'SELECT user_id, username_clean
|
|
|
4c79b5 |
FROM ' . USERCONV_TABLE . '
|
|
|
4c79b5 |
WHERE ' . $db->sql_in_set('username_clean', $colliding_names);
|
|
|
4c79b5 |
$result = $db->sql_query($sql);
|
|
|
4c79b5 |
unset($colliding_names);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$colliding_user_ids = array();
|
|
|
4c79b5 |
while ($row = $db->sql_fetchrow($result))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$colliding_user_ids[(int) $row['user_id']] = $row['username_clean'];
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
$db->sql_freeresult($result);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$sql = 'SELECT username, user_id, user_posts
|
|
|
4c79b5 |
FROM ' . $convert->src_table_prefix . 'users
|
|
|
4c79b5 |
WHERE ' . $src_db->sql_in_set('user_id', array_keys($colliding_user_ids));
|
|
|
4c79b5 |
$result = $src_db->sql_query($sql);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$colliding_users = array();
|
|
|
4c79b5 |
while ($row = $src_db->sql_fetchrow($result))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$row['user_id'] = (int) $row['user_id'];
|
|
|
4c79b5 |
if (isset($colliding_user_ids[$row['user_id']]))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$colliding_users[$colliding_user_ids[$row['user_id']]][] = $row;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
$src_db->sql_freeresult($result);
|
|
|
4c79b5 |
unset($colliding_user_ids);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$list = '';
|
|
|
4c79b5 |
foreach ($colliding_users as $username_clean => $users)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$list .= sprintf($user->lang['COLLIDING_CLEAN_USERNAME'], $username_clean) . " \n";
|
|
|
4c79b5 |
foreach ($users as $i => $row)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$list .= sprintf($user->lang['COLLIDING_USER'], $row['user_id'], phpbb_set_default_encoding($row['username']), $row['user_posts']) . " \n";
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$lang['INST_ERR_FATAL'] = $user->lang['CONV_ERR_FATAL'];
|
|
|
4c79b5 |
$convert->p_master->error('' . $user->lang['COLLIDING_USERNAMES_FOUND'] . '
' . $list . '', __LINE__, __FILE__);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$drop_sql = 'DROP TABLE ' . USERCONV_TABLE;
|
|
|
4c79b5 |
$db->sql_query($drop_sql);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
?>
|