Re: Browser Sniffing
| From: | David Otton | Date: | Wed, 05 Mar 2003 02:34:46 +0000 |
| Subject: | Re: Browser Sniffing | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-138212@lists.php.net to get a copy of this message | ||
On Tue, 04 Mar 2003 18:32:33 -0700, you wrote:
> I know, it can't be done in PHP. That's not exactly what I'm here
>for. I have a client who would like to redirect people to a polite
>'upgrade your browser' page whenever people visit his site (which has
>been developed in PHP no less). My question here is, how can I make
>this so that regardless of what URL someone comes in to, it will always
>run the sniffer prior to loading the actual URL they visited? In other
>words, whether the visitor comes to the main url (http://www.site.org),
>or whether they are going to a specific link
>(http://ww.site.org/seethis/), the client would like the sniffer to
>check them all.
include ('badcode.inc')
at the top of every file.
badcode.inc looks at the HTTP_USER_AGENT, if it doesn't like it does a
header('Location: ')
to your "we don't want you as a customer" page, followed by
exit()
simple. You can probably deny access with mod_rewrite rules, also. That
may be quicker and more complete (the above only works with PHP pages,
obviously).
> I know I can stick the whole javascript sniffer into each and every
Forget about javascript. I bet half the users you want to exclude don't
run javascript.
> Suggestions welcome.
Well... don't do it. It's such a bad idea, on so many levels...