<?php echo "PHP_SELF : " . $_SERVER['PHP_SELF'] . "<br />"; echo "GATEWAY_INTERFACE : " . $_SERVER['GATEWAY_INTERFACE'] . "<br />"; echo "SERVER_ADDR : " . $_SERVER['SERVER_ADDR'] . "<br />"; echo "SERVER_NAME : " . $_SERVER['SERVER_NAME'] . "<br />"; echo "SERVER_SOFTWARE : " . $_SERVER['SERVER_SOFTWARE'] . "<br />"; echo "SERVER_PROTOCOL : " . $_SERVER['SERVER_PROTOCOL'] . "<br />"; echo "REQUEST_METHOD : " . $_SERVER['REQUEST_METHOD'] . "<br />"; echo "REQUEST_TIME : " . $_SERVER['REQUEST_TIME'] . "<br />"; echo "REQUEST_TIME_FLOAT : " . $_SERVER['REQUEST_TIME_FLOAT'] . "<br />"; echo "QUERY_STRING : " . $_SERVER['QUERY_STRING'] . "<br />"; echo "DOCUMENT_ROOT : " . $_SERVER['DOCUMENT_ROOT'] . "<br />"; echo "HTTP_ACCEPT : " . $_SERVER['HTTP_ACCEPT'] . "<br />"; echo "HTTP_ACCEPT_CHARSET : " . $_SERVER['HTTP_ACCEPT_CHARSET'] . "<br />"; echo "HTTP_ACCEPT_ENCODING : " . $_SERVER['HTTP_ACCEPT_ENCODING'] . "<br />"; echo "HTTP_ACCEPT_LANGUAGE : " . $_SERVER['HTTP_ACCEPT_LANGUAGE'] . "<br />"; echo "HTTP_CONNECTION : " . $_SERVER['HTTP_CONNECTION'] . "<br />"; echo "HTTP_HOST : " . $_SERVER['HTTP_HOST'] . "<br />"; echo "HTTP_REFERER : " . $_SERVER['HTTP_REFERER'] . "<br />"; echo "HTTP_USER_AGENT : " . $_SERVER['HTTP_USER_AGENT'] . "<br />"; echo "HTTPS : " . $_SERVER['HTTPS'] . "<br />"; echo "REMOTE_ADDR : " . $_SERVER['REMOTE_ADDR'] . "<br />"; // ไอพีเน็ตของเรา echo "REMOTE_HOST : " . $_SERVER['REMOTE_HOST'] . "<br />"; echo "REMOTE_PORT : " . $_SERVER['REMOTE_PORT'] . "<br />"; echo "REMOTE_USER : " . $_SERVER['REMOTE_USER'] . "<br />"; echo "REDIRECT_REMOTE_USER : " . $_SERVER['REDIRECT_REMOTE_USER'] . "<br />"; echo "SCRIPT_FILENAME : " . $_SERVER['SCRIPT_FILENAME'] . "<br />"; echo "SERVER_ADMIN : " . $_SERVER['SERVER_ADMIN'] . "<br />"; echo "SERVER_PORT : " . $_SERVER['SERVER_PORT'] . "<br />"; echo "SERVER_SIGNATURE : " . $_SERVER['SERVER_SIGNATURE'] . "<br />"; echo "PATH_TRANSLATED : " . $_SERVER['PATH_TRANSLATED'] . "<br />"; echo "SCRIPT_NAME : " . $_SERVER['SCRIPT_NAME'] . "<br />"; echo "REQUEST_URI : " . $_SERVER['REQUEST_URI'] . "<br />"; echo "PHP_AUTH_DIGEST : " . $_SERVER['PHP_AUTH_DIGEST'] . "<br />"; echo "PHP_AUTH_USER : " . $_SERVER['PHP_AUTH_USER'] . "<br />"; echo "PHP_AUTH_PW : " . $_SERVER['PHP_AUTH_PW'] . "<br />"; echo "AUTH_TYPE : " . $_SERVER['AUTH_TYPE'] . "<br />"; echo "PATH_INFO : " . $_SERVER['PATH_INFO'] . "<br />"; echo "ORIG_PATH_INFO : " . $_SERVER['ORIG_PATH_INFO'] . "<br />"; ?>
function get_client_ip() { $ipaddress = ''; if ($_SERVER['HTTP_CLIENT_IP']) $ipaddress = $_SERVER['HTTP_CLIENT_IP']; else if($_SERVER['HTTP_X_FORWARDED_FOR']) $ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR']; else if($_SERVER['HTTP_X_FORWARDED']) $ipaddress = $_SERVER['HTTP_X_FORWARDED']; else if($_SERVER['HTTP_FORWARDED_FOR']) $ipaddress = $_SERVER['HTTP_FORWARDED_FOR']; else if($_SERVER['HTTP_FORWARDED']) $ipaddress = $_SERVER['HTTP_FORWARDED']; else if($_SERVER['REMOTE_ADDR']) $ipaddress = $_SERVER['REMOTE_ADDR']; else $ipaddress = 'UNKNOWN'; return $ipaddress; }
เพิ่มอันนี้เข้าไปอีกตัว
HTTP_X_CLUSTER_CLIENT_IP
public static function real_ip($default = '0.0.0.0', $exclude_reserved = false) { static $server_keys = null; if (empty($server_keys)) { $server_keys = array('HTTP_CLIENT_IP', 'REMOTE_ADDR'); if (\Config::get('security.allow_x_headers', false)) { $server_keys = array_merge(array('HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_X_FORWARDED_FOR'), $server_keys); } } foreach ($server_keys as $key) { if ( ! static::server($key)) { continue; } $ips = explode(',', static::server($key)); array_walk($ips, function (&$ip) { $ip = trim($ip); }); $ips = array_filter($ips, function($ip) use($exclude_reserved) { return filter_var($ip, FILTER_VALIDATE_IP, $exclude_reserved ? FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE : null); }); if ($ips) { return reset($ips); } } return \Fuel::value($default); }