pre handling fix
[lhc/web/wiklou.git] / includes / SpecialStatistics.php
1 <?php
2
3 function wfSpecialStatistics()
4 {
5 global $wgUser, $wgOut, $wgLang;
6 $fname = "wfSpecialStatistics";
7
8 $wgOut->addHTML( "<h2>" . wfMsg( "sitestats" ) . "</h2>\n" );
9
10 $sql = "SELECT COUNT(cur_id) AS total FROM cur";
11 $res = wfQuery( $sql, DB_READ, $fname );
12 $row = wfFetchObject( $res );
13 $total = $row->total;
14
15 $sql = "SELECT ss_total_views, ss_total_edits, ss_good_articles " .
16 "FROM site_stats WHERE ss_row_id=1";
17 $res = wfQuery( $sql, DB_READ, $fname );
18 $row = wfFetchObject( $res );
19 $views = $row->ss_total_views;
20 $edits = $row->ss_total_edits;
21 $good = $row->ss_good_articles;
22
23 $text = wfMsg( "sitestatstext",
24 $wgLang->formatNum( $total ),
25 $wgLang->formatNum( $good ),
26 $wgLang->formatNum( $views ),
27 $wgLang->formatNum( $edits ),
28 $wgLang->formatNum( sprintf( "%.2f", $total ? $edits / $total : 0 ) ),
29 $wgLang->formatNum( sprintf( "%.2f", $edits ? $views / $edits : 0 ) ) );
30
31 $wgOut->addWikiText( $text );
32 $wgOut->addHTML( "<h2>" . wfMsg( "userstats" ) . "</h2>\n" );
33
34 $sql = "SELECT COUNT(user_id) AS total FROM user";
35 $res = wfQuery( $sql, DB_READ, $fname );
36 $row = wfFetchObject( $res );
37 $total = $row->total;
38
39 $sql = "SELECT COUNT(user_id) AS total FROM user " .
40 "WHERE user_rights LIKE '%sysop%'";
41 $res = wfQuery( $sql, DB_READ, $fname );
42 $row = wfFetchObject( $res );
43 $admins = $row->total;
44
45 $sk = $wgUser->getSkin();
46 $ap = "[[" . wfMsg( "administrators" ) . "]]";
47
48 $text = wfMsg( "userstatstext",
49 $wgLang->formatNum( $total ),
50 $wgLang->formatNum( $admins ), $ap );
51 $wgOut->addWikiText( $text );
52 }
53
54 ?>