Index: branches/stable/phase3/wiki.phtml |
— | — | @@ -3,13 +3,6 @@ |
4 | 4 | # |
5 | 5 | $wgRequestTime = microtime(); |
6 | 6 | |
7 | | -session_cache_limiter( "private, must-revalidate" ); |
8 | | -session_start(); |
9 | | -session_register( "wsUserID" ); |
10 | | -session_register( "wsUserName" ); |
11 | | -session_register( "wsUserPassword" ); |
12 | | -session_register( "wsUploadFiles" ); |
13 | | - |
14 | 7 | global $IP; |
15 | 8 | include_once( "./LocalSettings.php" ); |
16 | 9 | include_once( "$IP/Setup.php" ); |
Index: branches/stable/phase3/includes/User.php |
— | — | @@ -446,20 +446,20 @@ |
447 | 447 | function setCookies() |
448 | 448 | { |
449 | 449 | global $wsUserID, $wsUserName, $wsUserPassword; |
450 | | - global $wgCookieExpiration; |
| 450 | + global $wgCookieExpiration, $wgCookiePath, $wgCookieDomain; |
451 | 451 | if ( 0 == $this->mId ) return; |
452 | 452 | $this->loadFromDatabase(); |
453 | 453 | $exp = time() + $wgCookieExpiration; |
454 | 454 | |
455 | 455 | $wsUserID = $this->mId; |
456 | | - setcookie( "wcUserID", $this->mId, $exp, "/" ); |
| 456 | + setcookie( "wcUserID", $this->mId, $exp, $wgCookiePath, $wgCookieDomain ); |
457 | 457 | |
458 | 458 | $wsUserName = $this->mName; |
459 | | - setcookie( "wcUserName", $this->mName, $exp, "/" ); |
| 459 | + setcookie( "wcUserName", $this->mName, $exp, $wgCookiePath, $wgCookieDomain ); |
460 | 460 | |
461 | 461 | $wsUserPassword = $this->mPassword; |
462 | 462 | if ( 1 == $this->getOption( "rememberpassword" ) ) { |
463 | | - setcookie( "wcUserPassword", $this->mCookiePassword, $exp, "/" ); |
| 463 | + setcookie( "wcUserPassword", $this->mCookiePassword, $exp, $wgCookiePath, $wgCookieDomain ); |
464 | 464 | } else { |
465 | 465 | setcookie( "wcUserPassword", "", time() - 3600 ); |
466 | 466 | } |
— | — | @@ -467,13 +467,13 @@ |
468 | 468 | |
469 | 469 | function logout() |
470 | 470 | { |
471 | | - global $wsUserID; |
| 471 | + global $wsUserID, $wgCookiePath, $wgCookieDomain; |
472 | 472 | $this->mId = 0; |
473 | 473 | |
474 | 474 | $wsUserID = 0; |
475 | 475 | |
476 | | - setcookie( "wcUserID", "", time() - 3600 ); |
477 | | - setcookie( "wcUserPassword", "", time() - 3600 ); |
| 476 | + setcookie( "wcUserID", "", time() - 3600, $wgCookiePath, $wgCookieDomain ); |
| 477 | + setcookie( "wcUserPassword", "", time() - 3600, $wgCookiePath, $wgCookieDomain ); |
478 | 478 | } |
479 | 479 | |
480 | 480 | function saveSettings() |
Index: branches/stable/phase3/includes/DefaultSettings.php |
— | — | @@ -43,6 +43,7 @@ |
44 | 44 | $wgUseMemCached = false; |
45 | 45 | $wgMemCachedServers = array( "127.0.0.1:11000" ); |
46 | 46 | $wgMemCachedDebug = false; |
| 47 | +$wgSessionsInMemcached = false; |
47 | 48 | |
48 | 49 | # Language settings |
49 | 50 | # |
— | — | @@ -94,6 +95,11 @@ |
95 | 96 | |
96 | 97 | $wgCookieExpiration = 2592000; |
97 | 98 | |
| 99 | +# Set to set an explicit domain on the login cookies |
| 100 | +# eg, "justthis.domain.org" or ".any.subdomain.net" |
| 101 | +$wgCookieDomain = ""; |
| 102 | +$wgCookiePath = "/"; |
| 103 | + |
98 | 104 | $wgAllowExternalImages = true; |
99 | 105 | $wgMiserMode = false; # Disable database-intensive features |
100 | 106 | $wgUseTeX = false; |
Index: branches/stable/phase3/includes/SpecialUserlogin.php |
— | — | @@ -103,7 +103,8 @@ |
104 | 104 | /* private */ function mailPassword() |
105 | 105 | { |
106 | 106 | global $wgUser, $wpName, $wgDeferredUpdateList, $wgOutputEncoding; |
107 | | - |
| 107 | + global $wgCookiePath, $wgCookieDomain; |
| 108 | + |
108 | 109 | if ( "" == $wpName ) { |
109 | 110 | mainLoginForm( wfMsg( "noname" ) ); |
110 | 111 | return; |
— | — | @@ -126,7 +127,7 @@ |
127 | 128 | $np = User::randomPassword(); |
128 | 129 | $u->setNewpassword( $np ); |
129 | 130 | |
130 | | - setcookie( "wcUserPassword", "", time() - 3600 ); |
| 131 | + setcookie( "wcUserPassword", "", time() - 3600, $wgCookiePath, $wgCookieDomain ); |
131 | 132 | $u->saveSettings(); |
132 | 133 | |
133 | 134 | $ip = getenv( "REMOTE_ADDR" ); |
Index: branches/stable/phase3/includes/Setup.php |
— | — | @@ -45,6 +45,17 @@ |
46 | 46 | } |
47 | 47 | $wgLang = new $wgLangClass(); |
48 | 48 | |
| 49 | +if( $wgSessionsInMemcached ) { |
| 50 | + include_once( "$IP/MemcachedSessions.php" ); |
| 51 | +} |
| 52 | +session_set_cookie_params( 3600, $wgCookiePath, $wgCookieDomain ); |
| 53 | +session_cache_limiter( "private, must-revalidate" ); |
| 54 | +session_start(); |
| 55 | +session_register( "wsUserID" ); |
| 56 | +session_register( "wsUserName" ); |
| 57 | +session_register( "wsUserPassword" ); |
| 58 | +session_register( "wsUploadFiles" ); |
| 59 | + |
49 | 60 | $wgUser = User::loadFromSession(); |
50 | 61 | $wgDeferredUpdateList = array(); |
51 | 62 | $wgLinkCache = new LinkCache(); |
Index: branches/stable/phase3/includes/MemcachedSessions.php |
— | — | @@ -0,0 +1,54 @@ |
| 2 | +<? |
| 3 | + |
| 4 | +/* |
| 5 | + This file gets included if $wgSessionsInMemcache is set in the config. |
| 6 | + It redirects session handling functions to store their data in memcached |
| 7 | + instead of the local filesystem. Depending on circumstances, it may also |
| 8 | + be necessary to change the cookie settings to work across hostnames. |
| 9 | + |
| 10 | + See: http://www.php.net/manual/en/function.session-set-save-handler.php |
| 11 | +*/ |
| 12 | + |
| 13 | + |
| 14 | +function memsess_key( $id ) { |
| 15 | + global $wgDBname; |
| 16 | + return "$wgDBname:session:$id"; |
| 17 | +} |
| 18 | + |
| 19 | +function memsess_open( $save_path, $session_name ) { |
| 20 | + # NOP, $wgMemc should be set up already |
| 21 | + return true; |
| 22 | +} |
| 23 | + |
| 24 | +function memsess_close() { |
| 25 | + # NOP |
| 26 | + return true; |
| 27 | +} |
| 28 | + |
| 29 | +function memsess_read( $id ) { |
| 30 | + global $wgMemc; |
| 31 | + $data = $wgMemc->get( memsess_key( $id ) ); |
| 32 | + if( $data === FALSE ) return ""; |
| 33 | + return $data; |
| 34 | +} |
| 35 | + |
| 36 | +function memsess_write( $id, $data ) { |
| 37 | + global $wgMemc; |
| 38 | + $wgMemc->set( memsess_key( $id ), $data, 3600 ); |
| 39 | + return true; |
| 40 | +} |
| 41 | + |
| 42 | +function memsess_destroy( $id ) { |
| 43 | + global $wgMemc; |
| 44 | + $wgMemc->delete( memsess_key( $id ) ); |
| 45 | + return true; |
| 46 | +} |
| 47 | + |
| 48 | +function memsess_gc( $maxlifetime ) { |
| 49 | + # NOP: Memcached performs garbage collection. |
| 50 | + return true; |
| 51 | +} |
| 52 | + |
| 53 | +session_set_save_handler( "memsess_open", "memsess_close", "memsess_read", "memsess_write", "memsess_destroy", "memsess_gc" ); |
| 54 | + |
| 55 | +?> |
Property changes on: branches/stable/phase3/includes/MemcachedSessions.php |
___________________________________________________________________ |
Name: svn:eol-style |
1 | 56 | + native |
Name: svn:keywords |
2 | 57 | + Author Date Id Revision |