MediawikiExtensions/Top Pages

A new extension to display the most popular wiki pages, ordered by number of hits.

example
10

result
10

extension source
setHook( "toppages", "renderTopPages" ); }

function renderTopPages( $input ) {

$input = mysql_escape_string($input);

if (is_int($input)){ $limit = $input; } else { $limit = 5; }
 * 1) check if input is integer else set to 5

$hd = mysql_connect("localhost", "wikiuser", "password") or die ("Unable to connect"); mysql_select_db ("wikidb", $hd) or die ("Unable to select database");

$res= mysql_query("select cur_title,cur_counter from cur order by cur_counter DESC limit $input", $hd) or die ("Unable to run query");

$output=" ";

return $output; }