v-wordpress-plugin-updater/update-api/public/index.php
Nikolai X. Shadeauxs 4bd538c4c1 modified: update-api/app/Core/Response.php
modified:   update-api/app/Helpers/EncryptionHelper.php
	modified:   update-api/app/Helpers/ValidationHelper.php
	modified:   update-api/public/assets/js/header-scripts.js
	modified:   update-api/public/index.php
	modified:   update-api/public/install.php
2026-04-05 20:17:11 -04:00

37 lines
1 KiB
PHP

<?php
// phpcs:ignoreFile PSR1.Files.SideEffects.FoundWithSymbols
/**
* Project: UpdateAPI
* Author: Vontainment <services@vontainment.com>
* License: https://opensource.org/licenses/MIT MIT License
* Link: https://vontainment.com
* Version: 4.0.0
*
* File: index.php
* Description: WordPress Update API
*/
require_once __DIR__ . '/../config.php';
require_once __DIR__ . '/../vendor/autoload.php';
use App\Core\Router;
use App\Core\ErrorManager;
use App\Core\SessionManager;
$session = SessionManager::getInstance();
$session->start();
if (!$session->get('csrf_token')) {
$isStrong = false;
$bytes = openssl_random_pseudo_bytes(32, $isStrong);
if ($bytes === false || $isStrong !== true) {
throw new RuntimeException('Unable to generate cryptographically secure CSRF token bytes.');
}
$session->set('csrf_token', bin2hex($bytes));
}
ErrorManager::handle(function (): void {
$uri = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
Router::getInstance()->dispatch($_SERVER['REQUEST_METHOD'], $uri);
});