Wikiscan

Wikiscan is a tool written in PHP, external to MediaWiki, that computes and displays historical statistics about a wiki.

Wikiscan was created in 2011 on the initiative of a voluntary user for WMF wikis, available at http://wikiscan.org/. Most of the software development was done on a voluntary basis. Part of it was subsidized by the Wikimedia Foundation and the Wikimedia France association. Server hosting is currently supported by the Wikimedia France association.

The code was originally available on the wikiscan.org website for download. However, it's not available anymore. In 2021, User:Ciencia Al Poder was interested in this tool for another wiki project and downloaded a copy of the code before it was removed, documented some parts of it, did a general review to fix some issues so it works on independent wikis.

This tool generates statistics by querying the wiki's database, and stored on its own database. Data displayed on the tool is not updated on real time. The statistics data must be generated on a regular basis, using cron or similar.

Download
Code can be downloaded from GitHub: https://github.com/ciencia/wikiscan/

Requisites
This tool currently needs to be installed on it's own domain or subdomain. It doesn't support installing on a subdirectory other than the web root.


 * Webserver
 * PHP 5.5 or newer, tested on PHP 7.3
 * PHP modules : mbstring, curl, gd, mysqlnd, memcached
 * MySQL
 * It uses its own database and also needs access to the wiki's database
 * Memcached
 * Used for caching results

Installation

 * 1) Extract Wikiscan to a directory (example /var/www/wikiscan/)
 * 2) Create a new Mysql database (example wikiscan_stats)
 * 3) Import ctrl/stats.sql to create the tables.
 * 4) Create or configure a Mysql user with SELECT,INSERT,UPDATE,DELETE rights to the wikiscan database (example: wikiscan_user)
 * 5) Create or configure a Mysql user with SELECT rights to the wiki's database (it can be the same previously created user)
 * 6) Go to config/ directory
 * 7) Copy db_conf.sample.php to db_conf.php
 * 8) Edit db_conf.php
 * 9) Configure "db" with your Mediawiki database
 * 10) Configure "dbs" with the new stats database
 * 11) Copy local_conf.sample.php to local_conf.php
 * 12) Edit local_conf.php to configure local paths and wiki urls
 * 13) Make the directories wpstats/ cache/ and img/* writable

The site should work at this stage but without any statistics yet.

Setting up rewrite rules
This tool generates some links that expect an existing set of rewrite rules for them to work.

apache
You can see code in the .htaccess file.

nginx
With alternate paths in Spanish:

Configuration parameters
Edit the conf/local_conf.php file, adding or updating keys of the $local_conf variable:

Multi wiki site
This tool was created originally for a single wiki, and then expanded to serve all WMF wikis under the wikiscan.org domain. In this multi wiki setup, each wiki has its own wikiscan database, and there's an additional database with data to coordinate all wikis. Under this multi-wiki setup, this tool makes heavy use of undocumented and WMF-specific database views, and also it has connections with Wikidata.

This multi wiki behavior is controlled by the 'multi' configuration parameter, that defaults to false.

Supported languages
Currently supported languages:
 * English (en)
 * Français (fr)
 * Spanish (es)

To add more languages, copy or add a file in include/languages/ with the desired language code, translating from an existing one.

Known issues

 * It doesn't support wikis with a non-empty set (Bug #1).

Populating statistics for the first time
To update all daily stats and user stats, execute :

php ctrl/run.php fullupdate php ctrl/run.php fullupdate_months

To update last hours, execute :

php ctrl/run.php update_live

To update grid, execute :

php ctrl/run.php update_sum

Update statistics periodically
To update statistics regularly you can set up cron jobs to run several scripts:


 * ctrl/run.php update_live: Updates section hours and grid. Run it several times a day. It's fast.
 * ctrl/run.php update_sum: Updates calendar and users section. Run it at least once a day.
 * ctrl/run.php update_misc: Updates userstats graphs. Run it at least once a week.