fc0a1410c93004714260bdb62499ed0fa3b459a5
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( "Maintenance.php" );
19 class ShowStats
extends Maintenance
{
20 public function __construct() {
21 $this->mDescription
= "Show the cached statistics";
23 public function execute() {
25 'ss_total_views' => 'Total views',
26 'ss_total_edits' => 'Total edits',
27 'ss_good_articles' => 'Number of articles',
28 'ss_total_pages' => 'Total pages',
29 'ss_users' => 'Number of users',
30 'ss_admins' => 'Number of admins',
31 'ss_images' => 'Number of images',
34 // Get cached stats from slave database
35 $dbr = wfGetDB( DB_SLAVE
);
36 $stats = $dbr->selectRow( 'site_stats', '*', '', __METHOD__
);
38 // Get maximum size for each column
39 $max_length_value = $max_length_desc = 0;
40 foreach( $fields as $field => $desc ) {
41 $max_length_value = max( $max_length_value, strlen( $stats->$field ) );
42 $max_length_desc = max( $max_length_desc , strlen( $desc )) ;
46 foreach( $fields as $field => $desc ) {
47 $this->output( sprintf( "%-{$max_length_desc}s: %{$max_length_value}d\n", $desc, $stats->$field ) );
52 $maintClass = "ShowStats";
53 require_once( DO_MAINTENANCE
);