how to get information about browser using apache

  • crazzyDemon
  • Beginner
  • Beginner
  • User avatar
  • Posts: 55

Post 3+ Months Ago

Hi,

i need to show different pages depends on enabled javascript in client browser or not.

i'm looking someting like
Code: [ Select ]
get_browser();

function in PHP.

Thanks.
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • joebert
  • Sledgehammer
  • Genius
  • User avatar
  • Posts: 13496
  • Loc: Florida

Post 3+ Months Ago

I imagine you're stuck doing it at the server because of existing content that would make no sense to start over with, but just so you know for next time, you're doing it wrong. :)

Without using a custom Apache module or hacking together a ghastly BrowserMatch chain, the closest things Apache has to get_browser are Content Negotiation which deals with the visitors Language & is really of no use here, and RewriteMap which is of use because it will let us return a different URI based on the output of an external application, such as a shell script that mimicks the functionality of get_browser using our own browscap.ini.

Managing browser capabilities at the server is inefficient, considering that a single <script src...> line in the HTML source can be used to offload the processing required entirely to the visitors computer. If the <script> loads, JS is enabled and that <script> can be used to enhance the application via the DOM. I believe the term is "Unobtrusive Javascript".
  • gkumar
  • Beginner
  • Beginner
  • gkumar
  • Posts: 39

Post 3+ Months Ago

Every HTTP requests made by any client web browsers to an Apache should conform to the HTTP specification and provide certain set of headers information for the server to parse and understand. Useful headers information that can be retrieved in PHP by function apache_request_headers() includes:

1. User-Agent: Operating System, browser and its version number, …
2. Accept-Language: Requesting client language
3. Accept-Charset: Character set of the client
4. …

To get an array of the above client request headers information, just use apache_request_headers() function:

Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: No registered users and 90 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.