Tweak to use local random, don't trust mysql's; new seed
[lhc/web/wiklou.git] / includes / SpecialRandompage.php
1 <?
2
3 function wfSpecialRandompage()
4 {
5 global $wgOut, $wgTitle, $wgArticle, $force;
6 $fname = "wfSpecialRandompage";
7
8 wfSeedRandom();
9 $rand = mt_rand() / mt_getrandmax();
10 $sqlget = "SELECT cur_id,cur_title
11 FROM cur USE INDEX (cur_random)
12 WHERE cur_namespace=0 AND cur_is_redirect=0
13 AND cur_random>$rand
14 ORDER BY cur_random
15 LIMIT 1";
16 $res = wfQuery( $sqlget, $fname );
17 if( $s = wfFetchObject( $res ) ) {
18 $rt = wfUrlEncode( $s->cur_title );
19 } else {
20 # No articles?!
21 $rt = "";
22 }
23
24 $wgOut->reportTime(); # for logfile
25 $wgOut->redirect( wfLocalUrl( $rt ) );
26 }
27
28 ?>