* @package MediaWiki
*/
-/**
- *
- */
-require_once( 'WatchedItem.php' );
-
# Number of characters in user_token field
define( 'USER_TOKEN_LENGTH', 32 );
/**
* Static factory method
* @param string $name Username, validated by Title:newFromText()
+ * @param bool $validate Validate username
* @return User
* @static
*/
- function newFromName( $name ) {
+ function newFromName( $name, $validate = true ) {
# Force usernames to capital
global $wgContLang;
$name = $wgContLang->ucfirst( $name );
global $wgAuth;
$canonicalName = $wgAuth->getCanonicalName( $t->getText() );
- if( !User::isValidUserName( $canonicalName ) ) {
+ if( $validate && !User::isValidUserName( $canonicalName ) ) {
return null;
}
}
/**
- * does the string match an anonymous IPv4 address?
+ * Does the string match an anonymous IPv4 address?
*
- * Note: We match \d{1,3}\.\d{1,3}\.\d{1,3}\.xxx as an anonymous IP
+ * This function exists for username validation, in order to reject
+ * usernames which are similar in form to IP addresses. Strings such
+ * as 300.300.300.300 will return true because it looks like an IP
+ * address, despite not being strictly valid.
+ *
+ * We match \d{1,3}\.\d{1,3}\.\d{1,3}\.xxx as an anonymous IP
* address because the usemod software would "cloak" anonymous IP
* addresses like this, if we allowed accounts like this to be created
* new users could get the old edits of these anonymous users.
$this->inDnsBlacklist( $ip, 'http.dnsbl.sorbs.net.' );
}
- function inOpmBlacklist( $ip ) {
- global $wgEnableOpm;
- return $wgEnableOpm &&
- $this->inDnsBlacklist( $ip, 'opm.blitzed.org.' );
- }
-
function inDnsBlacklist( $ip, $base ) {
$fname = 'User::inDnsBlacklist';
wfProfileIn( $fname );
* @deprecated
*/
function isSysop() {
- wfDebugDieBacktrace( "Call to deprecated (v1.7) User::isSysop() method\n" );
+ throw new MWException( "Call to deprecated (v1.7) User::isSysop() method\n" );
#return $this->isAllowed( 'protect' );
}
* @deprecated
*/
function isDeveloper() {
- wfDebugDieBacktrace( "Call to deprecated (v1.7) User::isDeveloper() method\n" );
+ throw new MWException( "Call to deprecated (v1.7) User::isDeveloper() method\n" );
#return $this->isAllowed( 'siteadmin' );
}
* @deprecated
*/
function isBureaucrat() {
- wfDebugDieBacktrace( "Call to deprecated (v1.7) User::isBureaucrat() method\n" );
+ throw new MWException( "Call to deprecated (v1.7) User::isBureaucrat() method\n" );
#return $this->isAllowed( 'makesysop' );
}