PHP Classes
elePHPant
Icontem

PHP Cloudflare IP GEO: Get the IP of a user of a site that uses Cloudfare

Recommend this page to a friend!
  Info   View files Example   View files View files (3)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2019-06-25 (2 months ago) RSS 2.0 feedNot yet rated by the usersTotal: 115 All time: 9,081 This week: 288Up
Version License PHP version Categories
cfgeo 1.0.0GNU General Publi...5.6Networking, PHP 5, Geography
Description Author

This class can get the IP of a user of a site that uses Cloudfare.

It takes the current user IP address from the HTTP headers that were sent to the server.

If the current site accesses are handled by Cloudflare, it checks specific headers set by Cloudflare servers that pass the current user computer IP address as well the two letter code of the country associated to that IP address.

The class can also return the name of the country associated to the current user country code.

Innovation Award
PHP Programming Innovation award nominee
June 2019
Number 10
Cloudflare is a popular proxy service that can help many sites to handle requests for their pages faster by serving those pages from servers spread around the world that cache the contents of the pages.

When a browser is used to access a site that is handled by Cloudflare, the actual site server does not see the IP address of the computer that runs the browser in the same way that happens when a site is not using Cloudflare to serve its pages.

The actual IP address that the user computer uses is passed to your site by Cloudflare using specific request variables.

This package can get the user IP address passed by Cloudflare, as well the country where the user is located.

Manuel Lemos
Name: Meraj-Ul Islam <contact>
Classes: 2 packages by
Country: Bangladesh Bangladesh
Age: 22
All time rank: 360747 in Bangladesh Bangladesh
Week rank: 300 Up8 in Bangladesh Bangladesh Up
Innovation award
Innovation award
Nominee: 1x

 

Details
There are three functions available in this class. Call them individually along with the class.
To get ip address from cloudflare, call: getClientIp()
To get country code from cloudflare, call: getCountryCode()
To get country from cloudflare, call: getCountryName()
  Files folder image Files  
File Role Description
Plain text file class.cfgeo.php Class The main class
Accessible without login Plain text file example.php Example Example usage of the class
Accessible without login Plain text file readme.txt Doc. The documentation file

 Version Control Unique User Downloads Download Rankings  
 0%
Total:115
This week:0
All time:9,081
This week:288Up