Skip to main content

PHP_SERVER

Vasyl MartyniukLess than 1 minute

Syntax

${PHP_SERVER.<pathToProperty>}

Definition

Get data from the PHP super global $_SERVERopen in new window. The value from the $_SERVER is extracted AS-IS, so it is important to control the actual value data type by casting it accordingly. Refer to the Typecasting section for more detail.

Here is an example of values that you can have access to through PHP_SERVER marker. Note, that depending on a server and website's configurations, different set of values will exist.

Array
(
    [SERVER_SOFTWARE] => nginx/1.16.0
    [REQUEST_URI] => /wp-admin/user-edit.php
    [PATH] => /.../php-8.3.0+1/bin/darwin/ghostscript/bin
    [GS_LIB] => /.../php-8.3.0+1/bin/darwin/ghostscript/Resource/Init
    [MAGICK_CODER_MODULE_PATH] => /.../php-8.3.0+1/bin/darwin/ImageMagick/modules-Q16/coders
    [USER] => xxx
    [HOME] => /Users/xxx
    [HTTP_COOKIE] => ...
    [HTTP_ACCEPT_LANGUAGE] => en-US,en;q=0.9
    [HTTP_ACCEPT_ENCODING] => gzip, deflate, br, zstd
    [HTTP_REFERER] => https://demo.aamportal/wp-admin/user-edit.php
    [HTTP_SEC_FETCH_DEST] => document
    [HTTP_SEC_FETCH_USER] => ?1
    [HTTP_SEC_FETCH_MODE] => navigate
    [HTTP_SEC_FETCH_SITE] => same-origin
    [HTTP_ACCEPT] => text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
    [HTTP_USER_AGENT] => Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36
    [HTTP_UPGRADE_INSECURE_REQUESTS] => 1
    [HTTP_SEC_CH_UA_PLATFORM] => "macOS"
    [HTTP_SEC_CH_UA_MOBILE] => ?0
    [HTTP_SEC_CH_UA] => "Google Chrome";v="123", "Not:A-Brand";v="8", "Chromium";v="123"
    [HTTP_CACHE_CONTROL] => max-age=0
    [HTTP_CONNECTION] => keep-alive
    [HTTP_HOST] => demo.aamportal.com:10004
    [REDIRECT_STATUS] => 200
    [HTTPS] =>
    [SERVER_NAME] => demo.aamportal.com
    [SERVER_PORT] => 10004
    [SERVER_ADDR] => ...
    [REMOTE_PORT] => 58855
    [REMOTE_ADDR] => ...
    [GATEWAY_INTERFACE] => CGI/1.1
    [SERVER_PROTOCOL] => HTTP/1.1
    [DOCUMENT_ROOT] => /.../public
    [DOCUMENT_URI] => /wp-admin/user-edit.php
    [PATH_TRANSLATED] => /.../public
    [PATH_INFO] =>
    [SCRIPT_NAME] => /wp-admin/user-edit.php
    [SCRIPT_FILENAME] => /.../public/wp-admin/user-edit.php
    [CONTENT_LENGTH] =>
    [CONTENT_TYPE] =>
    [REQUEST_METHOD] => GET
    [QUERY_STRING] => user_id=3&wp_http_referer=%2Fwp-admin%2Fusers.php
    [FCGI_ROLE] => RESPONDER
    [PHP_SELF] => /wp-admin/user-edit.php
    [REQUEST_TIME_FLOAT] => 1713654362.0545
    [REQUEST_TIME] => 1713654362
)

In the example below, we hide certain pages, posts, and terms from the classical navigation menu editor.

{
    "Statement": [
        {
            "Effect": "deny",
            "Resource": [
                "Post:page:about",
                "Post:page:calendar",
                "Post:post:9285",
                "Term:category:news"
            ],
            "Action": "List",
            "Condition": {
                "Equals": {
                    "${PHP_SERVER.PHP_SELF}": "/wp-admin/nav-menus.php"
                }
            }
        }
    ]
}