/** * Callback processor * * @since bbPress (r3813) */ public function process_callback() { // Verify intent check_ajax_referer('bbp_converter_process'); if (!ini_get('safe_mode')) { set_time_limit(0); ini_set('memory_limit', '256M'); ini_set('implicit_flush', '1'); ignore_user_abort(true); } // Save step and count so that it can be restarted. if (!get_option('_bbp_converter_step') || !empty($_POST['_bbp_converter_restart'])) { update_option('_bbp_converter_step', 1); update_option('_bbp_converter_start', 0); } $step = (int) get_option('_bbp_converter_step', 1); $min = (int) get_option('_bbp_converter_start', 0); $count = (int) (!empty($_POST['_bbp_converter_rows'])) ? $_POST['_bbp_converter_rows'] : 100; $max = $min + $count - 1; $start = $min; // Bail if platform did not get saved $platform = !empty($_POST['_bbp_converter_platform']) ? $_POST['_bbp_converter_platform'] : get_option('_bbp_converter_platform'); if (empty($platform)) { return; } // Include the appropriate converter. $converter = bbp_new_converter($platform); switch ($step) { // STEP 1. Clean all tables. case 1: if (!empty($_POST['_bbp_converter_clean'])) { if ($converter->clean($start)) { update_option('_bbp_converter_step', $step + 1); update_option('_bbp_converter_start', 0); $this->sync_table(true); if (empty($start)) { $this->converter_output(__('No data to clean', 'bbpress')); } } else { update_option('_bbp_converter_start', $max + 1); $this->converter_output(sprintf(__('Deleting previously converted data (%1$s - %2$s)', 'bbpress'), $min, $max)); } } else { update_option('_bbp_converter_step', $step + 1); update_option('_bbp_converter_start', 0); } break; // STEP 2. Convert users. // STEP 2. Convert users. case 2: if (!empty($_POST['_bbp_converter_convert_users'])) { if ($converter->convert_users($start)) { update_option('_bbp_converter_step', $step + 1); update_option('_bbp_converter_start', 0); if (empty($start)) { $this->converter_output(__('No users to convert', 'bbpress')); } } else { update_option('_bbp_converter_start', $max + 1); $this->converter_output(sprintf(__('Converting users (%1$s - %2$s)', 'bbpress'), $min, $max)); } } else { update_option('_bbp_converter_step', $step + 1); update_option('_bbp_converter_start', 0); } break; // STEP 3. Clean passwords. // STEP 3. Clean passwords. case 3: if (!empty($_POST['_bbp_converter_convert_users'])) { if ($converter->clean_passwords($start)) { update_option('_bbp_converter_step', $step + 1); update_option('_bbp_converter_start', 0); if (empty($start)) { $this->converter_output(__('No passwords to clear', 'bbpress')); } } else { update_option('_bbp_converter_start', $max + 1); $this->converter_output(sprintf(__('Delete users wordpress default passwords (%1$s - %2$s)', 'bbpress'), $min, $max)); } } else { update_option('_bbp_converter_step', $step + 1); update_option('_bbp_converter_start', 0); } break; // STEP 4. Convert forums. // STEP 4. Convert forums. case 4: if ($converter->convert_forums($start)) { update_option('_bbp_converter_step', $step + 1); update_option('_bbp_converter_start', 0); if (empty($start)) { $this->converter_output(__('No forums to convert', 'bbpress')); } } else { update_option('_bbp_converter_start', $max + 1); $this->converter_output(sprintf(__('Converting forums (%1$s - %2$s)', 'bbpress'), $min, $max)); } break; // STEP 5. Convert forum parents. // STEP 5. Convert forum parents. case 5: if ($converter->convert_forum_parents($start)) { update_option('_bbp_converter_step', $step + 1); update_option('_bbp_converter_start', 0); if (empty($start)) { $this->converter_output(__('No forum parents to convert', 'bbpress')); } } else { update_option('_bbp_converter_start', $max + 1); $this->converter_output(sprintf(__('Calculating forum hierarchy (%1$s - %2$s)', 'bbpress'), $min, $max)); } break; // STEP 6. Convert topics. // STEP 6. Convert topics. case 6: if ($converter->convert_topics($start)) { update_option('_bbp_converter_step', $step + 1); update_option('_bbp_converter_start', 0); if (empty($start)) { $this->converter_output(__('No topics to convert', 'bbpress')); } } else { update_option('_bbp_converter_start', $max + 1); $this->converter_output(sprintf(__('Converting topics (%1$s - %2$s)', 'bbpress'), $min, $max)); } break; // STEP 7. Convert tags. // STEP 7. Convert tags. case 7: if ($converter->convert_tags($start)) { update_option('_bbp_converter_step', $step + 1); update_option('_bbp_converter_start', 0); if (empty($start)) { $this->converter_output(__('No tags to convert', 'bbpress')); } } else { update_option('_bbp_converter_start', $max + 1); $this->converter_output(sprintf(__('Converting topic tags (%1$s - %2$s)', 'bbpress'), $min, $max)); } break; // STEP 8. Convert replies. // STEP 8. Convert replies. case 8: if ($converter->convert_replies($start)) { update_option('_bbp_converter_step', $step + 1); update_option('_bbp_converter_start', 0); if (empty($start)) { $this->converter_output(__('No replies to convert', 'bbpress')); } } else { update_option('_bbp_converter_start', $max + 1); $this->converter_output(sprintf(__('Converting replies (%1$s - %2$s)', 'bbpress'), $min, $max)); } break; default: delete_option('_bbp_converter_step'); delete_option('_bbp_converter_start'); delete_option('_bbp_converter_query'); $this->converter_output(__('Conversion Complete', 'bbpress')); break; } }
/** * Convert passwords from previous platfrom encryption to WordPress encryption. * * @since bbPress (r3813) * @global WPDB $wpdb */ function bbp_user_maybe_convert_pass() { // Bail if no username $username = !empty($_POST['log']) ? $_POST['log'] : ''; if (empty($username)) { return; } global $wpdb; // Bail if no user password to convert $row = $wpdb->get_row("SELECT * FROM {$wpdb->users} INNER JOIN {$wpdb->usermeta} ON user_id = ID WHERE meta_key = '_bbp_class' AND user_login = '******' LIMIT 1"); if (empty($row) || is_wp_error($row)) { return; } // Setup admin (to include converter) require_once bbpress()->includes_dir . 'admin/admin.php'; // Create the admin object bbp_admin(); // Convert password require_once bbpress()->admin->admin_dir . 'converter.php'; require_once bbpress()->admin->admin_dir . 'converters/' . $row->meta_value . '.php'; // Create the converter $converter = bbp_new_converter($row->meta_value); // Try to call the conversion method if (is_a($converter, 'BBP_Converter_Base') && method_exists($converter, 'callback_pass')) { $converter->callback_pass($username, $_POST['pwd']); } }
/** * Callback processor * * @since 2.1.0 bbPress (r3813) */ public function process_callback() { // Bail if user cannot view import page if (!current_user_can('bbp_tools_import_page')) { wp_die('0'); } // Verify intent check_ajax_referer('bbp_converter_process'); if (!ini_get('safe_mode')) { set_time_limit(0); ini_set('memory_limit', '256M'); ini_set('implicit_flush', '1'); ignore_user_abort(true); } // Save step and count so that it can be restarted. if (!get_option('_bbp_converter_step') || !empty($_POST['_bbp_converter_restart'])) { update_option('_bbp_converter_step', 1); update_option('_bbp_converter_start', 0); } $step = (int) get_option('_bbp_converter_step', 1); $min = (int) get_option('_bbp_converter_start', 0); $count = (int) (!empty($_POST['_bbp_converter_rows'])) ? $_POST['_bbp_converter_rows'] : 100; $max = $min + $count - 1; $start = $min; // Bail if platform did not get saved $platform = !empty($_POST['_bbp_converter_platform']) ? $_POST['_bbp_converter_platform'] : get_option('_bbp_converter_platform'); if (empty($platform)) { return; } // Include the appropriate converter. $converter = bbp_new_converter($platform); switch ($step) { // STEP 1. Clean all tables. case 1: if (!empty($_POST['_bbp_converter_clean'])) { if ($converter->clean($start)) { update_option('_bbp_converter_step', $step + 1); update_option('_bbp_converter_start', 0); $this->sync_table(true); if (empty($start)) { $this->converter_output(__('No data to clean', 'bbpress')); } } else { update_option('_bbp_converter_start', $max + 1); $this->converter_output(sprintf(__('Deleting previously converted data (%1$s - %2$s)', 'bbpress'), $min, $max)); } } else { update_option('_bbp_converter_step', $step + 1); update_option('_bbp_converter_start', 0); } break; // STEP 2. Convert users. // STEP 2. Convert users. case 2: if (!empty($_POST['_bbp_converter_convert_users'])) { if ($converter->convert_users($start)) { update_option('_bbp_converter_step', $step + 1); update_option('_bbp_converter_start', 0); if (empty($start)) { $this->converter_output(__('No users to convert', 'bbpress')); } } else { update_option('_bbp_converter_start', $max + 1); $this->converter_output(sprintf(__('Converting users (%1$s - %2$s)', 'bbpress'), $min, $max)); } } else { update_option('_bbp_converter_step', $step + 1); update_option('_bbp_converter_start', 0); } break; // STEP 3. Clean passwords. // STEP 3. Clean passwords. case 3: if (!empty($_POST['_bbp_converter_convert_users'])) { if ($converter->clean_passwords($start)) { update_option('_bbp_converter_step', $step + 1); update_option('_bbp_converter_start', 0); if (empty($start)) { $this->converter_output(__('No passwords to clear', 'bbpress')); } } else { update_option('_bbp_converter_start', $max + 1); $this->converter_output(sprintf(__('Delete users WordPress default passwords (%1$s - %2$s)', 'bbpress'), $min, $max)); } } else { update_option('_bbp_converter_step', $step + 1); update_option('_bbp_converter_start', 0); } break; // STEP 4. Convert forums. // STEP 4. Convert forums. case 4: if ($converter->convert_forums($start)) { update_option('_bbp_converter_step', $step + 1); update_option('_bbp_converter_start', 0); if (empty($start)) { $this->converter_output(__('No forums to convert', 'bbpress')); } } else { update_option('_bbp_converter_start', $max + 1); $this->converter_output(sprintf(__('Converting forums (%1$s - %2$s)', 'bbpress'), $min, $max)); } break; // STEP 5. Convert forum parents. // STEP 5. Convert forum parents. case 5: if ($converter->convert_forum_parents($start)) { update_option('_bbp_converter_step', $step + 1); update_option('_bbp_converter_start', 0); if (empty($start)) { $this->converter_output(__('No forum parents to convert', 'bbpress')); } } else { update_option('_bbp_converter_start', $max + 1); $this->converter_output(sprintf(__('Calculating forum hierarchy (%1$s - %2$s)', 'bbpress'), $min, $max)); } break; // STEP 6. Convert forum subscriptions. // STEP 6. Convert forum subscriptions. case 6: if ($converter->convert_forum_subscriptions($start)) { update_option('_bbp_converter_step', $step + 1); update_option('_bbp_converter_start', 0); if (empty($start)) { $this->converter_output(__('No forum subscriptions to convert', 'bbpress')); } } else { update_option('_bbp_converter_start', $max + 1); $this->converter_output(sprintf(__('Converting forum subscriptions (%1$s - %2$s)', 'bbpress'), $min, $max)); } break; // STEP 7. Convert topics. // STEP 7. Convert topics. case 7: if ($converter->convert_topics($start)) { update_option('_bbp_converter_step', $step + 1); update_option('_bbp_converter_start', 0); if (empty($start)) { $this->converter_output(__('No topics to convert', 'bbpress')); } } else { update_option('_bbp_converter_start', $max + 1); $this->converter_output(sprintf(__('Converting topics (%1$s - %2$s)', 'bbpress'), $min, $max)); } break; // STEP 8. Convert anonymous topic authors. // STEP 8. Convert anonymous topic authors. case 8: if ($converter->convert_anonymous_topic_authors($start)) { update_option('_bbp_converter_step', $step + 1); update_option('_bbp_converter_start', 0); if (empty($start)) { $this->converter_output(__('No anonymous topic authors to convert', 'bbpress')); } } else { update_option('_bbp_converter_start', $max + 1); $this->converter_output(sprintf(__('Converting anonymous topic authors (%1$s - %2$s)', 'bbpress'), $min, $max)); } break; // STEP 9. Stick topics. // STEP 9. Stick topics. case 9: if ($converter->convert_topic_stickies($start)) { update_option('_bbp_converter_step', $step + 1); update_option('_bbp_converter_start', 0); if (empty($start)) { $this->converter_output(__('No stickies to stick', 'bbpress')); } } else { update_option('_bbp_converter_start', $max + 1); $this->converter_output(sprintf(__('Calculating topic stickies (%1$s - %2$s)', 'bbpress'), $min, $max)); } break; // STEP 10. Stick to front topics (Super Sicky). // STEP 10. Stick to front topics (Super Sicky). case 10: if ($converter->convert_topic_super_stickies($start)) { update_option('_bbp_converter_step', $step + 1); update_option('_bbp_converter_start', 0); if (empty($start)) { $this->converter_output(__('No super stickies to stick', 'bbpress')); } } else { update_option('_bbp_converter_start', $max + 1); $this->converter_output(sprintf(__('Calculating topic super stickies (%1$s - %2$s)', 'bbpress'), $min, $max)); } break; // STEP 11. Closed topics. // STEP 11. Closed topics. case 11: if ($converter->convert_topic_closed_topics($start)) { update_option('_bbp_converter_step', $step + 1); update_option('_bbp_converter_start', 0); if (empty($start)) { $this->converter_output(__('No closed topics to close', 'bbpress')); } } else { update_option('_bbp_converter_start', $max + 1); $this->converter_output(sprintf(__('Calculating closed topics (%1$s - %2$s)', 'bbpress'), $min, $max)); } break; // STEP 12. Convert topic tags. // STEP 12. Convert topic tags. case 12: if ($converter->convert_tags($start)) { update_option('_bbp_converter_step', $step + 1); update_option('_bbp_converter_start', 0); if (empty($start)) { $this->converter_output(__('No topic tags to convert', 'bbpress')); } } else { update_option('_bbp_converter_start', $max + 1); $this->converter_output(sprintf(__('Converting topic tags (%1$s - %2$s)', 'bbpress'), $min, $max)); } break; // STEP 13. Convert topic subscriptions. // STEP 13. Convert topic subscriptions. case 13: if ($converter->convert_topic_subscriptions($start)) { update_option('_bbp_converter_step', $step + 1); update_option('_bbp_converter_start', 0); if (empty($start)) { $this->converter_output(__('No topic subscriptions to convert', 'bbpress')); } } else { update_option('_bbp_converter_start', $max + 1); $this->converter_output(sprintf(__('Converting topic subscriptions (%1$s - %2$s)', 'bbpress'), $min, $max)); } break; // STEP 14. Convert topic favorites. // STEP 14. Convert topic favorites. case 14: if ($converter->convert_favorites($start)) { update_option('_bbp_converter_step', $step + 1); update_option('_bbp_converter_start', 0); if (empty($start)) { $this->converter_output(__('No favorites to convert', 'bbpress')); } } else { update_option('_bbp_converter_start', $max + 1); $this->converter_output(sprintf(__('Converting favorites (%1$s - %2$s)', 'bbpress'), $min, $max)); } break; // STEP 15. Convert replies. // STEP 15. Convert replies. case 15: if ($converter->convert_replies($start)) { update_option('_bbp_converter_step', $step + 1); update_option('_bbp_converter_start', 0); if (empty($start)) { $this->converter_output(__('No replies to convert', 'bbpress')); } } else { update_option('_bbp_converter_start', $max + 1); $this->converter_output(sprintf(__('Converting replies (%1$s - %2$s)', 'bbpress'), $min, $max)); } break; // STEP 16. Convert anonymous reply authors. // STEP 16. Convert anonymous reply authors. case 16: if ($converter->convert_anonymous_reply_authors($start)) { update_option('_bbp_converter_step', $step + 1); update_option('_bbp_converter_start', 0); if (empty($start)) { $this->converter_output(__('No anonymous reply authors to convert', 'bbpress')); } } else { update_option('_bbp_converter_start', $max + 1); $this->converter_output(sprintf(__('Converting anonymous reply authors (%1$s - %2$s)', 'bbpress'), $min, $max)); } break; // STEP 17. Convert threaded replies parents. // STEP 17. Convert threaded replies parents. case 17: if ($converter->convert_reply_to_parents($start)) { update_option('_bbp_converter_step', $step + 1); update_option('_bbp_converter_start', 0); if (empty($start)) { $this->converter_output(__('No threaded replies to convert', 'bbpress')); } } else { update_option('_bbp_converter_start', $max + 1); $this->converter_output(sprintf(__('Calculating threaded replies parents (%1$s - %2$s)', 'bbpress'), $min, $max)); } break; default: delete_option('_bbp_converter_step'); delete_option('_bbp_converter_start'); delete_option('_bbp_converter_query'); $this->converter_output(__('Conversion Complete', 'bbpress')); break; } }