00001 <?php
00002
# See user.doc
00003
00004 require_once( '
WatchedItem.php' );
00005
00006
class User {
00007 var $mId, $mName, $mPassword, $mEmail, $mNewtalk;
00008 var $mRights, $mOptions;
00009 var $mDataLoaded, $mNewpassword;
00010 var $mSkin;
00011 var $mBlockedby, $mBlockreason;
00012 var $mTouched;
00013 var $mCookiePassword;
00014 var $mRealName;
00015
00016 function User() {
00017 $this->loadDefaults();
00018 }
00019
00020
# Static factory method
00021
#
00022
function newFromName( $name ) {
00023 $u =
new User();
00024
00025
# Clean up name according to title rules
00026
00027 $t = Title::newFromText( $name );
00028 $u->setName( $t->getText() );
00029
return $u;
00030 }
00031
00032 function whoIs( $
id ) {
00033
return wfGetSQL( 'user', 'user_name', 'user_id='.$
id );
00034 }
00035
00036 function whoIsReal( $
id ) {
00037
return wfGetSQL( 'user', 'user_real_name', 'user_id='.$
id );
00038 }
00039
00040 function idFromName( $name ) {
00041 $nt = Title::newFromText( $name );
00042
if( is_null( $nt ) ) {
00043
# Illegal name
00044
return null;
00045 }
00046
$sql =
"SELECT user_id FROM user WHERE user_name='" .
00047
wfStrencode( $nt->getText() ) .
"'";
00048
$res =
wfQuery( $sql, DB_READ, 'User::idFromName' );
00049
00050
if ( 0 ==
wfNumRows( $res ) ) {
00051
return 0;
00052 }
else {
00053
$s =
wfFetchObject( $res );
00054
wfFreeResult( $res );
00055
return $s->user_id;
00056 }
00057 }
00058
00059
# does the string match an anonymous user IP address?
00060
function isIP( $name ) {
00061
return preg_match(
"/^\d{1,3}\.\d{1,3}.\d{1,3}\.\d{1,3}$/",$name);
00062
00063 }
00064
00065 function randomPassword() {
00066 $pwchars = 'ABCDEFGHJKLMNPQRSTUVWXYZabcdefghjkmnpqrstuvwxyz';
00067 $l = strlen( $pwchars ) - 1;
00068
00069
wfSeedRandom();
00070 $np = $pwchars{mt_rand( 0, $l )} . $pwchars{mt_rand( 0, $l )} .
00071 $pwchars{mt_rand( 0, $l )} . chr( mt_rand(48, 57) ) .
00072 $pwchars{mt_rand( 0, $l )} . $pwchars{mt_rand( 0, $l )} .
00073 $pwchars{mt_rand( 0, $l )};
00074
return $np;
00075 }
00076
00077 function loadDefaults() {
00078 global
$wgLang,
$wgIP;
00079 global
$wgNamespacesToBeSearchedDefault;
00080
00081 $this->mId = $this->mNewtalk = 0;
00082 $this->mName =
$wgIP;
00083 $this->mEmail = '';
00084 $this->mPassword = $this->mNewpassword = '';
00085 $this->mRights = array();
00086 $defOpt =
$wgLang->getDefaultUserOptions() ;
00087 foreach ( $defOpt as $oname => $val ) {
00088 $this->mOptions[$oname] = $val;
00089 }
00090 foreach ($wgNamespacesToBeSearchedDefault as $nsnum => $val) {
00091 $this->mOptions['searchNs'.$nsnum] = $val;
00092 }
00093 unset( $this->mSkin );
00094 $this->mDataLoaded =
false;
00095 $this->mBlockedby = -1; # Unset
00096 $this->mTouched =
'0'; # Allow any pages to be cached
00097 $this->cookiePassword = '';
00098 }
00099
00100 function getBlockedStatus()
00101 {
00102 global
$wgIP,
$wgBlockCache;
00103
00104
if ( -1 != $this->mBlockedby ) {
return; }
00105
00106 $this->mBlockedby = 0;
00107
00108
# User blocking
00109
if ( $this->mId ) {
00110 $block =
new Block();
00111
if ( $block->load( $wgIP , $this->mId ) ) {
00112 $this->mBlockedby = $block->mBy;
00113 $this->mBlockreason = $block->mReason;
00114 }
00115 }
00116
00117
# IP/range blocking
00118
if ( !$this->mBlockedby ) {
00119 $block =
$wgBlockCache->get( $wgIP );
00120
if ( $block !==
false ) {
00121 $this->mBlockedby = $block->mBy;
00122 $this->mBlockreason = $block->mReason;
00123 }
00124 }
00125 }
00126
00127 function isBlocked()
00128 {
00129 $this->getBlockedStatus();
00130
if ( 0 == $this->mBlockedby ) {
return false; }
00131
return true;
00132 }
00133
00134 function blockedBy() {
00135 $this->getBlockedStatus();
00136
return $this->mBlockedby;
00137 }
00138
00139 function blockedFor() {
00140 $this->getBlockedStatus();
00141
return $this->mBlockreason;
00142 }
00143
00144 function SetupSession() {
00145 global
$wgSessionsInMemcached,
$wgCookiePath,
$wgCookieDomain;
00146
if(
$wgSessionsInMemcached ) {
00147 require_once( 'MemcachedSessions.php' );
00148 }
00149 session_set_cookie_params( 0, $wgCookiePath, $wgCookieDomain );
00150 session_cache_limiter( '
private, must-revalidate' );
00151 @session_start();
00152 }
00153
00154 function loadFromSession()
00155 {
00156 global
$wgMemc,
$wgDBname;
00157
00158
if ( isset( $_SESSION['wsUserID'] ) ) {
00159
if ( 0 != $_SESSION['wsUserID'] ) {
00160 $sId = $_SESSION['wsUserID'];
00161 }
else {
00162
return new User();
00163 }
00164 }
else if ( isset( $_COOKIE[
"{$wgDBname}UserID"] ) ) {
00165 $sId = IntVal( $_COOKIE[
"{$wgDBname}UserID"] );
00166 $_SESSION['wsUserID'] = $sId;
00167 }
else {
00168
return new User();
00169 }
00170
if ( isset( $_SESSION['wsUserName'] ) ) {
00171 $sName = $_SESSION['wsUserName'];
00172 }
else if ( isset( $_COOKIE[
"{$wgDBname}UserName"] ) ) {
00173 $sName = $_COOKIE[
"{$wgDBname}UserName"];
00174 $_SESSION['wsUserName'] = $sName;
00175 }
else {
00176
return new User();
00177 }
00178
00179 $passwordCorrect = FALSE;
00180
$user =
$wgMemc->get( $key =
"$wgDBname:user:id:$sId" );
00181
if($makenew = !
$user) {
00182
wfDebug(
"User::loadFromSession() unable to load from memcached\n" );
00183
$user =
new User();
00184
$user->mId = $sId;
00185
$user->loadFromDatabase();
00186 }
else {
00187
wfDebug(
"User::loadFromSession() got from cache!\n" );
00188 }
00189
00190
if ( isset( $_SESSION['wsUserPassword'] ) ) {
00191 $passwordCorrect = $_SESSION['wsUserPassword'] ==
$user->mPassword;
00192 }
else if ( isset( $_COOKIE[
"{$wgDBname}Password"] ) ) {
00193
$user->mCookiePassword = $_COOKIE[
"{$wgDBname}Password"];
00194 $_SESSION['wsUserPassword'] =
$user->addSalt( $
user->mCookiePassword );
00195 $passwordCorrect = $_SESSION['wsUserPassword'] ==
$user->mPassword;
00196 }
else {
00197
return new User(); # Can't log in from session
00198 }
00199
00200
if ( ( $sName ==
$user->mName ) && $passwordCorrect ) {
00201
if($makenew) {
00202
if(
$wgMemc->set( $key, $user ))
00203
wfDebug(
"User::loadFromSession() successfully saved user\n" );
00204
else
00205
wfDebug(
"User::loadFromSession() unable to save to memcached\n" );
00206 }
00207
$user->spreadBlock();
00208
return $user;
00209 }
00210
return new User(); # Can't log in from session
00211 }
00212
00213 function loadFromDatabase()
00214 {
00215 global
$wgCommandLineMode;
00216
if ( $this->mDataLoaded ||
$wgCommandLineMode ) {
00217
return;
00218 }
00219
00220
# Paranoia
00221
$this->mId = IntVal( $this->mId );
00222
00223
# check in separate table if there are changes to the talk page
00224
$this->mNewtalk=0; # reset talk
page status
00225
if($this->mId) {
00226
$sql =
"SELECT 1 FROM user_newtalk WHERE user_id={$this->mId}";
00227
$res =
wfQuery ($sql, DB_READ,
"User::loadFromDatabase" );
00228
00229
if (
wfNumRows($res)>0) {
00230 $this->mNewtalk= 1;
00231 }
00232
wfFreeResult( $res );
00233 }
else {
00234 global
$wgDBname,
$wgMemc;
00235 $key =
"$wgDBname:newtalk:ip:{$this->mName}";
00236 $newtalk =
$wgMemc->get( $key );
00237
if( ! is_integer( $newtalk ) ){
00238
$sql =
"SELECT 1 FROM user_newtalk WHERE user_ip='{$this->mName}'";
00239
$res =
wfQuery ($sql, DB_READ,
"User::loadFromDatabase" );
00240
00241 $this->mNewtalk = (
wfNumRows($res)>0) ? 1 : 0;
00242
wfFreeResult( $res );
00243
00244
$wgMemc->set( $key, $this->mNewtalk, time() );
00245 }
else {
00246 $this->mNewtalk = $newtalk ? 1 : 0;
00247 }
00248 }
00249
if(!$this->mId) {
00250 $this->mDataLoaded =
true;
00251
return;
00252 } # the
following stuff
is for non-anonymous users only
00253
00254
$sql =
"SELECT user_name,user_password,user_newpassword,user_email," .
00255
"user_real_name,user_options,user_rights,user_touched " .
00256
" FROM user WHERE user_id=" . $this->mId;
00257
$res =
wfQuery( $sql, DB_READ,
"User::loadFromDatabase" );
00258
00259
if (
wfNumRows( $res ) > 0 ) {
00260
$s =
wfFetchObject( $res );
00261 $this->mName =
$s->user_name;
00262 $this->mEmail =
$s->user_email;
00263 $this->mRealName =
$s->user_real_name;
00264 $this->mPassword =
$s->user_password;
00265 $this->mNewpassword =
$s->user_newpassword;
00266 $this->decodeOptions( $s->user_options );
00267 $this->mRights = explode(
",", strtolower( $s->user_rights ) );
00268 $this->mTouched =
$s->user_touched;
00269 }
00270
00271
wfFreeResult( $res );
00272 $this->mDataLoaded =
true;
00273 }
00274
00275 function getID() {
return $this->mId; }
00276 function setID( $v ) {
00277 $this->mId = $v;
00278 $this->mDataLoaded =
false;
00279 }
00280
00281 function getName() {
00282 $this->loadFromDatabase();
00283
return $this->mName;
00284 }
00285
00286 function setName( $str ) {
00287 $this->loadFromDatabase();
00288 $this->mName = $str;
00289 }
00290
00291 function getNewtalk() {
00292 $this->loadFromDatabase();
00293
return ( 0 != $this->mNewtalk );
00294 }
00295
00296 function setNewtalk( $val )
00297 {
00298 $this->loadFromDatabase();
00299 $this->mNewtalk = $val;
00300 $this->invalidateCache();
00301 }
00302
00303 function invalidateCache() {
00304 $this->loadFromDatabase();
00305 $this->mTouched =
wfTimestampNow();
00306
# Don't forget to save the options after this or
00307
# it won't take effect!
00308
}
00309
00310 function validateCache( $timestamp ) {
00311 $this->loadFromDatabase();
00312
return ($timestamp >= $this->mTouched);
00313 }
00314
00315 function getPassword() {
00316 $this->loadFromDatabase();
00317
return $this->mPassword;
00318 }
00319
00320 function getNewpassword() {
00321 $this->loadFromDatabase();
00322
return $this->mNewpassword;
00323 }
00324
00325 function addSalt( $p ) {
00326 global
$wgPasswordSalt;
00327
if(
$wgPasswordSalt)
00328
return md5(
"{$this->mId}-{$p}" );
00329
else
00330
return $p;
00331 }
00332
00333 function encryptPassword( $p ) {
00334
return $this->addSalt( md5( $p ) );
00335 }
00336
00337 function setPassword( $str ) {
00338 $this->loadFromDatabase();
00339 $this->setCookiePassword( $str );
00340 $this->mPassword = $this->encryptPassword( $str );
00341 $this->mNewpassword = '';
00342 }
00343
00344 function setCookiePassword( $str ) {
00345 $this->loadFromDatabase();
00346 $this->mCookiePassword = md5( $str );
00347 }
00348
00349 function setNewpassword( $str ) {
00350 $this->loadFromDatabase();
00351 $this->mNewpassword = $this->encryptPassword( $str );
00352 }
00353
00354 function getEmail() {
00355 $this->loadFromDatabase();
00356
return $this->mEmail;
00357 }
00358
00359 function setEmail( $str ) {
00360 $this->loadFromDatabase();
00361 $this->mEmail = $str;
00362 }
00363
00364 function getRealName() {
00365 $this->loadFromDatabase();
00366
return $this->mRealName;
00367 }
00368
00369 function setRealName( $str ) {
00370 $this->loadFromDatabase();
00371 $this->mRealName = $str;
00372 }
00373
00374 function getOption( $oname ) {
00375 $this->loadFromDatabase();
00376
if ( array_key_exists( $oname, $this->mOptions ) ) {
00377
return $this->mOptions[$oname];
00378 }
else {
00379
return '';
00380 }
00381 }
00382
00383 function setOption( $oname, $val ) {
00384 $this->loadFromDatabase();
00385
if ( $oname == 'skin' ) {
00386
# Clear cached skin, so the new one displays immediately in Special:Preferences
00387
unset( $this->mSkin );
00388 }
00389 $this->mOptions[$oname] = $val;
00390 $this->invalidateCache();
00391 }
00392
00393 function getRights() {
00394 $this->loadFromDatabase();
00395
return $this->mRights;
00396 }
00397
00398 function addRight( $rname ) {
00399 $this->loadFromDatabase();
00400 array_push( $this->mRights, $rname );
00401 $this->invalidateCache();
00402 }
00403
00404 function isSysop() {
00405 $this->loadFromDatabase();
00406
if ( 0 == $this->mId ) {
return false; }
00407
00408
return in_array( 'sysop', $this->mRights );
00409 }
00410
00411 function isDeveloper() {
00412 $this->loadFromDatabase();
00413
if ( 0 == $this->mId ) {
return false; }
00414
00415
return in_array( 'developer', $this->mRights );
00416 }
00417
00418 function isBureaucrat() {
00419 $this->loadFromDatabase();
00420
if ( 0 == $this->mId ) {
return false; }
00421
00422
return in_array( 'bureaucrat', $this->mRights );
00423 }
00424
00425 function isBot() {
00426 $this->loadFromDatabase();
00427
00428
# Why was this here? I need a UID=0 conversion script [TS]
00429
# if ( 0 == $this->mId ) { return false; }
00430
00431
return in_array( 'bot', $this->mRights );
00432 }
00433
00434 function &getSkin() {
00435
if ( ! isset( $this->mSkin ) ) {
00436
# get all skin names available from SkinNames.php
00437
$skinNames = Skin::getSkinNames();
00438
# get the user skin
00439
$userSkin = $this->getOption( 'skin' );
00440
if ( $userSkin == '' ) { $userSkin = 'standard'; }
00441
00442
if ( !isset( $skinNames[$userSkin] ) ) {
00443
# in case the user skin could not be found find a replacement
00444
$fallback = array(
00445 0 => '
SkinStandard',
00446 1 => '
SkinNostalgia',
00447 2 => '
SkinCologneBlue');
00448
# if phptal is enabled we should have monobook skin that superseed
00449
# the good old SkinStandard.
00450
if ( isset( $skinNames['monobook'] ) ) {
00451 $fallback[0] = 'SkinMonoBook';
00452 }
00453
00454
if(is_numeric($userSkin) && isset( $fallback[$userSkin]) ){
00455 $sn = $fallback[$userSkin];
00456 }
else {
00457 $sn = '
SkinStandard';
00458 }
00459 }
else {
00460
# The user skin is available
00461
$sn = 'Skin' . $skinNames[$userSkin];
00462 }
00463
00464
# only require the needed stuff
00465
switch($sn) {
00466
case 'SkinMonoBook':
00467 require_once( 'SkinPHPTal.php' );
00468
break;
00469
case '
SkinStandard':
00470 require_once( '
SkinStandard.php' );
00471
break;
00472
case '
SkinNostalgia':
00473 require_once( '
SkinNostalgia.php' );
00474
break;
00475
case '
SkinCologneBlue':
00476 require_once( '
SkinCologneBlue.php' );
00477
break;
00478 }
00479
# now we can create the skin object
00480
$this->mSkin =
new $sn;
00481 }
00482
return $this->mSkin;
00483 }
00484
00485 function isWatched( $title ) {
00486 $wl =
WatchedItem::fromUserTitle( $
this, $title );
00487
return $wl->isWatched();
00488 }
00489
00490 function addWatch( $title ) {
00491 $wl =
WatchedItem::fromUserTitle( $
this, $title );
00492 $wl->addWatch();
00493 $this->invalidateCache();
00494 }
00495
00496 function removeWatch( $title ) {
00497 $wl =
WatchedItem::fromUserTitle( $
this, $title );
00498 $wl->removeWatch();
00499 $this->invalidateCache();
00500 }
00501
00502
00503 function encodeOptions() {
00504 $a = array();
00505 foreach ( $this->mOptions as $oname => $oval ) {
00506 array_push( $a, $oname.
'='.$oval );
00507 }
00508
$s = implode(
"\n", $a );
00509
return wfStrencode( $s );
00510 }
00511
00512 function decodeOptions( $str ) {
00513 $a = explode(
"\n", $str );
00514 foreach ( $a as $s ) {
00515
if ( preg_match(
"/^(.[^=]*)=(.*)$/", $s, $m ) ) {
00516 $this->mOptions[$m[1]] = $m[2];
00517 }
00518 }
00519 }
00520
00521 function setCookies() {
00522 global
$wgCookieExpiration,
$wgCookiePath,
$wgCookieDomain,
$wgDBname;
00523
if ( 0 == $this->mId )
return;
00524 $this->loadFromDatabase();
00525 $exp = time() +
$wgCookieExpiration;
00526
00527 $_SESSION['wsUserID'] = $this->mId;
00528 setcookie( $wgDBname.'UserID', $this->mId, $exp, $wgCookiePath, $wgCookieDomain );
00529
00530 $_SESSION['wsUserName'] = $this->mName;
00531 setcookie( $wgDBname.'UserName', $this->mName, $exp, $wgCookiePath, $wgCookieDomain );
00532
00533 $_SESSION['wsUserPassword'] = $this->mPassword;
00534
if ( 1 == $this->getOption( 'rememberpassword' ) ) {
00535 setcookie( $wgDBname.'Password', $this->mCookiePassword, $exp, $wgCookiePath, $wgCookieDomain );
00536 }
else {
00537 setcookie( $wgDBname.'Password', '', time() - 3600 );
00538 }
00539 }
00540
00541 function logout() {
00542 global
$wgCookiePath,
$wgCookieDomain,
$wgDBname;
00543 $this->mId = 0;
00544
00545 $_SESSION['wsUserID'] = 0;
00546
00547 setcookie( $wgDBname.'UserID', '', time() - 3600, $wgCookiePath, $wgCookieDomain );
00548 setcookie( $wgDBname.'Password', '', time() - 3600, $wgCookiePath, $wgCookieDomain );
00549 }
00550
00551 function saveSettings() {
00552 global
$wgMemc,
$wgDBname;
00553
00554
if ( ! $this->mNewtalk ) {
00555
if( $this->mId ) {
00556
$sql=
"DELETE FROM user_newtalk WHERE user_id={$this->mId}";
00557
wfQuery ($sql, DB_WRITE,
"User::saveSettings");
00558 }
else {
00559
$sql=
"DELETE FROM user_newtalk WHERE user_ip='{$this->mName}'";
00560
wfQuery ($sql, DB_WRITE,
"User::saveSettings");
00561
$wgMemc->delete(
"$wgDBname:newtalk:ip:{$this->mName}" );
00562 }
00563 }
00564
if ( 0 == $this->mId ) {
return; }
00565
00566
$sql =
"UPDATE user SET " .
00567
"user_name= '" .
wfStrencode( $this->mName ) .
"', " .
00568
"user_password= '" .
wfStrencode( $this->mPassword ) .
"', " .
00569
"user_newpassword= '" .
wfStrencode( $this->mNewpassword ) .
"', " .
00570
"user_real_name= '" .
wfStrencode( $this->mRealName ) .
"', " .
00571
"user_email= '" .
wfStrencode( $this->mEmail ) .
"', " .
00572
"user_options= '" . $this->encodeOptions() .
"', " .
00573
"user_rights= '" .
wfStrencode( implode(
",", $this->mRights ) ) .
"', " .
00574
"user_touched= '" .
wfStrencode( $this->mTouched ) .
00575
"' WHERE user_id={$this->mId}";
00576
wfQuery( $sql, DB_WRITE,
"User::saveSettings" );
00577
$wgMemc->delete(
"$wgDBname:user:id:$this->mId" );
00578 }
00579
00580
# Checks if a user with the given name exists
00581
#
00582
function idForName() {
00583 $gotid = 0;
00584
$s = trim( $this->mName );
00585
if ( 0 == strcmp( '', $s ) )
return 0;
00586
00587
$sql =
"SELECT user_id FROM user WHERE user_name='" .
00588
wfStrencode( $s ) .
"'";
00589
$res =
wfQuery( $sql, DB_READ,
"User::idForName" );
00590
if ( 0 ==
wfNumRows( $res ) ) {
return 0; }
00591
00592
$s =
wfFetchObject( $res );
00593
if ( '' ==
$s )
return 0;
00594
00595 $gotid =
$s->user_id;
00596
wfFreeResult( $res );
00597
return $gotid;
00598 }
00599
00600 function addToDatabase() {
00601
$sql =
"INSERT INTO user (user_name,user_password,user_newpassword," .
00602
"user_email, user_real_name, user_rights, user_options) " .
00603
" VALUES ('" .
wfStrencode( $this->mName ) .
"', '" .
00604
wfStrencode( $this->mPassword ) .
"', '" .
00605
wfStrencode( $this->mNewpassword ) .
"', '" .
00606
wfStrencode( $this->mEmail ) .
"', '" .
00607
wfStrencode( $this->mRealName ) .
"', '" .
00608
wfStrencode( implode(
',', $this->mRights ) ) .
"', '" .
00609 $this->encodeOptions() .
"')";
00610
wfQuery( $sql, DB_WRITE,
"User::addToDatabase" );
00611 $this->mId = $this->idForName();
00612 }
00613
00614 function spreadBlock()
00615 {
00616 global
$wgIP;
00617
# If the (non-anonymous) user is blocked, this function will block any IP address
00618
# that they successfully log on from.
00619
$fname = 'User::spreadBlock';
00620
00621
wfDebug(
"User:spreadBlock()\n" );
00622
if ( $this->mId == 0 ) {
00623
return;
00624 }
00625
00626 $userblock =
Block::newFromDB( '', $this->mId );
00627
if ( !$userblock->isValid() ) {
00628
return;
00629 }
00630
00631
# Check if this IP address is already blocked
00632
$ipblock =
Block::newFromDB( $wgIP );
00633
if ( $ipblock->isValid() ) {
00634
# Just update the timestamp
00635
$ipblock->updateTimestamp();
00636
return;
00637 }
00638
00639
# Make a new block object with the desired properties
00640
wfDebug(
"Autoblocking {$this->mName}@{$wgIP}\n" );
00641 $ipblock->mAddress =
$wgIP;
00642 $ipblock->mUser = 0;
00643 $ipblock->mBy = $userblock->mBy;
00644 $ipblock->mReason =
wfMsg( 'autoblocker', $this->getName(), $userblock->mReason );
00645 $ipblock->mTimestamp =
wfTimestampNow();
00646 $ipblock->mAuto = 1;
00647
# If the user is already blocked with an expiry date, we don't
00648
# want to pile on top of that!
00649
if($userblock->mExpiry) {
00650 $ipblock->mExpiry = min ( $userblock->mExpiry, Block::getAutoblockExpiry( $ipblock->mTimestamp ));
00651 }
else {
00652 $ipblock->mExpiry =
Block::getAutoblockExpiry( $ipblock->mTimestamp );
00653 }
00654
00655
# Insert it
00656
$ipblock->insert();
00657
00658 }
00659
00660 function getPageRenderingHash(){
00661
static $hash =
false;
00662
if( $hash ){
00663
return $hash;
00664 }
00665
00666
00667
00668
00669 $confstr = $this->getOption( 'quickbar' );
00670 $confstr .=
'!' . $this->getOption( 'underline' );
00671 $confstr .=
'!' . $this->getOption( 'hover' );
00672 $confstr .=
'!' . $this->getOption( 'skin' );
00673 $confstr .=
'!' . $this->getOption( 'math' );
00674 $confstr .=
'!' . $this->getOption( 'highlightbroken' );
00675 $confstr .=
'!' . $this->getOption( 'stubthreshold' );
00676 $confstr .=
'!' . $this->getOption( 'editsection' );
00677 $confstr .=
'!' . $this->getOption( 'editsectiononrightclick' );
00678 $confstr .=
'!' . $this->getOption( 'showtoc' );
00679 $confstr .=
'!' . $this->getOption( 'date' );
00680
00681
if(strlen($confstr) > 32)
00682 $hash = md5($confstr);
00683
else
00684 $hash = $confstr;
00685
return $hash;
00686 }
00687
00688 function isAllowedToCreateAccount() {
00689 global
$wgWhitelistAccount;
00690 $allowed =
false;
00691
00692
if (!
$wgWhitelistAccount) {
return 1; };
00693 foreach ($wgWhitelistAccount as $right => $ok) {
00694 $userHasRight = (!strcmp($right, 'user') || in_array($right, $this->getRights()));
00695 $allowed |= ($ok && $userHasRight);
00696 }
00697
return $allowed;
00698 }
00699
00700
# Set mDataLoaded, return previous value
00701
# Use this to prevent DB access in command-line scripts or similar situations
00702
function setLoaded( $loaded )
00703 {
00704
wfSetVar( $this->mDataLoaded, $loaded );
00705 }
00706
00707 function getUserPage() {
00708
return Title::makeTitle( NS_USER, $this->mName );
00709 }
00710 }
00711
00712 ?>