/**
  * Processes step2
  * User confirms the settings, so we now do the import
  * @throws Exception
  */
 function processStep2()
 {
     // Only process with POST
     if (!empty($_POST)) {
         // Validate the nonce
         if (isset($_POST['_drupal2wp_nonce'])) {
             if (wp_verify_nonce($_POST['_drupal2wp_nonce'], 'drupal2wp-step2-nonce')) {
                 $importOptions = isset($_POST['options']) ? $_POST['options'] : array();
                 if (!empty($importOptions)) {
                     // Save to session
                     $_SESSION['options'] = $importOptions;
                     // Init the Drupal importer
                     $this->_drupalImporter = new Drupal2WordPress_DrupalImporter();
                     // Check the DB connection
                     if (!$this->_drupalImporter->check()) {
                         throw new Exception('Failed to connect to the Drupal database.');
                     } else {
                         // Process step2
                         $this->nextStep = 3;
                     }
                 } else {
                     // Process step2
                     $this->nextStep = 2;
                     throw new Exception(__('No import options selected.', 'drupal2wp'));
                 }
             } else {
                 throw new Exception(__('Form validation failed.', 'drupal2wp'));
             }
         } else {
             do_action('drupal2wp_view_step2_submit', $this);
         }
     }
 }
 /**
  * Gets the singleton instance
  * @return Drupal2WordPress_DrupalImporter
  */
 public static function getInstance()
 {
     if (!isset(self::$instance)) {
         self::$instance = new self();
     }
     return self::$instance;
 }
 /**
  * Construct the plugin
  * Adds the admin menu
  */
 public function __construct()
 {
     // Only process if in admin
     if (is_admin()) {
         // Add admin menu
         add_action('admin_menu', array($this, 'addMenuItem'));
         // Use a session so we can store the db details (safer than a cookie)
         // @todo use an encrypted cookie instead
         if (!session_id()) {
             session_start();
         }
         // Validate the iframe nonce
         if (isset($_GET['_drupal2wp_wpnonce']) && wp_verify_nonce($_GET['_drupal2wp_wpnonce'], 'drupal2wp_import_iframe')) {
             Drupal2WordPress_DrupalImporter::process();
         }
     }
 }