More information about the Underscore mailing list

[_] IP to country databases

Martin Wheatley martin at spodnet.net
Thu Jul 25 13:14:39 BST 2013

Yeah, I use PHP.

Will look at geoip didn't know it was available as an extension, I was 
running with the MaxMind PHP code.

We do get some foreign enquiries, so I could score on language accept 
header.

URL's are blocked completely already

Spamhaus - seems like a possible solution too, will test it and see how 
quick it performs.

Some good suggestions, thanks.

Martin


On 25/07/2013 11:46, David Goodwin wrote:
> Assuming you're using php (!?) there's a geoip extension - which I think uses maxmind.
>
> But you do need to make sure you've got an up to date version of their DB - so using e.g. Debian stable is probably a bad idea, you'd want to get it from e.g. Debian back ports or similar.
>
>
>
> Usage is quite simple - e.g.
>
> $continent = geoip_continent_code_by_name($remote_ip);
>
> (e.g. 'AS' for Asia).
>
>
> I also found it useful to :
>
>   * Check the language accept header from the remote user - if they're not english, then perhaps they're dodgy…
>   * See if there are e.g. obvious non-english characters in the content -  ( 	if(preg_match("/\p{Han}+/u", $text)) { …. }  )
>   * See if there are more than N URLs (where N is >= 1 in  your case?)
>   * Use spamhaus - like :
>
> $remote_ip = $_SERVER['REMOTE_ADDR'];
> $rbl = 'sbl-xbl.spamhaus.org';
> $rev = array_reverse(explode('.', $remote_ip));
> $lookup = implode('.', $rev) . '.' . $rbl;
> $spamhaus_result = gethostbyname($lookup);
> if(preg_match('/127.0.0./', $spamhaus_result)) {
> 	// spamhaus lookup for $remote_ip failed ($spamhaus_result). Probably spam
> }
> else {
> 	// $remote_ip not listed in spamhaus ($spamhaus_result) ...
> }
>
>
> thanks,
>
> David
>
>
> On 25 Jul 2013, at 11:35, Martin Wheatley <martin at spodnet.net> wrote:
>
>> Hi,
>>
>> Has anyone had any experience in using the free ip address to country databases out there, maxmind, ip2location ?
>>
>> Are there any others ? Any issues ?
>>
>> As part of an ongoing attempt to clean up enquiries on a website I need to filter out or put warning messages on enquiries from outside of the UK, so want to block certain countries, and add warning messages onto the emails for others.
>>
>> I don't need 100% accurate results, as I would just put a warning message if it doesn't come up with something useful (I've found maxmind doesn't have enough data for the ip addresses I tested with for instance).
>>
>> Are there any free high availability web services I could use (although would prefer local install for availability and speed reasons).
>>
>> Thanks
>>
>> Martin
>>
>> --
>> underscore_ list info/archive -> http://www.under-score.org.uk/mailman/listinfo/underscore
>
>