17 public static function requestToGlobal(\Psr\Http\Message\ServerRequestInterface $request) {
18 $method = $request->getMethod ();
19 $uri = $request->getUri ();
20 $parameters = $request->getQueryParams ();
21 $parsedBody = $request->getParsedBody ();
22 $headers = $request->getHeaders ();
24 list ( $host, $port, $scheme, $userInfo, $path, $uQuery ) = [ $uri->getHost (),$uri->getPort (),$uri->getScheme (),$uri->getUserInfo (),$uri->getPath (),$uri->getQuery () ];
25 $server = array_replace ( [
26 'SERVER_NAME' =>
'localhost',
28 'HTTP_HOST' =>
'localhost',
29 'HTTP_USER_AGENT' =>
'Ubiquity',
30 'HTTP_ACCEPT' =>
'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
31 'HTTP_ACCEPT_LANGUAGE' =>
'en-us,en;q=0.5',
32 'HTTP_ACCEPT_CHARSET' =>
'ISO-8859-1,utf-8;q=0.7,*;q=0.7',
33 'REMOTE_ADDR' =>
'127.0.0.1',
35 'SCRIPT_FILENAME' =>
'',
36 'SERVER_PROTOCOL' =>
'HTTP/1.1',
37 'REQUEST_TIME' => time () ], $request->getServerParams () );
38 $server [
'PATH_INFO'] =
'';
39 $server [
'REQUEST_METHOD'] = \strtoupper ( $method );
42 $server [
'SERVER_NAME'] = $host;
43 $server [
'HTTP_HOST'] = $host;
45 if ($scheme !=
null) {
46 if (
'https' === $scheme) {
47 $server [
'HTTPS'] =
'on';
48 $server [
'SERVER_PORT'] = 443;
50 unset ( $server [
'HTTPS'] );
51 $server [
'SERVER_PORT'] = 80;
55 $server [
'SERVER_PORT'] = $port;
56 $server [
'HTTP_HOST'] .=
':' . $port;
58 if ($userInfo !=
null) {
59 $userInfo = explode (
':', $userInfo );
60 $server [
'PHP_AUTH_USER'] = $userInfo [0];
61 if (\count ( $userInfo ) > 1) {
62 $server [
'PHP_AUTH_PW'] = $userInfo [1];
66 switch (\strtoupper ( $method )) {
70 if (! isset ( $server [
'CONTENT_TYPE'] )) {
71 $server [
'CONTENT_TYPE'] =
'application/x-www-form-urlencoded';
82 if ($uQuery !=
null) {
83 \parse_str ( \html_entity_decode ( $uQuery ), $qs );
85 $query = \array_replace ( $qs, $query );
86 $queryString = \http_build_query ( $query,
'',
'&' );
88 $queryString = $uQuery;
91 $queryString = \http_build_query ( $query,
'',
'&' );
93 $server [
'REQUEST_URI'] = $path . (
'' !== $queryString ?
'?' . $queryString :
'');
94 $server [
'QUERY_STRING'] = $queryString;
95 if (isset ( $headers [
'X-Requested-With'] ) && array_search (
'XMLHttpRequest', $headers [
'X-Requested-With'] ) !==
false) {
96 $server [
'HTTP_X_REQUESTED_WITH'] =
'XMLHttpRequest';
98 if (\strtoupper ( $method ) ===
'POST') {
101 if (\count ( $parameters ) > 0) {
102 $_GET = \array_merge ( $_GET, $parameters );