*" 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://sourceforge.net/projects/phpwiki
== API for ~AnalyseAccessLogSql
* input arguments:
- *$mode* contains the name of the query requested in the plugin parameters.
- *$accesslog* contains the qualified name of the accesslog table, which may or may not be equal to "accesslog".
- *$whereConditions* contains the conditions (specific user, etc.) requested in the plugin parameters.
* output:
- *$query* must contain the final SQL query to be executed.
* conventions:
- While constructing the query string,
* each clause is on a separate line and
* each clause contains the required trailing punctuation or space.
- The mode parameter is, by default, displayed as the caption in the final output, so please choose a user friendly name.
- The column names displayed on the wiki page are generated from the SQL column names defined in the queries, so please choose user friendly names. MySQL allows column names to include spaces. If spaces are not allowed, then "*_*" is probably the next best choice.
* language hints for PHP newbies - please remember:
- terminate statements with "*;*",
- assignment uses "*=*" and comparison uses "*==*",
- concatenate strings using the "*.*" operator,
- the parentheses around the expression "*=($whereConditions ? 'WHERE '.$whereConditions : '' )=*" are essential,
- strings enclosed in single quotes may not contain substrings enclosed in single quotes (actually the truth is more complex but let's leave it like that here), and
- strings enclosed in double quotes will evaluate and replace variable names so that, for example, *"FROM $accesslog "* might be evaluated to *"FROM phpwiki_accesslog "*.
== Author
[Charles Corrigan|PhpWiki:CharlesCorrigan] %%%
Changes by [Reini Urban|PhpWiki:ReiniUrban]
----
[[PhpWikiDocumentation]] [[CategoryWikiPlugin]]