Guest User

prickett

a guest
Apr 24th, 2008
472
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3.  
  4. class browser
  5. {
  6.  
  7.     private $agent_strings = array(
  8.         'Dillo',
  9.         'MIDP-',
  10.         'Ericsson',
  11.         'SonyEricsson',
  12.         'AvantGo',
  13.         'ATTWS',
  14.         'i-mode',
  15.         'SEC-',
  16.         'R600',
  17.         'Opera Mini'
  18.         );
  19.  
  20.  
  21.     private $browser_width_expections = array(
  22.         'Opera Mini'    => '98%',
  23.         'AvantGo'       => '95%'
  24.     );
  25.    
  26.  
  27.     public $browser = 'OTHER';
  28.  
  29.  
  30.     const DEFAULT_BROWSER_WIDTH = '100%';
  31.  
  32.  
  33.  
  34.     public function set_browser( $agent )
  35.     {
  36.  
  37.         foreach( $this->agent_strings as $str ) {
  38.             if ( stristr( $agent, $str ) !== FALSE ) {
  39.                 $this->browser = $str;
  40.                 break;
  41.             }
  42.         }
  43.  
  44.     } // END function set_browser
  45.  
  46.  
  47.  
  48.     public function get_width()
  49.     {
  50.  
  51.         if ( isset( $this->browser_width_expections[$this->browser] ) ) {
  52.             return $this->browser_width_expections[$this->browser];
  53.         }
  54.  
  55.         return self::DEFAULT_BROWSER_WIDTH;
  56.  
  57.     } // END function get_width
  58.  
  59. } // END class detect
  60.  
  61.  
  62.  
  63. $obj = new browser();
  64. $obj->set_browser( getenv("HTTP_USER_AGENT") );
  65.  
  66.  
  67. print 'Detected Browser: '.$obj->browser.'<br>';
  68. print 'Use width:'.$obj->get_width().'<br>';
  69.  
  70.  
  71. ?>
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×