Verzeichnisstruktur phpBB-3.0.0


Veröffentlicht
12.12.2007

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

convert_phpbb20.php

Zuletzt modifiziert: 09.10.2024, 12:51 - Dateigröße: 38.46 KiB


001  <?php
002  /**
003  *
004  * @package install
005  * @version $Id$
006  * @copyright (c) 2006 phpBB Group
007  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
008  *
009  */
010   
011  /**
012  * NOTE to potential convertor authors. Please use this file to get
013  * familiar with the structure since we added some bare explanations here.
014  *
015  * Since this file gets included more than once on one page you are not able to add functions to it.
016  * Instead use a functions_ file.
017  *
018  * @ignore
019  */
020  if (!defined('IN_PHPBB'))
021  {
022      exit;
023  }
024   
025  include($phpbb_root_path . 'config.' . $phpEx);
026  unset($dbpasswd);
027   
028  /**
029  * $convertor_data provides some basic information about this convertor which is
030  * used on the initial list of convertors and to populate the default settings
031  */
032  $convertor_data = array(
033      'forum_name'    => 'phpBB 2.0.x',
034      'version'        => '1.0.0',
035      'phpbb_version'    => '3.0.0',
036      'author'        => '<a href="http://www.phpbb.com/">phpBB Group</a>',
037      'dbms'            => $dbms,
038      'dbhost'        => $dbhost,
039      'dbport'        => $dbport,
040      'dbuser'        => $dbuser,
041      'dbpasswd'        => '',
042      'dbname'        => $dbname,
043      'table_prefix'    => 'phpbb_',
044      'forum_path'    => '../forums',
045      'author_notes'    => '',
046  );
047   
048  /**
049  * $tables is a list of the tables (minus prefix) which we expect to find in the
050  * source forum. It is used to guess the prefix if the specified prefix is incorrect
051  */
052  $tables = array(
053      'auth_access',
054      'banlist',
055      'categories',
056      'disallow',
057      'forum_prune',
058      'forums',
059      'groups',
060      'posts',
061      'posts_text',
062      'privmsgs',
063      'privmsgs_text',
064      'ranks',
065      'smilies',
066      'topics',
067      'topics_watch',
068      'user_group',
069      'users',
070      'vote_desc',
071      'vote_results',
072      'vote_voters',
073      'words'
074  );
075   
076  /**
077  * $config_schema details how the board configuration information is stored in the source forum.
078  *
079  * 'table_format' can take the value 'file' to indicate a config file. In this case array_name
080  * is set to indicate the name of the array the config values are stored in
081  * 'table_format' can be an array if the values are stored in a table which is an assosciative array
082  * (as per phpBB 2.0.x)
083  * If left empty, values are assumed to be stored in a table where each config setting is
084  * a column (as per phpBB 1.x)
085  *
086  * In either of the latter cases 'table_name' indicates the name of the table in the database
087  *
088  * 'settings' is an array which maps the name of the config directive in the source forum
089  * to the config directive in phpBB3. It can either be a direct mapping or use a function.
090  * Please note that the contents of the old config value are passed to the function, therefore
091  * an in-built function requiring the variable passed by reference is not able to be used. Since
092  * empty() is such a function we created the function is_empty() to be used instead.
093  */
094  $config_schema = array(
095      'table_name'    =>    'config',
096      'table_format'    =>    array('config_name' => 'config_value'),
097      'settings'        =>    array(
098          'allow_bbcode'            => 'allow_bbcode',
099          'allow_smilies'            => 'allow_smilies',
100          'allow_sig'                => 'allow_sig',
101          'allow_namechange'        => 'allow_namechange',
102          'allow_avatar_local'    => 'allow_avatar_local',
103          'allow_avatar_remote'    => 'allow_avatar_remote',
104          'allow_avatar_upload'    => 'allow_avatar_upload',
105          'board_disable'            => 'board_disable',
106          'sitename'                => 'phpbb_set_encoding(sitename)',
107          'site_desc'                => 'phpbb_set_encoding(site_desc)',
108          'session_length'        => 'session_length',
109          'board_email_sig'        => 'phpbb_set_encoding(board_email_sig)',
110          'posts_per_page'        => 'posts_per_page',
111          'topics_per_page'        => 'topics_per_page',
112          'enable_confirm'        => 'enable_confirm',
113          'board_email_form'        => 'board_email_form',
114          'override_user_style'    => 'override_user_style',
115          'hot_threshold'            => 'hot_threshold',
116          'max_poll_options'        => 'max_poll_options',
117          'max_sig_chars'            => 'max_sig_chars',
118          'pm_max_msgs'            => 'max_inbox_privmsgs',
119          'smtp_delivery'            => 'smtp_delivery',
120          'smtp_host'                => 'smtp_host',
121          'smtp_username'            => 'smtp_username',
122          'smtp_password'            => 'smtp_password',
123          'require_activation'    => 'require_activation',
124          'flood_interval'        => 'flood_interval',
125          'avatar_filesize'        => 'avatar_filesize',
126          'avatar_max_width'        => 'avatar_max_width',
127          'avatar_max_height'        => 'avatar_max_height',
128          'default_dateformat'    => 'default_dateformat',
129          'board_timezone'        => 'board_timezone',
130          'allow_privmsg'            => 'not(privmsg_disable)',
131          'gzip_compress'            => 'gzip_compress',
132          'coppa_enable'            => 'is_empty(coppa_mail)',
133          'coppa_fax'                => 'coppa_fax',
134          'coppa_mail'            => 'coppa_mail',
135          'record_online_users'    => 'record_online_users',
136          'record_online_date'    => 'record_online_date',
137          'board_startdate'        => 'board_startdate',
138      )
139  );
140   
141  /**
142  * $test_file is the name of a file which is present on the source
143  * forum which can be used to check that the path specified by the
144  * user was correct
145  */
146  $test_file = 'modcp.php';
147   
148  /**
149  * If this is set then we are not generating the first page of information but getting the conversion information.
150  */
151  if (!$get_info)
152  {
153      // Test to see if the birthday MOD is installed on the source forum
154      // Niels' birthday mod
155      if (get_config_value('birthday_required') !== false || get_config_value('bday_require') !== false)
156      {
157          define('MOD_BIRTHDAY', true);
158      }
159   
160      // TerraFrost's validated birthday mod
161      if (get_config_value('bday_require') !== false)
162      {
163          define('MOD_BIRTHDAY_TERRA', true);
164      }
165   
166      // Test to see if the attachment MOD is installed on the source forum
167      // If it is, we will convert this data as well
168      $src_db->sql_return_on_error(true);
169   
170      $sql = "SELECT config_value
171          FROM {$convert->src_table_prefix}attachments_config
172          WHERE config_name = 'upload_dir'";
173      $result = $src_db->sql_query($sql);
174   
175      if ($result && $row = $src_db->sql_fetchrow($result))
176      {
177          // Here the constant is defined
178          define('MOD_ATTACHMENT', true);
179   
180          // Here i add more tables to be checked in the old forum
181          $tables += array(
182              'attachments',
183              'attachments_desc',
184              'extensions',
185              'extension_groups'
186          );
187   
188          $src_db->sql_freeresult($result);
189      }
190      else if ($result)
191      {
192          $src_db->sql_freeresult($result);
193      }
194      
195   
196      /**
197      * Tests for further MODs can be included here.
198      * Please use constants for this, prefixing them with MOD_
199      */
200   
201      $src_db->sql_return_on_error(false);
202   
203      // Now let us set a temporary config variable for user id incrementing
204      $sql = "SELECT user_id
205          FROM {$convert->src_table_prefix}users
206          WHERE user_id = 1";
207      $result = $src_db->sql_query($sql);
208      $user_id = (int) $src_db->sql_fetchfield('user_id');
209      $src_db->sql_freeresult($result);
210   
211      // If there is a user id 1, we need to increment user ids. :/
212      if ($user_id === 1)
213      {
214          // Try to get the maximum user id possible...
215          $sql = "SELECT MAX(user_id) AS max_user_id
216              FROM {$convert->src_table_prefix}users";
217          $result = $src_db->sql_query($sql);
218          $user_id = (int) $src_db->sql_fetchfield('max_user_id');
219          $src_db->sql_freeresult($result);
220   
221          set_config('increment_user_id', ($user_id + 1), true);
222      }
223      else
224      {
225          set_config('increment_user_id', 0, true);
226      }
227   
228      // Overwrite maximum avatar width/height
229      @define('DEFAULT_AVATAR_X_CUSTOM', get_config_value('avatar_max_width'));
230      @define('DEFAULT_AVATAR_Y_CUSTOM', get_config_value('avatar_max_height'));
231   
232  /**
233  *    Description on how to use the convertor framework.
234  *
235  *    'schema' Syntax Description
236  *        -> 'target'            => Target Table. If not specified the next table will be handled
237  *        -> 'primary'        => Primary Key. If this is specified then this table is processed in batches
238  *        -> 'query_first'    => array('target' or 'src', Query to execute before beginning the process
239  *                                (if more than one then specified as array))
240  *        -> 'function_first'    => Function to execute before beginning the process (if more than one then specified as array)
241  *                                (This is mostly useful if variables need to be given to the converting process)
242  *        -> 'test_file'        => This is not used at the moment but should be filled with a file from the old installation
243  *
244  *        // DB Functions
245  *        'distinct'    => Add DISTINCT to the select query
246  *        'where'        => Add WHERE to the select query
247  *        'group_by'    => Add GROUP BY to the select query
248  *        'left_join'    => Add LEFT JOIN to the select query (if more than one joins specified as array)
249  *        'having'    => Add HAVING to the select query
250  *
251  *        // DB INSERT array
252  *        This one consist of three parameters
253  *        First Parameter:
254  *                            The key need to be filled within the target table
255  *                            If this is empty, the target table gets not assigned the source value
256  *        Second Parameter:
257  *                            Source value. If the first parameter is specified, it will be assigned this value.
258  *                            If the first parameter is empty, this only gets added to the select query
259  *        Third Parameter:
260  *                            Custom Function. Function to execute while storing source value into target table.
261  *                            The functions return value get stored.
262  *                            The function parameter consist of the value of the second parameter.
263  *
264  *                            types:
265  *                                - empty string == execute nothing
266  *                                - string == function to execute
267  *                                - array == complex execution instructions
268  *        
269  *        Complex execution instructions:
270  *        @todo test complex execution instructions - in theory they will work fine
271  *
272  *                            By defining an array as the third parameter you are able to define some statements to be executed. The key
273  *                            is defining what to execute, numbers can be appended...
274  *
275  *                            'function' => execute function
276  *                            'execute' => run code, whereby all occurrences of {VALUE} get replaced by the last returned value.
277  *                                        The result *must* be assigned/stored to {RESULT}.
278  *                            'typecast'    => typecast value
279  *
280  *                            The returned variables will be made always available to the next function to continue to work with.
281  *
282  *                            example (variable inputted is an integer of 1):
283  *
284  *                            array(
285  *                                'function1'        => 'increment_by_one',        // returned variable is 2
286  *                                'typecast'        => 'string',                // typecast variable to be a string
287  *                                'execute'        => '{RESULT} = {VALUE} . ' is good';', // returned variable is '2 is good'
288  *                                'function2'        => 'replace_good_with_bad',                // returned variable is '2 is bad'
289  *                            ),
290  *
291  */
292   
293      $convertor = array(
294          'test_file'                => 'viewtopic.php',
295   
296          'avatar_path'            => get_config_value('avatar_path') . '/',
297          'avatar_gallery_path'    => get_config_value('avatar_gallery_path') . '/',
298          'smilies_path'            => get_config_value('smilies_path') . '/',
299          'upload_path'            => (defined('MOD_ATTACHMENT')) ? phpbb_get_files_dir() . '/' : '',
300          'thumbnails'            => (defined('MOD_ATTACHMENT')) ? array('thumbs/', 't_') : '',
301          'ranks_path'            => false, // phpBB 2.0.x had no config value for a ranks path
302   
303          // We empty some tables to have clean data available
304          'query_first'            => array(
305              array('target', $convert->truncate_statement . SEARCH_RESULTS_TABLE),
306              array('target', $convert->truncate_statement . SEARCH_WORDLIST_TABLE),
307              array('target', $convert->truncate_statement . SEARCH_WORDMATCH_TABLE),
308              array('target', $convert->truncate_statement . LOG_TABLE),
309          ),
310          
311  //    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.
312  //    Instead every file gets copied while processing the corresponding attachment entry.
313  //        if (defined("MOD_ATTACHMENT")) { import_attachment_files(); phpbb_copy_thumbnails(); }
314   
315          // phpBB2 allowed some similar usernames to coexist which would have the same
316          // username_clean in phpBB3 which is not possible, so we'll give the admin a list
317          // of user ids and usernames and let him deicde what he wants to do with them
318          'execute_first'    => '
319              phpbb_check_username_collisions();
320              import_avatar_gallery();
321              if (defined("MOD_ATTACHMENT")) phpbb_import_attach_config();
322              phpbb_insert_forums();
323          ',
324   
325          'execute_last'    => array('
326              add_bots();
327          ', '
328              update_folder_pm_count();
329          ', '
330              update_unread_count();
331          ', '
332              phpbb_convert_authentication(\'start\');
333          ', '
334              phpbb_convert_authentication(\'first\');
335          ', '
336              phpbb_convert_authentication(\'second\');
337          ', '
338              phpbb_convert_authentication(\'third\');
339          '),
340   
341          'schema' => array(
342   
343              array(
344                  'target'        => (defined('MOD_ATTACHMENT')) ? ATTACHMENTS_TABLE : '',
345                  'primary'        => 'attachments.attach_id',
346                  'query_first'    => (defined('MOD_ATTACHMENT')) ? array('target', $convert->truncate_statement . ATTACHMENTS_TABLE) : '',
347                  'autoincrement'    => 'attach_id',
348   
349                  array('attach_id',                'attachments.attach_id',                ''),
350                  array('post_msg_id',            'attachments.post_id',                    ''),
351                  array('topic_id',                'posts.topic_id',                        ''),
352                  array('in_message',                0,                                        ''),
353                  array('is_orphan',                0,                                        ''),
354                  array('poster_id',                'attachments.user_id_1 AS poster_id',    'phpbb_user_id'),
355                  array('physical_filename',        'attachments_desc.physical_filename',    'import_attachment'),
356                  array('real_filename',            'attachments_desc.real_filename',        'phpbb_set_encoding'),
357                  array('download_count',            'attachments_desc.download_count',        ''),
358                  array('attach_comment',            'attachments_desc.comment',                array('function1' => 'phpbb_set_encoding', 'function2' => 'utf8_htmlspecialchars')),
359                  array('extension',                'attachments_desc.extension',            ''),
360                  array('mimetype',                'attachments_desc.mimetype',            ''),
361                  array('filesize',                'attachments_desc.filesize',            ''),
362                  array('filetime',                'attachments_desc.filetime',            ''),
363                  array('thumbnail',                'attachments_desc.thumbnail',            ''),
364   
365                  'where'            => 'attachments_desc.attach_id = attachments.attach_id AND attachments.privmsgs_id = 0 AND posts.post_id = attachments.post_id',
366                  'group_by'        => 'attachments.attach_id'
367              ),
368   
369              array(
370                  'target'        => (defined('MOD_ATTACHMENT')) ? ATTACHMENTS_TABLE : '',
371                  'primary'        => 'attachments.attach_id',
372                  'autoincrement'    => 'attach_id',
373   
374                  array('attach_id',                'attachments.attach_id',                ''),
375                  array('post_msg_id',            'attachments.privmsgs_id',                ''),
376                  array('topic_id',                0,                                        ''),
377                  array('in_message',                1,                                        ''),
378                  array('is_orphan',                0,                                        ''),
379                  array('poster_id',                'attachments.user_id_1 AS poster_id',    'phpbb_user_id'),
380                  array('physical_filename',        'attachments_desc.physical_filename',    'import_attachment'),
381                  array('real_filename',            'attachments_desc.real_filename',        ''),
382                  array('download_count',            'attachments_desc.download_count',        ''),
383                  array('attach_comment',            'attachments_desc.comment',                array('function1' => 'phpbb_set_encoding', 'function2' => 'utf8_htmlspecialchars')),
384                  array('extension',                'attachments_desc.extension',            ''),
385                  array('mimetype',                'attachments_desc.mimetype',            ''),
386                  array('filesize',                'attachments_desc.filesize',            ''),
387                  array('filetime',                'attachments_desc.filetime',            ''),
388                  array('thumbnail',                'attachments_desc.thumbnail',            ''),
389   
390                  'where'            => 'attachments_desc.attach_id = attachments.attach_id AND attachments.post_id = 0',
391                  'group_by'        => 'attachments.attach_id'
392              ),
393   
394              array(
395                  'target'        => (defined('MOD_ATTACHMENT')) ? EXTENSIONS_TABLE : '',
396                  'query_first'    => (defined('MOD_ATTACHMENT')) ? array('target', $convert->truncate_statement . EXTENSIONS_TABLE) : '',
397                  'autoincrement'    => 'extension_id',
398   
399                  array('extension_id',            'extensions.ext_id',                ''),
400                  array('group_id',                'extensions.group_id',                ''),
401                  array('extension',                'extensions.extension',                ''),
402              ),
403   
404              array(
405                  'target'        => (defined('MOD_ATTACHMENT')) ? EXTENSION_GROUPS_TABLE : '',
406                  'query_first'    => (defined('MOD_ATTACHMENT')) ? array('target', $convert->truncate_statement . EXTENSION_GROUPS_TABLE) : '',
407                  'autoincrement'    => 'group_id',
408   
409                  array('group_id',                'extension_groups.group_id',            ''),
410                  array('group_name',                'extension_groups.group_name',            array('function1' => 'phpbb_set_encoding', 'function2' => 'utf8_htmlspecialchars')),
411                  array('cat_id',                    'extension_groups.cat_id',                'phpbb_attachment_category'),
412                  array('allow_group',            'extension_groups.allow_group',            ''),
413                  array('download_mode',            1,                                        ''),
414                  array('upload_icon',            '',                                        ''),
415                  array('max_filesize',            'extension_groups.max_filesize',        ''),
416                  array('allowed_forums',            'extension_groups.forum_permissions',    'phpbb_attachment_forum_perms'),
417                  array('allow_in_pm',            1,                                        ''),
418              ),
419   
420              array(
421                  'target'        => BANLIST_TABLE,
422                  'query_first'    => array('target', $convert->truncate_statement . BANLIST_TABLE),
423   
424                  array('ban_ip',                    'banlist.ban_ip',                    'decode_ban_ip'),
425                  array('ban_userid',                'banlist.ban_userid',                'phpbb_user_id'),
426                  array('ban_email',                'banlist.ban_email',                ''),
427                  array('ban_reason',                '',                                    ''),
428                  array('ban_give_reason',        '',                                    ''),
429   
430                  'where'            => "banlist.ban_ip NOT LIKE '%.%'",
431              ),
432   
433              array(
434                  'target'        => BANLIST_TABLE,
435   
436                  array('ban_ip',                    'banlist.ban_ip',    ''),
437                  array('ban_userid',                0,                    ''),
438                  array('ban_email',                '',                    ''),
439                  array('ban_reason',                '',                    ''),
440                  array('ban_give_reason',        '',                    ''),
441   
442                  'where'            => "banlist.ban_ip LIKE '%.%'",
443              ),
444   
445              array(
446                  'target'        => DISALLOW_TABLE,
447                  'query_first'    => array('target', $convert->truncate_statement . DISALLOW_TABLE),
448   
449                  array('disallow_username',        'disallow.disallow_username',                'phpbb_disallowed_username'),
450              ),
451   
452              array(
453                  'target'        => RANKS_TABLE,
454                  'query_first'    => array('target', $convert->truncate_statement . RANKS_TABLE),
455                  'autoincrement'    => 'rank_id',
456   
457                  array('rank_id',                    'ranks.rank_id',                ''),
458                  array('rank_title',                    'ranks.rank_title',                array('function1' => 'phpbb_set_default_encoding', 'function2' => 'utf8_htmlspecialchars')),
459                  array('rank_min',                    'ranks.rank_min',                array('typecast' => 'int', 'execute' => '{RESULT} = ({VALUE}[0] < 0) ? 0 : {VALUE}[0];')),
460                  array('rank_special',                'ranks.rank_special',            ''),
461                  array('rank_image',                    'ranks.rank_image',                'import_rank'),
462              ),
463   
464              array(
465                  'target'        => TOPICS_TABLE,
466                  'query_first'    => array('target', $convert->truncate_statement . TOPICS_TABLE),
467                  'primary'        => 'topics.topic_id',
468                  'autoincrement'    => 'topic_id',
469   
470                  array('topic_id',                'topics.topic_id',                    ''),
471                  array('forum_id',                'topics.forum_id',                    ''),
472                  array('icon_id',                0,                                    ''),
473                  array('topic_poster',            'topics.topic_poster AS poster_id',    'phpbb_user_id'),
474                  array('topic_attachment',        ((defined('MOD_ATTACHMENT')) ? 'topics.topic_attachment' : 0), ''),
475                  array('topic_title',            'topics.topic_title',                'phpbb_set_encoding'),
476                  array('topic_time',                'topics.topic_time',                ''),
477                  array('topic_views',            'topics.topic_views',                ''),
478                  array('topic_replies',            'topics.topic_replies',                ''),
479                  array('topic_replies_real',        'topics.topic_replies',                ''),
480                  array('topic_last_post_id',        'topics.topic_last_post_id',        ''),
481                  array('topic_status',            'topics.topic_status',                'is_topic_locked'),
482                  array('topic_moved_id',            0,                                    ''),
483                  array('topic_type',                'topics.topic_type',                'phpbb_convert_topic_type'),
484                  array('topic_first_post_id',    'topics.topic_first_post_id',        ''),
485   
486                  array('poll_title',                'vote_desc.vote_text',                array('function1' => 'null_to_str', 'function2' => 'phpbb_set_encoding', 'function3' => 'utf8_htmlspecialchars')),
487                  array('poll_start',                'vote_desc.vote_start',                'null_to_zero'),
488                  array('poll_length',            'vote_desc.vote_length',            'null_to_zero'),
489                  array('poll_max_options',        1,                                    ''),
490                  array('poll_vote_change',        0,                                    ''),
491   
492                  'left_join'        => 'topics LEFT JOIN vote_desc ON topics.topic_id = vote_desc.topic_id AND topics.topic_vote = 1',
493                  'where'            => 'topics.topic_moved_id = 0',
494              ),
495   
496              array(
497                  'target'        => TOPICS_TABLE,
498                  'primary'        => 'topics.topic_id',
499                  'autoincrement'    => 'topic_id',
500   
501                  array('topic_id',                'topics.topic_id',                    ''),
502                  array('forum_id',                'topics.forum_id',                    ''),
503                  array('icon_id',                0,                                    ''),
504                  array('topic_poster',            'topics.topic_poster AS poster_id',    'phpbb_user_id'),
505                  array('topic_attachment',        ((defined('MOD_ATTACHMENT')) ? 'topics.topic_attachment' : 0), ''),
506                  array('topic_title',            'topics.topic_title',                'phpbb_set_encoding'),
507                  array('topic_time',                'topics.topic_time',                ''),
508                  array('topic_views',            'topics.topic_views',                ''),
509                  array('topic_replies',            'topics.topic_replies',                ''),
510                  array('topic_replies_real',        'topics.topic_replies',                ''),
511                  array('topic_last_post_id',        'topics.topic_last_post_id',        ''),
512                  array('topic_status',            ITEM_MOVED,                            ''),
513                  array('topic_moved_id',            'topics.topic_moved_id',            ''),
514                  array('topic_type',                'topics.topic_type',                'phpbb_convert_topic_type'),
515                  array('topic_first_post_id',    'topics.topic_first_post_id',        ''),
516   
517                  array('poll_title',                'vote_desc.vote_text',                array('function1' => 'null_to_str', 'function2' => 'phpbb_set_encoding', 'function3' => 'utf8_htmlspecialchars')),
518                  array('poll_start',                'vote_desc.vote_start',                'null_to_zero'),
519                  array('poll_length',            'vote_desc.vote_length',            'null_to_zero'),
520                  array('poll_max_options',        1,                                    ''),
521                  array('poll_vote_change',        0,                                    ''),
522   
523                  'left_join'        => 'topics LEFT JOIN vote_desc ON topics.topic_id = vote_desc.topic_id AND topics.topic_vote = 1',
524                  'where'            => 'topics.topic_moved_id <> 0',
525              ),
526   
527              array(
528                  'target'        => TOPICS_WATCH_TABLE,
529                  'primary'        => 'topics_watch.topic_id',
530                  'query_first'    => array('target', $convert->truncate_statement . TOPICS_WATCH_TABLE),
531   
532                  array('topic_id',                'topics_watch.topic_id',            ''),
533                  array('user_id',                'topics_watch.user_id',                'phpbb_user_id'),
534                  array('notify_status',            'topics_watch.notify_status',        ''),
535              ),
536   
537              array(
538                  'target'        => SMILIES_TABLE,
539                  'query_first'    => array('target', $convert->truncate_statement . SMILIES_TABLE),
540                  'autoincrement'    => 'smiley_id',
541   
542                  array('smiley_id',                'smilies.smilies_id',                ''),
543                  array('code',                    'smilies.code',                        array('function1' => 'phpbb_smilie_html_decode', 'function2' => 'phpbb_set_encoding', 'function3' => 'utf8_htmlspecialchars')),
544                  array('emotion',                'smilies.emoticon',                    'phpbb_set_encoding'),
545                  array('smiley_url',                'smilies.smile_url',                'import_smiley'),
546                  array('smiley_width',            'smilies.smile_url',                'get_smiley_width'),
547                  array('smiley_height',            'smilies.smile_url',                'get_smiley_height'),
548                  array('smiley_order',            'smilies.smilies_id',                ''),
549                  array('display_on_posting',        'smilies.smilies_id',                'get_smiley_display'),
550   
551                  'order_by'        => 'smilies.smilies_id ASC',
552              ),
553   
554              array(
555                  'target'        => POLL_OPTIONS_TABLE,
556                  'primary'        => 'vote_results.vote_option_id',
557                  'query_first'    => array('target', $convert->truncate_statement . POLL_OPTIONS_TABLE),
558   
559                  array('poll_option_id',            'vote_results.vote_option_id',        ''),
560                  array('topic_id',                'vote_desc.topic_id',                ''),
561                  array('',                        'topics.topic_poster AS poster_id',    'phpbb_user_id'),
562                  array('poll_option_text',        'vote_results.vote_option_text',    array('function1' => 'phpbb_set_encoding', 'function2' => 'utf8_htmlspecialchars')),
563                  array('poll_option_total',        'vote_results.vote_result',            ''),
564   
565                  'where'            => 'vote_results.vote_id = vote_desc.vote_id',
566                  'left_join'        => 'vote_desc LEFT JOIN topics ON topics.topic_id = vote_desc.topic_id',
567              ),
568   
569              array(
570                  'target'        => POLL_VOTES_TABLE,
571                  'primary'        => 'vote_desc.topic_id',
572                  'query_first'    => array('target', $convert->truncate_statement . POLL_VOTES_TABLE),
573   
574                  array('poll_option_id',            VOTE_CONVERTED,                        ''),
575                  array('topic_id',                'vote_desc.topic_id',                ''),
576                  array('vote_user_id',            'vote_voters.vote_user_id',            'phpbb_user_id'),
577                  array('vote_user_ip',            'vote_voters.vote_user_ip',            'decode_ip'),
578   
579                  'where'            => 'vote_voters.vote_id = vote_desc.vote_id',
580              ),
581   
582              array(
583                  'target'        => WORDS_TABLE,
584                  'primary'        => 'words.word_id',
585                  'query_first'    => array('target', $convert->truncate_statement . WORDS_TABLE),
586                  'autoincrement'    => 'word_id',
587   
588                  array('word_id',                'words.word_id',                    ''),
589                  array('word',                    'words.word',                        'phpbb_set_encoding'),
590                  array('replacement',            'words.replacement',                'phpbb_set_encoding'),
591              ),
592   
593              array(
594                  'target'        => POSTS_TABLE,
595                  'primary'        => 'posts.post_id',
596                  'autoincrement'    => 'post_id',
597                  'query_first'    => array('target', $convert->truncate_statement . POSTS_TABLE),
598                  'execute_first'    => '
599                      $config["max_post_chars"] = 0;
600                      $config["max_quote_depth"] = 0;
601                  ',
602   
603                  array('post_id',                'posts.post_id',                    ''),
604                  array('topic_id',                'posts.topic_id',                    ''),
605                  array('forum_id',                'posts.forum_id',                    ''),
606                  array('poster_id',                'posts.poster_id',                    'phpbb_user_id'),
607                  array('icon_id',                0,                                    ''),
608                  array('poster_ip',                'posts.poster_ip',                    'decode_ip'),
609                  array('post_time',                'posts.post_time',                    ''),
610                  array('enable_bbcode',            'posts.enable_bbcode',                ''),
611                  array('',                        'posts.enable_html',                ''),
612                  array('enable_smilies',            'posts.enable_smilies',                ''),
613                  array('enable_sig',                'posts.enable_sig',                    ''),
614                  array('enable_magic_url',        1,                                    ''),
615                  array('post_username',            'posts.post_username',                'phpbb_set_encoding'),
616                  array('post_subject',            'posts_text.post_subject',            'phpbb_set_encoding'),
617                  array('post_attachment',        ((defined('MOD_ATTACHMENT')) ? 'posts.post_attachment' : 0), ''),
618                  array('post_edit_time',            'posts.post_edit_time',                array('typecast' => 'int')),
619                  array('post_edit_count',        'posts.post_edit_count',            ''),
620                  array('post_edit_reason',        '',                                    ''),
621                  array('post_edit_user',            '',                                    'phpbb_post_edit_user'),
622   
623                  array('bbcode_uid',                'posts.post_time',                    'make_uid'),
624                  array('post_text',                'posts_text.post_text',                'phpbb_prepare_message'),
625                  array('',                        'posts_text.bbcode_uid AS old_bbcode_uid',            ''),
626                  array('bbcode_bitfield',        '',                                    'get_bbcode_bitfield'),
627                  array('post_checksum',            '',                                    ''),
628   
629                  // Commented out inline search indexing, this takes up a LOT of time. :D
630                  // @todo We either need to enable this or call the rebuild search functionality post convert
631  /*                array('',                        '',                                    'search_indexing'),
632                  array('',                        'posts_text.post_text AS message',    ''),
633                  array('',                        'posts_text.post_subject AS title',    ''),*/
634   
635                  'where'            =>    'posts.post_id = posts_text.post_id'
636              ),
637   
638              array(
639                  'target'        => PRIVMSGS_TABLE,
640                  'primary'        => 'privmsgs.privmsgs_id',
641                  'autoincrement'    => 'msg_id',
642                  'query_first'    => array(
643                      array('target', $convert->truncate_statement . PRIVMSGS_TABLE),
644                      array('target', $convert->truncate_statement . PRIVMSGS_RULES_TABLE),
645                  ),
646   
647                  'execute_first'    => '
648                      $config["max_post_chars"] = 0;
649                      $config["max_quote_depth"] = 0;
650                  ',
651   
652                  array('msg_id',                    'privmsgs.privmsgs_id',                ''),
653                  array('root_level',                0,                                    ''),
654                  array('author_id',                'privmsgs.privmsgs_from_userid AS poster_id',    'phpbb_user_id'),
655                  array('icon_id',                0,                                    ''),
656                  array('author_ip',                'privmsgs.privmsgs_ip',                'decode_ip'),
657                  array('message_time',            'privmsgs.privmsgs_date',            ''),
658                  array('enable_bbcode',            'privmsgs.privmsgs_enable_bbcode AS enable_bbcode',    ''),
659                  array('',                        'privmsgs.privmsgs_enable_html AS enable_html',    ''),
660                  array('enable_smilies',            'privmsgs.privmsgs_enable_smilies AS enable_smilies',    ''),
661                  array('enable_magic_url',        1,                                    ''),
662                  array('enable_sig',                'privmsgs.privmsgs_attach_sig',        ''),
663                  array('message_subject',        'privmsgs.privmsgs_subject',        'phpbb_set_encoding'), // Already specialchared in 2.0.x
664                  array('message_attachment',        ((defined('MOD_ATTACHMENT')) ? 'privmsgs.privmsgs_attachment' : 0), ''),
665                  array('message_edit_reason',    '',                                    ''),
666                  array('message_edit_user',        0,                                    ''),
667                  array('message_edit_time',        0,                                    ''),
668                  array('message_edit_count',        0,                                    ''),
669   
670                  array('bbcode_uid',                'privmsgs.privmsgs_date AS post_time',    'make_uid'),
671                  array('message_text',            'privmsgs_text.privmsgs_text',            'phpbb_prepare_message'),
672                  array('',                        'privmsgs_text.privmsgs_bbcode_uid AS old_bbcode_uid',            ''),
673                  array('bbcode_bitfield',        '',                                        'get_bbcode_bitfield'),
674                  array('to_address',                'privmsgs.privmsgs_to_userid',            'phpbb_privmsgs_to_userid'),
675                  array('bcc_address',            '',                                        ''),
676   
677                  'where'            =>    'privmsgs.privmsgs_id = privmsgs_text.privmsgs_text_id'
678              ),
679   
680              array(
681                  'target'        => PRIVMSGS_FOLDER_TABLE,
682                  'primary'        => 'users.user_id',
683                  'query_first'    => array('target', $convert->truncate_statement . PRIVMSGS_FOLDER_TABLE),
684   
685                  array('user_id',                'users.user_id',                        'phpbb_user_id'),
686                  array('folder_name',            $user->lang['CONV_SAVED_MESSAGES'],        ''),
687                  array('pm_count',                0,                                        ''),
688              
689                  'where'            => 'users.user_id <> -1',
690              ),
691   
692              // Inbox
693              array(
694                  'target'        => PRIVMSGS_TO_TABLE,
695                  'primary'        => 'privmsgs.privmsgs_id',
696                  'query_first'    => array('target', $convert->truncate_statement . PRIVMSGS_TO_TABLE),
697   
698                  array('msg_id',                    'privmsgs.privmsgs_id',                    ''),
699                  array('user_id',                'privmsgs.privmsgs_to_userid',            'phpbb_user_id'),
700                  array('author_id',                'privmsgs.privmsgs_from_userid',        'phpbb_user_id'),
701                  array('pm_deleted',                0,                                        ''),
702                  array('pm_new',                    'privmsgs.privmsgs_type',                'phpbb_new_pm'),
703                  array('pm_unread',                'privmsgs.privmsgs_type',                'phpbb_unread_pm'),
704                  array('pm_replied',                0,                                        ''),
705                  array('pm_marked',                0,                                        ''),
706                  array('pm_forwarded',            0,                                        ''),
707                  array('folder_id',                PRIVMSGS_INBOX,                            ''),
708   
709                  'where'            => 'privmsgs.privmsgs_id = privmsgs_text.privmsgs_text_id
710                                          AND (privmsgs.privmsgs_type = 0 OR privmsgs.privmsgs_type = 1 OR privmsgs.privmsgs_type = 5)',
711              ),
712              
713              // Outbox
714              array(
715                  'target'        => PRIVMSGS_TO_TABLE,
716                  'primary'        => 'privmsgs.privmsgs_id',
717   
718                  array('msg_id',                    'privmsgs.privmsgs_id',                    ''),
719                  array('user_id',                'privmsgs.privmsgs_from_userid',        'phpbb_user_id'),
720                  array('author_id',                'privmsgs.privmsgs_from_userid',        'phpbb_user_id'),
721                  array('pm_deleted',                0,                                        ''),
722                  array('pm_new',                    0,                                        ''),
723                  array('pm_unread',                0,                                        ''),
724                  array('pm_replied',                0,                                        ''),
725                  array('pm_marked',                0,                                        ''),
726                  array('pm_forwarded',            0,                                        ''),
727                  array('folder_id',                PRIVMSGS_OUTBOX,                        ''),
728   
729                  'where'            => 'privmsgs.privmsgs_id = privmsgs_text.privmsgs_text_id
730                                          AND (privmsgs.privmsgs_type = 1 OR privmsgs.privmsgs_type = 5)',
731              ),
732   
733              // Sentbox
734              array(
735                  'target'        => PRIVMSGS_TO_TABLE,
736                  'primary'        => 'privmsgs.privmsgs_id',
737   
738                  array('msg_id',                    'privmsgs.privmsgs_id',                    ''),
739                  array('user_id',                'privmsgs.privmsgs_from_userid',        'phpbb_user_id'),
740                  array('author_id',                'privmsgs.privmsgs_from_userid',        'phpbb_user_id'),
741                  array('pm_deleted',                0,                                        ''),
742                  array('pm_new',                    'privmsgs.privmsgs_type',                'phpbb_new_pm'),
743                  array('pm_unread',                'privmsgs.privmsgs_type',                'phpbb_unread_pm'),
744                  array('pm_replied',                0,                                        ''),
745                  array('pm_marked',                0,                                        ''),
746                  array('pm_forwarded',            0,                                        ''),
747                  array('folder_id',                PRIVMSGS_SENTBOX,                        ''),
748   
749                  'where'            => 'privmsgs.privmsgs_id = privmsgs_text.privmsgs_text_id
750                                          AND privmsgs.privmsgs_type = 2',
751              ),
752   
753              // Savebox (SAVED IN)
754              array(
755                  'target'        => PRIVMSGS_TO_TABLE,
756                  'primary'        => 'privmsgs.privmsgs_id',
757   
758                  array('msg_id',                    'privmsgs.privmsgs_id',                    ''),
759                  array('user_id',                'privmsgs.privmsgs_to_userid',            'phpbb_user_id'),
760                  array('author_id',                'privmsgs.privmsgs_from_userid',        'phpbb_user_id'),
761                  array('pm_deleted',                0,                                        ''),
762                  array('pm_new',                    'privmsgs.privmsgs_type',                'phpbb_new_pm'),
763                  array('pm_unread',                'privmsgs.privmsgs_type',                'phpbb_unread_pm'),
764                  array('pm_replied',                0,                                        ''),
765                  array('pm_marked',                0,                                        ''),
766                  array('pm_forwarded',            0,                                        ''),
767                  array('folder_id',                'privmsgs.privmsgs_to_userid',            'phpbb_get_savebox_id'),
768   
769                  'where'            => 'privmsgs.privmsgs_id = privmsgs_text.privmsgs_text_id
770                                          AND privmsgs.privmsgs_type = 3',
771              ),
772   
773              // Savebox (SAVED OUT)
774              array(
775                  'target'        => PRIVMSGS_TO_TABLE,
776                  'primary'        => 'privmsgs.privmsgs_id',
777   
778                  array('msg_id',                    'privmsgs.privmsgs_id',                    ''),
779                  array('user_id',                'privmsgs.privmsgs_from_userid',        'phpbb_user_id'),
780                  array('author_id',                'privmsgs.privmsgs_from_userid',        'phpbb_user_id'),
781                  array('pm_deleted',                0,                                        ''),
782                  array('pm_new',                    'privmsgs.privmsgs_type',                'phpbb_new_pm'),
783                  array('pm_unread',                'privmsgs.privmsgs_type',                'phpbb_unread_pm'),
784                  array('pm_replied',                0,                                        ''),
785                  array('pm_marked',                0,                                        ''),
786                  array('pm_forwarded',            0,                                        ''),
787                  array('folder_id',                'privmsgs.privmsgs_from_userid',        'phpbb_get_savebox_id'),
788   
789                  'where'            => 'privmsgs.privmsgs_id = privmsgs_text.privmsgs_text_id
790                                          AND privmsgs.privmsgs_type = 4',
791              ),
792   
793              array(
794                  'target'        => GROUPS_TABLE,
795                  'autoincrement'    => 'group_id',
796                  'query_first'    => array('target', $convert->truncate_statement . GROUPS_TABLE),
797   
798                  array('group_id',                'groups.group_id',                    ''),
799                  array('group_type',                'groups.group_type',                'phpbb_convert_group_type'),
800                  array('group_display',            0,                                    ''),
801                  array('group_legend',            0,                                    ''),
802                  array('group_name',                'groups.group_name',                'phpbb_convert_group_name'), // phpbb_set_encoding called in phpbb_convert_group_name
803                  array('group_desc',                'groups.group_description',            'phpbb_set_encoding'),
804   
805                  'where'            => 'groups.group_single_user = 0',
806              ),
807   
808              array(
809                  'target'        => USER_GROUP_TABLE,
810                  'query_first'    => array('target', $convert->truncate_statement . USER_GROUP_TABLE),
811                  'execute_first'    => '
812                      add_default_groups();
813                  ',
814   
815                  array('group_id',        'groups.group_id',                    ''),
816                  array('user_id',        'groups.group_moderator',            'phpbb_user_id'),
817                  array('group_leader',    1,                                    ''),
818                  array('user_pending',    0,                                    ''),
819   
820                  'where'            => 'groups.group_single_user = 0 AND groups.group_moderator <> 0',
821              ),
822   
823              array(
824                  'target'        => USER_GROUP_TABLE,
825   
826                  array('group_id',        'user_group.group_id',                ''),
827                  array('user_id',        'user_group.user_id',                'phpbb_user_id'),
828                  array('group_leader',    0,                                    ''),
829                  array('user_pending',    'user_group.user_pending',            ''),
830   
831                  'where'            => 'user_group.group_id = groups.group_id AND groups.group_single_user = 0 AND groups.group_moderator <> user_group.user_id',
832              ),
833   
834              array(
835                  'target'        => USERS_TABLE,
836                  'primary'        => 'users.user_id',
837                  'autoincrement'    => 'user_id',
838                  'query_first'    => array(
839                      array('target', 'DELETE FROM ' . USERS_TABLE . ' WHERE user_id <> ' . ANONYMOUS),
840                      array('target', $convert->truncate_statement . BOTS_TABLE)
841                  ),
842   
843                  'execute_last'    => '
844                      remove_invalid_users();
845                  ',
846   
847                  array('user_id',                'users.user_id',                    'phpbb_user_id'),
848                  array('',                        'users.user_id AS poster_id',        'phpbb_user_id'),
849                  array('user_type',                'users.user_active',                'set_user_type'),
850                  array('group_id',                'users.user_level',                    'phpbb_set_primary_group'),
851                  array('user_regdate',            'users.user_regdate',                ''),
852                  array('username',                'users.username',                    'phpbb_set_default_encoding'), // recode to utf8 with default lang
853                  array('username_clean',            'users.username',                    array('function1' => 'phpbb_set_default_encoding', 'function2' => 'utf8_clean_string')),
854                  array('user_password',            'users.user_password',                ''),
855                  array('user_pass_convert',        1,                                    ''),
856                  array('user_posts',                'users.user_posts',                    'intval'),
857                  array('user_email',                'users.user_email',                    'strtolower'),
858                  array('user_email_hash',        'users.user_email',                    'gen_email_hash'),
859                  array('user_birthday',            ((defined('MOD_BIRTHDAY')) ? 'users.user_birthday' : ''),    'phpbb_get_birthday'),
860                  array('user_lastvisit',            'users.user_lastvisit',                'intval'),
861                  array('user_lastmark',            'users.user_lastvisit',                'intval'),
862                  array('user_lang',                $config['default_lang'],            ''),
863                  array('',                        'users.user_lang',                    ''),
864                  array('user_timezone',            'users.user_timezone',                'floatval'),
865                  array('user_dateformat',        'users.user_dateformat',            array('function1' => 'phpbb_set_encoding', 'function2' => 'fill_dateformat')),
866                  array('user_inactive_reason',    '',                                    'phpbb_inactive_reason'),
867                  array('user_inactive_time',        '',                                    'phpbb_inactive_time'),
868   
869                  array('user_interests',            'users.user_interests',                array('function1' => 'phpbb_set_encoding')),
870                  array('user_occ',                'users.user_occ',                    array('function1' => 'phpbb_set_encoding')),
871                  array('user_website',            'users.user_website',                'validate_website'),
872                  array('user_jabber',            '',                                    ''),
873                  array('user_msnm',                'users.user_msnm',                    array('function1' => 'phpbb_set_encoding')),
874                  array('user_yim',                'users.user_yim',                    array('function1' => 'phpbb_set_encoding')),
875                  array('user_aim',                'users.user_aim',                    array('function1' => 'phpbb_set_encoding')),
876                  array('user_icq',                'users.user_icq',                    array('function1' => 'phpbb_set_encoding')),
877                  array('user_from',                'users.user_from',                    array('function1' => 'phpbb_set_encoding')),
878                  array('user_rank',                'users.user_rank',                    'intval'),
879                  array('user_permissions',        '',                                    ''),
880   
881                  array('user_avatar',            'users.user_avatar',                'phpbb_import_avatar'),
882                  array('user_avatar_type',        'users.user_avatar_type',            'phpbb_avatar_type'),
883                  array('user_avatar_width',        'users.user_avatar',                'phpbb_get_avatar_width'),
884                  array('user_avatar_height',        'users.user_avatar',                'phpbb_get_avatar_height'),
885   
886                  array('user_new_privmsg',        'users.user_new_privmsg',            ''),
887                  array('user_unread_privmsg',    0,                                    ''), //'users.user_unread_privmsg'
888                  array('user_last_privmsg',        'users.user_last_privmsg',            'intval'),
889                  array('user_emailtime',            'users.user_emailtime',                'null_to_zero'),
890                  array('user_notify',            'users.user_notify',                'intval'),
891                  array('user_notify_pm',            'users.user_notify_pm',                'intval'),
892                  array('user_notify_type',        NOTIFY_EMAIL,                        ''),
893                  array('user_allow_pm',            'users.user_allow_pm',                'intval'),
894                  array('user_allow_viewonline',    'users.user_allow_viewonline',        'intval'),
895                  array('user_allow_viewemail',    'users.user_viewemail',                'intval'),
896                  array('user_actkey',            'users.user_actkey',                ''),
897                  array('user_newpasswd',            '',                                    ''), // Users need to re-request their password...
898                  array('user_style',                $config['default_style'],            ''),
899   
900                  array('user_options',            '',                                    'set_user_options'),
901                  array('',                        'users.user_popup_pm AS popuppm',    ''),
902                  array('',                        'users.user_allowhtml AS html',        ''),
903                  array('',                        'users.user_allowbbcode AS bbcode',    ''),
904                  array('',                        'users.user_allowsmile AS smile',    ''),
905                  array('',                        'users.user_attachsig AS attachsig',''),
906   
907                  array('user_sig_bbcode_uid',        'users.user_regdate',                            'make_uid'),
908                  array('user_sig',                    'users.user_sig',                                'phpbb_prepare_message'),
909                  array('',                            'users.user_sig_bbcode_uid AS old_bbcode_uid',    ''),
910                  array('user_sig_bbcode_bitfield',    '',                                                'get_bbcode_bitfield'),
911                  array('',                            'users.user_regdate AS post_time',                ''),
912   
913                  'where'            => 'users.user_id <> -1',
914              ),
915          ),
916      );
917  }
918   
919  ?>