/
var
/
www
/
barefootlaw.org
/
wp-content
/
plugins
/
wp-health
/
request
/
Upload File
HOME
<?php use WPUmbrella\Core\Kernel; use WPUmbrella\Core\Controllers; use WPUmbrella\Core\UmbrellaRequest; use WPUmbrella\Models\Backup\BackupProcessedData; use WPUmbrella\Helpers\Controller; use WPUmbrella\Helpers\Directory; use WPUmbrella\Core\Exceptions\BackupNotCreated; 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'; function wp_umbrella_prevent_not_active() { if (is_plugin_active('wp-health/wp-health.php')) { return; } wp_umbrella_response([ 'code' => 'not_authorized' ]); return; } function wp_umbrella_load_wp() { while ( ! is_file( 'wp-load.php' ) ) { if ( is_dir( '..' ) && getcwd() != '/' ) { chdir( '..' ); } else { die( 'Could not find WordPress!' ); } } require_once( 'wp-load.php' ); } // ===== <Deprecated> ===== if ($method === 'GET' && isset($_GET['x-action']) && $_GET['x-action'] === '/v1/login') { if (!isset($_GET['x-action']) || !isset($_GET['x-umbrella'])) { wp_umbrella_response([ 'code' => 'not_authorized' ]); return; } $tokenUmbrella = $_GET['x-umbrella']; $actionUmbrella = $_GET['x-action']; $projectIdUmbrella = isset($_GET['x-project']) ? $_GET['x-project'] : null; if(!defined('WP_UMBRELLA_FALLBACK_REQUEST')){ define('WP_UMBRELLA_FALLBACK_REQUEST', true); } } // ===== </Deprecated> ===== if ($method === 'POST' && isset($_POST['x-action']) && $_POST['x-action'] === '/v1/login') { if(!defined('WP_UMBRELLA_FALLBACK_REQUEST')){ define('WP_UMBRELLA_FALLBACK_REQUEST', true); } } if(!defined('WP_UMBRELLA_FALLBACK_REQUEST')){ wp_umbrella_response([ 'code' => 'not_authorized' ]); return; } if (!defined('ABSPATH')) { wp_umbrella_load_wp(); } if (!function_exists('is_plugin_active') && defined('ABSPATH')) { require_once ABSPATH . 'wp-admin/includes/plugin.php'; } $request = UmbrellaRequest::createFromGlobals(); try { require_once __DIR__ . '/../vendor/autoload.php'; require_once __DIR__ . '/../wp-umbrella-functions.php'; wp_umbrella_init_defined(); Kernel::setSettings([ 'file' => __DIR__ . '/../wp-health.php', 'slug' => 'wp-health', 'main_file' => 'wp-health', 'root' => __DIR__ . '/../', ]); Kernel::buildContainer(); if (!defined('WP_UMBRELLA_IS_ADMIN')) { Kernel::trySetupAdmin(); } } catch (\Exception $e) { wp_umbrella_response([ 'code' => 'error' ]); return; } $controllers = Controllers::getControllers(); $isAlreadyExecuted = false; $action = $request->getAction(); foreach ($controllers as $key => $item) { if (!isset($item['route']) || empty($item['route'])) { continue; } foreach ($item['methods'] as $keyMethod => $data) { $route = $item['route']; $methodKernel = $data['method']; if ($methodKernel !== $method) { continue; } if ($action !== $key) { continue; } if ($isAlreadyExecuted) { continue; } $isAlreadyExecuted = true; $options = isset($data['options']) ? $data['options'] : []; $options['from'] = Controller::PHP; $options['route'] = $route; $options['method'] = $method; $options['version'] = isset($data['version']) ? $data['version'] : 'v1'; $controller = new $data['class']($options); $controller->execute(); } }