/
var
/
www
/
barefootlaw.org
/
wp-content
/
plugins
/
wp-health
/
wpu-backup
/
Upload File
HOME
<?php define('WP_UMBRELLA_INIT_BACKUP', true); function wp_umbrella_response($data, $status = 200) { header('Cache-Control: no-cache'); header('Content-Type: application/json'); http_response_code($status); echo json_encode($data); exit; } $method = isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : null; if (!$method) { wp_umbrella_response([ 'code' => 'not_authorized' ]); return; } require_once __DIR__ . '/../wp-umbrella-request-functions.php'; if (!$method) { wp_umbrella_response([ 'success' => false, 'data' => [ 'code' => 'not_authorized' ] ],403); return; } if(!file_exists(__DIR__ . '/vendor/autoload.php')){ wp_umbrella_response([ 'success' => false, 'data' => [ 'code' => 'missing_dependencies', 'message' => 'Missing dependencies' ] ],400); } require_once __DIR__ . '/vendor/autoload.php'; // Require Security if(!file_exists(__DIR__ . '/security.php')){ wp_umbrella_response([ 'success' => false, 'data' => [ 'code' => 'security_file_not_found', 'message' => 'Security file not found' ] ],400); return; } require_once __DIR__ . '/../wp-umbrella-functions.php'; wp_umbrella_init_defined_standalone(); require_once __DIR__ . '/security.php'; // Require Config if(!file_exists(__DIR__ . '/config.php')){ wp_umbrella_response([ 'success' => false, 'data' => [ 'code' => 'config_file_not_found', 'message' => 'Config file not found' ] ],400); return; } require_once __DIR__ . '/../vendor/autoload.php'; $headers = wp_umbrella_get_headers(); if (!isset($headers['x-umbrella']) || !isset($headers['x-backup-action']) || !isset($headers['x-project'])) { wp_umbrella_response([ 'success' => false, 'data' => [ 'code' => 'not_authorized' ] ],403); return; } if(hash_equals($headers['x-umbrella'], TOKEN)) { wp_umbrella_response([ 'success' => false, 'data' => [ 'code' => 'not_authorized' ] ],403); return; } // Deprecated if((int) $headers['x-project'] !== PROJECT_ID) { wp_umbrella_response([ 'success' => false, 'data' => [ 'code' => 'not_authorized' ] ],403); return; } //===== if((int) $headers['x-secret-token'] !== PROJECT_ID) { wp_umbrella_response([ 'success' => false, 'data' => [ 'code' => 'not_authorized' ] ],403); return; } $action = $headers['x-backup-action']; $data = wp_umbrella_get_parameters($method); try { \WPUmbrella\Core\Kernel::setSettings([ 'file' => __DIR__ . '/../wp-health.php', 'slug' => 'wp-health', 'main_file' => 'wp-health', 'root' => __DIR__ . '/../', ]); \WPUmbrella\Core\Kernel::buildContainer(); $response = [ 'success' => false, 'data' => [ 'code' => 'action_not_found' ] ]; switch($action){ case 'prepare-batch-database': $runner = new \WPUmbrella\Services\Backup\QueueRunner\V2\BackupQueuePrepareDatabaseBatch(); $runner->setTypeClient("guzzle"); $response = $runner->run(); break; case 'check-batch-database': $options = []; if(isset($data['divided_memory'])){ $options['divided_memory'] = $data['divided_memory']; } $runner = new \WPUmbrella\Services\Backup\QueueRunner\V2\BackupQueueCheckDatabaseBatch(); $runner->setTypeClient("guzzle"); $response = $runner->run($options); break; case 'backup-files': $runner = new \WPUmbrella\Services\Backup\QueueRunner\V2\BackupQueueRunnerFiles(); $runner->setApi(new WPUmbrellaBackup\Api\Backup()); $response = $runner->run(); break; case 'backup-database': $runner = new \WPUmbrella\Services\Backup\QueueRunner\V2\BackupQueueRunnerDatabase(); $runner->setApi(new WPUmbrellaBackup\Api\Backup()); $response = $runner->run(); break; case 'cleanup': wp_umbrella_get_service('BackupExecutorV2')->cleanup(); $response = [ 'success' => true, 'data' => [ 'code' => WPUmbrella\Core\Constants\CodeResponse::BACKUP_FINISH ] ]; break; } $status = $response['success'] ? 200 : 400; wp_umbrella_response($response, $status); } catch (\Exception $e) { wp_umbrella_response([ 'success' => false, 'data' => [ 'code' => 'internal_error', 'message' => $e->getMessage() ] ], 500); }