b2evolution PHP Cross Reference Blogging Systems

Source: /inc/tools/wpimportxml.ctrl.php - 103 lines - 2901 bytes - Text - Print

Description: This file implements the UI controller for Wordpress XML 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 Wordpress XML 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: wpimportxml.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/_wp.funcs.php' );
  17  
  18  /**

  19   * @var action

  20   *

  21   * values:

  22   * 1) 'file'

  23   * 2) 'import'

  24   */
  25  param( 'action', 'string' );
  26  
  27  if( !empty( $action ) )
  28  {    // Try to obtain some serious time to do some serious processing (15 minutes)
  29      set_max_execution_time( 900 );
  30      // Turn off the output buffering to do the correct work of the function flush()

  31      @ini_set( 'output_buffering', 'off' );
  32  }
  33  
  34  
  35  switch( $action )
  36  {
  37      case 'import':
  38          // Check that this action request is not a CSRF hacked request:

  39          $Session->assert_received_crumb( 'wpxml' );
  40  
  41          $wp_blog_ID = param( 'wp_blog_ID', 'integer', 0 );
  42          param_check_not_empty( 'wp_blog_ID', T_('Please select a blog!') );
  43  
  44          // XML File

  45          $xml_file = param( 'wp_file', 'string', '' );
  46          if( empty( $xml_file ) )
  47          { // File is not selected
  48              param_error( 'wp_file', T_('Please select file to import.') );
  49          }
  50          else if( ! preg_match( '/\.(xml|txt|zip)$/i', $xml_file ) )
  51          { // Extension is incorrect
  52              param_error( 'wp_file', sprintf( T_('&laquo;%s&raquo; has an unrecognized extension.'), $xml_file ) );
  53          }
  54  
  55          if( param_errors_detected() )
  56          { // Stop import if errors exist
  57              $action = 'file';
  58              break;
  59          }
  60  
  61          break;
  62  }
  63  
  64  
  65  // Highlight the requested tab (if valid):

  66  $AdminUI->set_path( 'options', 'misc', 'import' );
  67  
  68  $AdminUI->breadcrumbpath_init( false );
  69  $AdminUI->breadcrumbpath_add( T_('System'), '?ctrl=system' );
  70  $AdminUI->breadcrumbpath_add( T_('Maintenance'), '?ctrl=tools' );
  71  $AdminUI->breadcrumbpath_add( T_('Import'), '?ctrl=tools&amp;tab3=import' );
  72  $AdminUI->breadcrumbpath_add( T_('WordPress XML Importer'), '?ctrl=wpimportxml' );
  73  
  74  
  75  // Display <html><head>...</head> section! (Note: should be done early if actions do not redirect)

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

  79  $AdminUI->disp_body_top();
  80  
  81  // Begin payload block:

  82  $AdminUI->disp_payload_begin();
  83  
  84  switch( $action )
  85  {
  86      case 'import':    // Step 2
  87          $AdminUI->disp_view( 'tools/views/_wpxml_import.form.php' );
  88          break;
  89  
  90      case 'file':    // Step 1
  91      default:
  92          $AdminUI->disp_view( 'tools/views/_wpxml_file.form.php' );
  93          break;
  94  }
  95  
  96  
  97  // End payload block:

  98  $AdminUI->disp_payload_end();
  99  
 100  // Display body bottom, debug info and close </html>:

 101  $AdminUI->disp_global_footer();
 102  
 103  ?>

title

Description

title

Description

title

Description

title

title

Body