# Reject various classes of invalid names
$canonicalName = $t->getText();
if( !User::isValidUserName( $canonicalName ) ) {
return null;
}
# Reject various classes of invalid names
$canonicalName = $t->getText();
if( !User::isValidUserName( $canonicalName ) ) {
return null;
}
/**
* Factory method to fetch whichever use has a given email confirmation code.
* This code is generated when an account is created or its e-mail address
/**
* Factory method to fetch whichever use has a given email confirmation code.
* This code is generated when an account is created or its e-mail address
* silly "incomplete type" errors when skins are cached
*/
function __sleep() {
return array( 'mId', 'mName', 'mPassword', 'mEmail', 'mNewtalk',
* silly "incomplete type" errors when skins are cached
*/
function __sleep() {
return array( 'mId', 'mName', 'mPassword', 'mEmail', 'mNewtalk',
- 'mEmailAuthenticated', 'mRights', 'mOptions', 'mDataLoaded',
- 'mNewpassword', 'mBlockedby', 'mBlockreason', 'mTouched',
+ 'mEmailAuthenticated', 'mRights', 'mOptions', 'mDataLoaded',
+ 'mNewpassword', 'mBlockedby', 'mBlockreason', 'mTouched',
'mToken', 'mRealName', 'mHash', 'mGroups' );
}
'mToken', 'mRealName', 'mHash', 'mGroups' );
}
*/
function isValidUserName( $name ) {
global $wgContLang, $wgMaxNameChars;
*/
function isValidUserName( $name ) {
global $wgContLang, $wgMaxNameChars;
global $wgContLang, $wgIP, $wgDBname;
global $wgNamespacesToBeSearchedDefault;
global $wgContLang, $wgIP, $wgDBname;
global $wgNamespacesToBeSearchedDefault;
$this->mRights = array();
$this->mGroups = array();
$this->mOptions = User::getDefaultOptions();
$this->mRights = array();
$this->mGroups = array();
$this->mOptions = User::getDefaultOptions();
foreach( $wgNamespacesToBeSearchedDefault as $nsnum => $val ) {
$this->mOptions['searchNs'.$nsnum] = $val;
}
foreach( $wgNamespacesToBeSearchedDefault as $nsnum => $val ) {
$this->mOptions['searchNs'.$nsnum] = $val;
}
/**
* Combine the language default options with any site-specific options
* and add the default language variants.
/**
* Combine the language default options with any site-specific options
* and add the default language variants.
*/
global $wgContLang, $wgDefaultUserOptions;
$defOpt = $wgDefaultUserOptions + $wgContLang->getDefaultUserOptions();
*/
global $wgContLang, $wgDefaultUserOptions;
$defOpt = $wgDefaultUserOptions + $wgContLang->getDefaultUserOptions();
/**
* default language setting
*/
$variant = $wgContLang->getPreferredVariant();
$defOpt['variant'] = $variant;
$defOpt['language'] = $variant;
/**
* default language setting
*/
$variant = $wgContLang->getPreferredVariant();
$defOpt['variant'] = $variant;
$defOpt['language'] = $variant;
# Local list
if ( array_key_exists( $wgIP, $wgProxyList ) ) {
$this->mBlockedby = wfMsg( 'proxyblocker' );
# Local list
if ( array_key_exists( $wgIP, $wgProxyList ) ) {
$this->mBlockedby = wfMsg( 'proxyblocker' );
function inOpmBlacklist( $ip ) {
global $wgEnableOpm;
return $wgEnableOpm &&
$this->inDnsBlacklist( $ip, 'opm.blitzed.org.' );
}
function inOpmBlacklist( $ip ) {
global $wgEnableOpm;
return $wgEnableOpm &&
$this->inDnsBlacklist( $ip, 'opm.blitzed.org.' );
}
function inDnsBlacklist( $ip, $base ) {
$fname = 'User::inDnsBlacklist';
wfProfileIn( $fname );
function inDnsBlacklist( $ip, $base ) {
$fname = 'User::inDnsBlacklist';
wfProfileIn( $fname );
if ( preg_match( '/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/', $ip, $m ) ) {
# Make hostname
for ( $i=4; $i>=1; $i-- ) {
if ( preg_match( '/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/', $ip, $m ) ) {
# Make hostname
for ( $i=4; $i>=1; $i-- ) {
global $wgMemc, $wgIP, $wgDBname, $wgRateLimitLog;
$fname = 'User::pingLimiter';
$limits = $wgRateLimits[$action];
$keys = array();
$id = $this->getId();
global $wgMemc, $wgIP, $wgDBname, $wgRateLimitLog;
$fname = 'User::pingLimiter';
$limits = $wgRateLimits[$action];
$keys = array();
$id = $this->getId();
if( isset( $limits['anon'] ) && $id == 0 ) {
$keys["$wgDBname:limiter:$action:anon"] = $limits['anon'];
}
if( isset( $limits['anon'] ) && $id == 0 ) {
$keys["$wgDBname:limiter:$action:anon"] = $limits['anon'];
}
if( isset( $limits['user'] ) && $id != 0 ) {
$keys["$wgDBname:limiter:$action:user:$id"] = $limits['user'];
}
if( isset( $limits['user'] ) && $id != 0 ) {
$keys["$wgDBname:limiter:$action:user:$id"] = $limits['user'];
}
$triggered = false;
foreach( $keys as $key => $limit ) {
list( $max, $period ) = $limit;
$triggered = false;
foreach( $keys as $key => $limit ) {
list( $max, $period ) = $limit;
/**
* Check if user is blocked
* @return bool True if blocked, false otherwise
/**
* Check if user is blocked
* @return bool True if blocked, false otherwise
*/
function isBlockedFrom( $title, $bFromSlave = false ) {
global $wgBlockAllowsUTEdit;
*/
function isBlockedFrom( $title, $bFromSlave = false ) {
global $wgBlockAllowsUTEdit;
function loadFromDatabase() {
global $wgCommandLineMode;
$fname = "User::loadFromDatabase";
function loadFromDatabase() {
global $wgCommandLineMode;
$fname = "User::loadFromDatabase";
# loading in a command line script, don't assume all command line scripts need it like this
#if ( $this->mDataLoaded || $wgCommandLineMode ) {
if ( $this->mDataLoaded ) {
# loading in a command line script, don't assume all command line scripts need it like this
#if ( $this->mDataLoaded || $wgCommandLineMode ) {
if ( $this->mDataLoaded ) {
$dbr =& wfGetDB( DB_SLAVE );
$s = $dbr->selectRow( 'user', array( 'user_name','user_password','user_newpassword','user_email',
'user_email_authenticated',
'user_real_name','user_options','user_touched', 'user_token' ),
array( 'user_id' => $this->mId ), $fname );
$dbr =& wfGetDB( DB_SLAVE );
$s = $dbr->selectRow( 'user', array( 'user_name','user_password','user_newpassword','user_email',
'user_email_authenticated',
'user_real_name','user_options','user_touched', 'user_token' ),
array( 'user_id' => $this->mId ), $fname );
# Load the newtalk status if it is unloaded (mNewtalk=-1)
if( $this->mNewtalk == -1 ) {
$this->mNewtalk = 0; # reset talk page status
# Load the newtalk status if it is unloaded (mNewtalk=-1)
if( $this->mNewtalk == -1 ) {
$this->mNewtalk = 0; # reset talk page status
$dbr =& wfGetDB( DB_SLAVE );
if ( $wgUseEnotif ) {
$res = $dbr->select( 'watchlist',
$dbr =& wfGetDB( DB_SLAVE );
if ( $wgUseEnotif ) {
$res = $dbr->select( 'watchlist',
function setCookiePassword( $str ) {
$this->loadFromDatabase();
$this->mCookiePassword = md5( $str );
function setCookiePassword( $str ) {
$this->loadFromDatabase();
$this->mCookiePassword = md5( $str );
$this->mGroups = array_merge( $this->mGroups, array( $group ) );
$this->mRights = User::getGroupPermissions( $this->getEffectiveGroups() );
$this->mGroups = array_merge( $this->mGroups, array( $group ) );
$this->mRights = User::getGroupPermissions( $this->getEffectiveGroups() );
$this->mGroups = array_diff( $this->mGroups, array( $group ) );
$this->mRights = User::getGroupPermissions( $this->getEffectiveGroups() );
$this->mGroups = array_diff( $this->mGroups, array( $group ) );
$this->mRights = User::getGroupPermissions( $this->getEffectiveGroups() );
# Grab the skin class and initialise it. Each skin checks for PHPTal
# and will not load if it's not enabled.
require_once( $IP.'/skins/'.$sn.'.php' );
# Grab the skin class and initialise it. Each skin checks for PHPTal
# and will not load if it's not enabled.
require_once( $IP.'/skins/'.$sn.'.php' );
// The query to find out if it is watched is cached both in memcached and per-invocation,
// and when it does have to be executed, it can be on a slave
// If this is the user's newtalk page, we always update the timestamp
if ($title->getNamespace() == NS_USER_TALK &&
// The query to find out if it is watched is cached both in memcached and per-invocation,
// and when it does have to be executed, it can be on a slave
// If this is the user's newtalk page, we always update the timestamp
if ($title->getNamespace() == NS_USER_TALK &&
$dbw =& wfGetDB( DB_MASTER );
$success = $dbw->update( 'watchlist',
array( /* SET */
$dbw =& wfGetDB( DB_MASTER );
$success = $dbw->update( 'watchlist',
array( /* SET */
/**
* Save value of new talk flag.
*/
function saveNewtalk() {
global $wgDBname, $wgMemc, $wgUseEnotif;
/**
* Save value of new talk flag.
*/
function saveNewtalk() {
global $wgDBname, $wgMemc, $wgUseEnotif;
# Update user_touched, so that newtalk notifications in the client cache are invalidated
if ( $changed && $this->getID() ) {
# Update user_touched, so that newtalk notifications in the client cache are invalidated
if ( $changed && $this->getID() ) {
/*SET*/ array( 'user_touched' => $this->mTouched ),
/*WHERE*/ array( 'user_id' => $this->getID() ),
$fname);
/*SET*/ array( 'user_touched' => $this->mTouched ),
/*WHERE*/ array( 'user_id' => $this->getID() ),
$fname);
if( $wgAuth->authenticate( $this->getName(), $password ) ) {
return true;
} elseif( $wgAuth->strict() ) {
if( $wgAuth->authenticate( $this->getName(), $password ) ) {
return true;
} elseif( $wgAuth->strict() ) {
/**
* Initialize (if necessary) and return a session token value
* which can be used in edit forms to show that the user's
/**
* Initialize (if necessary) and return a session token value
* which can be used in edit forms to show that the user's
/**
* Generate a hex-y looking random token for various uses.
* Could be made more cryptographically sure if someone cares.
/**
* Generate a hex-y looking random token for various uses.
* Could be made more cryptographically sure if someone cares.
/**
* Check given value against the token value stored in the session.
* A match should confirm that the form was submitted from the
/**
* Check given value against the token value stored in the session.
* A match should confirm that the form was submitted from the
function matchEditToken( $val, $salt = '' ) {
return ( $val == $this->editToken( $salt ) );
}
function matchEditToken( $val, $salt = '' ) {
return ( $val == $this->editToken( $salt ) );
}
/**
* Generate a new e-mail confirmation token and send a confirmation
* mail to the user's given address.
/**
* Generate a new e-mail confirmation token and send a confirmation
* mail to the user's given address.
require_once( 'UserMailer.php' );
$error = userMailer( $this->getEmail(), $from, $subject, $body );
require_once( 'UserMailer.php' );
$error = userMailer( $this->getEmail(), $from, $subject, $body );
/**
* Generate, store, and return a new e-mail confirmation code.
* A hash (unsalted since it's used as a key) is stored.
/**
* Generate, store, and return a new e-mail confirmation code.
* A hash (unsalted since it's used as a key) is stored.
$now = time();
$expires = $now + 7 * 24 * 60 * 60;
$expiration = wfTimestamp( TS_MW, $expires );
$now = time();
$expires = $now + 7 * 24 * 60 * 60;
$expiration = wfTimestamp( TS_MW, $expires );
$dbw =& wfGetDB( DB_MASTER );
$dbw->update( 'user',
array( 'user_email_token' => $hash,
'user_email_token_expires' => $dbw->timestamp( $expires ) ),
array( 'user_id' => $this->mId ),
$fname );
$dbw =& wfGetDB( DB_MASTER );
$dbw->update( 'user',
array( 'user_email_token' => $hash,
'user_email_token_expires' => $dbw->timestamp( $expires ) ),
array( 'user_id' => $this->mId ),
$fname );
/**
* Generate and store a new e-mail confirmation token, and return
* the URL the user can use to confirm.
/**
* Generate and store a new e-mail confirmation token, and return
* the URL the user can use to confirm.
$title = Title::makeTitle( NS_SPECIAL, 'Confirmemail/' . $token );
return $title->getFullUrl();
}
$title = Title::makeTitle( NS_SPECIAL, 'Confirmemail/' . $token );
return $title->getFullUrl();
}
/**
* Is this user's e-mail address valid-looking and confirmed within
* limits of the current site configuration?
/**
* Is this user's e-mail address valid-looking and confirmed within
* limits of the current site configuration?
/**
* @param array $groups list of groups
* @return array list of permission key names for given groups combined
/**
* @param array $groups list of groups
* @return array list of permission key names for given groups combined