my $param="$_[0]";
# <-----
if (! $param) { return ''; }
- if (!$LoadedOverride){&LoadOverrideFile_geoip();}
- my $res=$TmpDomainLookup{$param}||'';
+ my $res= TmpLookup_geoip($param);
if (! $res) {
$res=lc($gi->country_code_by_addr($param)) || 'unknown';
$TmpDomainLookup{$param}=$res;
my $param="$_[0]";
# <-----
if (! $param) { return ''; }
- if (!$LoadedOverride){&LoadOverrideFile_geoip();}
- my $res=$TmpDomainLookup{$param}||'';
+ my $res = TmpLookup_geoip($param);
if (! $res) {
$res=lc($gi->country_code_by_name($param)) || 'unknown';
$TmpDomainLookup{$param}=$res;
print "</th>";
}
elsif ($param) {
- # try loading our override file if we haven't yet
- if (!$LoadedOverride){&LoadOverrideFile_geoip();}
my $ip=0;
my $key;
if ($param =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/) { # IPv4 address
}
print "<td>";
if ($key && $ip==4) {
- my $res;
- if ($gi){ $res = $TmpDomainLookup{$gi->get_ip_address($param)}||''; }
- else { $res = $TmpDomainLookup{$param}||''; }
+ my $res = TmpLookup_geoip($param);
if (!$res){$res=lc($gi->country_code_by_addr($param)) if $gi;}
if ($Debug) { debug(" Plugin $PluginName: GetCountryByIp for $param: [$res]",5); }
if ($res) { print $DomainsHashIDLib{$res}?$DomainsHashIDLib{$res}:"<span style=\"color: #$color_other\">$Message[0]</span>"; }
print "<span style=\"color: #$color_other\">$Message[0]</span>";
}
if (! $key) {
- my $res;
- if ($gi){ $res = $TmpDomainLookup{$gi->get_ip_address($param)}||''; }
- else { $res = $TmpDomainLookup{$param}||''; }
+ my $res = TmpLookup_geoip($param);
if (!$res){$res=lc($gi->country_code_by_addr($param)) if $gi;}
if ($Debug) { debug(" Plugin $PluginName: GetCountryByHostname for $param: [$res]",5); }
if ($res) { print $DomainsHashIDLib{$res}?$DomainsHashIDLib{$res}:"<span style=\"color: #$color_other\">$Message[0]</span>"; }
debug(" Plugin $PluginName: Overload file loaded: ".(scalar keys %TmpDomainLookup)." entries found.");
}
+#-----------------------------------------------------------------------------
+# PLUGIN FUNCTION: TmpLookup
+# Searches the temporary hash for the parameter value and returns the corresponding
+# GEOIP entry
+#-----------------------------------------------------------------------------
+sub TmpLookup_geoip(){
+ $param = shift;
+ if (!$LoadedOverride){&LoadOverrideFile_geoip();}
+ my $val;
+ if ($gi &&
+ (($type eq 'geoip' && $gi->VERSION >= 1.30) ||
+ $type eq 'geoippureperl' && $gi->VERSION >= 1.17)){
+ $val = $TmpDomainLookup{$gi->get_ip_address($param)};
+ }
+ else {$val = $TmpDomainLookup{$param};}
+ return $val || '';
+}
+
1; # Do not remove this line
print "</th>";
}
elsif ($param) {
- # try loading our override file if we haven't yet
- if (!$LoadedOverride){&LoadOverrideFile_geoip_asn_maxmind();}
my $ip=0;
my $key;
if ($param =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/) { # IPv4 address
print "<td>";
my $asn = 0;
if ($key && $ip==4) {
- if ($geoip_asn_maxmind){$asn = $TmpLookup{$geoip_asn_maxmind->get_ip_address($param)};}
- else {$asn = $TmpLookup{$param};}
+ $asn = TmpLookup_geoip_asn_maxmind($param);
if (!$asn && $type eq 'geoippureperl')
{
# Function org_by_addr does not exists in PurePerl but org_by_name do same
debug(" Plugin $PluginName: IPv6 not supported by MaxMind Free DBs: $key",3);
}
if (! $key) {
- if ($geoip_asn_maxmind){$asn = $TmpLookup{$geoip_asn_maxmind->get_ip_address($param)};}
- else {$asn = $TmpLookup{$param};}
+ $asn = TmpLookup_geoip_asn_maxmind($param);
if (!$asn && $type eq 'geoippureperl')
{
$asn=$geoip_asn_maxmind->org_by_name($param) if $geoip_asn_maxmind;
sub SectionProcessIp_geoip_asn_maxmind {
my $param="$_[0]"; # Param must be an IP
# <-----
- my $asn = 0;
- if (!$LoadedOverride){&LoadOverrideFile_geoip_asn_maxmind();}
- if ($geoip_asn_maxmind){$asn = $TmpLookup{$geoip_asn_maxmind->get_ip_address($param)};}
- else {$asn = $TmpLookup{$param};}
+ my $asn = TmpLookup_geoip_asn_maxmind($param);
if (!$asn && $type eq 'geoippureperl')
{
# Function org_by_addr does not exists in PurePerl but org_by_name do same
sub SectionProcessHostname_geoip_asn_maxmind {
my $param="$_[0]"; # Param must be an IP
# <-----
- my $asn=0;
- if ($geoip_asn_maxmind){$asn = $TmpLookup{$geoip_asn_maxmind->get_ip_address($param)};}
- else {$asn = $TmpLookup{$param};}
+ my $asn = TmpLookup_geoip_asn_maxmind($param);
if (!$asn && $type eq 'geoippureperl')
{
$asn=$geoip_asn_maxmind->org_by_name($param) if $geoip_asn_maxmind;
return $string;
}
+#-----------------------------------------------------------------------------
+# PLUGIN FUNCTION: TmpLookup
+# Searches the temporary hash for the parameter value and returns the corresponding
+# GEOIP entry
+#-----------------------------------------------------------------------------
+sub TmpLookup_geoip_asn_maxmind(){
+ $param = shift;
+ if (!$LoadedOverride){&LoadOverrideFile_geoip_asn_maxmind();}
+ my $val;
+ if ($geoip_asn_maxmind &&
+ (($type eq 'geoip' && $geoip_asn_maxmind->VERSION >= 1.30) ||
+ $type eq 'geoippureperl' && $geoip_asn_maxmind->VERSION >= 1.17)){
+ $val = $TmpLookup{$geoip_asn_maxmind->get_ip_address($param)};
+ }
+ else {$val = $TmpLookup{$param};}
+ return $val || '';
+}
+
+
1; # Do not remove this line
sub GetCountryCodeByAddr_geoip_city_maxmind {
my $param="$_[0]";
# <-----
- if (!$LoadedOverride){&LoadOverrideFile_geoip_city_maxmind();}
- my $res=$TmpDomainLookup{$param}||'';
+ my $res = TmpLookup_geoip_city_maxmind($param);
if ($type eq 'geoippureperl') {
if (! $res) {
my @record = ();
sub GetCountryCodeByName_geoip_city_maxmind {
my $param="$_[0]";
# <-----
- if (!$LoadedOverride){&LoadOverrideFile_geoip_city_maxmind();}
- my $res=$TmpDomainLookup{$param}||'';
+ my $res = TmpLookup_geoip_city_maxmind($param);
if ($type eq 'geoippureperl') {
if (! $res) {
my @record = ();
elsif ($param)
{
# try loading our override file if we haven't yet
- if (!$LoadedOverride){&LoadOverrideFile_geoip_city_maxmind();}
my $ip=0;
my $key;
if ($param =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/) { # IPv4 address
if ($key && $ip==4) {
my $country;
my $city;
- my @res;
- if ($geoip_city_maxmind){@res = @{$TmpDomainLookup{$geoip_city_maxmind->get_ip_address($param)}};}
- else {@res = @{$TmpDomainLookup{$param}};}
+ my @res = TmpLookup_geoip_city_maxmind($param);
+ if (!@res){
+ @res=$geoip_city_maxmind->get_city_record($param) if $geoip_city_maxmind;
+ }
if (@res){
$country = $res[0];
$city = $res[4];
if (! $key) {
my $country;
my $city;
- my @res;
- if ($geoip_city_maxmind){@res = @{$TmpDomainLookup{$geoip_city_maxmind->get_ip_address($param)}};}
- else {@res = @{$TmpDomainLookup{$param}};}
+ my @res = TmpLookup_geoip_city_maxmind($param);
+ if (!@res){
+ @res=$geoip_city_maxmind->get_city_record($param) if $geoip_city_maxmind;
+ }
if (@res){
$country = $res[0];
$city = $res[4];
sub SectionProcessIp_geoip_city_maxmind {
my $param="$_[0]"; # Param must be an IP
# <-----
- if (!$LoadedOverride){&LoadOverrideFile_geoip_city_maxmind();}
if ($type eq 'geoippureperl') {
- my @record = ();
- my @res;
- if ($geoip_city_maxmind){@res = @{$TmpDomainLookup{$geoip_city_maxmind->get_ip_address($param)}};}
- else {@res = @{$TmpDomainLookup{$param}};}
- if (!@res){
+ my @record = TmpLookup_geoip_city_maxmind($param);
+ if (!@record){
@record=$geoip_city_maxmind->get_city_record($param) if $geoip_city_maxmind;
}
if ($Debug) { debug(" Plugin $PluginName: GetCityByName for $param: [@record]",5); }
else
{
my $record=();
- if ($TmpDomainLookup{$param}){
- @record = $TmpDomainLookup{$param};
+ my $city, $countrycity, $region;
+ my @rec = TmpLookup_geoip_city_maxmind($param);
+ if (@rec){
+ $city = $rec[4];
+ $countrycity = $rec[3];
+ $region = $rec[0];
}else{
$record=$geoip_city_maxmind->record_by_addr($param) if $geoip_city_maxmind;
+ if ($record){
+ $city = $record->city;
+ $countrycity = $record->country_code;
+ $region = $record->region;
+ }
}
- if ($Debug) { debug(" Plugin $PluginName: GetCityByIp for $param: [$record]",5); }
- if ($record) {
- my $city=$record->city;
+ if ($Debug) { debug(" Plugin $PluginName: GetCityByIp for $param: [$city]",5); }
+ if ($city) {
# if ($PageBool) { $_city_p{$city}++; }
if ($city) {
- my $countrycity=($record->country_code).'_'.$city;
+ my $countrycity=$countrycity.'_'.$city;
$countrycity=~s/ /%20/g;
- if ($record->region) { $countrycity.='_'.$record->region; }
+ if ($region) { $countrycity.='_'.$region; }
$_city_h{lc($countrycity)}++;
} else {
$_city_h{'unknown'}++;
#-----------------------------------------------------------------------------
sub SectionProcessHostname_geoip_city_maxmind {
my $param="$_[0]"; # Param must be an IP
- # <-----
- # if the record is already in our temp array, then return
- #if ($TmpDomainLookup{$param}){ return; }
- if (!$LoadedOverride){&LoadOverrideFile_geoip_city_maxmind();}
if ($type eq 'geoippureperl') {
- my @record = ();
- my @res;
- if ($geoip_city_maxmind){@res = @{$TmpDomainLookup{$geoip_city_maxmind->get_ip_address($param)}};}
- else {@res = @{$TmpDomainLookup{$param}};}
- if (!@res){
+ my @record = TmpLookup_geoip_city_maxmind($param);
+ if (!@record){
@record=$geoip_city_maxmind->get_city_record($param) if $geoip_city_maxmind;
}
if ($Debug) { debug(" Plugin $PluginName: GetCityByName for $param: [@record]",5); }
else
{
my $record=();
- if ($TmpDomainLookup{$param}){
- @record = $TmpDomainLookup{$param};
+ my @rec = TmpLookup_geoip_city_maxmind($param);
+ if (@rec){
+ $record->city = $rec[4];
+ $record->region = $rec[3];
+ $record->country_code = $rec[0];
}else{
$record=$geoip_city_maxmind->record_by_name($param) if $geoip_city_maxmind;
}
return;
}
+#-----------------------------------------------------------------------------
+# PLUGIN FUNCTION: TmpLookup
+# Searches the temporary hash for the parameter value and returns the corresponding
+# GEOIP entry
+#-----------------------------------------------------------------------------
+sub TmpLookup_geoip_city_maxmind(){
+ $param = shift;
+ if (!$LoadedOverride){&LoadOverrideFile_geoip_city_maxmind();}
+ my @val = ();
+ if ($geoip_city_maxmind &&
+ (($type eq 'geoip' && $geoip_city_maxmind->VERSION >= 1.30) ||
+ $type eq 'geoippureperl' && $geoip_city_maxmind->VERSION >= 1.17)){
+ @val = @{$TmpDomainLookup{$geoip_city_maxmind->get_ip_address($param)}};
+ }
+ else {@val = @{$TmpDomainLookup{$param};}}
+ return @val;
+}
+
+
1; # Do not remove this line
print "</th>";
}
elsif ($param) {
- # try loading our override file if we haven't yet
- if (!$LoadedOverride){&LoadOverrideFile_geoip_isp_maxmind();}
my $ip=0;
my $key;
if ($param =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/) { # IPv4 address
}
print "<td>";
if ($key && $ip==4) {
- my $isp;
- if ($geoip_isp_maxmind){$isp = $TmpDomainLookup{$geoip_isp_maxmind->get_ip_address($param)};}
- else {$isp = $TmpDomainLookup{$param};}
+ my $isp = TmpLookup_geoip_isp_maxmind($param);
if (!$isp && $type eq 'geoippureperl')
{
# Function isp_by_addr does not exists in PurePerl but isp_by_name do same
print "<span style=\"color: #$color_other\">$Message[0]</span>";
}
if (! $key) {
- my $isp;
- if ($geoip_isp_maxmind){$isp = $TmpDomainLookup{$geoip_isp_maxmind->get_ip_address($param)};}
- else {$isp = $TmpDomainLookup{$param};}
+ my $isp = TmpLookup_geoip_isp_maxmind($param);
if (!$isp && $type eq 'geoippureperl')
{
$isp=$geoip_isp_maxmind->isp_by_name($param) if $geoip_isp_maxmind;
sub SectionProcessIp_geoip_isp_maxmind {
my $param="$_[0]"; # Param must be an IP
# <-----
- if (!$LoadedOverride){&LoadOverrideFile_geoip_isp_maxmind();}
- my $isp;
- if ($geoip_isp_maxmind){$isp = $TmpDomainLookup{$geoip_isp_maxmind->get_ip_address($param)};}
- else {$isp = $TmpDomainLookup{$param};}
+ my $isp = TmpLookup_geoip_isp_maxmind($param);
if (!$isp && $type eq 'geoippureperl')
{
# Function isp_by_addr does not exists in PurePerl but isp_by_name do same
sub SectionProcessHostname_geoip_isp_maxmind {
my $param="$_[0]"; # Param must be an IP
# <-----
- if (!$LoadedOverride){&LoadOverrideFile_geoip_isp_maxmind();}
- my $isp;
- if ($geoip_isp_maxmind){$isp = $TmpDomainLookup{$geoip_isp_maxmind->get_ip_address($param)};}
- else {$isp = $TmpDomainLookup{$param};}
+ my $isp = TmpLookup_geoip_isp_maxmind($param);
if (!$isp && $type eq 'geoippureperl')
{
$isp=$geoip_isp_maxmind->isp_by_name($param) if $geoip_isp_maxmind;
return;
}
+#-----------------------------------------------------------------------------
+# PLUGIN FUNCTION: TmpLookup
+# Searches the temporary hash for the parameter value and returns the corresponding
+# GEOIP entry
+#-----------------------------------------------------------------------------
+sub TmpLookup_geoip_isp_maxmind(){
+ $param = shift;
+ if (!$LoadedOverride){&LoadOverrideFile_geoip_isp_maxmind();}
+ my $val;
+ if ($geoip_isp_maxmind &&
+ (($type eq 'geoip' && $geoip_isp_maxmind->VERSION >= 1.30) ||
+ $type eq 'geoippureperl' && $geoip_isp_maxmind->VERSION >= 1.17)){
+ $val = $TmpDomainLookup{$geoip_isp_maxmind->get_ip_address($param)};
+ }
+ else {$val = $TmpDomainLookup{$param};}
+ return $val || '';
+}
+
1; # Do not remove this line
print "</th>";
}
elsif ($param) {
- if (!$LoadedOverride){&LoadOverrideFile_geoip_org_maxmind();}
my $ip=0;
my $key;
if ($param =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/) { # IPv4 address
}
print "<td>";
if ($key && $ip==4) {
- my $org;
- if ($geoip_org_maxmind){$org = $TmpDomainLookup{$geoip_org_maxmind->get_ip_address($param)};}
- else {$org = $TmpDomainLookup{$param};}
+ my $org = TmpLookup_geoip_org_maxmind($param);
if (!$org && $type eq 'geoippureperl')
{
# Function org_by_addr does not exists in PurePerl but org_by_name do same
print "<span style=\"color: #$color_other\">$Message[0]</span>";
}
if (! $key) {
- my $org;
- if ($geoip_org_maxmind){$org = $TmpDomainLookup{$geoip_org_maxmind->get_ip_address($param)};}
- else {$org = $TmpDomainLookup{$param};}
+ my $org = TmpLookup_geoip_org_maxmind($param);
if (!$org && $type eq 'geoippureperl')
{
$org=$geoip_org_maxmind->org_by_name($param) if $geoip_org_maxmind;
sub SectionProcessIp_geoip_org_maxmind {
my $param="$_[0]"; # Param must be an IP
# <-----
- if (!$LoadedOverride){&LoadOverrideFile_geoip_org_maxmind();}
- my $org;
- if ($geoip_org_maxmind){$org = $TmpDomainLookup{$geoip_org_maxmind->get_ip_address($param)};}
- else {$org = $TmpDomainLookup{$param};}
+ my $org = TmpLookup_geoip_org_maxmind($param);
if (!$org && $type eq 'geoippureperl')
{
# Function org_by_addr does not exists in PurePerl but org_by_name do same
sub SectionProcessHostname_geoip_org_maxmind {
my $param="$_[0]"; # Param must be an IP
# <-----
- if (!$LoadedOverride){&LoadOverrideFile_geoip_org_maxmind();}
- my $org;
- if ($geoip_org_maxmind){$org = $TmpDomainLookup{$geoip_org_maxmind->get_ip_address($param)};}
- else {$org = $TmpDomainLookup{$param};}
+ my $org = TmpLookup_geoip_org_maxmind($param);
if (!$org && $type eq 'geoippureperl')
{
$org=$geoip_org_maxmind->org_by_name($param) if $geoip_org_maxmind;
return;
}
+#-----------------------------------------------------------------------------
+# PLUGIN FUNCTION: TmpLookup
+# Searches the temporary hash for the parameter value and returns the corresponding
+# GEOIP entry
+#-----------------------------------------------------------------------------
+sub TmpLookup_geoip_org_maxmind(){
+ $param = shift;
+ if (!$LoadedOverride){&LoadOverrideFile_geoip_org_maxmind();}
+ my $val;
+ if ($geoip_org_maxmind &&
+ (($type eq 'geoip' && $geoip_org_maxmind->VERSION >= 1.30) ||
+ $type eq 'geoippureperl' && $geoip_org_maxmind->VERSION >= 1.17)){
+ $val = $TmpDomainLookup{$geoip_org_maxmind->get_ip_address($param)};
+ }
+ else {$val = $TmpDomainLookup{$param};}
+ return $val || '';
+}
+
1; # Do not remove this line
print "<td>";
if ($key && $ip==4) {
my ($res1,$res2,$countryregion)=();
- my @res;
- if ($geoip_region_maxmind){@res = @{$TmpDomainLookup{$geoip_region_maxmind->get_ip_address($param)}};}
- else {@res = @{$TmpDomainLookup{$param}};}
+ my @res = TmpLookup_geoip_region_maxmind($param);
if (@res){
$res1 = $res[0];
$res2 = $res[1];
}
if (! $key) {
my ($res1,$res2,$countryregion)=();
- my @res;
- if ($geoip_region_maxmind){@res = @{$TmpDomainLookup{$geoip_region_maxmind->get_ip_address($param)}};}
- else {@res = @{$TmpDomainLookup{$param}};}
+ my @res = TmpLookup_geoip_region_maxmind($param);
if (@res){
$res1 = $res[0];
$res2 = $res[1];
sub SectionProcessIp_geoip_region_maxmind {
my $param="$_[0]"; # Param must be an IP
# <-----
- if (!$LoadedOverride){&LoadOverrideFile_geoip_region_maxmind();}
my ($res1,$res2,$countryregion)=();
- my @res;
- if ($geoip_region_maxmind){@res = @{$TmpDomainLookup{$geoip_region_maxmind->get_ip_address($param)}};}
- else {@res = @{$TmpDomainLookup{$param}};}
+ my @res = TmpLookup_geoip_region_maxmind($param);
if (@res){
$res1 = $res[0];
$res2 = $res[1];
sub SectionProcessHostname_geoip_region_maxmind {
my $param="$_[0]"; # Param must be a hostname
# <-----
- if (!$LoadedOverride){&LoadOverrideFile_geoip_region_maxmind();}
my ($res1,$res2,$countryregion)=();
- my @res;
- if ($geoip_region_maxmind){@res = @{$TmpDomainLookup{$geoip_region_maxmind->get_ip_address($param)}};}
- else {@res = @{$TmpDomainLookup{$param}};}
+ my @res = TmpLookup_geoip_region_maxmind($param);
if (@res){
$res1 = $res[0];
$res2 = $res[1];
return;
}
+#-----------------------------------------------------------------------------
+# PLUGIN FUNCTION: TmpLookup
+# Searches the temporary hash for the parameter value and returns the corresponding
+# GEOIP entry
+#-----------------------------------------------------------------------------
+sub TmpLookup_geoip_region_maxmind(){
+ $param = shift;
+ if (!$LoadedOverride){&LoadOverrideFile_geoip_region_maxmind();}
+ my @val = ();
+ if ($geoip_region_maxmind &&
+ (($type eq 'geoip' && $geoip_region_maxmind->VERSION >= 1.30) ||
+ $type eq 'geoippureperl' && $geoip_region_maxmind->VERSION >= 1.17)){
+ @val = @{$TmpDomainLookup{$geoip_region_maxmind->get_ip_address($param)}};
+ }
+ else {@val = @{$TmpDomainLookup{$param};}}
+ return @val;
+}
+
1; # Do not remove this line