4 function wfSpecialRandompage()
6 global $wgOut, $wgTitle, $wgArticle, $wgExtraRandompageSQL;
7 $fname = "wfSpecialRandompage";
10 $rand = mt_rand() / mt_getrandmax();
11 # interpolation and sprintf() can muck up with locale-specific decimal separator
12 $randstr = number_format( $rand, 12, ".", "" );
13 $db =& wfGetDB( DB_READ
);
14 $use_index = $db->useIndexClause( 'cur_random' );
15 if ( $wgExtraRandompageSQL ) {
16 $extra = "AND ($wgExtraRandompageSQL)";
20 $sqlget = "SELECT cur_id,cur_title
22 WHERE cur_namespace=0 AND cur_is_redirect=0 $extra
23 AND cur_random>$randstr
26 $res = $db->query( $sqlget, $fname );
27 if( $s = $db->fetchObject( $res ) ) {
28 $rt = wfUrlEncode( $s->cur_title
);
34 $wgOut->reportTime(); # for logfile
35 $wgOut->redirect( wfLocalUrl( $rt ) );