aboutsummaryrefslogtreecommitdiffstats
path: root/includes/SpecialStatistics.php
blob: a6433aaeb6a9854081d67ffaf2208148e43fffb4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php

function wfSpecialStatistics()
{
	global $wgUser, $wgOut, $wgLang;
	$fname = "wfSpecialStatistics";

	$wgOut->addHTML( "<h2>" . wfMsg( "sitestats" ) . "</h2>\n" );

	$sql = "SELECT COUNT(cur_id) AS total FROM cur";
	$res = wfQuery( $sql, DB_READ, $fname );
	$row = wfFetchObject( $res );
	$total = $row->total;

	$sql = "SELECT ss_total_views, ss_total_edits, ss_good_articles " .
	  "FROM site_stats WHERE ss_row_id=1";
	$res = wfQuery( $sql, DB_READ, $fname );
	$row = wfFetchObject( $res );
	$views = $row->ss_total_views;
	$edits = $row->ss_total_edits;
	$good = $row->ss_good_articles;

	$text = wfMsg( "sitestatstext",
		$wgLang->formatNum( $total ),
		$wgLang->formatNum( $good ),
		$wgLang->formatNum( $views ),
		$wgLang->formatNum( $edits ),
		$wgLang->formatNum( sprintf( "%.2f", $total ? $edits / $total : 0 ) ),
		$wgLang->formatNum( sprintf( "%.2f", $edits ? $views / $edits : 0 ) ) );

	$wgOut->addWikiText( $text );
	$wgOut->addHTML( "<h2>" . wfMsg( "userstats" ) . "</h2>\n" );

	$sql = "SELECT COUNT(user_id) AS total FROM user";
	$res = wfQuery( $sql, DB_READ, $fname );
	$row = wfFetchObject( $res );
	$total = $row->total;

	$sql = "SELECT COUNT(user_id) AS total FROM user " .
	  "WHERE user_rights LIKE '%sysop%'";
	$res = wfQuery( $sql, DB_READ, $fname );
	$row = wfFetchObject( $res );
	$admins = $row->total;

	$sk = $wgUser->getSkin();
	$ap = "[[" . wfMsg( "administrators" ) . "]]";

	$text = wfMsg( "userstatstext",
		$wgLang->formatNum( $total ),
		$wgLang->formatNum( $admins ), $ap );
	$wgOut->addWikiText( $text );
}

?>