cbbbb64c1d9fa10a23030c7b7b3e214f92bd312e
[lhc/web/wiklou.git] / includes / SpecialStatistics.php
1 <?
2
3 function wfSpecialStatistics()
4 {
5 global $wgUser, $wgOut;
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, $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, $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 = str_replace( "$1", $total, wfMsg( "sitestatstext" ) );
24 $text = str_replace( "$2", $good, $text );
25 $text = str_replace( "$3", $views, $text );
26 $text = str_replace( "$4", $edits, $text );
27 $text = str_replace( "$5", sprintf( "%.2f", $edits / $total ), $text );
28 $text = str_replace( "$6", sprintf( "%.2f", $views / $edits ), $text );
29
30 $wgOut->addHTML( $text );
31 $wgOut->addHTML( "<h2>" . wfMsg( "userstats" ) . "</h2>\n" );
32
33 $sql = "SELECT COUNT(user_id) AS total FROM user";
34 $res = wfQuery( $sql, $fname );
35 $row = wfFetchObject( $res );
36 $total = $row->total;
37
38 $sql = "SELECT COUNT(user_id) AS total FROM user " .
39 "WHERE user_rights <> ''";
40 $res = wfQuery( $sql, $fname );
41 $row = wfFetchObject( $res );
42 $admins = $row->total;
43
44 $sk = $wgUser->getSkin();
45 $ap = $sk->makeKnownLink( wfMsg( "administrators" ), "" );
46
47 $text = str_replace( "$1", $total, wfMsg( "userstatstext" ) );
48 $text = str_replace( "$2", $admins, $text );
49 $text = str_replace( "$3", $ap, $text );
50 $wgOut->addHTML( $text );
51 }
52
53 ?>