b2evolution PHP Cross Reference Blogging Systems

Source: /inc/tools/phpbbimport.ctrl.php - 231 lines - 7069 bytes - Text - Print

Description: This file implements the UI controller for phpBB importer. b2evolution - {@link http://b2evolution.net/} Released under GNU GPL License - {@link http://b2evolution.net/about/license.html}

   1  <?php
   2  /**

   3   * This file implements the UI controller for phpBB importer.

   4   *

   5   * b2evolution - {@link http://b2evolution.net/}

   6   * Released under GNU GPL License - {@link http://b2evolution.net/about/license.html}

   7   * @copyright (c)2003-2014 by Francois Planque - {@link http://fplanque.com/}

   8   *

   9   * @package admin

  10   * @author fplanque: Francois PLANQUE.

  11   *

  12   * @version $Id: phpbbimport.ctrl.php 74 2011-10-26 13:49:38Z fplanque $

  13   */
  14  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  15  
  16  load_funcs( 'tools/model/_phpbb.funcs.php' );
  17  
  18  param( 'action', 'string' );
  19  
  20  if( !empty( $action ) )
  21  {    // Try to obtain some serious time to do some serious processing (15 minutes)
  22      set_max_execution_time( 900 );
  23      // Turn off the output buffering to do the correct work of the function flush()

  24      @ini_set( 'output_buffering', 'off' );
  25  }
  26  
  27  /**

  28   * @var step

  29   *

  30   * values:

  31   * 1) 'config'

  32   * 2) 'groups'

  33   * 3) 'users'

  34   * 4) 'forums' -> categories

  35   * 5) 'topics' -> posts

  36   * 6) 'replies' -> comments

  37   * 7) 'messages'

  38   */
  39  $step = param( 'step', 'string', 'config' );
  40  
  41  
  42  // Initialize the config variables for phpBB

  43  phpbb_init_config();
  44  
  45  switch( $action )
  46  {
  47      case 'database':    // Action for Step 1
  48          // Check that this action request is not a CSRF hacked request:

  49          $Session->assert_received_crumb( 'phpbb' );
  50  
  51          $phpbb_db_host = param( 'db_host', 'string', true );
  52          $phpbb_db_name = param( 'db_name', 'string', true );
  53          $phpbb_db_user = param( 'db_user', 'string', true );
  54          $phpbb_db_pass = param( 'db_pass', 'string', true );
  55          $phpbb_db_prefix = param( 'db_prefix', 'string', '' );
  56          $phpbb_path_avatars = param( 'path_avatars', 'string', '' );
  57          $forum_blog_ID = param( 'forum_blog_ID', 'integer', 0 );
  58  
  59          param_check_not_empty( 'db_host', T_('Please enter a database host!') );
  60          param_check_not_empty( 'db_name', T_('Please enter a database name!') );
  61          param_check_not_empty( 'db_user', T_('Please enter a username!') );
  62          param_check_not_empty( 'db_pass', T_('Please enter a password!') );
  63          param_check_not_empty( 'forum_blog_ID', T_('Please select a blog!') );
  64  
  65          if( param_errors_detected() )
  66          {
  67              break;
  68          }
  69  
  70          $phpbb_db_config = array(
  71                  'user'     => $phpbb_db_user,
  72                  'password' => $phpbb_db_pass,
  73                  'name'     => $phpbb_db_name,
  74                  'host'     => $phpbb_db_host,
  75                  'prefix'   => $phpbb_db_prefix,
  76                  'aliases'  => phpbb_tables_aliases( $phpbb_db_prefix ),
  77                  'use_transactions'   => $db_config['use_transactions'],
  78                  'table_options'      => $db_config['table_options'],
  79                  'connection_charset' => $DB->connection_charset,        // Use same charset as main DB connection so that charsets match!
  80                  'halt_on_error' => false,
  81                  'show_errors'   => false,
  82                  'new_link'      => true,
  83  
  84                  'log_queries' => true,
  85                  'debug_dump_rows' => 20,
  86              );
  87  
  88          // Test connect to DB:

  89          $phpbb_DB = new DB( $phpbb_db_config );
  90          unset( $phpbb_db_config['aliases'] );
  91  
  92          if( $phpbb_DB->error )
  93          {
  94              $Messages->add( $phpbb_DB->last_error, 'error' );
  95              break;
  96          }
  97  
  98          // Save DB config of phpBB in the session

  99          phpbb_set_var( 'db_config', $phpbb_db_config );
 100          phpbb_set_var( 'blog_ID', $forum_blog_ID );
 101          phpbb_set_var( 'path_avatars', $phpbb_path_avatars );
 102  
 103          $step = 'groups';
 104          break;
 105  
 106      case "users":    // Action for Step 2
 107          // Check that this action request is not a CSRF hacked request:

 108          $Session->assert_received_crumb( 'phpbb' );
 109  
 110          $phpbb_ranks = param( 'phpbb_ranks', 'array/integer', array() );
 111          $phpbb_group_default = param( 'phpbb_group_default', 'integer' );
 112          $phpbb_group_invalid = param( 'phpbb_group_invalid', 'integer' );
 113  
 114          param_check_not_empty( 'phpbb_group_default', T_('Please select a default group!') );
 115  
 116          phpbb_set_var( 'ranks', $phpbb_ranks );
 117          phpbb_set_var( 'group_default', $phpbb_group_default );
 118          phpbb_set_var( 'group_invalid', $phpbb_group_invalid );
 119  
 120          $phpbb_categories = param( 'phpbb_categories', 'array/integer', array() );
 121          $phpbb_forums = param( 'phpbb_forums', 'array/integer', array() );
 122          phpbb_set_var( 'import_categories', $phpbb_categories );
 123          phpbb_set_var( 'import_forums', $phpbb_forums );
 124  
 125          if( empty( $phpbb_categories ) && empty( $phpbb_forums ) )
 126          {
 127              $Messages->add( T_('Please select at least one forum to import!') );
 128          }
 129  
 130          if( param_errors_detected() )
 131          {
 132              $step = 'groups';
 133              break;
 134          }
 135  
 136          // Set this action to complete all processes in the form

 137          $flush_action = 'users';
 138  
 139          $step = 'users';
 140          break;
 141  
 142      case 'forums':    // Action for Step 3
 143      case 'topics':    // Action for Step 4
 144      case 'replies':    // Action for Step 5
 145      case 'messages':    // Action for Step 6
 146          // Check that this action request is not a CSRF hacked request:

 147          $Session->assert_received_crumb( 'phpbb' );
 148  
 149          // Set this action to complete all processes in the form

 150          $flush_action = $action;
 151  
 152          $step = $action;
 153          break;
 154  
 155      case 'finish':    // Action for last step
 156          // Check that this action request is not a CSRF hacked request:

 157          $Session->assert_received_crumb( 'phpbb' );
 158  
 159          $BlogCache = & get_BlogCache();
 160          $Blog = & $BlogCache->get_by_ID( phpbb_get_var( 'blog_ID' ) );
 161  
 162          phpbb_clear_temporary_data();
 163  
 164          // Redirect to Blog

 165          header_redirect( $Blog->get( 'url' ) );
 166          break;
 167  }
 168  
 169  
 170  // Highlight the requested tab (if valid):

 171  $AdminUI->set_path( 'options', 'misc', 'import' );
 172  
 173  $AdminUI->breadcrumbpath_init( false );
 174  $AdminUI->breadcrumbpath_add( T_('System'), '?ctrl=system' );
 175  $AdminUI->breadcrumbpath_add( T_('Maintenance'), '?ctrl=tools' );
 176  $AdminUI->breadcrumbpath_add( T_('Import'), '?ctrl=tools&amp;tab3=import' );
 177  $AdminUI->breadcrumbpath_add( T_('phpBB Importer'), '?ctrl=phpbbimport' );
 178  
 179  
 180  // Display <html><head>...</head> section! (Note: should be done early if actions do not redirect)

 181  $AdminUI->disp_html_head();
 182  
 183  // Display title, menu, messages, etc. (Note: messages MUST be displayed AFTER the actions)

 184  $AdminUI->disp_body_top();
 185  
 186  // Begin payload block:

 187  $AdminUI->disp_payload_begin();
 188  
 189  switch( $step )
 190  {
 191      case 'groups':    // Step 2
 192          phpbb_unset_var( 'current_step' );
 193          $AdminUI->disp_view( 'tools/views/_phpbb_groups.form.php' );
 194          // $phpbb_DB->dump_queries();

 195          break;
 196  
 197      case 'users':    // Step 3
 198          $AdminUI->disp_view( 'tools/views/_phpbb_users.form.php' );
 199          break;
 200  
 201      case 'forums':    // Step 4
 202          $AdminUI->disp_view( 'tools/views/_phpbb_forums.form.php' );
 203          break;
 204  
 205      case 'topics':    // Step 5
 206          $AdminUI->disp_view( 'tools/views/_phpbb_topics.form.php' );
 207          break;
 208  
 209      case 'replies':    // Step 6
 210          $AdminUI->disp_view( 'tools/views/_phpbb_replies.form.php' );
 211          break;
 212  
 213      case 'messages':    // Step 7
 214          $AdminUI->disp_view( 'tools/views/_phpbb_messages.form.php' );
 215          break;
 216  
 217      case 'config':    // Step 1
 218      default:
 219          phpbb_unset_var( 'current_step' );
 220          $AdminUI->disp_view( 'tools/views/_phpbb_config.form.php' );
 221          break;
 222  }
 223  
 224  
 225  // End payload block:

 226  $AdminUI->disp_payload_end();
 227  
 228  // Display body bottom, debug info and close </html>:

 229  $AdminUI->disp_global_footer();
 230  
 231  ?>

title

Description

title

Description

title

Description

title

title

Body