6 * @copyright (c) 2006 phpBB Group
7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
12 * NOTE to potential convertor authors. Please use this file to get
13 * familiar with the structure since we added some bare explanations here.
15 * Since this file gets included more than once on one page you are not able to add functions to it.
16 * Instead use a functions_ file.
20 if (!defined('IN_PHPBB'))
25 include($phpbb_root_path . 'config.' . $phpEx);
29 * $convertor_data provides some basic information about this convertor which is
30 * used on the initial list of convertors and to populate the default settings
32 $convertor_data = array(
33 'forum_name' => 'phpBB 2.0.x',
35 'phpbb_version' => '3.0.10',
36 'author' => '<a href="http://www.phpbb.com/">phpBB Group</a>',
43 'table_prefix' => 'phpbb_',
44 'forum_path' => '../forums',
49 * $tables is a list of the tables (minus prefix) which we expect to find in the
50 * source forum. It is used to guess the prefix if the specified prefix is incorrect
77 * $config_schema details how the board configuration information is stored in the source forum.
79 * 'table_format' can take the value 'file' to indicate a config file. In this case array_name
80 * is set to indicate the name of the array the config values are stored in
81 * Example of using a file:
82 * $config_schema = array(
83 * 'table_format' => 'file',
84 * 'filename' => 'NAME OF FILE', // If the file is not in the root directory, the path needs to be added with no leading slash
85 * 'array_name' => 'NAME OF ARRAY', // Only used if the configuration file stores the setting in an array.
86 * 'settings' => array(
87 * 'board_email' => 'SUPPORT_EMAIL', // target config name => source target name
90 * 'table_format' can be an array if the values are stored in a table which is an assosciative array
91 * (as per phpBB 2.0.x)
92 * If left empty, values are assumed to be stored in a table where each config setting is
93 * a column (as per phpBB 1.x)
95 * In either of the latter cases 'table_name' indicates the name of the table in the database
97 * 'settings' is an array which maps the name of the config directive in the source forum
98 * to the config directive in phpBB3. It can either be a direct mapping or use a function.
99 * Please note that the contents of the old config value are passed to the function, therefore
100 * an in-built function requiring the variable passed by reference is not able to be used. Since
101 * empty() is such a function we created the function is_empty() to be used instead.
103 $config_schema = array(
104 'table_name' => 'config',
105 'table_format' => array('config_name' => 'config_value'),
107 'allow_bbcode' => 'allow_bbcode',
108 'allow_smilies' => 'allow_smilies',
109 'allow_sig' => 'allow_sig',
110 'allow_namechange' => 'allow_namechange',
111 'allow_avatar_local' => 'allow_avatar_local',
112 'allow_avatar_remote' => 'allow_avatar_remote',
113 'allow_avatar_upload' => 'allow_avatar_upload',
114 'board_disable' => 'board_disable',
115 'sitename' => 'phpbb_set_encoding(sitename)',
116 'site_desc' => 'phpbb_set_encoding(site_desc)',
117 'session_length' => 'session_length',
118 'board_email_sig' => 'phpbb_set_encoding(board_email_sig)',
119 'posts_per_page' => 'posts_per_page',
120 'topics_per_page' => 'topics_per_page',
121 'enable_confirm' => 'enable_confirm',
122 'board_email_form' => 'board_email_form',
123 'override_user_style' => 'override_user_style',
124 'hot_threshold' => 'hot_threshold',
125 'max_poll_options' => 'max_poll_options',
126 'max_sig_chars' => 'max_sig_chars',
127 'pm_max_msgs' => 'max_inbox_privmsgs',
128 'smtp_delivery' => 'smtp_delivery',
129 'smtp_host' => 'smtp_host',
130 'smtp_username' => 'smtp_username',
131 'smtp_password' => 'smtp_password',
132 'require_activation' => 'require_activation',
133 'flood_interval' => 'flood_interval',
134 'avatar_filesize' => 'avatar_filesize',
135 'avatar_max_width' => 'avatar_max_width',
136 'avatar_max_height' => 'avatar_max_height',
137 'default_dateformat' => 'phpbb_set_encoding(default_dateformat)',
138 'board_timezone' => 'board_timezone',
139 'allow_privmsg' => 'not(privmsg_disable)',
140 'gzip_compress' => 'gzip_compress',
141 'coppa_enable' => '!is_empty(coppa_mail)',
142 'coppa_fax' => 'coppa_fax',
143 'coppa_mail' => 'coppa_mail',
144 'record_online_users' => 'record_online_users',
145 'record_online_date' => 'record_online_date',
146 'board_startdate' => 'board_startdate',
151 * $test_file is the name of a file which is present on the source
152 * forum which can be used to check that the path specified by the
155 $test_file = 'modcp.php';
158 * If this is set then we are not generating the first page of information but getting the conversion information.
162 // Test to see if the birthday MOD is installed on the source forum
163 // Niels' birthday mod
164 if (get_config_value('birthday_required') !== false || get_config_value('bday_require') !== false)
166 define('MOD_BIRTHDAY', true);
169 // TerraFrost's validated birthday mod
170 if (get_config_value('bday_require') !== false)
172 define('MOD_BIRTHDAY_TERRA', true);
175 // Test to see if the attachment MOD is installed on the source forum
176 // If it is, we will convert this data as well
177 $src_db->sql_return_on_error(true);
179 $sql = "SELECT config_value
180 FROM {$convert->src_table_prefix}attachments_config
181 WHERE config_name = 'upload_dir'";
182 $result = $src_db->sql_query($sql);
184 if ($result && $row = $src_db->sql_fetchrow($result))
186 // Here the constant is defined
187 define('MOD_ATTACHMENT', true);
189 // Here i add more tables to be checked in the old forum
197 $src_db->sql_freeresult($result);
201 $src_db->sql_freeresult($result);
206 * Tests for further MODs can be included here.
207 * Please use constants for this, prefixing them with MOD_
210 $src_db->sql_return_on_error(false);
212 // Now let us set a temporary config variable for user id incrementing
213 $sql = "SELECT user_id
214 FROM {$convert->src_table_prefix}users
216 $result = $src_db->sql_query($sql);
217 $user_id = (int) $src_db->sql_fetchfield('user_id');
218 $src_db->sql_freeresult($result);
220 // If there is a user id 1, we need to increment user ids. :/
223 // Try to get the maximum user id possible...
224 $sql = "SELECT MAX(user_id) AS max_user_id
225 FROM {$convert->src_table_prefix}users";
226 $result = $src_db->sql_query($sql);
227 $user_id = (int) $src_db->sql_fetchfield('max_user_id');
228 $src_db->sql_freeresult($result);
230 set_config('increment_user_id', ($user_id + 1), true);
234 set_config('increment_user_id', 0, true);
237 // Overwrite maximum avatar width/height
238 @define('DEFAULT_AVATAR_X_CUSTOM', get_config_value('avatar_max_width'));
239 @define('DEFAULT_AVATAR_Y_CUSTOM', get_config_value('avatar_max_height'));
241 // additional table used only during conversion
242 @define('USERCONV_TABLE', $table_prefix . 'userconv');
245 * Description on how to use the convertor framework.
247 * 'schema' Syntax Description
248 * -> 'target' => Target Table. If not specified the next table will be handled
249 * -> 'primary' => Primary Key. If this is specified then this table is processed in batches
250 * -> 'query_first' => array('target' or 'src', Query to execute before beginning the process
251 * (if more than one then specified as array))
252 * -> 'function_first' => Function to execute before beginning the process (if more than one then specified as array)
253 * (This is mostly useful if variables need to be given to the converting process)
254 * -> 'test_file' => This is not used at the moment but should be filled with a file from the old installation
257 * 'distinct' => Add DISTINCT to the select query
258 * 'where' => Add WHERE to the select query
259 * 'group_by' => Add GROUP BY to the select query
260 * 'left_join' => Add LEFT JOIN to the select query (if more than one joins specified as array)
261 * 'having' => Add HAVING to the select query
264 * This one consist of three parameters
266 * The key need to be filled within the target table
267 * If this is empty, the target table gets not assigned the source value
269 * Source value. If the first parameter is specified, it will be assigned this value.
270 * If the first parameter is empty, this only gets added to the select query
272 * Custom Function. Function to execute while storing source value into target table.
273 * The functions return value get stored.
274 * The function parameter consist of the value of the second parameter.
277 * - empty string == execute nothing
278 * - string == function to execute
279 * - array == complex execution instructions
281 * Complex execution instructions:
282 * @todo test complex execution instructions - in theory they will work fine
284 * By defining an array as the third parameter you are able to define some statements to be executed. The key
285 * is defining what to execute, numbers can be appended...
287 * 'function' => execute function
288 * 'execute' => run code, whereby all occurrences of {VALUE} get replaced by the last returned value.
289 * The result *must* be assigned/stored to {RESULT}.
290 * 'typecast' => typecast value
292 * The returned variables will be made always available to the next function to continue to work with.
294 * example (variable inputted is an integer of 1):
297 * 'function1' => 'increment_by_one', // returned variable is 2
298 * 'typecast' => 'string', // typecast variable to be a string
299 * 'execute' => '{RESULT} = {VALUE} . ' is good';', // returned variable is '2 is good'
300 * 'function2' => 'replace_good_with_bad', // returned variable is '2 is bad'
306 'test_file' => 'viewtopic.php',
308 'avatar_path' => get_config_value('avatar_path') . '/',
309 'avatar_gallery_path' => get_config_value('avatar_gallery_path') . '/',
310 'smilies_path' => get_config_value('smilies_path') . '/',
311 'upload_path' => (defined('MOD_ATTACHMENT')) ? phpbb_get_files_dir() . '/' : '',
312 'thumbnails' => (defined('MOD_ATTACHMENT')) ? array('thumbs/', 't_') : '',
313 'ranks_path' => false, // phpBB 2.0.x had no config value for a ranks path
315 // We empty some tables to have clean data available
316 'query_first' => array(
317 array('target', $convert->truncate_statement . SEARCH_RESULTS_TABLE),
318 array('target', $convert->truncate_statement . SEARCH_WORDLIST_TABLE),
319 array('target', $convert->truncate_statement . SEARCH_WORDMATCH_TABLE),
320 array('target', $convert->truncate_statement . LOG_TABLE),
323 // 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.
324 // Instead every file gets copied while processing the corresponding attachment entry.
325 // if (defined("MOD_ATTACHMENT")) { import_attachment_files(); phpbb_copy_thumbnails(); }
327 // phpBB2 allowed some similar usernames to coexist which would have the same
328 // username_clean in phpBB3 which is not possible, so we'll give the admin a list
329 // of user ids and usernames and let him deicde what he wants to do with them
331 phpbb_create_userconv_table();
332 import_avatar_gallery();
333 if (defined("MOD_ATTACHMENT")) phpbb_import_attach_config();
334 phpbb_insert_forums();
337 'execute_last' => array('
340 update_folder_pm_count();
342 update_unread_count();
344 phpbb_convert_authentication(\'start\');
346 phpbb_convert_authentication(\'first\');
348 phpbb_convert_authentication(\'second\');
350 phpbb_convert_authentication(\'third\');
355 'target' => USERCONV_TABLE,
356 'query_first' => array('target', $convert->truncate_statement . USERCONV_TABLE),
359 array('user_id', 'users.user_id', ''),
360 array('username_clean', 'users.username', array('function1' => 'phpbb_set_encoding', 'function2' => 'utf8_clean_string')),
364 'target' => (defined('MOD_ATTACHMENT')) ? ATTACHMENTS_TABLE : '',
365 'primary' => 'attachments.attach_id',
366 'query_first' => (defined('MOD_ATTACHMENT')) ? array('target', $convert->truncate_statement . ATTACHMENTS_TABLE) : '',
367 'autoincrement' => 'attach_id',
369 array('attach_id', 'attachments.attach_id', ''),
370 array('post_msg_id', 'attachments.post_id', ''),
371 array('topic_id', 'posts.topic_id', ''),
372 array('in_message', 0, ''),
373 array('is_orphan', 0, ''),
374 array('poster_id', 'attachments.user_id_1 AS poster_id', 'phpbb_user_id'),
375 array('physical_filename', 'attachments_desc.physical_filename', 'import_attachment'),
376 array('real_filename', 'attachments_desc.real_filename', 'phpbb_set_encoding'),
377 array('download_count', 'attachments_desc.download_count', ''),
378 array('attach_comment', 'attachments_desc.comment', array('function1' => 'phpbb_set_encoding', 'function2' => 'utf8_htmlspecialchars')),
379 array('extension', 'attachments_desc.extension', ''),
380 array('mimetype', 'attachments_desc.mimetype', ''),
381 array('filesize', 'attachments_desc.filesize', ''),
382 array('filetime', 'attachments_desc.filetime', ''),
383 array('thumbnail', 'attachments_desc.thumbnail', ''),
385 'where' => 'attachments_desc.attach_id = attachments.attach_id AND attachments.privmsgs_id = 0 AND posts.post_id = attachments.post_id',
386 'group_by' => 'attachments.attach_id'
390 'target' => (defined('MOD_ATTACHMENT')) ? ATTACHMENTS_TABLE : '',
391 'primary' => 'attachments.attach_id',
392 'autoincrement' => 'attach_id',
394 array('attach_id', 'attachments.attach_id', ''),
395 array('post_msg_id', 'attachments.privmsgs_id', ''),
396 array('topic_id', 0, ''),
397 array('in_message', 1, ''),
398 array('is_orphan', 0, ''),
399 array('poster_id', 'attachments.user_id_1 AS poster_id', 'phpbb_user_id'),
400 array('physical_filename', 'attachments_desc.physical_filename', 'import_attachment'),
401 array('real_filename', 'attachments_desc.real_filename', ''),
402 array('download_count', 'attachments_desc.download_count', ''),
403 array('attach_comment', 'attachments_desc.comment', array('function1' => 'phpbb_set_encoding', 'function2' => 'utf8_htmlspecialchars')),
404 array('extension', 'attachments_desc.extension', ''),
405 array('mimetype', 'attachments_desc.mimetype', ''),
406 array('filesize', 'attachments_desc.filesize', ''),
407 array('filetime', 'attachments_desc.filetime', ''),
408 array('thumbnail', 'attachments_desc.thumbnail', ''),
410 'where' => 'attachments_desc.attach_id = attachments.attach_id AND attachments.post_id = 0',
411 'group_by' => 'attachments.attach_id'
415 'target' => (defined('MOD_ATTACHMENT')) ? EXTENSIONS_TABLE : '',
416 'query_first' => (defined('MOD_ATTACHMENT')) ? array('target', $convert->truncate_statement . EXTENSIONS_TABLE) : '',
417 'autoincrement' => 'extension_id',
419 array('extension_id', 'extensions.ext_id', ''),
420 array('group_id', 'extensions.group_id', ''),
421 array('extension', 'extensions.extension', ''),
425 'target' => (defined('MOD_ATTACHMENT')) ? EXTENSION_GROUPS_TABLE : '',
426 'query_first' => (defined('MOD_ATTACHMENT')) ? array('target', $convert->truncate_statement . EXTENSION_GROUPS_TABLE) : '',
427 'autoincrement' => 'group_id',
429 array('group_id', 'extension_groups.group_id', ''),
430 array('group_name', 'extension_groups.group_name', array('function1' => 'phpbb_set_encoding', 'function2' => 'utf8_htmlspecialchars')),
431 array('cat_id', 'extension_groups.cat_id', 'phpbb_attachment_category'),
432 array('allow_group', 'extension_groups.allow_group', ''),
433 array('download_mode', 1, ''),
434 array('upload_icon', '', ''),
435 array('max_filesize', 'extension_groups.max_filesize', ''),
436 array('allowed_forums', 'extension_groups.forum_permissions', 'phpbb_attachment_forum_perms'),
437 array('allow_in_pm', 1, ''),
441 'target' => BANLIST_TABLE,
442 'execute_first' => 'phpbb_check_username_collisions();',
443 'query_first' => array('target', $convert->truncate_statement . BANLIST_TABLE),
445 array('ban_ip', 'banlist.ban_ip', 'decode_ban_ip'),
446 array('ban_userid', 'banlist.ban_userid', 'phpbb_user_id'),
447 array('ban_email', 'banlist.ban_email', ''),
448 array('ban_reason', '', ''),
449 array('ban_give_reason', '', ''),
451 'where' => "banlist.ban_ip NOT LIKE '%.%'",
455 'target' => BANLIST_TABLE,
457 array('ban_ip', 'banlist.ban_ip', ''),
458 array('ban_userid', 0, ''),
459 array('ban_email', '', ''),
460 array('ban_reason', '', ''),
461 array('ban_give_reason', '', ''),
463 'where' => "banlist.ban_ip LIKE '%.%'",
467 'target' => DISALLOW_TABLE,
468 'query_first' => array('target', $convert->truncate_statement . DISALLOW_TABLE),
470 array('disallow_username', 'disallow.disallow_username', 'phpbb_disallowed_username'),
474 'target' => RANKS_TABLE,
475 'query_first' => array('target', $convert->truncate_statement . RANKS_TABLE),
476 'autoincrement' => 'rank_id',
478 array('rank_id', 'ranks.rank_id', ''),
479 array('rank_title', 'ranks.rank_title', array('function1' => 'phpbb_set_default_encoding', 'function2' => 'utf8_htmlspecialchars')),
480 array('rank_min', 'ranks.rank_min', array('typecast' => 'int', 'execute' => '{RESULT} = ({VALUE}[0] < 0) ? 0 : {VALUE}[0];')),
481 array('rank_special', 'ranks.rank_special', ''),
482 array('rank_image', 'ranks.rank_image', 'import_rank'),
486 'target' => TOPICS_TABLE,
487 'query_first' => array('target', $convert->truncate_statement . TOPICS_TABLE),
488 'primary' => 'topics.topic_id',
489 'autoincrement' => 'topic_id',
491 array('topic_id', 'topics.topic_id', ''),
492 array('forum_id', 'topics.forum_id', ''),
493 array('icon_id', 0, ''),
494 array('topic_poster', 'topics.topic_poster AS poster_id', 'phpbb_user_id'),
495 array('topic_attachment', ((defined('MOD_ATTACHMENT')) ? 'topics.topic_attachment' : 0), ''),
496 array('topic_title', 'topics.topic_title', 'phpbb_set_encoding'),
497 array('topic_time', 'topics.topic_time', ''),
498 array('topic_views', 'topics.topic_views', ''),
499 array('topic_replies', 'topics.topic_replies', ''),
500 array('topic_replies_real', 'topics.topic_replies', ''),
501 array('topic_last_post_id', 'topics.topic_last_post_id', ''),
502 array('topic_status', 'topics.topic_status', 'is_topic_locked'),
503 array('topic_moved_id', 0, ''),
504 array('topic_type', 'topics.topic_type', 'phpbb_convert_topic_type'),
505 array('topic_first_post_id', 'topics.topic_first_post_id', ''),
506 array('topic_last_view_time', 'posts.post_time', 'intval'),
507 array('poll_title', 'vote_desc.vote_text', array('function1' => 'null_to_str', 'function2' => 'phpbb_set_encoding', 'function3' => 'htmlspecialchars_decode', 'function4' => 'utf8_htmlspecialchars')),
508 array('poll_start', 'vote_desc.vote_start', 'null_to_zero'),
509 array('poll_length', 'vote_desc.vote_length', 'null_to_zero'),
510 array('poll_max_options', 1, ''),
511 array('poll_vote_change', 0, ''),
513 'left_join' => array ( 'topics LEFT JOIN vote_desc ON topics.topic_id = vote_desc.topic_id AND topics.topic_vote = 1',
514 'topics LEFT JOIN posts ON topics.topic_last_post_id = posts.post_id',
516 'where' => 'topics.topic_moved_id = 0',
520 'target' => TOPICS_TABLE,
521 'primary' => 'topics.topic_id',
522 'autoincrement' => 'topic_id',
524 array('topic_id', 'topics.topic_id', ''),
525 array('forum_id', 'topics.forum_id', ''),
526 array('icon_id', 0, ''),
527 array('topic_poster', 'topics.topic_poster AS poster_id', 'phpbb_user_id'),
528 array('topic_attachment', ((defined('MOD_ATTACHMENT')) ? 'topics.topic_attachment' : 0), ''),
529 array('topic_title', 'topics.topic_title', 'phpbb_set_encoding'),
530 array('topic_time', 'topics.topic_time', ''),
531 array('topic_views', 'topics.topic_views', ''),
532 array('topic_replies', 'topics.topic_replies', ''),
533 array('topic_replies_real', 'topics.topic_replies', ''),
534 array('topic_last_post_id', 'topics.topic_last_post_id', ''),
535 array('topic_status', ITEM_MOVED, ''),
536 array('topic_moved_id', 'topics.topic_moved_id', ''),
537 array('topic_type', 'topics.topic_type', 'phpbb_convert_topic_type'),
538 array('topic_first_post_id', 'topics.topic_first_post_id', ''),
540 array('poll_title', 'vote_desc.vote_text', array('function1' => 'null_to_str', 'function2' => 'phpbb_set_encoding', 'function3' => 'htmlspecialchars_decode', 'function4' => 'utf8_htmlspecialchars')),
541 array('poll_start', 'vote_desc.vote_start', 'null_to_zero'),
542 array('poll_length', 'vote_desc.vote_length', 'null_to_zero'),
543 array('poll_max_options', 1, ''),
544 array('poll_vote_change', 0, ''),
546 'left_join' => 'topics LEFT JOIN vote_desc ON topics.topic_id = vote_desc.topic_id AND topics.topic_vote = 1',
547 'where' => 'topics.topic_moved_id <> 0',
551 'target' => TOPICS_WATCH_TABLE,
552 'primary' => 'topics_watch.topic_id',
553 'query_first' => array('target', $convert->truncate_statement . TOPICS_WATCH_TABLE),
555 array('topic_id', 'topics_watch.topic_id', ''),
556 array('user_id', 'topics_watch.user_id', 'phpbb_user_id'),
557 array('notify_status', 'topics_watch.notify_status', ''),
561 'target' => SMILIES_TABLE,
562 'query_first' => array('target', $convert->truncate_statement . SMILIES_TABLE),
563 'autoincrement' => 'smiley_id',
565 array('smiley_id', 'smilies.smilies_id', ''),
566 array('code', 'smilies.code', array('function1' => 'phpbb_smilie_html_decode', 'function2' => 'phpbb_set_encoding', 'function3' => 'utf8_htmlspecialchars')),
567 array('emotion', 'smilies.emoticon', 'phpbb_set_encoding'),
568 array('smiley_url', 'smilies.smile_url', 'import_smiley'),
569 array('smiley_width', 'smilies.smile_url', 'get_smiley_width'),
570 array('smiley_height', 'smilies.smile_url', 'get_smiley_height'),
571 array('smiley_order', 'smilies.smilies_id', ''),
572 array('display_on_posting', 'smilies.smilies_id', 'get_smiley_display'),
574 'order_by' => 'smilies.smilies_id ASC',
578 'target' => POLL_OPTIONS_TABLE,
579 'primary' => 'vote_results.vote_option_id',
580 'query_first' => array('target', $convert->truncate_statement . POLL_OPTIONS_TABLE),
582 array('poll_option_id', 'vote_results.vote_option_id', ''),
583 array('topic_id', 'vote_desc.topic_id', ''),
584 array('', 'topics.topic_poster AS poster_id', 'phpbb_user_id'),
585 array('poll_option_text', 'vote_results.vote_option_text', array('function1' => 'phpbb_set_encoding', 'function2' => 'htmlspecialchars_decode', 'function3' => 'utf8_htmlspecialchars')),
586 array('poll_option_total', 'vote_results.vote_result', ''),
588 'where' => 'vote_results.vote_id = vote_desc.vote_id',
589 'left_join' => 'vote_desc LEFT JOIN topics ON topics.topic_id = vote_desc.topic_id',
593 'target' => POLL_VOTES_TABLE,
594 'primary' => 'vote_desc.topic_id',
595 'query_first' => array('target', $convert->truncate_statement . POLL_VOTES_TABLE),
597 array('poll_option_id', VOTE_CONVERTED, ''),
598 array('topic_id', 'vote_desc.topic_id', ''),
599 array('vote_user_id', 'vote_voters.vote_user_id', 'phpbb_user_id'),
600 array('vote_user_ip', 'vote_voters.vote_user_ip', 'decode_ip'),
602 'where' => 'vote_voters.vote_id = vote_desc.vote_id',
606 'target' => WORDS_TABLE,
607 'primary' => 'words.word_id',
608 'query_first' => array('target', $convert->truncate_statement . WORDS_TABLE),
609 'autoincrement' => 'word_id',
611 array('word_id', 'words.word_id', ''),
612 array('word', 'words.word', 'phpbb_set_encoding'),
613 array('replacement', 'words.replacement', 'phpbb_set_encoding'),
617 'target' => POSTS_TABLE,
618 'primary' => 'posts.post_id',
619 'autoincrement' => 'post_id',
620 'query_first' => array('target', $convert->truncate_statement . POSTS_TABLE),
622 $config["max_post_chars"] = 0;
623 $config["min_post_chars"] = 0;
624 $config["max_quote_depth"] = 0;
627 array('post_id', 'posts.post_id', ''),
628 array('topic_id', 'posts.topic_id', ''),
629 array('forum_id', 'posts.forum_id', ''),
630 array('poster_id', 'posts.poster_id', 'phpbb_user_id'),
631 array('icon_id', 0, ''),
632 array('poster_ip', 'posts.poster_ip', 'decode_ip'),
633 array('post_time', 'posts.post_time', ''),
634 array('enable_bbcode', 'posts.enable_bbcode', ''),
635 array('', 'posts.enable_html', ''),
636 array('enable_smilies', 'posts.enable_smilies', ''),
637 array('enable_sig', 'posts.enable_sig', ''),
638 array('enable_magic_url', 1, ''),
639 array('post_username', 'posts.post_username', 'phpbb_set_encoding'),
640 array('post_subject', 'posts_text.post_subject', 'phpbb_set_encoding'),
641 array('post_attachment', ((defined('MOD_ATTACHMENT')) ? 'posts.post_attachment' : 0), ''),
642 array('post_edit_time', 'posts.post_edit_time', array('typecast' => 'int')),
643 array('post_edit_count', 'posts.post_edit_count', ''),
644 array('post_edit_reason', '', ''),
645 array('post_edit_user', '', 'phpbb_post_edit_user'),
647 array('bbcode_uid', 'posts.post_time', 'make_uid'),
648 array('post_text', 'posts_text.post_text', 'phpbb_prepare_message'),
649 array('', 'posts_text.bbcode_uid AS old_bbcode_uid', ''),
650 array('bbcode_bitfield', '', 'get_bbcode_bitfield'),
651 array('post_checksum', '', ''),
653 // Commented out inline search indexing, this takes up a LOT of time. :D
654 // @todo We either need to enable this or call the rebuild search functionality post convert
655 /* array('', '', 'search_indexing'),
656 array('', 'posts_text.post_text AS message', ''),
657 array('', 'posts_text.post_subject AS title', ''),*/
659 'where' => 'posts.post_id = posts_text.post_id'
663 'target' => PRIVMSGS_TABLE,
664 'primary' => 'privmsgs.privmsgs_id',
665 'autoincrement' => 'msg_id',
666 'query_first' => array(
667 array('target', $convert->truncate_statement . PRIVMSGS_TABLE),
668 array('target', $convert->truncate_statement . PRIVMSGS_RULES_TABLE),
672 $config["max_post_chars"] = 0;
673 $config["min_post_chars"] = 0;
674 $config["max_quote_depth"] = 0;
677 array('msg_id', 'privmsgs.privmsgs_id', ''),
678 array('root_level', 0, ''),
679 array('author_id', 'privmsgs.privmsgs_from_userid AS poster_id', 'phpbb_user_id'),
680 array('icon_id', 0, ''),
681 array('author_ip', 'privmsgs.privmsgs_ip', 'decode_ip'),
682 array('message_time', 'privmsgs.privmsgs_date', ''),
683 array('enable_bbcode', 'privmsgs.privmsgs_enable_bbcode AS enable_bbcode', ''),
684 array('', 'privmsgs.privmsgs_enable_html AS enable_html', ''),
685 array('enable_smilies', 'privmsgs.privmsgs_enable_smilies AS enable_smilies', ''),
686 array('enable_magic_url', 1, ''),
687 array('enable_sig', 'privmsgs.privmsgs_attach_sig', ''),
688 array('message_subject', 'privmsgs.privmsgs_subject', 'phpbb_set_encoding'), // Already specialchared in 2.0.x
689 array('message_attachment', ((defined('MOD_ATTACHMENT')) ? 'privmsgs.privmsgs_attachment' : 0), ''),
690 array('message_edit_reason', '', ''),
691 array('message_edit_user', 0, ''),
692 array('message_edit_time', 0, ''),
693 array('message_edit_count', 0, ''),
695 array('bbcode_uid', 'privmsgs.privmsgs_date AS post_time', 'make_uid'),
696 array('message_text', 'privmsgs_text.privmsgs_text', 'phpbb_prepare_message'),
697 array('', 'privmsgs_text.privmsgs_bbcode_uid AS old_bbcode_uid', ''),
698 array('bbcode_bitfield', '', 'get_bbcode_bitfield'),
699 array('to_address', 'privmsgs.privmsgs_to_userid', 'phpbb_privmsgs_to_userid'),
700 array('bcc_address', '', ''),
702 'where' => 'privmsgs.privmsgs_id = privmsgs_text.privmsgs_text_id'
706 'target' => PRIVMSGS_FOLDER_TABLE,
707 'primary' => 'users.user_id',
708 'query_first' => array('target', $convert->truncate_statement . PRIVMSGS_FOLDER_TABLE),
710 array('user_id', 'users.user_id', 'phpbb_user_id'),
711 array('folder_name', $user->lang['CONV_SAVED_MESSAGES'], ''),
712 array('pm_count', 0, ''),
714 'where' => 'users.user_id <> -1',
719 'target' => PRIVMSGS_TO_TABLE,
720 'primary' => 'privmsgs.privmsgs_id',
721 'query_first' => array('target', $convert->truncate_statement . PRIVMSGS_TO_TABLE),
723 array('msg_id', 'privmsgs.privmsgs_id', ''),
724 array('user_id', 'privmsgs.privmsgs_to_userid', 'phpbb_user_id'),
725 array('author_id', 'privmsgs.privmsgs_from_userid', 'phpbb_user_id'),
726 array('pm_deleted', 0, ''),
727 array('pm_new', 'privmsgs.privmsgs_type', 'phpbb_new_pm'),
728 array('pm_unread', 'privmsgs.privmsgs_type', 'phpbb_unread_pm'),
729 array('pm_replied', 0, ''),
730 array('pm_marked', 0, ''),
731 array('pm_forwarded', 0, ''),
732 array('folder_id', PRIVMSGS_INBOX, ''),
734 'where' => 'privmsgs.privmsgs_id = privmsgs_text.privmsgs_text_id
735 AND (privmsgs.privmsgs_type = 0 OR privmsgs.privmsgs_type = 1 OR privmsgs.privmsgs_type = 5)',
740 'target' => PRIVMSGS_TO_TABLE,
741 'primary' => 'privmsgs.privmsgs_id',
743 array('msg_id', 'privmsgs.privmsgs_id', ''),
744 array('user_id', 'privmsgs.privmsgs_from_userid', 'phpbb_user_id'),
745 array('author_id', 'privmsgs.privmsgs_from_userid', 'phpbb_user_id'),
746 array('pm_deleted', 0, ''),
747 array('pm_new', 0, ''),
748 array('pm_unread', 0, ''),
749 array('pm_replied', 0, ''),
750 array('pm_marked', 0, ''),
751 array('pm_forwarded', 0, ''),
752 array('folder_id', PRIVMSGS_OUTBOX, ''),
754 'where' => 'privmsgs.privmsgs_id = privmsgs_text.privmsgs_text_id
755 AND (privmsgs.privmsgs_type = 1 OR privmsgs.privmsgs_type = 5)',
760 'target' => PRIVMSGS_TO_TABLE,
761 'primary' => 'privmsgs.privmsgs_id',
763 array('msg_id', 'privmsgs.privmsgs_id', ''),
764 array('user_id', 'privmsgs.privmsgs_from_userid', 'phpbb_user_id'),
765 array('author_id', 'privmsgs.privmsgs_from_userid', 'phpbb_user_id'),
766 array('pm_deleted', 0, ''),
767 array('pm_new', 'privmsgs.privmsgs_type', 'phpbb_new_pm'),
768 array('pm_unread', 'privmsgs.privmsgs_type', 'phpbb_unread_pm'),
769 array('pm_replied', 0, ''),
770 array('pm_marked', 0, ''),
771 array('pm_forwarded', 0, ''),
772 array('folder_id', PRIVMSGS_SENTBOX, ''),
774 'where' => 'privmsgs.privmsgs_id = privmsgs_text.privmsgs_text_id
775 AND privmsgs.privmsgs_type = 2',
778 // Savebox (SAVED IN)
780 'target' => PRIVMSGS_TO_TABLE,
781 'primary' => 'privmsgs.privmsgs_id',
783 array('msg_id', 'privmsgs.privmsgs_id', ''),
784 array('user_id', 'privmsgs.privmsgs_to_userid', 'phpbb_user_id'),
785 array('author_id', 'privmsgs.privmsgs_from_userid', 'phpbb_user_id'),
786 array('pm_deleted', 0, ''),
787 array('pm_new', 'privmsgs.privmsgs_type', 'phpbb_new_pm'),
788 array('pm_unread', 'privmsgs.privmsgs_type', 'phpbb_unread_pm'),
789 array('pm_replied', 0, ''),
790 array('pm_marked', 0, ''),
791 array('pm_forwarded', 0, ''),
792 array('folder_id', 'privmsgs.privmsgs_to_userid', 'phpbb_get_savebox_id'),
794 'where' => 'privmsgs.privmsgs_id = privmsgs_text.privmsgs_text_id
795 AND privmsgs.privmsgs_type = 3',
798 // Savebox (SAVED OUT)
800 'target' => PRIVMSGS_TO_TABLE,
801 'primary' => 'privmsgs.privmsgs_id',
803 array('msg_id', 'privmsgs.privmsgs_id', ''),
804 array('user_id', 'privmsgs.privmsgs_from_userid', 'phpbb_user_id'),
805 array('author_id', 'privmsgs.privmsgs_from_userid', 'phpbb_user_id'),
806 array('pm_deleted', 0, ''),
807 array('pm_new', 'privmsgs.privmsgs_type', 'phpbb_new_pm'),
808 array('pm_unread', 'privmsgs.privmsgs_type', 'phpbb_unread_pm'),
809 array('pm_replied', 0, ''),
810 array('pm_marked', 0, ''),
811 array('pm_forwarded', 0, ''),
812 array('folder_id', 'privmsgs.privmsgs_from_userid', 'phpbb_get_savebox_id'),
814 'where' => 'privmsgs.privmsgs_id = privmsgs_text.privmsgs_text_id
815 AND privmsgs.privmsgs_type = 4',
819 'target' => GROUPS_TABLE,
820 'autoincrement' => 'group_id',
821 'query_first' => array('target', $convert->truncate_statement . GROUPS_TABLE),
823 array('group_id', 'groups.group_id', ''),
824 array('group_type', 'groups.group_type', 'phpbb_convert_group_type'),
825 array('group_display', 0, ''),
826 array('group_legend', 0, ''),
827 array('group_name', 'groups.group_name', 'phpbb_convert_group_name'), // phpbb_set_encoding called in phpbb_convert_group_name
828 array('group_desc', 'groups.group_description', 'phpbb_set_encoding'),
830 'where' => 'groups.group_single_user = 0',
834 'target' => USER_GROUP_TABLE,
835 'query_first' => array('target', $convert->truncate_statement . USER_GROUP_TABLE),
837 add_default_groups();
840 array('group_id', 'groups.group_id', ''),
841 array('user_id', 'groups.group_moderator', 'phpbb_user_id'),
842 array('group_leader', 1, ''),
843 array('user_pending', 0, ''),
845 'where' => 'groups.group_single_user = 0 AND groups.group_moderator <> 0',
849 'target' => USER_GROUP_TABLE,
851 array('group_id', 'user_group.group_id', ''),
852 array('user_id', 'user_group.user_id', 'phpbb_user_id'),
853 array('group_leader', 0, ''),
854 array('user_pending', 'user_group.user_pending', ''),
856 'where' => 'user_group.group_id = groups.group_id AND groups.group_single_user = 0 AND groups.group_moderator <> user_group.user_id',
860 'target' => USERS_TABLE,
861 'primary' => 'users.user_id',
862 'autoincrement' => 'user_id',
863 'query_first' => array(
864 array('target', 'DELETE FROM ' . USERS_TABLE . ' WHERE user_id <> ' . ANONYMOUS),
865 array('target', $convert->truncate_statement . BOTS_TABLE)
869 remove_invalid_users();
872 array('user_id', 'users.user_id', 'phpbb_user_id'),
873 array('', 'users.user_id AS poster_id', 'phpbb_user_id'),
874 array('user_type', 'users.user_active', 'set_user_type'),
875 array('group_id', 'users.user_level', 'phpbb_set_primary_group'),
876 array('user_regdate', 'users.user_regdate', ''),
877 array('username', 'users.username', 'phpbb_set_default_encoding'), // recode to utf8 with default lang
878 array('username_clean', 'users.username', array('function1' => 'phpbb_set_default_encoding', 'function2' => 'utf8_clean_string')),
879 array('user_password', 'users.user_password', 'phpbb_hash'),
880 array('user_pass_convert', 1, ''),
881 array('user_posts', 'users.user_posts', 'intval'),
882 array('user_email', 'users.user_email', 'strtolower'),
883 array('user_email_hash', 'users.user_email', 'gen_email_hash'),
884 array('user_birthday', ((defined('MOD_BIRTHDAY')) ? 'users.user_birthday' : ''), 'phpbb_get_birthday'),
885 array('user_lastvisit', 'users.user_lastvisit', 'intval'),
886 array('user_lastmark', 'users.user_lastvisit', 'intval'),
887 array('user_lang', $config['default_lang'], ''),
888 array('', 'users.user_lang', ''),
889 array('user_timezone', 'users.user_timezone', 'floatval'),
890 array('user_dateformat', 'users.user_dateformat', array('function1' => 'phpbb_set_encoding', 'function2' => 'fill_dateformat')),
891 array('user_inactive_reason', '', 'phpbb_inactive_reason'),
892 array('user_inactive_time', '', 'phpbb_inactive_time'),
894 array('user_interests', 'users.user_interests', array('function1' => 'phpbb_set_encoding')),
895 array('user_occ', 'users.user_occ', array('function1' => 'phpbb_set_encoding')),
896 array('user_website', 'users.user_website', 'validate_website'),
897 array('user_jabber', '', ''),
898 array('user_msnm', 'users.user_msnm', array('function1' => 'phpbb_set_encoding')),
899 array('user_yim', 'users.user_yim', array('function1' => 'phpbb_set_encoding')),
900 array('user_aim', 'users.user_aim', array('function1' => 'phpbb_set_encoding')),
901 array('user_icq', 'users.user_icq', array('function1' => 'phpbb_set_encoding')),
902 array('user_from', 'users.user_from', array('function1' => 'phpbb_set_encoding')),
903 array('user_rank', 'users.user_rank', 'intval'),
904 array('user_permissions', '', ''),
906 array('user_avatar', 'users.user_avatar', 'phpbb_import_avatar'),
907 array('user_avatar_type', 'users.user_avatar_type', 'phpbb_avatar_type'),
908 array('user_avatar_width', 'users.user_avatar', 'phpbb_get_avatar_width'),
909 array('user_avatar_height', 'users.user_avatar', 'phpbb_get_avatar_height'),
911 array('user_new_privmsg', 'users.user_new_privmsg', ''),
912 array('user_unread_privmsg', 0, ''), //'users.user_unread_privmsg'
913 array('user_last_privmsg', 'users.user_last_privmsg', 'intval'),
914 array('user_emailtime', 'users.user_emailtime', 'null_to_zero'),
915 array('user_notify', 'users.user_notify', 'intval'),
916 array('user_notify_pm', 'users.user_notify_pm', 'intval'),
917 array('user_notify_type', NOTIFY_EMAIL, ''),
918 array('user_allow_pm', 'users.user_allow_pm', 'intval'),
919 array('user_allow_viewonline', 'users.user_allow_viewonline', 'intval'),
920 array('user_allow_viewemail', 'users.user_viewemail', 'intval'),
921 array('user_actkey', 'users.user_actkey', ''),
922 array('user_newpasswd', '', ''), // Users need to re-request their password...
923 array('user_style', $config['default_style'], ''),
925 array('user_options', '', 'set_user_options'),
926 array('', 'users.user_popup_pm AS popuppm', ''),
927 array('', 'users.user_allowhtml AS html', ''),
928 array('', 'users.user_allowbbcode AS bbcode', ''),
929 array('', 'users.user_allowsmile AS smile', ''),
930 array('', 'users.user_attachsig AS attachsig',''),
932 array('user_sig_bbcode_uid', 'users.user_regdate', 'make_uid'),
933 array('user_sig', 'users.user_sig', 'phpbb_prepare_message'),
934 array('', 'users.user_sig_bbcode_uid AS old_bbcode_uid', ''),
935 array('user_sig_bbcode_bitfield', '', 'get_bbcode_bitfield'),
936 array('', 'users.user_regdate AS post_time', ''),
938 'where' => 'users.user_id <> -1',