The AnalyseAccessLogSql plugin provides a framework to analyse the SQL access log and display the results. This information may be sensitive and therefore this plugin is limited to administrator access only.

A small number of queries that may (or might not) use the MySQL specific dialect of SQL are provided in lib/plugin/AnalyseAccessLogSql.php. For more information, please see the section Adding new queries below.

Usage

Experimental! Will change a lot.

Usage

  <?plugin AnalyseAccessLogSql mode=<QUERY NAME> ?>

Parameters

mode (required parameter)
The name of the query to execute. See Adding new queries below.
period
Use in combination with the count parameter. The type of history period to retrieve from the SQL access log. Blank (the default) for all history, or one of "weeks", "days", "hours", or "minutes".
count
Use in combination with the period parameter. Must be a number. The number of periods to retrieve from the access log.
caption
The value of this parameter is used as the caption for the output. If not set, the caption on the table defaults to the mode.
center
If set, the table is centered on the page, otherwise left justified.
debugShowQuery
If set, the SQL will be displayed in the table footer. Useful while debugging new queries or just for interest.
user
Blank (the default) to retrieve all users, or a specific user, or "<NONE>" for SQL access log entries with no user.
host
Blank (the default) to retrieve all remote_hosts, or a specific host.
referrer
Blank (the default) to retrieve all referrers, "<NONE>" to retrieve entries with no referrer, otherwise any referrer that matches this parameter, truncating longer referrers before matching. So a parameter of referrer='http://localhost' will match 'http://localhost/wiki/index.php', 'http://localhost/wiki/index.php/HomePage' etc.
local_referrers
If set (the default), return all referrers. If not set, return only external referring sites, excluding references from within the wiki.

Adding new queries

The file lib/plugin/AnalyseAccessLogSql.php contains a default set of queries against the SQL access log. Feel free to change this file to suit your own needs, but please note that this requires filesystem access to the web server where PhpWiki is running. In particular, this file may need to be modified to correctly query databases other than MySQL. The queries supplied by default are: "Referring URLs", "Referring Domains", "Remote Hosts", "Users" and "Host Users".

To add a new query, add a new section towards the end of the file, using one of the existing queries as a template. An example of an existing query is:

} elseif ($mode=="Users") {
    $query = "SELECT "
        ."remote_user AS User, "
        ."count(*) AS 'Access Count' "
        ."FROM $accesslog "
        .($whereConditions ? 'WHERE '.$whereConditions : '')
        ."GROUP BY User";

If you do add a query, please consider contributing it back to the PhpWiki project at http://http://sourceforge.net/projects/phpwiki

API for AnalyseAccessLogSql

Author

PhpWiki:CharlesCorrigan
Changes by PhpWiki:ReiniUrban


PhpWikiDocumentation Help:WikiPlugin