4 function wfSpecialRandompage()
6 global $wgOut, $wgTitle, $wgArticle, $wgIsMySQL;
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 $use_index=$wgIsMySQL?
"USE INDEX (cur_random)":"";
14 $sqlget = "SELECT cur_id,cur_title
16 WHERE cur_namespace=0 AND cur_is_redirect=0
17 AND cur_random>$randstr
20 $res = wfQuery( $sqlget, DB_READ
, $fname );
21 if( $s = wfFetchObject( $res ) ) {
22 $rt = wfUrlEncode( $s->cur_title
);
28 $wgOut->reportTime(); # for logfile
29 $wgOut->redirect( wfLocalUrl( $rt ) );