Logging cleanup.
This commit is contained in:
parent
d1fad37022
commit
16a7e20441
27 changed files with 220 additions and 213 deletions
public
100
public/index.php
100
public/index.php
|
@ -5,6 +5,8 @@ use RuntimeException;
|
|||
use Index\MediaType;
|
||||
use Index\Http\Content\MultipartFormContent;
|
||||
use Index\Http\Content\Multipart\ValueMultipartFormData;
|
||||
use Index\Http\Routing\Router;
|
||||
use Index\Http\Routing\Routes\RouteInfo;
|
||||
use Misuzu\Auth\{AuthTokenBuilder,AuthTokenCookie,AuthTokenInfo};
|
||||
|
||||
require_once __DIR__ . '/../misuzu.php';
|
||||
|
@ -115,51 +117,6 @@ $router = $msz->createRouting($request);
|
|||
$msz->startTemplating();
|
||||
|
||||
if($msz->domainRoles->hasRole($request->getHeaderLine('Host'), 'main')) {
|
||||
// Reconstruct $_POST since PHP no longer makes it for us
|
||||
if($request->getBody()->isReadable() && empty($_POST)) {
|
||||
$mszRequestContent = (function($contentType, $stream) {
|
||||
if($contentType->equals('application/x-www-form-urlencoded')) {
|
||||
parse_str((string)$stream, $postVars);
|
||||
return $postVars;
|
||||
}
|
||||
|
||||
if($contentType->equals('multipart/form-data'))
|
||||
try {
|
||||
return MultipartFormContent::parseStream($stream, $contentType->boundary);
|
||||
} catch(RuntimeException $ex) {}
|
||||
|
||||
return null;
|
||||
})(MediaType::parse($request->getHeaderLine('Content-Type')), $request->getBody());
|
||||
|
||||
$_POST = (function($requestContent) {
|
||||
if(is_array($requestContent))
|
||||
return $requestContent;
|
||||
|
||||
if($requestContent instanceof MultipartFormContent) {
|
||||
$postVars = [];
|
||||
foreach($requestContent->params as $name => $values) {
|
||||
if(count($values) === 0)
|
||||
$postVars[$name] = '';
|
||||
elseif(count($values) === 1)
|
||||
$postVars[$name] = $values[0] instanceof ValueMultipartFormData ? (string)$values[0] : '';
|
||||
else {
|
||||
$postVar = [];
|
||||
foreach($values as $value)
|
||||
$postVars[] = $value instanceof ValueMultipartFormData ? (string)$value : '';
|
||||
|
||||
$postVars[$name] = $postVar;
|
||||
}
|
||||
}
|
||||
|
||||
return $postVars;
|
||||
}
|
||||
|
||||
return [];
|
||||
})($mszRequestContent);
|
||||
|
||||
$_REQUEST = array_merge($_GET, $_POST);
|
||||
}
|
||||
|
||||
$mszRequestPath = substr($request->requestTarget, 1);
|
||||
$mszLegacyPathPrefix = Misuzu::PATH_PUBLIC_LEGACY . '/';
|
||||
$mszLegacyPath = $mszLegacyPathPrefix . $mszRequestPath;
|
||||
|
@ -167,6 +124,14 @@ if($msz->domainRoles->hasRole($request->getHeaderLine('Host'), 'main')) {
|
|||
if(str_starts_with($mszLegacyPath, $mszLegacyPathPrefix)) {
|
||||
$mszLegacyPathReal = realpath($mszLegacyPath);
|
||||
if($mszLegacyPath === $mszLegacyPathReal || $mszLegacyPath === $mszLegacyPathReal . '/') {
|
||||
// this is here so filters can run...
|
||||
$router->router->route(RouteInfo::exact($request->method, $request->requestTarget, function() {}));
|
||||
$response = $router->router->handle($request);
|
||||
if($response->getBody()->getSize() > 0) {
|
||||
Router::output($response);
|
||||
exit;
|
||||
}
|
||||
|
||||
if(str_starts_with($mszRequestPath, 'manage') && !$msz->hasManageAccess())
|
||||
Template::throwError(403);
|
||||
|
||||
|
@ -174,6 +139,51 @@ if($msz->domainRoles->hasRole($request->getHeaderLine('Host'), 'main')) {
|
|||
$mszLegacyPath .= '/index.php';
|
||||
|
||||
if(is_file($mszLegacyPath)) {
|
||||
// Reconstruct $_POST since PHP no longer makes it for us
|
||||
if($request->getBody()->isReadable() && empty($_POST)) {
|
||||
$mszRequestContent = (function($contentType, $stream) {
|
||||
if($contentType->equals('application/x-www-form-urlencoded')) {
|
||||
parse_str((string)$stream, $postVars);
|
||||
return $postVars;
|
||||
}
|
||||
|
||||
if($contentType->equals('multipart/form-data'))
|
||||
try {
|
||||
return MultipartFormContent::parseStream($stream, $contentType->boundary);
|
||||
} catch(RuntimeException $ex) {}
|
||||
|
||||
return null;
|
||||
})(MediaType::parse($request->getHeaderLine('Content-Type')), $request->getBody());
|
||||
|
||||
$_POST = (function($requestContent) {
|
||||
if(is_array($requestContent))
|
||||
return $requestContent;
|
||||
|
||||
if($requestContent instanceof MultipartFormContent) {
|
||||
$postVars = [];
|
||||
foreach($requestContent->params as $name => $values) {
|
||||
if(count($values) === 0)
|
||||
$postVars[$name] = '';
|
||||
elseif(count($values) === 1)
|
||||
$postVars[$name] = $values[0] instanceof ValueMultipartFormData ? (string)$values[0] : '';
|
||||
else {
|
||||
$postVar = [];
|
||||
foreach($values as $value)
|
||||
$postVars[] = $value instanceof ValueMultipartFormData ? (string)$value : '';
|
||||
|
||||
$postVars[$name] = $postVar;
|
||||
}
|
||||
}
|
||||
|
||||
return $postVars;
|
||||
}
|
||||
|
||||
return [];
|
||||
})($mszRequestContent);
|
||||
|
||||
$_REQUEST = array_merge($_GET, $_POST);
|
||||
}
|
||||
|
||||
require_once $mszLegacyPath;
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue