$wgDBsqlpassword = "sqlpass";
$wgDBminWordLen = 4;
$wgDBtransactions = false; # Set to true if using InnoDB tables
+$wgDBmysql4 = false; # Set to true to use enhanced fulltext search
# Language settings
#
$wgEditEncoding = "";
$wgDocType = "-//W3C//DTD HTML 4.01 Transitional//EN";
$wgAmericanDates = false; # Enable for English module to print dates
+ # as eg 'May 12' instead of '12 May'
$wgLocalInterwiki = "w";
$wgShowIPinHeader = true; # For non-logged in users
return false;
}
+# Yay, more global functions!
+function wfCheckLimits( $deflimit = 50, $optionname = "rclimit" ) {
+ global $wgUser;
+
+ $limit = (int)$_REQUEST['limit'];
+ if( $limit < 0 ) $limit = 0;
+ if( ( $limit == 0 ) && ( $optionname != "" ) ) {
+ $limit = (int)$wgUser->getOption( $optionname );
+ }
+ if( $limit <= 0 ) $limit = $deflimit;
+ if( $limit > 5000 ) $limit = 5000; # We have *some* limits...
+
+ $offset = (int)$_REQUEST['offset'];
+ $offset = (int)$offset;
+ if( $offset < 0 ) $offset = 0;
+ if( $offset > 65000 ) $offset = 65000; # do we need a max? what?
+
+ return array( $limit, $offset );
+}
+
?>
{
# We display the query, so let's strip it for safety
#
+ global $wgDBmysql4;
$lc = SearchEngine::legalSearchChars() . "()";
+ if( $wgDBmysql4 ) $lc .= "\"~<>*+-";
$this->mUsertext = trim( preg_replace( "/[^{$lc}]/", " ", $text ) );
$this->mSearchterms = array();
}
global $wgUser, $wgTitle, $wgOut, $wgLang, $wgDisableTextSearch;
$fname = "SearchEngine::showResults";
- $offset = $_REQUEST['offset'];
- $limit = $_REQUEST['limit'];
$search = $_REQUEST['search'];
$powersearch = $this->powersearch(); /* Need side-effects here? */
$wgOut->setPageTitle( wfMsg( "searchresults" ) );
- $q = str_replace( "$1", $this->mUsertext,
- wfMsg( "searchquery" ) );
+ $q = wfMsg( "searchquery", htmlspecialchars( $this->mUsertext ) );
$wgOut->setSubtitle( $q );
$wgOut->setArticleFlag( false );
$wgOut->setRobotpolicy( "noindex,nofollow" );
$sk = $wgUser->getSkin();
- $text = str_replace( "$1", $sk->makeKnownLink(
- wfMsg( "searchhelppage" ), wfMsg( "searchingwikipedia" ) ),
- wfMsg( "searchresulttext" ) );
+ $text = wfMsg( "searchresulttext", $sk->makeKnownLink(
+ wfMsg( "searchhelppage" ), wfMsg( "searchingwikipedia" ) ) );
$wgOut->addHTML( $text );
$this->parseQuery();
"<p>" . wfMsg( "badquerytext" ) );
return;
}
- if ( ! isset( $limit ) ) {
- $limit = $wgUser->getOption( "searchlimit" );
- if ( ! $limit ) { $limit = 20; }
- }
- if ( ! $offset ) { $offset = 0; }
+ list( $limit, $offset ) = wfCheckLimits( 20, "searchlimit" );
$searchnamespaces = $this->queryNamespaces();
$redircond = $this->searchRedirects();
function parseQuery()
{
- global $wgDBminWordLen, $wgLang;
+ global $wgDBminWordLen, $wgLang, $wgDBmysql4;
+
+ if( $wgDBmysql4 ) {
+ # Use cleaner boolean search if available
+ return $this->parseQuery4();
+ }
$lc = SearchEngine::legalSearchChars() . "()";
$q = preg_replace( "/([()])/", " \\1 ", $this->mUsertext );
}
if ( 0 == count( $this->mSearchterms ) ) { return; }
- # To disable boolean:
- # $cond = "MATCH (##field##) AGAINST('" . wfStrencode( $q ) . "')";
-
$this->mTitlecond = "(" . str_replace( "##field##",
"si_title", $cond ) . " )";
$this->mTextcond = "(" . str_replace( "##field##",
"si_text", $cond ) . " AND (cur_is_redirect=0) )";
}
+
+ function parseQuery4()
+ {
+ # FIXME: not ready yet! Do not use.
+
+ global $wgLang;
+ $lc = SearchEngine::legalSearchChars();
+ #$q = preg_replace( "/([+-]?)([$lc]+)/e",
+ # "\"$1\" . \$wgLang->stripForSearch(\"$2\")",
+ # $this->mUsertext );
+
+ $q = $this->mUsertext;
+ $qq = wfStrencode( $q );
+ $this->mTitlecond = " MATCH(si_title) AGAINST('$qq' IN BOOLEAN MODE)";
+ $this->mTextcond = " (MATCH(si_text) AGAINST('$qq' IN BOOLEAN MODE) AND cur_is_redirect=0)";
+ }
function showHit( $row )
{
function wfSpecialAncientpages()
{
global $wgUser, $wgOut, $wgLang, $wgTitle;
- global $limit, $offset; # From query string
$fname = "wfSpecialAncientpages";
- if ( ! $limit ) {
- $limit = $wgUser->getOption( "rclimit" );
- if ( ! $limit ) { $limit = 50; }
- }
- if ( ! $offset ) { $offset = 0; }
+ list( $limit, $offset ) = wfCheckLimits();
$sql = "SELECT cur_title,cur_user,cur_user_text,cur_comment," .
"cur_timestamp FROM cur USE INDEX (namespace_redirect_timestamp) " .
function wfSpecialContributions()
{
- global $wgUser, $wgOut, $wgLang, $target, $offset, $limit, $hideminor;
+ global $wgUser, $wgOut, $wgLang, $target, $hideminor;
$fname = "wfSpecialContributions";
$sysop = $wgUser->isSysop();
$wgOut->errorpage( "notargettitle", "notargettext" );
return;
}
- $offset = (int)$offset;
- $limit = (int)$limit;
- if( $offset < 0 ) { $offset = 0; }
- if( $limit < 1 ) { $limit = 50; }
+ list( $limit, $offset ) = wfCheckLimits( 50, "" );
$target = wfCleanQueryVar( $target );
$nt = Title::newFromURL( $target );
$wgLang->specialpage( "Contributions" ), "target=" . wfUrlEncode( $target ) );
$wgOut->addHTML( "<br>{$sl}\n" );
- # Sorting slowness on cur and especially old
- # forces us to check RC table first
if ( 0 == $id ) {
$sql = "SELECT cur_namespace,cur_title,cur_timestamp,cur_comment FROM cur " .
"WHERE cur_user_text='" . wfStrencode( $nt->getText() ) . "' {$cmq} " .
$nOld = wfNumRows( $res2 );
- if ( 0 == $nCur && 0 == $nOld && 0 == $rcrows ) {
+ if ( 0 == $nCur && 0 == $nOld ) {
$wgOut->addHTML( "\n<p>" . wfMsg( "nocontribs" ) . "</p>\n" );
return;
}
function wfSpecialImagelist()
{
- global $wgUser, $wgOut, $wgLang, $sort, $limit;
+ global $wgUser, $wgOut, $wgLang, $sort;
global $wpIlMatch, $wpIlSubmit;
$fields = array( 'wpIlMatch' );
$sql .= " ORDER BY img_timestamp DESC";
$st = $bydate;
}
- if ( ! isset( $limit ) ) { $limit = 50; }
+ list( $limit, $offset ) = wfCheckLimits( 50 );
if ( 0 == $limit ) {
$lt = wfMsg( "all" );
} else {
}
$wgOut->addHTML( "<p>" . wfMsg( "imglegend" ) . "\n" );
- $text = str_replace( "$1", "<strong>{$lt}</strong>",
- wfMsg( "imagelisttext" ) );
- $text = str_replace( "$2", "<strong>{$st}</strong>", $text );
+ $text = wfMsg( "imagelisttext",
+ "<strong>{$lt}</strong>", "<strong>{$st}</strong>" );
$wgOut->addHTML( "<p>{$text}\n<p>" );
$sk = $wgUser->getSkin();
function wfSpecialListusers()
{
- global $wgUser, $wgOut, $wgLang, $offset, $limit;
+ global $wgUser, $wgOut, $wgLang;
- if ( ! $limit ) {
- $limit = $wgUser->getOption( "rclimit" );
- if ( ! $limit ) { $limit = 50; }
- }
- if ( ! $offset ) { $offset = 0; }
+ list( $limit, $offset ) = wfCheckLimits();
$top = wfShowingResults( $offset, $limit );
$wgOut->addHTML( "<p>{$top}\n" );
function wfSpecialLonelypages()
{
global $wgUser, $wgOut, $wgLang, $wgTitle;
- global $limit, $offset; # From query string
$fname = "wfSpecialLonelypages";
# Cache
return;
}
- if ( ! $limit ) {
- $limit = $wgUser->getOption( "rclimit" );
- if ( ! $limit ) { $limit = 50; }
- }
- if ( ! $offset ) { $offset = 0; }
+ list( $limit, $offset ) = wfCheckLimits();
$sql = "SELECT cur_title FROM cur LEFT JOIN links ON " .
"cur_id=l_to WHERE l_to IS NULL AND cur_namespace=0 AND " .
function wfSpecialLongpages()
{
global $wgUser, $wgOut, $wgLang, $wgTitle;
- global $limit, $offset; # From query string
$fname = "wfSpecialLongpages";
# Cache
return;
}
- if ( ! $limit ) {
- $limit = $wgUser->getOption( "rclimit" );
- if ( ! $limit ) { $limit = 50; }
- }
- if ( ! $offset ) { $offset = 0; }
+ list( $limit, $offset ) = wfCheckLimits();
$sql = "SELECT cur_title, LENGTH(cur_text) AS len FROM cur " .
"WHERE cur_namespace=0 AND cur_is_redirect=0 ORDER BY " .
function wfSpecialDisambiguations()
{
global $wgUser, $wgOut, $wgLang, $wgTitle;
- global $limit, $offset; # From query string
$fname = "wfSpecialDisambiguations";
- if ( ! $limit ) {
- $limit = $wgUser->getOption( "rclimit" );
- if ( ! $limit ) { $limit = 50; }
- }
- if ( ! $offset ) { $offset = 0; }
+ list( $limit, $offset ) = wfCheckLimits();
$dp = wfStrencode( wfMsg("disambiguationspage") );
function wfSpecialDoubleRedirects()
{
global $wgUser, $wgOut, $wgLang, $wgTitle;
- global $limit, $offset; # From query string
$fname = "wfSpecialDoubleRedirects";
- if ( ! $limit ) {
- $limit = $wgUser->getOption( "rclimit" );
- if ( ! $limit ) { $limit = 50; }
- }
- if ( ! $offset ) { $offset = 0; }
+ list( $limit, $offset ) = wfCheckLimits();
$sql = "SELECT l_from,l_to,cb.cur_text AS rt,cb.cur_title AS ti FROM links,cur AS ca, cur AS cb WHERE ca.cur_is_redirect=1 AND cb.cur_is_redirect=1 AND l_to=cb.cur_id AND l_from=ca.cur_title AND ca.cur_namespace=0 LIMIT {$offset}, {$limit}" ;
function wfSpecialBrokenRedirects()
{
global $wgUser, $wgOut, $wgLang, $wgTitle;
- global $limit, $offset; # From query string
$fname = "wfSpecialBrokenRedirects";
- if ( ! $limit ) {
- $limit = $wgUser->getOption( "rclimit" );
- if ( ! $limit ) { $limit = 50; }
- }
- if ( ! $offset ) { $offset = 0; }
+ list( $limit, $offset ) = wfCheckLimits();
$sql = "SELECT bl_to,cur_title FROM brokenlinks,cur WHERE cur_is_redirect=1 AND cur_namespace=0 AND bl_from=cur_id LIMIT {$offset}, {$limit}" ;
function wfSpecialSelfLinks()
{
global $wgUser, $wgOut, $wgLang, $wgTitle;
- global $limit, $offset; # From query string
$fname = "wfSpecialSelfLinks";
- if ( ! $limit ) {
- $limit = $wgUser->getOption( "rclimit" );
- if ( ! $limit ) { $limit = 50; }
- }
- if ( ! $offset ) { $offset = 0; }
+ list( $limit, $offset ) = wfCheckLimits();
$sql = "SELECT cur_title FROM cur,links WHERE cur_is_redirect=0 AND cur_namespace=0 AND l_from=cur_title AND l_to=cur_id LIMIT {$offset}, {$limit}";
function wfSpecialMispeelings ()
{
global $wgUser, $wgOut, $wgLang, $wgTitle;
- global $limit, $offset; # From query string
$sk = $wgUser->getSkin();
$fname = "wfSpecialMispeelings";
- if ( ! $limit ) {
- $limit = $wgUser->getOption( "rclimit" );
- if ( ! $limit ) { $limit = 50; }
- }
- if ( ! $offset ) { $offset = 0; }
+ list( $limit, $offset ) = wfCheckLimits();
# Determine page name
$ms = wfMsg ( "mispeelingspage" ) ;
function wfSpecialMissingLanguageLinks()
{
global $wgUser, $wgOut, $wgLang, $wgTitle, $thelang, $subfunction;
- global $limit, $offset; # From query string
$fname = "wfSpecialMissingLanguageLinks";
$subfunction = "missinglanguagelinks" ;
if ( $thelang == "w" ) $thelang = "en" ; # Fix for international wikis
- if ( ! $limit ) {
- $limit = $wgUser->getOption( "rclimit" );
- if ( ! $limit ) { $limit = 50; }
- }
- if ( ! $offset ) { $offset = 0; }
+ list( $limit, $offset ) = wfCheckLimits();
$sql = "SELECT cur_title FROM cur WHERE cur_namespace=0 AND cur_is_redirect=0 AND cur_title NOT LIKE '%/%' AND cur_text NOT LIKE '%[[{$thelang}:%' LIMIT {$offset}, {$limit}";
function wfSpecialNewpages()
{
global $wgUser, $wgOut, $wgLang, $wgTitle;
- global $limit, $offset; # From query string
$fname = "wfSpecialNewpages";
- if ( ! $limit ) {
- $limit = $wgUser->getOption( "rclimit" );
- if ( ! $limit ) { $limit = 50; }
- }
- if ( ! $offset ) { $offset = 0; }
+ list( $limit, $offset ) = wfCheckLimits();
-# $sql = "SELECT cur_title,cur_user,cur_user_text,cur_comment," .
-# "cur_timestamp FROM cur " .
-# "WHERE cur_is_new=1 AND cur_namespace=0 AND cur_is_redirect=0 " .
-# " ORDER BY cur_timestamp DESC LIMIT {$offset}, {$limit}";
$sql = "SELECT rc_title AS cur_title,rc_user AS cur_user,rc_user_text AS cur_user_text,cur_comment," .
"rc_timestamp AS cur_timestamp,length(cur_text) as cur_length FROM recentchanges,cur " .
"WHERE rc_cur_id=cur_id AND rc_new=1 AND rc_namespace=0 AND cur_text NOT LIKE '#REDIRECT%' " .
function wfSpecialPopularpages()
{
global $wgUser, $wgOut, $wgLang, $wgTitle;
- global $limit, $offset; # From query string
$fname = "wfSpecialPopularpages";
global $wgMiserMode;
return;
}
- if ( ! $limit ) {
- $limit = $wgUser->getOption( "rclimit" );
- if ( ! $limit ) { $limit = 50; }
- }
- if ( ! $offset ) { $offset = 0; }
+ list( $limit, $offset ) = wfCheckLimits();
$sql = "SELECT DISTINCT cur_title, cur_counter FROM cur " .
"WHERE cur_namespace=0 AND cur_is_redirect=0 ORDER BY " .
$s = "<ol start=" . ( $offset + 1 ) . ">";
while ( $obj = wfFetchObject( $res ) ) {
- $nv = str_replace( "$1", $obj->cur_counter, wfMsg( "nviews" ) );
+ $nv = wfMsg( "nviews", $obj->cur_counter );
$link = $sk->makeKnownLink( $obj->cur_title, "" );
$s .= "<li>{$link} ({$nv})</li>\n";
}
function wfSpecialRecentchanges()
{
global $wgUser, $wgOut, $wgLang, $wgTitle;
- global $days, $limit, $hideminor, $from, $hidebots; # From query string
+ global $days, $hideminor, $from, $hidebots; # From query string
$fname = "wfSpecialRecentchanges";
$sql = "SELECT MAX(rc_timestamp) AS lastmod FROM recentchanges";
$days = $wgUser->getOption( "rcdays" );
if ( ! $days ) { $days = 3; }
}
- if ( ! $limit ) {
- $limit = $wgUser->getOption( "rclimit" );
- if ( ! $limit ) { $limit = 100; }
- }
+ $days = (int)$days;
+ list( $limit, $offset ) = wfCheckLimits( 100, "rclimit" );
$cutoff = date( "YmdHis", time() - ( $days * 86400 ) );
if(preg_match('/^[0-9]{14}$/', $from) and $from > $cutoff) {
$cutoff = $from;
$res = wfQuery( $sql2, $fname );
if(isset($from)) {
- $note = str_replace( "$1", $limit, wfMsg( "rcnotefrom" ) );
- $note = str_replace( "$2", $wgLang->timeanddate( $from, true ), $note );
+ $note = wfMsg( "rcnotefrom", $limit,
+ $wgLang->timeanddate( $from, true ) );
} else {
- $note = str_replace( "$1", $limit, wfMsg( "rcnote" ) );
- $note = str_replace( "$2", $days, $note );
+ $note = wfMsg( "rcnote", $limit, $days );
}
$wgOut->addHTML( "\n<hr>\n{$note}\n<br>" );
$note = rcDayLimitLinks( $days, $limit );
$now = date( "YmdHis" );
- $note .= "<br>\n" . str_replace( "$1",
+ $note .= "<br>\n" . wfMsg( "rclistfrom",
$sk->makeKnownLink( $wgLang->specialPage( "Recentchanges" ),
- $wgLang->timeanddate( $now, true ), "from=$now" ),
- wfMsg( "rclistfrom" ) );
+ $wgLang->timeanddate( $now, true ), "from=$now" ) );
$wgOut->addHTML( "{$note}\n" );
rcDaysLink( $limit, 14, $page, $more ) . " | " .
rcDaysLink( $limit, 30, $page, $more ) .
( $doall ? ( " | " . rcDaysLink( $limit, 0, $page, $more ) ) : "" );
- $note = str_replace( "$1", $cl, wfMsg( "rclinks" ) );
- $note = str_replace( "$2", $dl, $note );
- $note = str_replace( "$3", $mlink, $note );
+ $note = wfMsg( "rclinks", $cl, $dl, $mlink );
return $note;
}
rcCountLink( 250, 0, $page, $more ) . " | " .
rcCountLink( 500, 0, $page, $more ) .
( $doall ? ( " | " . rcCountLink( 0, $days, $page, $more ) ) : "" );
- $note = str_replace( "$1", $cl, wfMsg( "rclinks" ) );
- $note = str_replace( "$3", $mlink, $note );
+ $note = wfMsg( "rclinks", $cl, "", $mlink );
return $note;
}
function wfSpecialRecentchangeslinked()
{
global $wgUser, $wgOut, $wgLang, $wgTitle;
- global $days, $limit, $target, $hideminor; # From query string
+ global $days, $target, $hideminor; # From query string
$fname = "wfSpecialRecentchangeslinked";
$wgOut->setPagetitle( wfMsg( "recentchanges" ) );
$days = $wgUser->getOption( "rcdays" );
if ( ! $days ) { $days = 7; }
}
- if ( ! $limit ) {
- $limit = $wgUser->getOption( "rclimit" );
- if ( ! $limit ) { $limit = 100; }
- }
+ $days = (int)$days;
+ list( $limit, $offset ) = wfCheckLimits( 100, "rclimit" );
$cutoff = date( "YmdHis", time() - ( $days * 86400 ) );
if ( ! isset( $hideminor ) ) {
"ORDER BY inverse_timestamp LIMIT {$limit}";
$res = wfQuery( $sql, $fname );
- $note = str_replace( "$1", $limit, wfMsg( "rcnote" ) );
- $note = str_replace( "$2", $days, $note );
+ $note = wfMsg( "rcnote", $limit, $days );
$wgOut->addHTML( "<hr>\n{$note}\n<br>" );
$tu = "target=" . $nt->getPrefixedURL();
function wfSpecialShortpages()
{
global $wgUser, $wgOut, $wgLang, $wgTitle;
- global $limit, $offset; # From query string
$fname = "wfSpecialShortpages";
# Cache
return;
}
- if ( ! $limit ) {
- $limit = $wgUser->getOption( "rclimit" );
- if ( ! $limit ) { $limit = 50; }
- }
- if ( ! $offset ) { $offset = 0; }
+ list( $limit, $offset ) = wfCheckLimits();
$sql = "SELECT cur_title, LENGTH(cur_text) AS len FROM cur " .
"WHERE cur_namespace=0 AND cur_is_redirect=0 ORDER BY " .
global $limit, $offset; # From query string
$fname = "wfSpecialUnusedimages";
- if ( ! $limit ) {
- $limit = $wgUser->getOption( "rclimit" );
- if ( ! $limit ) { $limit = 50; }
- }
- if ( ! $offset ) { $offset = 0; }
+ list( $limit, $offset ) = wfCheckLimits();
$sql = "SELECT img_name,img_user,img_user_text,img_timestamp,img_description " .
"FROM image LEFT JOIN imagelinks ON img_name=il_to WHERE il_to IS NULL " .
function wfSpecialWantedpages()
{
global $wgUser, $wgOut, $wgLang, $wgTitle;
- global $limit, $offset; # From query string
$fname = "wfSpecialWantedpages";
# Cache
return;
}
- if ( ! $limit ) {
- $limit = $wgUser->getOption( "rclimit" );
- if ( ! $limit ) { $limit = 50; }
- }
- if ( ! $offset ) { $offset = 0; }
+ list( $limit, $offset ) = wfCheckLimits();
$cache = "" ; # To be saved, eventually
$days = $wgUser->getOption( "rcdays" );
if ( ! $days ) { $days = 3; }
}
- if ( ! isset( $limit ) ) {
- $limit = $wgUser->getOption( "rclimit" );
- if ( ! $limit ) { $limit = 100; }
- }
- if ( $days == 0 ) {
+ $days = (int)$days;
+ list( $limit, $offset ) = wfCheckLimits( 100, "rclimit" );
+
+ if ( $days <= 0 ) {
$docutoff = '';
} else {
$docutoff = "cur_timestamp > '" .
return;
}
-# $sql = "SELECT DISTINCT
-# cur_id,cur_namespace,cur_title,cur_comment,
-# cur_user,cur_user_text,cur_timestamp,cur_minor_edit,cur_is_new
-# FROM cur,watchlist
-# WHERE wl_user={$uid} AND wl_namespace=cur_namespace & (~1) AND wl_title=cur_title
-# ORDER BY cur_timestamp DESC {$dolimit}";
$sql = "SELECT DISTINCT
cur_id,cur_namespace,cur_title,cur_comment,
cur_user,cur_user_text,cur_timestamp,cur_minor_edit,cur_is_new
return;
}
- $note = str_replace( "$1", $limit, wfMsg( "rcnote" ) );
- $note = str_replace( "$2", $days, $note );
+ $note = wfMsg( "rcnote", $limit, $days );
$wgOut->addHTML( "\n<hr>\n{$note}\n<br>" );
$note = rcDayLimitlinks( $days, $limit, "Watchlist", "", true );
$wgOut->addHTML( "{$note}\n" );
required for changes to OutputPage.php and elsewhere to continue
working on an older database.
+
* 2003-05-23: Index for "Oldest articles"
"Oldest articles" needs an index on namespace, redirect and timestamp
to be reasonably fast. (patch-oldestindex.sql)
OutputPage.php User.php maintenance/buildTables.inc maintenance/patch-cache.sql maintenance/patch-list.txt
+
+
+* 2003-05-30: File upload license fields
+Adds fields to 'image' table.