OMG - Spam on my new site

Danny

Affiliate Guard Dog Member
Joined
May 8, 2008
Messages
45
Reaction score
0
My is not even index by google and I got so much spam already. I check my comment table and I saw that their ip_numbers (not ip_address) are 0s (zero).

I used ip2long to convert the ip_address to ip_number {ip2long($_SERVER['REMOTE_ADDR'])}.

How come their IPs are 0s?



Code:
Hi everyone. Great site. Hold on.
cosmetics cosmetics cosmetics cosmetics cosmetics cosmetics cosmetics cosmetics 
[url=http://cosmetics]cPanel®[/url][url=http://cosmetics]cPanel®[/url][url=http://cosmetics]cPanel®[/url][url=http://cosmetics]cPanel®[/url][url=http://cosmetics]cPanel®[/url][url=http://cosmetics]cPanel®[/url][url=http://cosmetics]cPanel®[/url][url=http://cosmetics]cPanel®[/url][url=http://cosmetics]cPanel®[/url][url=http://cosmetics]cPanel®[/url]
 
Last edited:

Guard Dog

Guard Dog
Staff member
Joined
Dec 13, 2006
Messages
11,353
Reaction score
3,179
I am not sure why you would want to convert the IP address to a long data type? Wouldn't you want to see it as xxx.xxx.xxx.xxx?

Regardless, the following should work


PHP:
$referrer_ip = getenv(REMOTE_ADDR); 
$ip_address =ip2long($ip);

Or, if you are on versions of php earlier than 5.0:

PHP:
$remote_ip = getenv(REMOTE_ADDR); 
$ip_extract = explode (".",$remote_ip);
$code=($ip_extract[0] * 16777216) + ($ip_extract[1] * 65536) + ($ip_extract[2] * 256) + ($ip_extract[3]);


If you want to see it as xxx.xxx.xxx.xxx, then:

PHP:
$referrer_ip = getenv(REMOTE_ADDR);


If you want to grab each octet of the IP address:

PHP:
 $remote_ip = getenv(REMOTE_ADDR); 
$ip_extract = explode (".",$remote_ip);


$octet1 = $ip_extract[0];
$octet2 = $ip_extract[2];
$octet3 = $ip_extract[3];
$octet4 = $ip_extract[4];


I hope that helps :)
 

Danny

Affiliate Guard Dog Member
Joined
May 8, 2008
Messages
45
Reaction score
0
The reason I am using ip2long is because I implemented maxmind ip-country database on my system.

maxmind using ip number instead of ip address. So I like to use ip number as well for the ease and robustness of comparison.

There shouldn't be any problem as my server uses the latest version of PHP. But, I'll try your method.

I also need to implement captcha to minimize the spamming. :)
 

Guard Dog

Guard Dog
Staff member
Joined
Dec 13, 2006
Messages
11,353
Reaction score
3,179
The reason I am using ip2long is because I implemented maxmind ip-country database on my system.

maxmind using ip number instead of ip address. So I like to use ip number as well for the ease and robustness of comparison.

There shouldn't be any problem as my server uses the latest version of PHP. But, I'll try your method.

I also need to implement captcha to minimize the spamming. :)


I don't know why it wouldn't work, then... I would do an echo of the 'REMOTE_ADDR', then, to see if the problem starts there. There is a breakdown somewhere and it is either in the function or in the IP address itself.
 

Danny

Affiliate Guard Dog Member
Joined
May 8, 2008
Messages
45
Reaction score
0
Look, my ip address/number is shown correctly. I even try different IPs. I don't know why their ips doesn't shown!
 

Guard Dog

Guard Dog
Staff member
Joined
Dec 13, 2006
Messages
11,353
Reaction score
3,179
Here's a little function I found that might help you out:

PHP:
function GetIP()
{
   if (getenv("HTTP_CLIENT_IP") && strcasecmp(getenv("HTTP_CLIENT_IP"), "unknown"))
           $ip = getenv("HTTP_CLIENT_IP");
       else if (getenv("HTTP_X_FORWARDED_FOR") && strcasecmp(getenv("HTTP_X_FORWARDED_FOR"), "unknown"))
           $ip = getenv("HTTP_X_FORWARDED_FOR");
       else if (getenv("REMOTE_ADDR") && strcasecmp(getenv("REMOTE_ADDR"), "unknown"))
           $ip = getenv("REMOTE_ADDR");
else if (isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] && strcasecmp($_SERVER['REMOTE_ADDR'], "unknown"))
           $ip = $_SERVER['REMOTE_ADDR'];
       else
           $ip = "unknown";
   return($ip);
}

Now use the GetIP() function to return the IP and then convert it to a long data type.
 
Top