Skip to content.
TWiki > AgentPlugin

Agent Plugin

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: CCBot/1.0 (+http://www.commoncrawl.org/bot.html)
  • Use %AGENT{check="TYPE}% to choose predefined version independent identification.
    • Your Browser identifies as: unknown
  • Use %AGENT{check="VERSION"}% to choose predefined version dependent identification.
    • Your Browser identifies as: unknown
  • Use %AGENT{check="msie netscape4 netscape7"}% to select your own ID set - note that most specific rule names must be listed first
    • Your Browser yields: unknown
  • Add none="idontknow" to choose a different fallback id from "unknown"
  • Use %AGENT{check="gecko6 gecko7" none="nogecko" expgecko6="Gecko.*6" expgecko7="Gecko.*7"}% to specify seldomly needed checks
    • Your Browser yields: nogecko
  • Any non-alphanumeric character will be removed from the listes IDs for the check whilst the original ID will be returned: %AGENT{check=".msie .netscape" none=""}%
    • Your Browser yields "unknown"

AgentPlugin Global Settings

Plugin settings are stored as preferences variables. To reference a plugin setting write %<plugin>_<setting>%, i.e. This plugin identifies a browser using configurable rules.

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

  • Fallback value for nonmatching user agents:
    • Set NONE = unknown
  • Predefined ID sets - note that most specific rule names must be listed first:
    • Set CHECKTYPE = msie netscape
    • Set CHECKVERSION = msie50 msie52 msie5 msie 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 EXPNETSCAPE = Netscape
    • Set EXPNETSCAPE4 = Netscape/4
    • Set EXPNETSCAPE6 = Netscape/6
    • Set EXPNETSCAPE7 = Netscape/7

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

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
    data/TWiki/AgentPlugin.txt,v Plugin topic repository
    lib/TWiki/Plugins/AgentPlugin.pm Plugin Perl module
  • Test if the plugin is correctly installed:
    • Your Browser identifies as "CCBot/1.0 (+http://www.commoncrawl.org/bot.html)"

Plugin Author: AndyThaller?
Plugin Version: 31 Oct 2002 (V1.001)
Change History: 01 Nov 2002: Improved capabilities
31 Oct 2002: Initial version
31 Oct 2002: 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

-- AndyThaller? - 31 Oct 2002


Ultima versione: r1.1 - 01 Nov 2002 - 13:18 - Main.guest
 
Se riconosciuto dal sistema come utente: Main.guest