5 * @subpackage SpecialPage
11 function wfSpecialStatistics() {
12 global $wgUser, $wgOut, $wgLang, $wgRequest;
13 $fname = 'wfSpecialStatistics';
15 $action = $wgRequest->getVal( 'action' );
17 $dbr =& wfGetDB( DB_SLAVE
);
18 extract( $dbr->tableNames( 'page', 'site_stats', 'user', 'user_groups' ) );
20 $row = $dbr->selectRow( 'site_stats', '*', false, 'wfSpecialStatistics' );
21 $views = $row->ss_total_views
;
22 $edits = $row->ss_total_edits
;
23 $good = $row->ss_good_articles
;
25 # This code is somewhat schema-agnostic, because I'm changing it in a minor release -- TS
26 if ( isset( $row->ss_total_pages
) && $row->ss_total_pages
== -1 ) {
28 $u = new SiteStatsUpdate( 0, 0, 0 );
30 $row = $dbr->selectRow( 'site_stats', '*', false, 'wfSpecialStatistics' );
33 if ( isset( $row->ss_total_pages
) ) {
34 $total = $row->ss_total_pages
;
36 $sql = "SELECT COUNT(page_namespace) AS total FROM $page";
37 $res = $dbr->query( $sql, $fname );
38 $pageRow = $dbr->fetchObject( $res );
39 $total = $pageRow->total
;
42 if ( isset( $row->ss_users
) ) {
43 $users = $row->ss_users
;
45 $sql = "SELECT MAX(user_id) AS total FROM $user";
46 $res = $dbr->query( $sql, $fname );
47 $userRow = $dbr->fetchObject( $res );
48 $users = $userRow->total
;
51 $sql = "SELECT COUNT(*) AS total FROM $user_groups WHERE ug_group='sysop'";
52 $res = $dbr->query( $sql, $fname );
53 $row = $dbr->fetchObject( $res );
54 $admins = $row->total
;
56 if ($action == 'raw') {
58 header( 'Pragma: nocache' );
59 echo "total=$total;good=$good;views=$views;edits=$edits;users=$users;admins=$admins\n";
62 $text = '==' . wfMsg( 'sitestats' ) . "==\n" ;
63 $text .= wfMsg( 'sitestatstext',
64 $wgLang->formatNum( $total ),
65 $wgLang->formatNum( $good ),
66 $wgLang->formatNum( $views ),
67 $wgLang->formatNum( $edits ),
68 $wgLang->formatNum( sprintf( '%.2f', $total ?
$edits / $total : 0 ) ),
69 $wgLang->formatNum( sprintf( '%.2f', $edits ?
$views / $edits : 0 ) ) );
71 $text .= "\n==" . wfMsg( 'userstats' ) . "==\n";
73 $text .= wfMsg( 'userstatstext',
74 $wgLang->formatNum( $users ),
75 $wgLang->formatNum( $admins ),
76 '[[' . wfMsg( 'administrators' ) . ']]',
77 // should logically be after #admins, danm backwards compatability!
78 $wgLang->formatNum( sprintf( '%.2f', $admins / $users * 100 ) )
81 $wgOut->addWikiText( $text );