Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to check for media player using HTTP_USER_AGENT

Status
Not open for further replies.
Apr 28, 2006
69
NL
Hi all i want to write a php script that if only the request came from media player it work other wise it gives an error massage .for example if the request came from get or post or direct url execution in browser addrres i want it to send error message. I be happy if some one show me how to check for media players. I just do not know how to check for agent.Thanks


Code:
if($_SERVER['HTTP_USER_AGENT']=="your_user_agent") 
{ 
    //load your file 
} 
else 
{ 
    //load the error message 
}
 
It looks to me like you're on the right track.

If you need the actual strings, you can look here:
If what you need is not there, then I recommend you write a script that logs $_SERVER['HTTP_USER_AGENT'] to a file. You can then point various software at it and see what strings are sent.



Want the best answers? Ask the best questions! TANSTAAFL!
 
sleipnir214 many thanks for u reply. Could u show me how to log $_SERVER['HTTP_USER_AGENT'] to a file. When u see pointing it to to script .Do u mean opening the url from with in the sofware such as media player ?Thanks
 
I just tried this

<?php
$name=$_SERVER['HTTP_USER_AGENT'];
$handle = fopen("saved.txt", "w");
fputs($handle, $name);
fclose($handle);

?>

and get
from Windows Media Player 10

NSPlayer/10.0.0.3802


and
WinampMPEG/5.20

from Winamp 5.2

and from Firefox:
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.3) Gecko/20060426 Firefox/1.5.0.3

Bret Lanius
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top