Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8158983
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T17:46:49+00:00 2026-06-06T17:46:49+00:00

browscap.ini that get_browser() depends on is found at http://browsers.garykeith.com/downloads Does anyone know how to

  • 0

browscap.ini that get_browser() depends on is found at http://browsers.garykeith.com/downloads

Does anyone know how to port the seemingly simple get_browser() to CFML?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T17:46:50+00:00Added an answer on June 6, 2026 at 5:46 pm

    Solved!

    This is based on http://forums.adobe.com/thread/620512, and optimized for performance with improved correctness.

    It is still quite slow (~1s) because working with ini file with ColdFusion means every getProfileString() is a disk I/O! Might be faster with SSD. 🙂

    function get_browser(user_agent=CGI.HTTP_USER_AGENT, browscap_ini=expandPath("./browscap.ini"))
    {
        var result = {};
    
        // Read wildcard patterns from the INI file
        var browscap_list = getProfileSections(browscap_ini);
    
        // Seed some variables
        var browser_champion_pattern = "*";
    
        // Loop through the patterns to find the best match (relative to length of name pattern)
        for (var browser_name_pattern in browscap_list)
        {
            if (len(browser_name_pattern) >= len(browser_champion_pattern))
            {
                // Massage the wildcard into useable regex
                var browser_name_regex = replaceList(browser_name_pattern, ".,*,?,(,),[,]", "\.,.*,.,\(,\),\[,\]");
    
                if (left(browser_name_pattern, 1) != "*")
                    browser_name_regex = "^" & browser_name_regex;
    
                if (right(browser_name_pattern, 1) != "*")
                    browser_name_regex &= "$";
    
                // Test the resulting regex against the user agent
                if (reFindNoCase(browser_name_regex, user_agent))
                    browser_champion_pattern = browser_name_pattern;
            }
        }
    
        // Set the winning regex patterns
        var browser_name_pattern = browser_champion_pattern;
    
        // Fetch the winning info
        var keynames = listToArray(browscap_list[browser_champion_pattern]);
        for (var keyname in keynames)
            result[keyname] = getProfileString(browscap_ini, browser_champion_pattern, keyname);
    
        // Fetch the rest of the info from parents
        while (structKeyExists(result, "parent"))
        {
            var parent = result.parent;
    
            structDelete(result, "parent");
    
            var keynames = listToArray(browscap_list[parent]);
            for (var keyname in keynames)
                if (!structKeyExists(result, keyname))
                    result[keyname] = getProfileString(browscap_ini, parent, keyname);
        }
    
        return result;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried enabling php_browscap.ini so that I can use the get_browser function.
I've been using http://code.google.com/p/phpbrowscap/ for a project, and it usually works nice. But a
I downloaded the browscap.ini file and then pasted it to the directory C:\wamp\bin\php\php5.4.3\extras and
I'm using the get_browser() function in an attempt to warn people that their browser
For the past few years I have been using Gary Keith's browscap file to
I am developing an application that uses javascript to perform some arithmetical calculations in
I am trying to use PHP's built-in function get_browser() . I followed the instructions
When using the get_browser function in PHP on: Linux server - works perfectly. WAMP
I'm on Hostmonster running Linux and I want to install the browsercap.ini on my
I have a cronjob that summarize browser statistics. This cronjob loads data and then

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.