Home Backend Development PHP Tutorial 获得客户端真实的IP地址_PHP

获得客户端真实的IP地址_PHP

Jun 01, 2016 pm 12:39 PM
address client reality get

IP地址

function GetIP(){
if (getenv("HTTP_CLIENT_IP") && strcasecmp(getenv("HTTP_CLIENT_IP"), "unknown"))
$ip = getenv("HTTP_CLIENT_IP");
else if (getenv("HTTP_X_FORWARDED_FOR") && strcasecmp(getenv("HTTP_X_FORWARDED_FOR"), "unknown"))
$ip = getenv("HTTP_X_FORWARDED_FOR");
else if (getenv("REMOTE_ADDR") && strcasecmp(getenv("REMOTE_ADDR"), "unknown"))
$ip = getenv("REMOTE_ADDR");
else if (isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] && strcasecmp($_SERVER['REMOTE_ADDR'], "unknown"))
$ip = $_SERVER['REMOTE_ADDR'];
else
$ip = "unknown";
return($ip);
}


即使用户通过代理服务器上网,也能查出他的IP。但是要求代理服务器的类型是transparent类型。如果代理服务器是anonymous或者是high anonymous类型,HTTP_X_FORWARDED_FOR也无能为力了。
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Two Point Museum: All Exhibits And Where To Find Them
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to find and change your MAC address on Windows 11 How to find and change your MAC address on Windows 11 Apr 27, 2023 pm 04:04 PM

Are you wondering where to find or how to change your MAC address on Windows 11, but you don’t know how to do it yet? Since it is possible to hide the IP address, this article will provide simplified steps to set a custom MAC address from the device properties on Windows 11. Can the MAC address be changed? It is possible to change the default MAC address of a Windows computer, but device manufacturers strongly recommend not doing so as it may cause unexpected problems. On the Network Interface Controller (NIC), the MAC address is hardcoded and cannot be changed, but with some drivers this may be possible. In addition, users can also use third-party programs to change the MAC address

VMware Horizon Client cannot be opened [Fix] VMware Horizon Client cannot be opened [Fix] Feb 19, 2024 pm 11:21 PM

VMware Horizon Client helps you access virtual desktops conveniently. However, sometimes the virtual desktop infrastructure may experience startup issues. This article discusses the solutions you can take when the VMware Horizon client fails to start successfully. Why won't my VMware Horizon client open? When configuring VDI, if the VMWareHorizon client is not open, an error may occur. Please confirm that your IT administrator has provided the correct URL and credentials. If everything is fine, follow the solutions mentioned in this guide to resolve the issue. Fix VMWareHorizon Client Not Opening If VMW is not opening on your Windows computer

How to assign multiple IP addresses in one LAN card on Windows 10/11 How to assign multiple IP addresses in one LAN card on Windows 10/11 May 30, 2023 am 11:25 AM

Sometimes it is necessary to assign multiple addresses to a single LAN card. For example, if you need to run multiple websites with unique IP addresses or bind applications to different IP addresses, etc. If you are thinking about how to assign multiple addresses to a single network interface card or LAN card, this article will help you achieve it. Follow the steps below till the end and it will be done. So let’s get started! Assign multiple IP addresses to one LAN card Step 1: Use the Windows+R keys together to open the run prompt and type ncpa.cpl, then press the Enter key to open the Network Connection window. Step 2: Right click on your network adapter Ethernet or WiFi option and click Properties. Step 3: From the Properties Window

How to clear the Address Resolution Protocol (ARP) cache in Windows 10 How to clear the Address Resolution Protocol (ARP) cache in Windows 10 Apr 13, 2023 pm 07:43 PM

Address Resolution Protocol (ARP) is used to map MAC addresses to IP addresses. All hosts on the network will have their own IP address, but the network interface card (NIC) will have a MAC address rather than an IP address. ARP is a protocol used to associate IP addresses with MAC addresses. All these entries are collected and placed in the ARP cache. The mapped addresses are stored in cache and they usually do no harm. However, if the entries are incorrect or the ARP cache is corrupt, you may experience connectivity issues, loading issues, or errors. Therefore, you need to clear the ARP cache and fix the error. In this article, we will look at different methods on how to clear ARP cache. method

VMware Horizon client freezes or stalls while connecting [Fix] VMware Horizon client freezes or stalls while connecting [Fix] Mar 03, 2024 am 09:37 AM

When connecting to a VDI using the VMWareHorizon client, we may encounter situations where the application freezes during authentication or the connection blocks. This article will explore this issue and provide ways to resolve this situation. When the VMWareHorizon client experiences freezing or connection issues, there are a few things you can do to resolve the issue. Fix VMWareHorizon client freezes or gets stuck while connecting If VMWareHorizon client freezes or fails to connect on Windows 11/10, do the below mentioned solutions: Check network connection Restart Horizon client Check Horizon server status Clear client cache Fix Ho

Top 5 Ways to Find Your Mac's Address on iPhone Using the Settings App or Router Top 5 Ways to Find Your Mac's Address on iPhone Using the Settings App or Router Apr 13, 2023 pm 05:46 PM

Any device connected to the Internet has two types of addresses - a physical address and an Internet address. While Internet addresses locate devices globally, physical addresses help identify specific devices connected to a local network. This physical address is technically called a MAC address, and if you're wondering if your iPhone has one, yes, all phones (including iPhones) have their own unique MAC address. What is a MAC address? The Media Access Control or MAC address is a unique indicator used to identify your device from other devices connected to the same network. If you have a device that can connect to the internet, it will register a MAC address. This address is owned by

How to add a secondary IP address in Windows 11 How to add a secondary IP address in Windows 11 Apr 14, 2023 pm 04:10 PM

Why do I need to assign a secondary IP address in Windows 11? Now, we come to the most important question, why do you need to assign a secondary IP address or even multiple in Windows 11? Assuming you have a device with a default IP address and want to use another device, this may require adding a secondary device. Apart from this, it is also used to host various SSL websites. If you have to send a large amount of email in a short period of time, it may be helpful to obtain multiple IP addresses, as there are limits on how much can be sent from one IP address in a specific time frame. Additionally, some users set it up to avoid being blacklisted by spam filters. In addition, add auxiliary

Apple after-sales (apple after-sales point address) Apple after-sales (apple after-sales point address) Jan 11, 2024 pm 10:30 PM

Apple’s official after-sales phone number: Apple’s 24-hour service center phone number: 400-666-8800. The after-sales service telephone number for Apple mobile phones is: 400-666-8800. -627-2273. Apple’s customer service manual service hotline is 400-627-2273 for after-sales support; 400-666-8800 for the online store; and the only official Apple phone number is 400-666-8800. Apple's customer service hotline is 400-666-8800. You can call this number to inquire about hardware, software and third-party accessories of Apple products. It should be noted that Apple’s manual customer service does not provide services 24 hours a day. Their service hours are from 9 a.m. to 9 p.m. (Sundays are from 9 a.m. to 9 p.m.

See all articles