Remove ?>'s from files. They're pointless, and just asking for people to mess with...
[lhc/web/wiklou.git] / maintenance / showStats.php
1 <?php
2
3 /**
4 * Maintenance script to show the cached statistics.
5 * Give out the same output as [[Special:Statistics]]
6 *
7 * @author Ashar Voultoiz <hashar@altern.org>
8 * Based on initStats.php by:
9 * @author Brion Vibber
10 * @author Rob Church <robchur@gmail.com>
11 *
12 * @licence GNU General Public License 2.0 or later
13 */
14
15 require_once( 'commandLine.inc' );
16
17 #
18 # Configuration
19 #
20 $fields = array(
21 'ss_total_views' => 'Total views',
22 'ss_total_edits' => 'Total edits',
23 'ss_good_articles' => 'Number of articles',
24 'ss_total_pages' => 'Total pages',
25 'ss_users' => 'Number of users',
26 'ss_admins' => 'Number of admins',
27 'ss_images' => 'Number of images',
28 );
29
30 // Get cached stats from slave database
31 $dbr = wfGetDB( DB_SLAVE );
32 $fname = 'showStats';
33 $stats = $dbr->selectRow( 'site_stats', '*', '' );
34
35 // Get maximum size for each column
36 $max_length_value = $max_length_desc = 0;
37 foreach( $fields as $field => $desc ) {
38 $max_length_value = max( $max_length_value, strlen( $stats->$field ) );
39 $max_length_desc = max( $max_length_desc , strlen( $desc )) ;
40 }
41
42 // Show them
43 foreach( $fields as $field => $desc ) {
44 printf( "%-{$max_length_desc}s: %{$max_length_value}d\n", $desc, $stats->$field );
45 }
46