Jump to content

Archived

This topic is now archived and is closed to further replies.

wintallo

[SOLVED] User Agent Reader

Recommended Posts

Hey, I was wondering if anyone knew of a script that checked a user's browser user agent and either let them onto a page, or didn't let them onto a page. I mean, say I required a user to have the user agent:

Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.6) Gecko/20060728 Firefox/1.5.0.6

How would I make it so only people with this user agent could access a page. If you have no idea what i'm talking about, I want something that works like this website. (except not for PSP)

http://www.geneonanimation.com/psp/

Thanks!

Joel
wintallo.com

Share this post


Link to post
Share on other sites
[code]$ua = $_SERVER['HTTP_USER_AGENT'];
if ($ua != "some very long string") {
    die("You can't access this page as you have the wrong user agent");
}[/code]

Share this post


Link to post
Share on other sites
reliance on the user agent string is not bullet proof, because it is of course dependant on the user agent broadcasting it in the first place.

FireFox allows the user to change their user agent string quite easily for example.

In other words.. make your site accessible to all browsers.

Should also use a keyword search rather than standard comparison:
[code]<?php

if (stripos('mozilla', $_SERVER['HTTP_USER_AGENT']) === false) {
    die('Get firefox.');
}

?>[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.