compatibility1Add my vote for this tag create new tag
, view all tags

Agent Plugin

Identify a browser using configurable rules


This plugin allows to identify a browser according to it's the user_agent string it supplies in the query.

Syntax Rules

  • Use %AGENT% to print out the whole user_agent information.
    • Your Browser identifies as: %AGENT%
  • Use %AGENT{check="TYPE}% to choose predefined version independent identification.
    • Your Browser identifies as: %AGENT{check="TYPE"}%
  • Use %AGENT{check="VERSION"}% to choose predefined version dependent identification.
    • Your Browser identifies as: %AGENT{check="VERSION"}%
  • Use %AGENT{check="msie firefox3 firefox4 safari"}% to select your own ID set - note that most specific rule names must be listed first
    • Your Browser yields: %AGENT{check="msie firefox3 firefox4 safari"}%
  • Add none="idontknow" to choose a different fallback id from "%AGENTPLUGIN_NONE%"
  • Use %AGENT{check="gecko6 gecko7" none="nogecko" expgecko6="Gecko.*6" expgecko7="Gecko.*7"}% to specify seldomly needed checks
    • Your Browser yields: %AGENT{check="gecko6 gecko7" none="nogecko" expgecko6="Gecko.*6" expgecko7="Gecko.*7"}%
  • Any non-alphanumeric character will be removed from the listes IDs for the check whilst the original ID will be returned: %AGENT{check=".msie .firefox .safari" none=""}%
    • Your Browser yields "%AGENT{check=".msie .firefox .safari"}%"

AgentPlugin Global Settings

Plugin settings are stored as preferences variables. To reference a plugin setting write %<plugin>_<setting>%, i.e. %AGENTPLUGIN_SHORTDESCRIPTION%

  • One line description, is shown in the TextFormattingRules topic:
    • Set SHORTDESCRIPTION = Identify a browser using configurable rules

  • Fallback value for non-matching user agents:
    • Set NONE = unknown

  • Predefined ID sets - note that most specific rule names must be listed first:
    • Set CHECKTYPE = msie safari firefox netscape
    • Set CHECKVERSION = msie50 msie52 msie5 msie6 msie7 msie8 msie9 msie safari firefox1 firefox2 firefox30 firefox31 firefox32 firefox33 firefox34 firefox35 firefox36 firefox3 firefox40 firefox netscape4 netscape6 netscape7 netscape

  • Then, define expressions the user_agent information should be checked against to return the above identifiers:
    • Set EXPMSIE = MSIE
    • Set EXPMSIE5 = MSIE 5
    • Set EXPMSIE50 = MSIE 5.0
    • Set EXPMSIE52 = MSIE 5.2
    • Set EXPMSIE6 = MSIE 6
    • Set EXPMSIE7 = MSIE 7
    • Set EXPMSIE8 = MSIE 8
    • Set EXPMSIE9 = MSIE 9
    • Set EXPSAFARI = Safari
    • Set EXPFIREFOX = Firefox
    • Set EXPFIREFOX1 = Firefox/1
    • Set EXPFIREFOX2 = Firefox/2
    • Set EXPFIREFOX3 = Firefox/3
    • Set EXPFIREFOX30 = Firefox/3.0
    • Set EXPFIREFOX31 = Firefox/3.1
    • Set EXPFIREFOX32 = Firefox/3.2
    • Set EXPFIREFOX33 = Firefox/3.3
    • Set EXPFIREFOX34 = Firefox/3.4
    • Set EXPFIREFOX35 = Firefox/3.5
    • Set EXPFIREFOX36 = Firefox/3.6
    • Set EXPFIREFOX40 = Firefox/4.0
    • Set EXPNETSCAPE = Netscape
    • Set EXPNETSCAPE4 = Netscape/4
    • Set EXPNETSCAPE6 = Netscape/6
    • Set EXPNETSCAPE7 = Netscape/7

  • Debug plugin: (See output in data/debug.txt)
    • Set DEBUG = 0

Plugin Installation Instructions

Note: You do not need to install anything on the browser to use this plugin. The following instructions are for the administrator who installs the plugin on the server where TWiki is running.

  • Download the ZIP file from the Plugin web (see below)
  • Unzip AgentPlugin.zip in your twiki installation directory. Content:
    File: Description:
    data/TWiki/AgentPlugin.txt Plugin topic
    lib/TWiki/Plugins/AgentPlugin.pm Plugin Perl module
  • Visit configure in your TWiki installation, and enable the plugin in the {Plugins} section.
  • Test if the plugin is correctly installed:
    • Your Browser identifies as "%AGENT%"

Plugin Info

Plugin Author: TWiki:Main.AndyThaller
Copyright: © 2002 TWiki:Main.AndyThaller
© 2008-2011 TWiki:Main.TWikiContributors
License: GPL (GNU General Public License)
Plugin Version: 2011-02-01
Change History:  
2011-02-01: TWikibug:Item6638: Adding Firefox and Safari rules; doc improvements; changing TWIKIWEB to SYSTEMWEB -- TWiki:Main.PeterThoeny
2002-11-01: Improved capabilities
2002-10-31: Initial version
CPAN Dependencies: none
Other Dependencies: none
Perl Version: 5.005
Plugin Home: http://TWiki.org/cgi-bin/view/Plugins/AgentPlugin
Feedback: http://TWiki.org/cgi-bin/view/Plugins/AgentPluginDev

Related Topics: TWikiPreferences, TWikiPlugins

Topic attachments
I Attachment History Action Size Date Who Comment
Unknown file formatmd5 AgentPlugin.md5 r3 r2 r1 manage 0.2 K 2011-02-02 - 05:54 PeterThoeny  
Compressed Zip archivetgz AgentPlugin.tgz r3 r2 r1 manage 4.8 K 2011-02-02 - 05:54 PeterThoeny  
Compressed Zip archivezip AgentPlugin.zip r5 r4 r3 r2 r1 manage 6.2 K 2011-02-02 - 05:54 PeterThoeny  
Unknown file formatEXT AgentPlugin_installer r3 r2 r1 manage 3.3 K 2011-02-02 - 05:54 PeterThoeny  
Edit | Attach | Watch | Print version | History: r12 < r11 < r10 < r9 < r8 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r12 - 2013-10-16 - PeterThoeny
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2016 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.