MyBB Community Forums

Full Version: PHP User Agent Help
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I have writtena simple PHP dynamic image generator/ad rotator, that displays images for a vb project of mine.

However i want to display a certain image saying "Web Browsers are not allowed to access this page" when a broswer like firefox, IE, safari etc... visits the page. I want to do this so people cant fraudulently increase the number of views for ads. I have been asked to do this by a company, as they dont want people to just keep autrefreshing a browser to waste the ad views thay pay for.

I think I want to do it via user agents. But how do i dynamically alter the image displayed depending on user agent? in php?
Basically, if there is a user agent, then dont display an image.
if(!$_SERVER('HTTP_REFERER'))
{
	// User is accessing page directly
}

?
The problem I have is, it uses a picturebox in vb.net, then use the webdownloader class (or maybe it's webclient) to display the image. I don't know what user agent it uses.
>vb.net

sigh

Try it, .NET might send a referrer header.
Yeah Toungue vb.net

The most annoying language in the world
Seems I can set headers like this: http://msdn.microsoft.com/en-us/library/...S.80).aspx
It doesn't send the referral header automatically?
No, it goes without.

I could use:
if($_SERVER('HTTP_USER_AGENT') == "My Custom Header")
{
    // User is accessing page through my software
} else {
//user is using a standard browser (or is a bot)
}
Yea but you can easily spoof the useragent, I don't quite understand what you're checking for.
Its only to stop people from finding it by accident, and slow abusers down Smile
Even simpler solution - don't charge based on views, do it based on time or something else.
Pages: 1 2