This PHP library provides to get all possible information from an IP address. For example it can retrieve user's country, lat-long values, country code, zip code, ISP etc.
This library written by Emre Yavuz | github.com/emreyvz
Accessible Properties
- currentCountry
- currentCountryCode
- currentPlateNumber
- currentRegionName
- currentCity
- currentZip
- currentLat
- currentLon
- timezone
- isp
- org
- as
- ip
Accessible Methods
- getISPLogo(@param)
- clearTrCharacter(@param)
- requestWithNoHeader(@param)
$getInformationFromIP = new getInformationFromIP();
$getInformationFromIP->ip="198.51.100.0";
$getInformationFromIP->fetchData();
echo "City: " .$getInformationFromIP->getCurrentCity();
Some ISPs and logos may not avaible. Add 'AS Code' and ISP Logo URL to getISPLogo() method for proper return
$getInformationFromIP = new getInformationFromIP();
$getInformationFromIP->ip="198.51.100.0";
$getInformationFromIP->fetchData();
echo "ISP: " .$getInformationFromIP->getIsp();
echo "<img src='". $getInformationFromIP->getISPLogo() ."'>";
$bannedCountries = ["AU","AZ","ES"];
$getInformationFromIP = new getInformationFromIP();
$getInformationFromIP->ip="198.51.100.0";
$getInformationFromIP->fetchData();
if (in_array($getInformationFromIP->getCurrentCountryCode(), $bannedCountries))
{
header("Location: yourCountryBannedFromThisPage.html");
}
$acceptedCountries = ["AU","AZ","ES"];
$getInformationFromIP = new getInformationFromIP();
$getInformationFromIP->ip="198.51.100.0";
$getInformationFromIP->fetchData();
if (!in_array($getInformationFromIP->getCurrentCountryCode(), $acceptedCountries))
{
header("Location: yourCountryBlockedFromThisPage.html");
}
- Apache 2.0 License
- 2022 © Emre Yavuz