Camen Design Forum

Delete

(Leave this as-is, it’s a trap!)

To delete this post you must be either the original author or a designated moderator.
The content of the post will be removed but the name and date will remain.

  • The post will be removed completely from the thread, rather than blanked
  • Only posts on the last page of the thread can be removed completely (so as to not break permalinks)

RE[6]: Banning By IPs

Jos

I've changed my approach since freegeoip.net will be closed.

I've started to experiment with DNSBL's which is a simpler and in my case faster approach.

Im playing with the following code.

----

%
<?php
	function dnsblTjek( $ip_address = NULL, $dnsbl = NULL )
	{
				
		if( filter_var($ip_address, FILTER_VALIDATE_IP) === false ) //Invalid IP
			return false;
		

		/*reverse IP address */
		$array = explode( ".", $ip_address );
		$array = array_reverse( $array );
		$reverse_ip = implode( ".", $array );

		/* Perform the check */
		$result = gethostbyname( $reverse_ip.".".$dnsbl );
		return $result;
	}

	function isDanish($ipadress){
		$returncode= dnsblTjek( $ipadress, "zz.countries.nerd.dk" );
		if ($returncode == '127.0.0.208') //Code for denmark - https://en.wikipedia.org/wiki/ISO_3166-1_numeric
			return true;
		else 
			return false;
	}

	function isTorNode ($ipadress){
		$returncode= dnsblTjek( $ipadress, "torexit.dan.me.uk" );

		if ($returncode == '127.0.0.100') //see dan.me.uk
			return true;
		else 
			return false;
	}

isTorNode("185.220.101.6");
isDanish("185.220.101.6");
%

Your friendly neighbourhood moderators: Kroc, Impressed, Martijn