| Server IP : 101.53.144.229 / Your IP : 216.73.216.181 Web Server : Apache System : Linux host.gdigitalindia.in 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64 User : digitalshiksha ( 1179) PHP Version : 5.6.40 Disable Function : eval,show_source,system,shell_exec,escapeshellarg,escapeshellcmd,proc_close,proc_open,ini_alter,dl,show_source,curl_multi_exechellcmd, ini_restore,apache_get_modules,get_cfg_var,passthru, exec ,proc_get_status,fpassthru,c999_buff_prepare,c999_sess_put,c99_buff_prepare,c99_sess_put,proc_close,ini_alter,dl,symlink,link,proc_close,ini_alter,dl,symlink,link,mail MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/share/doc/GeoIP-1.5.0/ |
Upload File : |
#!/usr/bin/perl
use strict;
use warnings;
use POSIX;
use LWP::Simple;
use File::Copy;
use Carp;
my $ipdb = 'GeoIP.dat';
my $datadir = '/usr/share/GeoIP/';
my $fullpath = $datadir . $ipdb;
my $url = 'http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz';
my $date = strftime '%Y%m%d', localtime;
# Do we have an existing IP database?
if ( -e $fullpath ) {
print "Fetching " . $ipdb . " from " . $url . "\r\n";
if ( is_success( getstore( $url, $datadir . 'GeoIP.dat.gz' ) ) ) {
move( $fullpath, $datadir . $ipdb . '.' . $date )
|| croak "Can't move the old database aside\r\n";
system 'gzip', '-d', $datadir . 'GeoIP.dat.gz';
if ( $? ne 0 ) {
croak "Could not uncompress database - exited $?\r\n";
}
print "GeoIP database updated. Old copy is at " . $ipdb . "." . $date
. "\r\n";
}
else {
croak "Fetch failed - try again later?\r\n";
}
}
else {
croak "You don't appear to have a valid GeoIP database installed..\r\n";
}