wiki.techinc.nl/includes/SpecialStatistics.php
Tim Starling ac549401d4 * Support for table name prefixes throughout the code. No support yet for converting static SQL, which also means no installation. But it has been tested by creating the tables in the ordinary way and then renaming them
* DB_WRITE now called DB_MASTER, DB_READ now called DB_SLAVE
* Converted to use SQL wrapper functions instead of direct SQL in various places
* Experimental method for preserving the chronological order of events when slave servers are used. Untested.
* Fixes to the new post-parse existence test feature
* Some.. other stuff
2004-07-18 08:48:43 +00:00

58 lines
1.6 KiB
PHP

<?php
function wfSpecialStatistics()
{
global $wgUser, $wgOut, $wgLang;
$fname = "wfSpecialStatistics";
$wgOut->addHTML( "<h2>" . wfMsg( "sitestats" ) . "</h2>\n" );
$dbr =& wfGetDB( DB_SLAVE );
extract( $dbr->tableNames( 'cur', 'site_stats', 'user' ) );
$sql = "SELECT COUNT(cur_id) AS total FROM $cur";
$res = $dbr->query( $sql, $fname );
$row = $dbr->fetchObject( $res );
$total = $row->total;
$sql = "SELECT ss_total_views, ss_total_edits, ss_good_articles " .
"FROM $site_stats WHERE ss_row_id=1";
$res = $dbr->query( $sql, $fname );
$row = $dbr->fetchObject( $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 = $dbr->query( $sql, $fname );
$row = $dbr->fetchObject( $res );
$total = $row->total;
$sql = "SELECT COUNT(user_id) AS total FROM $user " .
"WHERE user_rights LIKE '%sysop%'";
$res = $dbr->query( $sql, $fname );
$row = $dbr->fetchObject( $res );
$admins = $row->total;
$sk = $wgUser->getSkin();
$ap = "[[" . wfMsg( "administrators" ) . "]]";
$text = wfMsg( "userstatstext",
$wgLang->formatNum( $total ),
$wgLang->formatNum( $admins ), $ap );
$wgOut->addWikiText( $text );
}
?>