Bug fix: correct problem with mutual logins for several installations on the same host
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@114 b3834d28-1941-0410-a4f8-b48e95affb8f
This commit is contained in:
parent
09cbb64c82
commit
74fb49098e
3 changed files with 20 additions and 2 deletions
14
constants.inc.php
Normal file
14
constants.inc.php
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
// Error codes
|
||||||
|
define('GENERAL_MESSAGE', 200);
|
||||||
|
define('GENERAL_ERROR', 202);
|
||||||
|
define('CRITICAL_MESSAGE', 203);
|
||||||
|
define('CRITICAL_ERROR', 204);
|
||||||
|
|
||||||
|
// Miscellanous
|
||||||
|
|
||||||
|
# INSTALLATION_ID is based on directory path and used as prefix (in session and cookie) to prevent mutual login for different installations on the same host server
|
||||||
|
define('INSTALLATION_ID', md5(dirname(realpath('.'))));
|
||||||
|
|
||||||
|
?>
|
|
@ -9,6 +9,7 @@ session_start();
|
||||||
|
|
||||||
require_once(dirname(__FILE__) .'/services/servicefactory.php');
|
require_once(dirname(__FILE__) .'/services/servicefactory.php');
|
||||||
require_once(dirname(__FILE__) .'/config.inc.php');
|
require_once(dirname(__FILE__) .'/config.inc.php');
|
||||||
|
require_once(dirname(__FILE__) .'/constants.inc.php');
|
||||||
require_once(dirname(__FILE__) .'/functions.inc.php');
|
require_once(dirname(__FILE__) .'/functions.inc.php');
|
||||||
|
|
||||||
// Determine the base URL
|
// Determine the base URL
|
||||||
|
|
|
@ -23,8 +23,8 @@ class UserService {
|
||||||
function UserService(& $db) {
|
function UserService(& $db) {
|
||||||
$this->db =& $db;
|
$this->db =& $db;
|
||||||
$this->tablename = $GLOBALS['tableprefix'] .'users';
|
$this->tablename = $GLOBALS['tableprefix'] .'users';
|
||||||
$this->sessionkey = $GLOBALS['cookieprefix'] .'-currentuserid';
|
$this->sessionkey = $GLOBALS['cookieprefix'].INSTALLATION_ID.'-currentuserid';
|
||||||
$this->cookiekey = $GLOBALS['cookieprefix'] .'-login';
|
$this->cookiekey = $GLOBALS['cookieprefix'].INSTALLATION_ID.'-login';
|
||||||
$this->profileurl = createURL('profile', '%2$s');
|
$this->profileurl = createURL('profile', '%2$s');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,8 +145,11 @@ class UserService {
|
||||||
|
|
||||||
function getCurrentUserId() {
|
function getCurrentUserId() {
|
||||||
if (isset($_SESSION[$this->getSessionKey()])) {
|
if (isset($_SESSION[$this->getSessionKey()])) {
|
||||||
|
//echo "session";die($_SESSION[$this->getSessionKey()]);
|
||||||
return $_SESSION[$this->getSessionKey()];
|
return $_SESSION[$this->getSessionKey()];
|
||||||
} else if (isset($_COOKIE[$this->getCookieKey()])) {
|
} else if (isset($_COOKIE[$this->getCookieKey()])) {
|
||||||
|
//echo "cookie";die();
|
||||||
|
|
||||||
$cook = split(':', $_COOKIE[$this->getCookieKey()]);
|
$cook = split(':', $_COOKIE[$this->getCookieKey()]);
|
||||||
//cookie looks like this: 'id:md5(username+password)'
|
//cookie looks like this: 'id:md5(username+password)'
|
||||||
$query = 'SELECT * FROM '. $this->getTableName() .
|
$query = 'SELECT * FROM '. $this->getTableName() .
|
||||||
|
|
Loading…
Reference in a new issue