}
/**
- *
+ * The User object encapsulates all of the user-specific settings (user_id,
+ * name, rights, password, email address, options, last login time). Client
+ * classes use the getXXX() functions to access these fields. These functions
+ * do all the work of determining whether the user is logged in,
+ * whether the requested option can be satisfied from cookies or
+ * whether a database query is needed. Most of the settings needed
+ * for rendering normal pages are set in the cookie to minimize use
+ * of the database.
*/
class User {
*
* @param string $password
* @return bool
- * @static
*/
- static function isValidPassword( $password ) {
- global $wgMinimalPasswordLength;
+ function isValidPassword( $password ) {
+ global $wgMinimalPasswordLength, $wgContLang;
$result = null;
if( !wfRunHooks( 'isValidPassword', array( $password, &$result ) ) ) return $result;
- if ($result === false) return false;
- return (strlen( $password ) >= $wgMinimalPasswordLength);
+ if ($result === false) return false;
+ return (strlen( $password ) >= $wgMinimalPasswordLength) &&
+ ($wgContLang->lc( $password ) !== $wgContLang->lc( $this->mName ));
}
/**
global $wgContLang;
$name = $wgContLang->ucfirst( $name );
+ # Reject names containing '#'; these will be cleaned up
+ # with title normalisation, but then it's too late to
+ # check elsewhere
+ if( strpos( $name, '#' ) !== false )
+ return false;
+
# Clean up name according to title rules
$t = Title::newFromText( $name );
if( is_null( $t ) ) {
* Load user data from the session or login cookie. If there are no valid
* credentials, initialises the user as an anon.
* @return true if the user is logged in, false otherwise
- *
- * @private
*/
- function loadFromSession() {
+ private function loadFromSession() {
global $wgMemc, $wgCookiePrefix;
if ( isset( $_SESSION['wsUserID'] ) ) {
*/
public function isPingLimitable() {
global $wgRateLimitsExcludedGroups;
- return array_intersect($this->getEffectiveGroups(), $wgRateLimitsExcludedGroups) != array();
+ return array_intersect($this->getEffectiveGroups(), $wgRateLimitsExcludedGroups) == array();
}
/**
} else {
$this->load();
if ( $this->mName === false ) {
- $this->mName = wfGetIP();
+ # Clean up IPs
+ $this->mName = IP::sanitizeIP( wfGetIP() );
}
- # Clean up IPs
- return IP::sanitizeIP($this->mName);
+ return $this->mName;
}
}
// extra options or other effects on the parser cache.
wfRunHooks( 'PageRenderingHash', array( &$confstr ) );
+ // Make it a valid memcached key fragment
+ $confstr = str_replace( ' ', '_', $confstr );
$this->mHash = $confstr;
return $confstr;
}
return $this->mBlock && $this->mBlock->mCreateAccount;
}
+ /**
+ * Determine if the user is blocked from using Special:Emailuser.
+ *
+ * @public
+ * @return boolean
+ */
+ function isBlockedFromEmailuser() {
+ $this->getBlockedStatus();
+ return $this->mBlock && $this->mBlock->mBlockEmail;
+ }
+
function isAllowedToCreateAccount() {
return $this->isAllowed( 'createaccount' ) && !$this->isBlockedFromCreateAccount();
}