New global config setting $wgMaxTocLevel: Maximum indent level of toc.
[lhc/web/wiklou.git] / includes / SpecialRandompage.php
1 <?php
2 # $Id$
3
4 function wfSpecialRandompage()
5 {
6 global $wgOut, $wgTitle, $wgArticle, $wgExtraRandompageSQL;
7 $fname = "wfSpecialRandompage";
8
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' );
15
16 if ( $wgExtraRandompageSQL ) {
17 $extra = "AND ($wgExtraRandompageSQL)";
18 } else {
19 $extra = '';
20 }
21 $sqlget = "SELECT cur_id,cur_title
22 FROM $cur $use_index
23 WHERE cur_namespace=0 AND cur_is_redirect=0 $extra
24 AND cur_random>$randstr
25 ORDER BY cur_random
26 LIMIT 1";
27 $res = $db->query( $sqlget, $fname );
28 if( $s = $db->fetchObject( $res ) ) {
29 $rt = wfUrlEncode( $s->cur_title );
30 } else {
31 # No articles?!
32 $rt = "";
33 }
34
35 $wgOut->reportTime(); # for logfile
36 $wgOut->redirect( wfLocalUrl( $rt ) );
37 }
38
39 ?>