forked from GNUsocial/gnu-social
use the session class to store sessions
This commit is contained in:
parent
0ca22cf6e2
commit
71dad1ff62
10
README
10
README
@ -1278,6 +1278,16 @@ type: type of search. Ignored if PostgreSQL or Sphinx are enabled. Can either
|
|||||||
systems. We'll probably add another type sometime in the future,
|
systems. We'll probably add another type sometime in the future,
|
||||||
with our own indexing system (maybe like MediaWiki's).
|
with our own indexing system (maybe like MediaWiki's).
|
||||||
|
|
||||||
|
sessions
|
||||||
|
--------
|
||||||
|
|
||||||
|
Session handling.
|
||||||
|
|
||||||
|
handle: boolean. Whether we should register our own PHP session-handling
|
||||||
|
code (using the database and memcache if enabled). Defaults to false.
|
||||||
|
Setting this to true makes some sense on large or multi-server
|
||||||
|
sites, but it probably won't hurt for smaller ones, either.
|
||||||
|
|
||||||
Troubleshooting
|
Troubleshooting
|
||||||
===============
|
===============
|
||||||
|
|
||||||
|
46
index.php
46
index.php
@ -73,6 +73,38 @@ function handleError($error)
|
|||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function checkMirror($action_obj)
|
||||||
|
{
|
||||||
|
global $config;
|
||||||
|
|
||||||
|
static $alwaysRW = array('session', 'remember_me');
|
||||||
|
|
||||||
|
if (common_config('db', 'mirror') && $action_obj->isReadOnly($args)) {
|
||||||
|
if (is_array(common_config('db', 'mirror'))) {
|
||||||
|
// "load balancing", ha ha
|
||||||
|
$arr = common_config('db', 'mirror');
|
||||||
|
$k = array_rand($arr);
|
||||||
|
$mirror = $arr[$k];
|
||||||
|
} else {
|
||||||
|
$mirror = common_config('db', 'mirror');
|
||||||
|
}
|
||||||
|
|
||||||
|
// We ensure that these tables always are used
|
||||||
|
// on the master DB
|
||||||
|
|
||||||
|
$config['db']['database_rw'] = $config['db']['database'];
|
||||||
|
$config['db']['ini_rw'] = INSTALLDIR.'/classes/laconica.ini';
|
||||||
|
|
||||||
|
foreach ($alwaysRW as $table) {
|
||||||
|
$config['db']['table_'.$table] = 'rw';
|
||||||
|
}
|
||||||
|
|
||||||
|
// everyone else uses the mirror
|
||||||
|
|
||||||
|
$config['db']['database'] = $mirror;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function main()
|
function main()
|
||||||
{
|
{
|
||||||
// quick check for fancy URL auto-detection support in installer.
|
// quick check for fancy URL auto-detection support in installer.
|
||||||
@ -146,19 +178,7 @@ function main()
|
|||||||
} else {
|
} else {
|
||||||
$action_obj = new $action_class();
|
$action_obj = new $action_class();
|
||||||
|
|
||||||
// XXX: find somewhere for this little block to live
|
checkMirror($action_obj);
|
||||||
|
|
||||||
if (common_config('db', 'mirror') && $action_obj->isReadOnly($args)) {
|
|
||||||
if (is_array(common_config('db', 'mirror'))) {
|
|
||||||
// "load balancing", ha ha
|
|
||||||
$arr = common_config('db', 'mirror');
|
|
||||||
$k = array_rand($arr);
|
|
||||||
$mirror = $arr[$k];
|
|
||||||
} else {
|
|
||||||
$mirror = common_config('db', 'mirror');
|
|
||||||
}
|
|
||||||
$config['db']['database'] = $mirror;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if ($action_obj->prepare($args)) {
|
if ($action_obj->prepare($args)) {
|
||||||
|
@ -254,6 +254,8 @@ $config =
|
|||||||
'oohembed' => array('endpoint' => 'http://oohembed.com/oohembed/'),
|
'oohembed' => array('endpoint' => 'http://oohembed.com/oohembed/'),
|
||||||
'search' =>
|
'search' =>
|
||||||
array('type' => 'fulltext'),
|
array('type' => 'fulltext'),
|
||||||
|
'sessions' =>
|
||||||
|
array('handle' => false), // whether to handle sessions ourselves
|
||||||
);
|
);
|
||||||
|
|
||||||
$config['db'] = &PEAR::getStaticProperty('DB_DataObject','options');
|
$config['db'] = &PEAR::getStaticProperty('DB_DataObject','options');
|
||||||
|
@ -144,6 +144,9 @@ function common_ensure_session()
|
|||||||
$c = $_COOKIE[session_name()];
|
$c = $_COOKIE[session_name()];
|
||||||
}
|
}
|
||||||
if (!common_have_session()) {
|
if (!common_have_session()) {
|
||||||
|
if (common_config('sessions', 'handle')) {
|
||||||
|
Session::setSaveHandler();
|
||||||
|
}
|
||||||
@session_start();
|
@session_start();
|
||||||
if (!isset($_SESSION['started'])) {
|
if (!isset($_SESSION['started'])) {
|
||||||
$_SESSION['started'] = time();
|
$_SESSION['started'] = time();
|
||||||
|
Loading…
Reference in New Issue
Block a user