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