MMO\core\server
MMO\core\server · 32 symbols · generated 5 Oct 2026
charset
server.php:696Extract the charset=... parameter's value from a Content-Type header.
- Namespace
MMO\core\server
| $header | array | string | a header line/value (extractContentType()), or an already-split list of them |
| returns | null | string | null if no charset parameter is present |
clientIP
server.php:478Get the client's IP address, checking a wider/differently-ordered set of headers than ip() (via \getenv() rather than $_SERVER directly -- functionally equivalent under most SAPIs). Falls back to '127.0.0.1' (and logs a warning) if nothing at all is available, e.g. running on the CLI.
- Namespace
MMO\core\server
| returns | string |
contentType
server.php:677Extract just the content-type value(s) from a Content-Type header, stripping any ;charset=.../other parameters.
- Namespace
MMO\core\server
| $header | array | string | a header line/value (extractContentType()), or an already-split list of them |
| $single = true | bool | if true, return just the first content-type; if false, return every one found |
| returns | array | string | '' (or []) if $header has no usable content-type at all |
Call graph
date
server.php:441Format a unix timestamp (or a parseable date string) as an RFC 7231 ("IMF-fixdate") GMT date, suitable for an HTTP header (e.g. Date, Expires, Last-Modified).
- Namespace
MMO\core\server
| $time = null | string | int | null | a unix timestamp, a string \strtotime() can parse, or null for the current time |
| returns | null | string | GMT date string (e.g. 'Mon, 01 Jan 2024 00:00:00 GMT'), or null if $time is an unparseable string |
decodeLink
server.php:501Decode one HTTP Link header value: <{href}>;rel="{rel}";title="{title}" ...
- Namespace
MMO\core\server- See
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Link
Call graph
Used by (1)
decodeRecipients
server.php:539Decode a comma-separated recipient list of the form "Name" <email>, other@example.com, ... (as used in mail headers like To/Cc) into [email => name] pairs.
- Namespace
MMO\core\server
| $recipients | string | |
| returns | array | [email => name] -- name is null for a recipient given as a bare email address |
Call graph
Used by (1)
defaultCharset
server.php:467Get PHP's configured default charset (the default_charset ini directive, e.g. 'UTF-8').
- Namespace
MMO\core\server
| returns | string |
Call graph
Used by (1)
defaultLanguage
server.php:454Guess a default language from the environment: $_SERVER['LANG'] (its part before any '.', e.g. the 'fr_FR' in 'fr_FR.UTF-8'), falling back to the TLD of $_SERVER['REMOTE_HOST'] if that's set (a weak signal at best -- most hosts don't reverse-resolve, and a TLD like '.com' says nothing about language).
- Namespace
MMO\core\server
| returns | string | an empty string if nothing could be determined |
Call graph
Used by (1)
DNSIP
server.php:367Look up a domain's A (IPv4) or AAAA (IPv6) record.
- Namespace
MMO\core\server
documentRoot
server.php:399Get the document root the running script is resolved against: under a web server $_SERVER['DOCUMENT_ROOT'] through realpath(), on the CLI as is (normally empty).
- Namespace
MMO\core\server- See
scriptName()builds the script's path on it, andApplication::DefaultConfigtakes it off that path again to find the site's url: both have to use this one value. A document root reached through a symlink -- mmo.admin'scurrent, a shared host's web root linked onto it -- is longer or shorter than its realpath, and taking the length of the one off a path built from the other gave the site a url likehttps://example.com/0.0/www.
| returns | string | '' when it cannot be resolved (a missing folder, an open_basedir restriction) |
Call graph
Used by (2)
encodeLink
server.php:519Reverse of decodeLink(): encode a uri and its attributes into an HTTP Link header value.
- Namespace
MMO\core\server
| $href | string | |
| $attrs = [] | array | ['attrName' => value, ...]. An array value is space-joined; null is skipped entirely. |
| returns | string |
Call graph
Used by (1)
exitCode
server.php:566Map an HTTP status code to a shell exit code (the EXIT_* constants), for a CLI request routed through the same Application/Route pipeline as an HTTP one (Application::run()).
- Namespace
MMO\core\server
| $http_status | int | |
| returns | int | 0 for any status < 400; a specific EXIT_* code for a handful of common statuses; EXIT_GENERAL_ERROR otherwise |
Call graph
Used by (2)
extension
server.php:714Reverse lookup: find a file extension whose MIMES entry matches a given content-type header (the first usable content-type found in $header, tried against every entry of MIMES).
- Namespace
MMO\core\server
| $header | array | string | the content type as an http header/value, or a list of types |
| returns | null | string | the extension (without '.'), or null if no MIMES entry matches |
extensionToContentType
server.php:753Build a Content-Type header value for a file extension (falling back to 'txt' if $ext is unknown).
- Namespace
MMO\core\server
| $ext | string | the extension, without '.' |
| $charset = 'utf-8' | null | string | appended as ;charset=... if given. null to omit it. |
| returns | string |
extractContentType
server.php:663Strip a leading Content-Type: label (if present) off a header line, and split it on , into its individual content-type values (a header CAN legally list several, comma-separated).
- Namespace
MMO\core\server
| $header | string | a full Content-Type: ... header line, or just its value |
| returns | array | a list of content type |
Call graph
Used by (3)
hostname
server.php:343Get the server's own hostname: $_SERVER['SERVER_NAME'] if set, else the system hostname.
- Namespace
MMO\core\server
| returns | string | 'localhost.localdomain' if nothing valid could be determined |
Call graph
Uses (1)
Used by (2)
httpStatus
server.php:610Sanitize a value for use as an HTTP status code: pass it through if it is an int that isHttpStatus(), else fall back to 500. Used e.g. when turning an exception's (arbitrary, application-defined) code into a response status, httpStatus($e->getCode()): that code is not always an int -- a PDOException's is its SQLSTATE, a string such as 'HY000' or '42S02' -- and a string is never taken for a status, even a numeric one ('23000' is a SQLSTATE).
- Namespace
MMO\core\server
Call graph
Uses (1)
Used by (1)
info
server.php:851Parses phpinfo() output and returns a structured array.
- Namespace
MMO\core\server
| $flags = MMO\core\server\INFO_ALL | int | phpinfo() flags (default: INFO_ALL). Same constants as phpinfo(). |
| returns | array | Associative array [ 'Section Name' => [ 'key' => 'value', ... ], ... ] In HTML mode, two-column rows produce 'key' => 'local_value' and three-column rows produce 'key' => ['local' => ..., 'master' => ...]. |
infoHTML
server.php:945Capture phpinfo()'s HTML output as a standalone, embeddable fragment: styles are rescoped under #phpinfo (instead of being global) and the surrounding <html>/<head>/<body> are stripped, so this can be inserted into an existing page (e.g. an admin panel) without it clobbering that page's own styles.
- Namespace
MMO\core\server
| returns | string |
ip
server.php:357Get the client's IP address, from the first of HTTP_CLIENT_IP/HTTP_X_FORWARDED_FOR/REMOTE_ADDR that's set.
- Namespace
MMO\core\server
| returns | string |
Call graph
Used by (1)
isContentType
server.php:768Test whether a Content-Type header matches a given file extension's MIME type(s) (extension()).
- Namespace
MMO\core\server
| $ext | string | the extension to test against (in MIMES) |
| $types | string | the content type header (can contain a charset or multiple types) |
| returns | bool |
Call graph
Uses (1)
Used by (1)
isHttpStatus
server.php:592Tells if $status is a plausible HTTP status code (100-599).
- Namespace
MMO\core\server
Call graph
Used by (1)
isOk
server.php:622Tells if a status is a "success" HTTP status: [200, 400).
- Namespace
MMO\core\server
Call graph
isValidHost
server.php:321Validate whether a string contains a valid value to use as a hostname or IP address.
- Namespace
MMO\core\server
Call graph
Used by (1)
matchAccept
server.php:820Parse a weighted Accept-family HTTP header (sortAccept()) and find the best-matching entry in $supported: the header's options are tried highest-weight first, and the first one present as a key in $supported wins; if only a wildcard matched, the FIRST entry of $supported is returned instead.
- Namespace
MMO\core\server
| $header | array | string | the HTTP "Accept" header to parse |
| $supported | array | a list of supported values. The KEYS are compared against the header (so they must be lowercased, matching sortAccept()'s own lowercasing); the matching entry's VALUE is what's returned, so keys/values can differ (e.g. mime-type key -> short-name value) |
| returns | null | string | the matched entry's value, or null if nothing (not even a wildcard) matched |
Call graph
Uses (1)
mime
server.php:738Get the MIME type(s) (MIMES) registered for a file extension.
- Namespace
MMO\core\server
| $ext | string | the extension, without '.' |
| $single = true | bool | if true, return only the first/canonical MIME type; if false, return every alias |
| returns | array | string | null | null if $ext isn't in MIMES |
origin
server.php:383Get the requesting page's url: the Referer header, falling back to the Origin header.
- Namespace
MMO\core\server
reasonPhrase
server.php:647Turn a message into an HTTP reason phrase (the status line's text, statusText in a browser): one line, of at most 1024 bytes, in ISO-8859-1 -- the only charset a status line has, so a browser reads it that way.
- Namespace
MMO\core\server
| $message | string | UTF-8 text |
| returns | string | ISO-8859-1 text; a character it has not becomes its nearest ascii (’ -> ') or ?. |
Call graph
Used by (1)
scriptName
server.php:408Get the absolute filename of the currently running script (works both under a web server and on the CLI).
- Namespace
MMO\core\server
| returns | string |
Call graph
sortAccept
server.php:786Parse a (comma-separated, or already split) Accept-family HTTP header (Accept, Accept-Language, ...) and sort its options by weight (the ;q= parameter), highest first. An option with no explicit weight is ranked by its position in the header (earlier = higher); a bare * or a type wildcard is ranked lowest of all (even below the lowest EXPLICIT weight) unless it has its own explicit ;q=.
- Namespace
MMO\core\server
Call graph
Used by (2)
statusMessage
server.php:634Get the human-readable message for an HTTP status or shell exit code (MESSAGES).
- Namespace
MMO\core\server
Call graph
url
server.php:419Get the current request's full url. On the CLI, this is a file:// uri built from scriptName().
- Namespace
MMO\core\server
| $join = true | bool | if true, return a joined string; if false, return the split parts array (split()) |
| returns | array | string |