4 * Maintenance script to show the cached statistics.
5 * Give out the same output as [[Special:Statistics]]
9 * @author Ashar Voultoiz <hashar@altern.org>
10 * Based on initStats.php by:
11 * @author Brion Vibber
12 * @author Rob Church <robchur@gmail.com>
14 * @license GNU General Public License 2.0 or later
17 require_once( 'commandLine.inc' );
23 'ss_total_views' => 'Total views',
24 'ss_total_edits' => 'Total edits',
25 'ss_good_articles' => 'Number of articles',
26 'ss_total_pages' => 'Total pages',
27 'ss_users' => 'Number of users',
28 'ss_admins' => 'Number of admins',
29 'ss_images' => 'Number of images',
32 // Get cached stats from slave database
33 $dbr = wfGetDB( DB_SLAVE );
35 $stats = $dbr->selectRow( 'site_stats', '*', '' );
37 // Get maximum size for each column
38 $max_length_value = $max_length_desc = 0;
39 foreach( $fields as $field => $desc ) {
40 $max_length_value = max( $max_length_value, strlen( $stats->$field ) );
41 $max_length_desc = max( $max_length_desc , strlen( $desc )) ;
45 foreach( $fields as $field => $desc ) {
46 printf( "%-{$max_length_desc}s: %{$max_length_value}d\n", $desc, $stats->$field );