Forum Moderators: coopster

Message Too Old, No Replies

Sniff a user's city by remote host

         

jake66

2:59 am on Dec 14, 2007 (gmt 0)

10+ Year Member



Is this possible?

I would like to redirect every user in "los angeles" for example, to a certain page.

I tried:

if ($_SERVER['REMOTE_HOST'] contains 'angeles'){
echo'it worked';
}

...but obviously it did not work.

Now I realize this isn't fool proof and not all ISPs place city names in the remote host. It doesn't need to be fool proof, as this is only a temporary redirect for now.

deMorte

9:41 am on Dec 14, 2007 (gmt 0)

10+ Year Member



Try this:


$host = $_SERVER['REMOTE_HOST'];

if ( strpos($host,'angeles'))
{
echo'it worked';
}

jake66

7:30 pm on Dec 15, 2007 (gmt 0)

10+ Year Member



Thank you so much!

Do I need to put any security filters to filter out html characters in case some script kiddie figures out they're being redirected and thinks they found a way into my site?

deMorte

11:35 am on Dec 17, 2007 (gmt 0)

10+ Year Member



I'm not sure what kind of information $_SERVER['REMOTE_HOST'] contains, I haven't really used this in any application.
If the html character filter does not create any problems, why not use it?
Then again, if this redirect is just a temporary solution, it may be a waste of time.