gethostbyaddr or .htaccess is best?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ripples
Forum Newbie
Posts: 6
Joined: Fri Jan 18, 2008 3:36 pm

gethostbyaddr or .htaccess is best?

Post by ripples »

Anybody know which method is faster/better for banning hosts:

php or .htaccess ?

Code: Select all

if(gethostbyaddr($_SERVER['REMOTE_ADDR'])=="something"{
exit;
}

Code: Select all

Order Deny,Allow
Deny from thesite.com
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: gethostbyaddr or .htaccess is best?

Post by RobertGonzalez »

Since PHP eventually gets parsed by the server, anything that can happen at the server request level would probably be much faster (even moreso since the request would not need to be interpreted like the PHP script would).
ripples
Forum Newbie
Posts: 6
Joined: Fri Jan 18, 2008 3:36 pm

Re: gethostbyaddr or .htaccess is best?

Post by ripples »

Ok, sounds logical :oops:

It seems it is not recommended to ban using hosts. Is it better to ban using IPs ? Why is that, is it faster ?

Is there any way to translate the below host to IP ranges ? (this host is really an ISP)

Code: Select all

Order Deny,Allow
Deny from .rima-tde.net
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: gethostbyaddr or .htaccess is best?

Post by RobertGonzalez »

You really don't want to ban by IP because IP addresses are terribly unreliable as identifiers.
Post Reply