PHP predefined variables in $_SERVER

伍光济
2023-12-01

Well, I found it was really handful if you want more flexibility when designing interchanges among some pages within a site. I output $_SERVER array under my Apache server:


Array
(
    [MIBDIRS] => C:/xampp/php/extras/mibs
    [MYSQL_HOME] => C:\xampp\mysql\bin
    [OPENSSL_CONF] => C:/xampp/apache/bin/openssl.cnf
    [PHP_PEAR_SYSCONF_DIR] => C:\xampp\php
    [PHPRC] => C:\xampp\php
    [TMP] => C:\xampp\tmp
    [HTTP_HOST] => 192.168.0.103
    [HTTP_USER_AGENT] => Mozilla/5.0 (Windows NT 5.1; rv:11.0) Gecko/20100101 Firefox/11.0
    [HTTP_ACCEPT] => text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    [HTTP_ACCEPT_LANGUAGE] => zh-tw,en-us;q=0.7,en;q=0.3
    [HTTP_ACCEPT_ENCODING] => gzip, deflate
    [HTTP_CONNECTION] => keep-alive
    [HTTP_REFERER] => http://192.168.0.103/edir-cms-v1.2/adv_playlist_rec.php?action=add&pl_id=1&mf_id=9
    [HTTP_COOKIE] => style=green; __utma=1.1515997172.1334735760.1334735760.1334735760.1; __utmz=1.1334735760.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); el-finder-last-elfinder=8ea8853cb93f2f9781e0bf6e857015ea; PHPSESSID=b5apedse2kln99q7a1dnk5khv2
    [HTTP_CACHE_CONTROL] => max-age=0
    [PATH] => C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\
    [SystemRoot] => C:\Windows
    [COMSPEC] => C:\Windows\system32\cmd.exe
    [PATHEXT] => .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
    [WINDIR] => C:\Windows
    [SERVER_SIGNATURE] => <address>Apache/2.2.14 (Win32) DAV/2 mod_ssl/2.2.14 OpenSSL/0.9.8l mod_autoindex_color PHP/5.3.1 mod_apreq2-20090110/2.7.1 mod_perl/2.0.4 Perl/v5.10.1 Server at 192.168.0.103 Port 80</address>

    [SERVER_SOFTWARE] => Apache/2.2.14 (Win32) DAV/2 mod_ssl/2.2.14 OpenSSL/0.9.8l mod_autoindex_color PHP/5.3.1 mod_apreq2-20090110/2.7.1 mod_perl/2.0.4 Perl/v5.10.1
    [SERVER_NAME] => 192.168.0.103
    [SERVER_ADDR] => 192.168.0.103
    [SERVER_PORT] => 80
    [REMOTE_ADDR] => 192.168.0.161
    [DOCUMENT_ROOT] => C:/xampp/htdocs
    [SERVER_ADMIN] => postmaster@localhost
    [SCRIPT_FILENAME] => C:/xampp/htdocs/edir-cms-v1.2/adv_playlist_rec.php
    [REMOTE_PORT] => 4956
    [GATEWAY_INTERFACE] => CGI/1.1
    [SERVER_PROTOCOL] => HTTP/1.1
    [REQUEST_METHOD] => GET
    [QUERY_STRING] => action=add&pl_id=1&mf_id=1
    [REQUEST_URI] => /edir-cms-v1.2/adv_playlist_rec.php?action=add&pl_id=1&mf_id=1
    [SCRIPT_NAME] => /edir-cms-v1.2/adv_playlist_rec.php
    [PHP_SELF] => /edir-cms-v1.2/adv_playlist_rec.php
    [REQUEST_TIME] => 1334897502
    [argv] => Array
        (
            [0] => action=add&pl_id=1&mf_id=1
        )


    [argc] => 1
)


This can be a reference for later use. And here is the official online document:


http://php.net/manual/en/reserved.variables.server.php


And here are two blogs talking about the security flaw when using PHP_SELF:


小心$_SERVER['PHP_SELF]使用漏洞

Php $ SERVER "PHP SELF" 漏洞



 


 类似资料: