Updated to latest Index as well as some minor bug fixes.
This commit is contained in:
parent
ad89d45cf0
commit
5ba8b30047
77 changed files with 900 additions and 937 deletions
public
|
@ -2,6 +2,9 @@
|
|||
namespace Misuzu;
|
||||
|
||||
use RuntimeException;
|
||||
use Index\MediaType;
|
||||
use Index\Http\Content\MultipartFormContent;
|
||||
use Index\Http\Content\Multipart\ValueMultipartFormData;
|
||||
use Misuzu\Auth\{AuthTokenBuilder,AuthTokenCookie,AuthTokenInfo};
|
||||
|
||||
require_once __DIR__ . '/../misuzu.php';
|
||||
|
@ -25,12 +28,12 @@ $request = \Index\Http\HttpRequest::fromRequest();
|
|||
|
||||
$tokenPacker = $msz->authCtx->createAuthTokenPacker();
|
||||
|
||||
if(filter_has_var(INPUT_COOKIE, 'msz_auth'))
|
||||
$tokenInfo = $tokenPacker->unpack(filter_input(INPUT_COOKIE, 'msz_auth'));
|
||||
elseif(filter_has_var(INPUT_COOKIE, 'msz_uid') && filter_has_var(INPUT_COOKIE, 'msz_sid')) {
|
||||
if(!empty($_COOKIE['msz_auth']) && is_string($_COOKIE['msz_auth']))
|
||||
$tokenInfo = $tokenPacker->unpack($_COOKIE['msz_auth']);
|
||||
elseif(!empty($_COOKIE['msz_uid']) && !empty($_COOKIE['msz_sid']) && is_string($_COOKIE['msz_uid']) && is_string($_COOKIE['msz_sid'])) {
|
||||
$tokenBuilder = new AuthTokenBuilder;
|
||||
$tokenBuilder->setUserId((string)filter_input(INPUT_COOKIE, 'msz_uid', FILTER_SANITIZE_NUMBER_INT));
|
||||
$tokenBuilder->setSessionToken((string)filter_input(INPUT_COOKIE, 'msz_sid'));
|
||||
$tokenBuilder->setUserId($_COOKIE['msz_uid']);
|
||||
$tokenBuilder->setSessionToken($_COOKIE['msz_sid']);
|
||||
$tokenInfo = $tokenBuilder->toInfo();
|
||||
$tokenBuilder = null;
|
||||
} else
|
||||
|
@ -39,7 +42,7 @@ elseif(filter_has_var(INPUT_COOKIE, 'msz_uid') && filter_has_var(INPUT_COOKIE, '
|
|||
$userInfo = null;
|
||||
$sessionInfo = null;
|
||||
$userInfoReal = null;
|
||||
$remoteAddr = (string)filter_input(INPUT_SERVER, 'REMOTE_ADDR');
|
||||
$remoteAddr = $_SERVER['REMOTE_ADDR'];
|
||||
|
||||
if($tokenInfo->hasUserId && $tokenInfo->hasSessionToken) {
|
||||
$tokenBuilder = new AuthTokenBuilder($tokenInfo);
|
||||
|
@ -112,7 +115,52 @@ $router = $msz->createRouting($request);
|
|||
$msz->startTemplating();
|
||||
|
||||
if($msz->domainRoles->hasRole($request->getHeaderLine('Host'), 'main')) {
|
||||
$mszRequestPath = substr($request->path, 1);
|
||||
// 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;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue