URL-escape the main page link on the logo
[mediawiki.git] / includes / SpecialRandompage.php
blob9eadd041f0c8d42759dbf5df7a3ee9e3ea182c63
1 <?
3 function wfSpecialRandompage()
5 global $wgOut, $wgTitle, $wgArticle, $force;
6 $fname = "wfSpecialRandompage";
8 wfSeedRandom();
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 $sqlget = "SELECT cur_id,cur_title
13 FROM cur USE INDEX (cur_random)
14 WHERE cur_namespace=0 AND cur_is_redirect=0
15 AND cur_random>$randstr
16 ORDER BY cur_random
17 LIMIT 1";
18 $res = wfQuery( $sqlget, $fname );
19 if( $s = wfFetchObject( $res ) ) {
20 $rt = wfUrlEncode( $s->cur_title );
21 } else {
22 # No articles?!
23 $rt = "";
26 $wgOut->reportTime(); # for logfile
27 $wgOut->redirect( wfLocalUrl( $rt ) );