HEX
Server: Apache/2.4.46 (Ubuntu)
System: Linux localhost 5.11.0-49-generic #55-Ubuntu SMP Wed Jan 12 17:36:34 UTC 2022 x86_64
User: root (0)
PHP: 7.4.16
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/html/dooblo.cccinfotech.com/wp-content/plugins/backup-backup/includes/restore-batching.php
<?php

  // Namespace
  namespace BMI\Plugin;
  
  use BMI\Plugin AS BMI;

  // Exit on GET access
  if (!(isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest' && isset($_POST['bmi_restore_secret']))) {
    echo 'Access denied!';
    exit;
  }

  // Double check because why not
  if (empty($_POST)) exit;
  if (!isset($_POST['bmi_restore_secret'])) exit;
  
  function fixSlashes($str, $slash = false) {
    // Old version
    // $str = str_replace('\\\\', DIRECTORY_SEPARATOR, $str);
    // $str = str_replace('\\', DIRECTORY_SEPARATOR, $str);
    // $str = str_replace('\/', DIRECTORY_SEPARATOR, $str);
    // $str = str_replace('/', DIRECTORY_SEPARATOR, $str);

    // if ($str[strlen($str) - 1] == DIRECTORY_SEPARATOR) {
    //   $str = substr($str, 0, -1);
    // }
    
    // Since 1.3.2
    $protocol = '';
    if ($slash == false) $slash = DIRECTORY_SEPARATOR;
    if (substr($str, 0, 7) == 'http://') $protocol = 'http://';
    else if (substr($str, 0, 8) == 'https://') $protocol = 'https://';
    
    $str = substr($str, strlen($protocol));
    $str = preg_replace('/[\\\\\/]+/', $slash, $str);
    $str = rtrim($str, '/\\' );

    return $protocol . $str;
  }
  
  // WP Loader
  function bmiLoadWordPressAndBackupPlugin() {
    
    // Define how WP should load
    define('WP_USE_THEMES', false);
    define('SHORTINIT', true);
    
    // Set path to our plugin's main file
    $bmiPluginPathToLoad = fixSlashes(dirname(__DIR__) . '/backup-backup.php');
    $bmiPluginPathToLoadPro = fixSlashes(dirname(dirname(__DIR__)) . '/backup-backup-pro/backup-backup-pro.php');

    // Use WP Globals and load WordPress
    global $wp, $wp_query, $wp_the_query, $wp_rewrite, $wp_did_header;
    require_once bmi_find_wordpress_base_path() . DIRECTORY_SEPARATOR . 'wp-load.php';
    global $wp_version;
    
    // Load directory WordPress constants 
    require_once ABSPATH . WPINC . '/formatting.php';
    require_once ABSPATH . WPINC . '/meta.php';
    wp_plugin_directory_constants();
    
    // Allow to register activation hook and realpath
    $GLOBALS['wp_plugin_paths'] = array();
    $GLOBALS['shortcode_tags'] = array();
    
    // Load all dependencies of WordPress for Backup plugin
    $dependencies = [
      ABSPATH . WPINC . '/l10n.php',
      ABSPATH . WPINC . '/plugin.php',
      ABSPATH . WPINC . '/link-template.php',
      ABSPATH . WPINC . '/class-wp-textdomain-registry.php',
      ABSPATH . WPINC . '/class-wp-locale.php',
      ABSPATH . WPINC . '/class-wp-locale-switcher.php',
      ABSPATH . WPINC . '/session.php',
      ABSPATH . WPINC . '/pluggable.php',
      ABSPATH . WPINC . '/class-wp-ajax-response.php',
      ABSPATH . WPINC . '/capabilities.php',
      ABSPATH . WPINC . '/class-wp-roles.php',
      ABSPATH . WPINC . '/class-wp-role.php',
      ABSPATH . WPINC . '/class-wp-user.php',
      ABSPATH . WPINC . '/class-wp-query.php',
      ABSPATH . WPINC . '/query.php',
      ABSPATH . WPINC . '/general-template.php',
      ABSPATH . WPINC . '/http.php',
      ABSPATH . WPINC . '/class-http.php',
      ABSPATH . WPINC . '/class-wp-http.php',
      ABSPATH . WPINC . '/class-wp-http-streams.php',
      ABSPATH . WPINC . '/class-wp-http-curl.php',
      ABSPATH . WPINC . '/class-wp-http-proxy.php',
      ABSPATH . WPINC . '/class-wp-http-cookie.php',
      ABSPATH . WPINC . '/class-wp-http-encoding.php',
      ABSPATH . WPINC . '/class-wp-http-response.php',
      ABSPATH . WPINC . '/class-wp-http-requests-response.php',
      ABSPATH . WPINC . '/class-wp-http-requests-hooks.php',
      ABSPATH . WPINC . '/widgets.php',
      ABSPATH . WPINC . '/class-wp-widget.php',
      ABSPATH . WPINC . '/class-wp-widget-factory.php',
      ABSPATH . WPINC . '/class-wp-user-request.php',
      ABSPATH . WPINC . '/user.php',
      ABSPATH . WPINC . '/class-wp-user-query.php',
      ABSPATH . WPINC . '/class-wp-session-tokens.php',
      ABSPATH . WPINC . '/class-wp-user-meta-session-tokens.php',
      ABSPATH . WPINC . '/rest-api.php',
      ABSPATH . WPINC . '/kses.php',
      ABSPATH . WPINC . '/theme.php',
      ABSPATH . WPINC . '/rewrite.php',
      ABSPATH . WPINC . '/class-wp-block-editor-context.php',
      ABSPATH . WPINC . '/class-wp-block-type.php',
      ABSPATH . WPINC . '/class-wp-block-pattern-categories-registry.php',
      ABSPATH . WPINC . '/class-wp-block-patterns-registry.php',
      ABSPATH . WPINC . '/class-wp-block-styles-registry.php',
      ABSPATH . WPINC . '/class-wp-block-type-registry.php',
      ABSPATH . WPINC . '/class-wp-block.php',
      ABSPATH . WPINC . '/class-wp-block-list.php',
      ABSPATH . WPINC . '/class-wp-block-parser-block.php',
      ABSPATH . WPINC . '/class-wp-block-parser-frame.php',
      ABSPATH . WPINC . '/class-wp-block-parser.php',
      ABSPATH . WPINC . '/blocks.php',
      ABSPATH . WPINC . '/blocks/index.php',
    ];
    
    for ($i = 0; $i < sizeof($dependencies); ++$i) { 
      $dependency = $dependencies[$i];
      if (strpos($dependency, 'class-http.php') && version_compare($wp_version, '5.9.0', '>=')) {
        continue;
      }
      if (strpos($dependency, 'session.php') && version_compare($wp_version, '4.7.0', '>=')) {
        continue;
      }
      if (file_exists($dependency)) require_once $dependency;
    }
    
    // Load Cookie Constants
    wp_cookie_constants();
    
    // Load SSL Constants for DB export
    wp_ssl_constants();
    
    // Register Translation
    if (class_exists('WP_Textdomain_Registry')) {
      $GLOBALS['wp_textdomain_registry'] = new \WP_Textdomain_Registry();
    }
    
    if (is_readable($bmiPluginPathToLoadPro)) {
      wp_register_plugin_realpath($bmiPluginPathToLoadPro);
      include_once $bmiPluginPathToLoadPro;
      
      require_once BMI_PRO_ROOT_DIR . '/classes/core' . ((BMI_PRO_DEBUG) ? '.to-enc' : '') . '.php';
      $bmi_pro_instance = new BMI_Pro_Core();
      $bmi_pro_instance->initialize();
    }
    
    // Register our backup plugin and load its contents
    wp_register_plugin_realpath($bmiPluginPathToLoad);
    include_once $bmiPluginPathToLoad;
    
    // Enable our plugin WITHOUT calling plugins_loaded hook – it's important
    require_once BMI_ROOT_DIR . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'constants.php';

    // Initialize backup-migration
    if (!class_exists('Backup_Migration_Plugin')) {

      // Require initializator
      require_once BMI_ROOT_DIR . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'initializer.php';

      // Initialize entire plugin
      $bmi_instance = new BMI\Backup_Migration_Plugin();
      $bmi_instance->initialize();

    }
    
  }
  
  // Find WordPress Path
  function bmi_find_wordpress_base_path() {

    $dir = dirname(__FILE__);
    $previous = null;

    do {

      if (file_exists($dir . '/wp-load.php') && file_exists($dir . '/wp-config.php')) return $dir;
      if ($previous == $dir) break;
      $previous = $dir;

    } while ($dir = dirname($dir));

    return null;

  }

  // Validate the secret
  if (gettype($_POST['bmi_restore_secret']) == 'string' && strlen($_POST['bmi_restore_secret']) == '64') {

    // Set definition for handler
    define('BMI_RESTORE_SECRET', $_POST['bmi_restore_secret']);
    define('BMI_POST_CONTINUE_RESTORE', true);

    // Tell WP to not use Themes and set Base Path
    define('BASE_PATH', bmi_find_wordpress_base_path() . '/');

    // Use WP Globals and load WordPress
    bmiLoadWordPressAndBackupPlugin();

  }