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.


Experimental! Will change a lot.


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


mode (required parameter)
The name of the query to execute. See Adding new queries below.
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".
Use in combination with the period parameter. Must be a number. The number of periods to retrieve from the access log.
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.
If set, the table is centered on the page, otherwise left justified.
If set, the SQL will be displayed in the table footer. Useful while debugging new queries or just for interest.
Blank (the default) to retrieve all users, or a specific user, or "<NONE>" for SQL access log entries with no user.
Blank (the default) to retrieve all remote_hosts, or a specific host.
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.
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://

API for AnalyseAccessLogSql


Changes by PhpWiki:ReiniUrban

PhpWikiDocumentation WikiPlugin

Last edited on Tuesday 25 October 2005 12:48:09

Edit | PageHistory | Diff  | PageInfo
Datenschutzerklärung & Impressum