From 286be59ed513931dcb567e32763d9c15781a499d Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Wed, 12 Nov 2003 13:07:08 +0000 Subject: [PATCH] Imported latest features from the stable branch --- includes/Article.php | 16 ++++++++++++-- includes/SpecialMovepage.php | 1 + includes/SpecialPreferences.php | 38 +++++++++++++++++++-------------- includes/SpecialUserlogin.php | 11 +++++----- includes/User.php | 28 ++++++++++++------------ 5 files changed, 57 insertions(+), 37 deletions(-) diff --git a/includes/Article.php b/includes/Article.php index 51d27dc055..e700d977e8 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -686,6 +686,11 @@ $wgLang->recodeForEdit( $wpTextbox1 ) . } } + # The talk page isn't in the regular link tables, so we need to update manually: + $talkns = $ns ^ 1; # talk -> normal; normal -> talk + $sql = "UPDATE cur set cur_touched='$now' WHERE cur_namespace=$talkns AND cur_title='" . wfStrencode( $ttl ) . "'"; + wfQuery( $sql ); + $this->showArticle( $text, wfMsg( "newarticle" ) ); } @@ -980,6 +985,12 @@ $wgLang->recodeForEdit( $wpTextbox1 ) . "cur_restrictions='{$limit}' WHERE cur_id={$id}"; wfQuery( $sql, DB_WRITE, "Article::protect" ); + $log = new LogPage( wfMsg( "protectlogpage" ), wfMsg( "protectlogtext" ) ); + if ( $limit === "" ) { + $log->addEntry( wfMsg( "unprotectedarticle", $wgTitle->getPrefixedText() ), "" ); + } else { + $log->addEntry( wfMsg( "protectedarticle", $wgTitle->getPrefixedText() ), "" ) + } $wgOut->redirect( wfLocalUrl( $this->mTitle->getPrefixedURL() ) ); } @@ -1436,12 +1447,13 @@ $wgLang->recodeForEdit( $wpTextbox1 ) . # $tc = "[&;%\\-,.\\(\\)' _0-9A-Za-z\\/:\\x80-\\xff]"; $np = "[&;%\\-,.' _0-9A-Za-z\\/:\\x80-\\xff]"; # No parens + $namespacechar = '[ _0-9A-Za-z\x80-\xff]'; # Namespaces can use non-ascii! $conpat = "/^({$np}+) \\(({$tc}+)\\)$/"; $p1 = "/\[\[({$np}+) \\(({$np}+)\\)\\|]]/"; # [[page (context)|]] $p2 = "/\[\[\\|({$tc}+)]]/"; # [[|page]] - $p3 = "/\[\[([A-Za-z _]+):({$np}+)\\|]]/"; # [[namespace:page|]] - $p4 = "/\[\[([A-Aa-z _]+):({$np}+) \\(({$np}+)\\)\\|]]/"; + $p3 = "/\[\[($namespacechar+):({$np}+)\\|]]/"; # [[namespace:page|]] + $p4 = "/\[\[($namespacechar+):({$np}+) \\(({$np}+)\\)\\|]]/"; # [[ns:page (cont)|]] $context = ""; $t = $this->mTitle->getText(); diff --git a/includes/SpecialMovepage.php b/includes/SpecialMovepage.php index 81d8bdc546..58471f8219 100644 --- a/includes/SpecialMovepage.php +++ b/includes/SpecialMovepage.php @@ -130,6 +130,7 @@ class MovePageForm { ( "" == $this->odt ) || ( "" != $this->ot->getInterwiki() ) || ( !$this->ot->userCanEdit() ) || + ( !$this->oldid ) || ( ! Namespace::isMovable( $nns ) ) || ( "" == $this->ndt ) || ( "" != $this->nt->getInterwiki() ) || diff --git a/includes/SpecialPreferences.php b/includes/SpecialPreferences.php index 822be3a02e..5149535730 100644 --- a/includes/SpecialPreferences.php +++ b/includes/SpecialPreferences.php @@ -4,8 +4,8 @@ function wfSpecialPreferences() global $wgUser, $wgOut, $wgUseDynamicDates, $action; global $wpSaveprefs, $wpReset; - $fields = array( "wpOldpass", "wpNewpass", "wpRetype", - "wpEmail", "wpNick" ); + $fields = array( "wpOldpass", "wpNewpass", "wpRetypePass", + "wpUserEmail", "wpNick" ); wfCleanFormFields( $fields ); if ( 0 == $wgUser->getID() ) { @@ -61,13 +61,13 @@ function wfSpecialPreferences() /* private */ function savePreferences() { global $wgUser, $wgLang, $wgDeferredUpdateList; - global $wpQuickbar, $wpOldpass, $wpNewpass, $wpRetype; - global $wpSkin, $wpMath, $wpDate, $wpEmail, $wpEmailFlag, $wpNick, $wpSearch, $wpRecent; + global $wpQuickbar, $wpOldpass, $wpNewpass, $wpRetypePass; + global $wpSkin, $wpMath, $wpDate, $wpUserEmail, $wpEmailFlag, $wpNick, $wpSearch, $wpRecent; global $wpSearchLines, $wpSearchChars, $wpStubs; global $wpRows, $wpCols, $wpHourDiff, $HTTP_POST_VARS; if ( "" != $wpNewpass ) { - if ( $wpNewpass != $wpRetype ) { + if ( $wpNewpass != $wpRetypePass ) { mainPrefsForm( wfMsg( "badretype" ) ); return; } @@ -80,7 +80,7 @@ function wfSpecialPreferences() } $wgUser->setPassword( $wpNewpass ); } - $wgUser->setEmail( $wpEmail ); + $wgUser->setEmail( $wpUserEmail ); $wgUser->setOption( "nickname", $wpNick ); $wgUser->setOption( "quickbar", $wpQuickbar ); $wgUser->setOption( "skin", $wpSkin ); @@ -125,13 +125,13 @@ function wfSpecialPreferences() /* private */ function resetPrefs() { global $wgUser, $wgLang; - global $wpQuickbar, $wpOldpass, $wpNewpass, $wpRetype, $wpStubs; - global $wpRows, $wpCols, $wpSkin, $wpMath, $wpDate, $wpEmail, $wpEmailFlag, $wpNick; + global $wpQuickbar, $wpOldpass, $wpNewpass, $wpRetypePass, $wpStubs; + global $wpRows, $wpCols, $wpSkin, $wpMath, $wpDate, $wpUserEmail, $wpEmailFlag, $wpNick; global $wpSearch, $wpRecent, $HTTP_POST_VARS; global $wpHourDiff, $wpSearchLines, $wpSearchChars; - $wpOldpass = $wpNewpass = $wpRetype = ""; - $wpEmail = $wgUser->getEmail(); + $wpOldpass = $wpNewpass = $wpRetypePass = ""; + $wpUserEmail = $wgUser->getEmail(); if ( 1 == $wgUser->getOption( "disablemail" ) ) { $wpEmailFlag = 1; } else { $wpEmailFlag = 0; } $wpNick = $wgUser->getOption( "nickname" ); @@ -181,6 +181,12 @@ function wfSpecialPreferences() $r1 .= "\n"; } + $name = str_replace( "_", " ", $ns[$i] ); + if ( "" == $name ) { $name = wfMsg( "blanknamespace" ); } + + if ( 0 != $i ) { $r1 .= " "; } + $r1 .= "\n"; } return $r1; @@ -192,8 +198,8 @@ function wfSpecialPreferences() /* private */ function mainPrefsForm( $err ) { global $wgUser, $wgOut, $wgLang, $wgUseDynamicDates; - global $wpQuickbar, $wpOldpass, $wpNewpass, $wpRetype; - global $wpSkin, $wpMath, $wpDate, $wpEmail, $wpEmailFlag, $wpNick, $wpSearch, $wpRecent; + global $wpQuickbar, $wpOldpass, $wpNewpass, $wpRetypePass; + global $wpSkin, $wpMath, $wpDate, $wpUserEmail, $wpEmailFlag, $wpNick, $wpSearch, $wpRecent; global $wpRows, $wpCols, $wpSaveprefs, $wpReset, $wpHourDiff; global $wpSearchLines, $wpSearchChars, $wpStubs, $wgValidSkinNames; @@ -262,12 +268,12 @@ value=\"$i\"$checked> {$qbs[$i]}
\n" ); # $wpOldpass = wfEscapeHTML( $wpOldpass ); $wpNewpass = wfEscapeHTML( $wpNewpass ); - $wpRetype = wfEscapeHTML( $wpRetype ); + $wpRetypePass = wfEscapeHTML( $wpRetypePass ); $wgOut->addHTML( "$cp:


