I have been designing a security system to stop bots from spamming my forum. Basically, it will check if there is any isp name detected from the ip address then if there is no detected isp, the submitted post will not be made. I know to detect the ip address, I simply use:

$ip=$_SERVER[REMOTE_ADDR];

However it will only get the ip numbers. I need a php script which will only get the isp so i can do something along the lines of the following.

if($isp='') { } else {
//rest of code
}

The above code is just a sketch of what I think it will look like but I just need to be able to get the isp information in the $isp variable. I have searched and searched all over google and the hotscripts website and still haven't found the answer. Would anybody here be able to provide any links or ways to find the isp without any other info being bundled in the defining of the $isp variable. An example of what the data stored in the $isp variable would look like is:
qld.bigpond.net.au
or
nyc.res.rr.com

Thanks in advance

Recommended Answers

All 7 Replies

It took a long time looking at the page you have suggested but I found the answer deep within the page ShawnCplus suggested. Below is the script I found deep within the suggested link which works perfectly.

<?php
    $ip = $_SERVER['REMOTE_ADDR'];
    $fullhost = gethostbyaddr($ip);
    $host = preg_replace("/^[^.]+./", "", $fullhost);

echo $host;
?>

So thanks ShawnCplus as your reply will really help with preventing bots from spamming my forum.
*Solved*

$ip = $_SERVER['REMOTE_ADDR']; 
		$isptc = gethostbyaddr($ip); 
		$ispoh = preg_split("/./", $isptc); 
		$xy = count($ispoh); 
		$x = $xy - 1; 
		$y = $xy - 2; 
		$i = $xy - 3; 
		$ispp = $ispoh[$i]; 
		$isp = $ispoh[$y] . "." . $ispoh[$x]; 
		echo"<b>ip: $ip</b><br>"; 
		echo"<b>isp: $ispp$isp</b>";

Hope this works for you.

No guys you need to purchase isp information database.

I have been designing a security system to stop bots from spamming my forum. Basically, it will check if there is any isp name detected from the ip address then if there is no detected isp, the submitted post will not be made. I know to detect the ip address, I simply use:

$ip=$_SERVER[REMOTE_ADDR];

However it will only get the ip numbers. I need a php script which will only get the isp so i can do something along the lines of the following.

if($isp='') { } else {
//rest of code
}

The above code is just a sketch of what I think it will look like but I just need to be able to get the isp information in the $isp variable. I have searched and searched all over google and the hotscripts website and still haven't found the answer. Would anybody here be able to provide any links or ways to find the isp without any other info being bundled in the defining of the $isp variable. An example of what the data stored in the $isp variable would look like is:
qld.bigpond.net.au
or
nyc.res.rr.com

Thanks in advance

To convert from ip to isp information. you need to purchase that database.

Your first two posts on daniweb are bumping a 2 year old topic which by the way is clearly marked solved. Did you not read my signature or what are you doing just joining to only bump a really old topic twice. If you have any questions then start a new topic with a link to this topic and I will happily answer your questions. But as mentioned before the following code works.

<?php
    $ip = $_SERVER['REMOTE_ADDR'];
    $fullhost = gethostbyaddr($ip);
    $host = preg_replace("/^[^.]+./", "", $fullhost);
echo $host;
?>

And in case your interested the explode function would be better to use in this situation instead of preg replace but still you don't need a database to get the hostname as the information is already posted to php where php can report it to you.
I don't mean to be nasty or anything but sometimes you should know your limits. Eg. how older topic to post on and weather to post on a topic that's already solved.

No guys you need to purchase isp information database.

Thanks cwarn23.

Welcome 07.nilu. We appreciate your help. Have you ever noticed that the current thread is two years old? Please do not resurrect old threads and have a look at forum rules.

Thread Closed.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.