This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Jul 20th, 2013  |  syntax: None  |  size: 2.00 KB  |  views: 985  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. request.env['HTTP_USER_AGENT']
  2.  
  3. Chrome out put is below
  4. Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.205 Safari/534.16
  5. Safari out put is below
  6. Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/5.0.5 Safari/533.21.1
  7. FireFox out put is below
  8. Mozilla/5.0 (Windows NT 5.1; rv:2.0) Gecko/20100101 Firefox/4.0
  9. Opera out put is below
  10. Opera/9.80 (Windows NT 5.1; U; en) Presto/2.8.131 Version/11.10
  11. Internet Explorer out put is below
  12. Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727)
  13.        
  14. if request.env['HTTP_USER_AGENT'] =~ /[^(]*[^)]Chrome//
  15.        
  16. if request.env['HTTP_USER_AGENT'] =~ /[^(]*[^)]*[^t]Firefox//
  17.        
  18. def browser_detection
  19.         result  = request.env['HTTP_USER_AGENT']
  20.         browser_compatible = ''
  21.         if result =~ /Safari/
  22.           unless result =~ /Chrome/
  23.             version = result.split('Version/')[1].split(' ').first.split('.').first
  24.             browser_compatible = 'Application is not functional for Safari version's '+version if version.to_i < 5
  25.           else
  26.             version = result.split('Chrome/')[1].split(' ').first.split('.').first
  27.             browser_compatible = 'Application is not functional for Chrome version's '+version if version.to_i < 10
  28.           end
  29.         elsif result =~ /Firefox/
  30.           version = result.split('Firefox/')[1].split('.').first
  31.           browser_compatible = 'Application is not functional for Firefox version's '+version if version.to_i < 5
  32.         elsif result =~ /Opera/
  33.           version = result.split('Version/')[1].split('.').first
  34.           browser_compatible = 'Application is not functional for Opera version's '+version if version.to_i < 11
  35.         elsif result =~ /MSIE/
  36.           version = result.split('MSIE')[1].split(' ').first
  37.           browser_compatible = 'Application is not functional for Microsoft Internet Explorer version's '+version if version.to_i < 9
  38.         end
  39.         return browser_compatible
  40.       end
clone this paste RAW Paste Data