-
+
\n" ); # Skin setting @@ -346,7 +352,7 @@ value=\"$i\"$checked> {$mathopts[$i]}
\n" ); # Email, etc. # - $wpEmail = wfEscapeHTML( $wpEmail ); + $wpUserEmail = wfEscapeHTML( $wpUserEmail ); $wpNick = wfEscapeHTML( $wpNick ); if ( $wpEmailFlag ) { $emfc = "checked"; } else { $emfc = ""; } @@ -354,7 +360,7 @@ value=\"$i\"$checked> {$mathopts[$i]}
\n" ); $ps = namespacesCheckboxes(); $wgOut->addHTML( " -
+



diff --git a/includes/SpecialUserlogin.php b/includes/SpecialUserlogin.php index 66f8d83af0..28d6d2d7d1 100644 --- a/includes/SpecialUserlogin.php +++ b/includes/SpecialUserlogin.php @@ -165,7 +165,8 @@ function wfSpecialUserlogin() /* private */ function mailPassword() { global $wgUser, $wpName, $wgDeferredUpdateList, $wgOutputEncoding; - + global $wgCookiePath, $wgCookieDomain, $wgDBname; + if ( "" == $wpName ) { mainLoginForm( wfMsg( "noname" ) ); return; @@ -202,7 +203,7 @@ function wfSpecialUserlogin() $np = User::randomPassword(); $u->setNewpassword( $np ); - setcookie( "wcUserPassword", "", time() - 3600 ); + setcookie( "{$wgDBname}Password", "", time() - 3600, $wgCookiePath, $wgCookieDomain ); $u->saveSettings(); $ip = getenv( "REMOTE_ADDR" ); @@ -264,7 +265,7 @@ function userNotPrivilegedMessage() { global $wgUser, $wgOut, $wgLang, $returnto; global $wpName, $wpPassword, $wpRetype, $wpRemember; - global $wpEmail, $HTTP_COOKIE_VARS; + global $wpEmail, $HTTP_COOKIE_VARS, $wgDBname; $le = wfMsg( "loginerror" ); $yn = wfMsg( "yourname" ); @@ -285,7 +286,7 @@ function userNotPrivilegedMessage() if ( 0 != $wgUser->getID() ) { $name = $wgUser->getName(); } else { - $name = $HTTP_COOKIE_VARS["wcUserName"]; + $name = $HTTP_COOKIE_VARS["{$wgDBname}UserName"]; } } $pwd = $wpPassword; @@ -319,7 +320,7 @@ color='red'>$err\n" ); } $wgOut->addHTML( " -
+
$yn: diff --git a/includes/User.php b/includes/User.php index 697354f7c7..ea9c0d58c8 100644 --- a/includes/User.php +++ b/includes/User.php @@ -135,16 +135,16 @@ class User { } else { return new User(); } - } else if ( isset( $HTTP_COOKIE_VARS["wcUserID"] ) ) { - $sId = $HTTP_COOKIE_VARS["wcUserID"]; + } else if ( isset( $HTTP_COOKIE_VARS["{$wgDBname}UserID"] ) ) { + $sId = $HTTP_COOKIE_VARS["{$wgDBname}UserID"]; $wsUserID = $sId; } else { return new User(); } if ( isset( $wsUserName ) ) { $sName = $wsUserName; - } else if ( isset( $HTTP_COOKIE_VARS["wcUserName"] ) ) { - $sName = $HTTP_COOKIE_VARS["wcUserName"]; + } else if ( isset( $HTTP_COOKIE_VARS["{$wgDBname}UserName"] ) ) { + $sName = $HTTP_COOKIE_VARS["{$wgDBname}UserName"]; $wsUserName = $sName; } else { return new User(); @@ -163,8 +163,8 @@ class User { if ( isset( $wsUserPassword ) ) { $passwordCorrect = $wsUserPassword == $user->mPassword; - } else if ( isset( $HTTP_COOKIE_VARS["wcUserPassword"] ) ) { - $user->mCookiePassword = $HTTP_COOKIE_VARS["wcUserPassword"]; + } else if ( isset( $HTTP_COOKIE_VARS["{$wgDBname}Password"] ) ) { + $user->mCookiePassword = $HTTP_COOKIE_VARS["{$wgDBname}Password"]; $wsUserPassword = $user->addSalt( $user->mCookiePassword ); $passwordCorrect = $wsUserPassword == $user->mPassword; } else { @@ -448,34 +448,34 @@ class User { function setCookies() { global $wsUserID, $wsUserName, $wsUserPassword; - global $wgCookieExpiration; + global $wgCookieExpiration, $wgCookiePath, $wgCookieDomain, $wgDBname; if ( 0 == $this->mId ) return; $this->loadFromDatabase(); $exp = time() + $wgCookieExpiration; $wsUserID = $this->mId; - setcookie( "wcUserID", $this->mId, $exp, "/" ); + setcookie( "{$wgDBname}UserID", $this->mId, $exp, $wgCookiePath, $wgCookieDomain ); $wsUserName = $this->mName; - setcookie( "wcUserName", $this->mName, $exp, "/" ); + setcookie( "{$wgDBname}UserName", $this->mName, $exp, $wgCookiePath, $wgCookieDomain ); $wsUserPassword = $this->mPassword; if ( 1 == $this->getOption( "rememberpassword" ) ) { - setcookie( "wcUserPassword", $this->mCookiePassword, $exp, "/" ); + setcookie( "{$wgDBname}Password", $this->mCookiePassword, $exp, $wgCookiePath, $wgCookieDomain ); } else { - setcookie( "wcUserPassword", "", time() - 3600 ); + setcookie( "{$wgDBname}Password", "", time() - 3600 ); } } function logout() { - global $wsUserID; + global $wsUserID, $wgCookiePath, $wgCookieDomain, $wgDBname; $this->mId = 0; $wsUserID = 0; - setcookie( "wcUserID", "", time() - 3600 ); - setcookie( "wcUserPassword", "", time() - 3600 ); + setcookie( "{$wgDBname}UserID", "", time() - 3600, $wgCookiePath, $wgCookieDomain ); + setcookie( "{$wgDBname}Password", "", time() - 3600, $wgCookiePath, $wgCookieDomain ); } function saveSettings() -- 2.20.1