@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
// Owned loopback QA only; the application still uses the verified candidate loader.
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
$root = realpath(getenv('SGC_STANDALONE_QA_ROOT') ?: '');
|
||||
$boundary = realpath(__DIR__.'/../../storage/framework/testing');
|
||||
$database = getenv('DB_DATABASE') ?: '';
|
||||
if (getenv('APP_ENV') !== 'standalone-qa' || getenv('COMPRAS_RUNTIME_ENABLED') !== 'true'
|
||||
|| getenv('COMPRAS_RUNTIME_PREPARE_ONLY') !== 'false' || getenv('COMPRAS_RUNTIME_SYNTHETIC_ONLY') !== 'true'
|
||||
|| ! preg_match('/^compras_standalone_qa_([a-f0-9]{12})$/D', $database, $matches)
|
||||
|| getenv('DB_USERNAME') !== 'compras_standalone_app_'.$matches[1]
|
||||
|| getenv('DB_HOST') !== '127.0.0.1' || getenv('DB_PORT') !== '55439'
|
||||
|| ($_SERVER['REMOTE_ADDR'] ?? '') !== '127.0.0.1' || ($_SERVER['SERVER_PORT'] ?? '') != getenv('SGC_STANDALONE_QA_PORT')
|
||||
|| $root === false || $boundary === false || dirname($root) !== $boundary || basename($root) !== 'rq01-ledger-qa-'.$matches[1]) {
|
||||
http_response_code(503);
|
||||
exit;
|
||||
}
|
||||
require __DIR__.'/../../vendor/autoload.php';
|
||||
$public = $root.'/public';
|
||||
$requestPath = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
|
||||
$asset = realpath($public.'/'.ltrim(rawurldecode($requestPath), '/'));
|
||||
$types = ['js' => 'text/javascript', 'css' => 'text/css', 'svg' => 'image/svg+xml', 'png' => 'image/png', 'ico' => 'image/x-icon', 'woff' => 'font/woff', 'woff2' => 'font/woff2'];
|
||||
if ($asset !== false && is_file($asset) && str_starts_with(str_replace('\\', '/', $asset), str_replace('\\', '/', $public).'/')
|
||||
&& isset($types[pathinfo($asset, PATHINFO_EXTENSION)])) {
|
||||
header('Content-Type: '.$types[pathinfo($asset, PATHINFO_EXTENSION)]);
|
||||
readfile($asset);
|
||||
exit;
|
||||
}
|
||||
$app = require __DIR__.'/../../bootstrap/app.php';
|
||||
$app->useStoragePath($root.'/storage');
|
||||
$app->usePublicPath($public);
|
||||
$app->handleRequest(Request::capture());
|
||||
Reference in New Issue
Block a user