Photoshop practical tutorial php GeoIP usage tutorial

WBOY
Release: 2016-07-29 08:44:36
Original
1097 people have browsed it

Introduction to GeoIP:
What is GepIP?
The so-called GeoIP is to use the visitor's IP to locate his longitude and latitude, country/region, province, city, and even street location information. The technology here is not a difficult problem, the key lies in having an accurate database. With accurate data sources, you can earn a little money with rare goods, but what we pursue is to promote the spirit of cooperation and collective contribution for everyone to enjoy.
How to use GeoIP?
First we need data information, so first obtain a free database: GeoIP.dat.gz, and then decompress it to get: GeoIP.dat, and then operate the data file on demand. The example here uses PHP.
Usage of GeoIP + PHP
Method 1:
Download the PHP file geoip.inc of GeoIP. Package download

Copy the code The code is as follows:


include("geoip.inc.php");
// Open the data file
$gi = geoip_open("GeoIP.dat",GEOIP_STANDARD);
/ / Get the country code
$country_code = geoip_country_code_by_addr($gi, $_SERVER['REMOTE_ADDR']);
echo "Your country code is: $country_code ";
// Get the country name
$country_name = geoip_country_name_by_addr($gi, $ _SERVER['REMOTE_ADDR']);
echo "Your country name is: $country_name ";
// Close the file
geoip_close($gi);


Note: If you test locally, because $_SERVER['REMOTE_ADDR'] and $_SERVER['REMOTE_ADDR'] may be 127.0.0.1, so the output content is empty. You can bring in the IP test yourself
Method 2:
Install GeoIP as a PHP extension
yum install GeoIP GeoIP-data GeoIP-devel
Download the GeoIP database
wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCity .dat.gz
gzip -d GeoLiteCity.dat.gz
mv GeoLiteCity.dat /var/lib/GeoIP/GeoIPCity.dat
Download the PECL extension of GeoIP
Download address http://pecl.php.net/package/geoip
wget -c http://pecl.php.net/get/geoip-1.0.7.tgz
tar -zxvf geoip-1.0.7.tgz
Install GeoIP PECL extension
cd geoip-1.0.7
/usr /local/php/bin/phpize
./configure --with-php-c/local/php/bin/php-config --with-geoip
make
make install
Add
extension=geoip in php.ini .so
Then restart php and that’s it
Now, you can use some of the GeoIP functions in the php manual

The above has introduced the photoshop practical tutorial and the php GeoIP usage tutorial, including the content of the photoshop practical tutorial. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!