Trying to get a speed increase out of the cache.

This commit is contained in:
skeeter 2002-01-13 04:06:40 +00:00
parent 3f95bef544
commit 25c4b80150
3 changed files with 60 additions and 44 deletions

View File

@ -163,7 +163,13 @@
$GLOBALS['phpgw_info']['user']['account_id'] = $this->account_id;
/* init the crypto object before appsession call below */
$this->key = md5($this->kp3 . $this->sessionid . $GLOBALS['phpgw_info']['server']['encryptkey']);
$this->iv = $GLOBALS['phpgw_info']['server']['mcrypt_iv'];
$GLOBALS['phpgw']->crypto->init(array($this->key,$this->iv));
$this->read_repositories(@$GLOBALS['phpgw_info']['server']['cache_phpgw_info']);
if ($this->user['expires'] != -1 && $this->user['expires'] < time())
{
if(is_object($GLOBALS['phpgw']->log))
@ -176,14 +182,14 @@
));
$GLOBALS['phpgw']->log->commit();
}
if(is_object($GLOBALS['phpgw']->crypto))
{
$GLOBALS['phpgw']->crypto->cleanup();
unset($GLOBALS['phpgw']->crypto);
}
return False;
}
/* init the crypto object before appsession call below */
$this->key = md5($this->kp3 . $this->sessionid . $GLOBALS['phpgw_info']['server']['encryptkey']);
$this->iv = $GLOBALS['phpgw_info']['server']['mcrypt_iv'];
$GLOBALS['phpgw']->crypto->init(array($this->key,$this->iv));
$GLOBALS['phpgw_info']['user'] = $this->user;
$GLOBALS['phpgw_info']['hooks'] = $this->hooks;
@ -203,7 +209,6 @@
));
$GLOBALS['phpgw']->log->commit();
}
if(is_object($GLOBALS['phpgw']->crypto))
{
$GLOBALS['phpgw']->crypto->cleanup();
@ -228,7 +233,6 @@
));
$GLOBALS['phpgw']->log->commit();
}
if(is_object($GLOBALS['phpgw']->crypto))
{
$GLOBALS['phpgw']->crypto->cleanup();
@ -255,12 +259,12 @@
));
$GLOBALS['phpgw']->log->commit();
}
if(is_object($GLOBALS['phpgw']->crypto))
{
$GLOBALS['phpgw']->crypto->cleanup();
unset($GLOBALS['phpgw']->crypto);
}
echo 'DEBUG: Sessions: account_id is empty!<br>'."\n";
return False;
}
else
@ -355,6 +359,11 @@
unset($GLOBALS['phpgw_info']['server']['default_domain']); /* we kill this for security reasons */
}
/* init the crypto object */
$this->key = md5($this->kp3 . $this->sessionid . $GLOBALS['phpgw_info']['server']['encryptkey']);
$this->iv = $GLOBALS['phpgw_info']['server']['mcrypt_iv'];
$GLOBALS['phpgw']->crypto->init(array($this->key,$this->iv));
$this->read_repositories(False);
if ($this->user['expires'] != -1 && $this->user['expires'] < time())
{
@ -372,11 +381,6 @@
return False;
}
/* init the crypto object */
$this->key = md5($this->kp3 . $this->sessionid . $GLOBALS['phpgw_info']['server']['encryptkey']);
$this->iv = $GLOBALS['phpgw_info']['server']['mcrypt_iv'];
$GLOBALS['phpgw']->crypto->init(array($this->key,$this->iv));
$GLOBALS['phpgw_info']['user'] = $this->user;
$GLOBALS['phpgw_info']['hooks'] = $this->hooks;
@ -666,7 +670,7 @@
/*************************************************************************\
* Functions for appsession data and session cache *
\*************************************************************************/
function read_repositories($cached='')
function read_repositories($cached='',$write_cache=True)
{
$GLOBALS['phpgw']->acl->acl($this->account_id);
$GLOBALS['phpgw']->accounts->accounts($this->account_id);
@ -686,17 +690,17 @@
}
else
{
$this->setup_cache();
$this->setup_cache($write_cache);
}
}
else
{
$this->setup_cache();
$this->setup_cache($write_cache);
}
$this->hooks = $GLOBALS['phpgw']->hooks->read();
}
function setup_cache()
function setup_cache($write_cache=True)
{
$this->user = $GLOBALS['phpgw']->accounts->read_repository();
$this->user['acl'] = $GLOBALS['phpgw']->acl->read_repository();
@ -713,8 +717,9 @@
$this->user['account_lid'] = $this->account_lid;
$this->user['userid'] = $this->account_lid;
$this->user['passwd'] = @$this->passwd;
if(@$GLOBALS['phpgw_info']['server']['cache_phpgw_info'])
if(@$GLOBALS['phpgw_info']['server']['cache_phpgw_info'] && $write_cache)
{
$this->delete_cache();
$this->appsession('phpgw_info_cache','phpgwapi',$this->user);
}
}
@ -728,7 +733,12 @@
$GLOBALS['phpgw']->db->query($query);
}
// This looks to be useless
// This will capture everything in the $GLOBALS['phpgw_info'] including server info,
// and store it in appsessions. This is really incompatible with any type of restoring
// from appsession as the saved user info is really in ['user'] rather than the root of
// the structure, which is what this class likes.
function save_repositories()
{
$phpgw_info_temp = $GLOBALS['phpgw_info'];
@ -771,7 +781,7 @@
if($data)
{
$data = $GLOBALS['phpgw']->crypto->decrypt($data);
//echo 'appsession returning: '; _debug_array($data);
// echo 'appsession returning: '; _debug_array($data);
return $data;
}
}

View File

@ -157,6 +157,11 @@
$GLOBALS['phpgw_info']['user']['account_id'] = $this->account_id;
/* init the crypto object before appsession call below */
$this->key = md5($this->kp3 . $this->sessionid . $GLOBALS['phpgw_info']['server']['encryptkey']);
$this->iv = $GLOBALS['phpgw_info']['server']['mcrypt_iv'];
$GLOBALS['phpgw']->crypto->init(array($this->key,$this->iv));
$this->read_repositories(@$GLOBALS['phpgw_info']['server']['cache_phpgw_info']);
if ($this->user['expires'] != -1 && $this->user['expires'] < time())
{
@ -170,14 +175,14 @@
));
$GLOBALS['phpgw']->log->commit();
}
if(is_object($GLOBALS['phpgw']->crypto))
{
$GLOBALS['phpgw']->crypto->cleanup();
unset($GLOBALS['phpgw']->crypto);
}
return False;
}
/* init the crypto object before appsession call below */
$this->key = md5($this->kp3 . $this->sessionid . $GLOBALS['phpgw_info']['server']['encryptkey']);
$this->iv = $GLOBALS['phpgw_info']['server']['mcrypt_iv'];
$GLOBALS['phpgw']->crypto->init(array($this->key,$this->iv));
$GLOBALS['phpgw_info']['user'] = $this->user;
$GLOBALS['phpgw_info']['hooks'] = $this->hooks;
@ -197,7 +202,6 @@
));
$GLOBALS['phpgw']->log->commit();
}
if(is_object($GLOBALS['phpgw']->crypto))
{
$GLOBALS['phpgw']->crypto->cleanup();
@ -222,7 +226,6 @@
));
$GLOBALS['phpgw']->log->commit();
}
if(is_object($GLOBALS['phpgw']->crypto))
{
$GLOBALS['phpgw']->crypto->cleanup();
@ -249,7 +252,6 @@
));
$GLOBALS['phpgw']->log->commit();
}
if(is_object($GLOBALS['phpgw']->crypto))
{
$GLOBALS['phpgw']->crypto->cleanup();
@ -660,7 +662,7 @@
/*************************************************************************\
* Functions for appsession data and session cache *
\*************************************************************************/
function read_repositories($cached='')
function read_repositories($cached='',$write_cache=True)
{
$GLOBALS['phpgw']->acl->acl($this->account_id);
$GLOBALS['phpgw']->accounts->accounts($this->account_id);
@ -690,7 +692,7 @@
$this->hooks = $GLOBALS['phpgw']->hooks->read();
}
function setup_cache()
function setup_cache($write_cache=True)
{
$this->user = $GLOBALS['phpgw']->accounts->read_repository();
$this->user['acl'] = $GLOBALS['phpgw']->acl->read_repository();
@ -707,8 +709,9 @@
$this->user['account_lid'] = $this->account_lid;
$this->user['userid'] = $this->account_lid;
$this->user['passwd'] = @$this->passwd;
if(@$GLOBALS['phpgw_info']['server']['cache_phpgw_info'])
if(@$GLOBALS['phpgw_info']['server']['cache_phpgw_info'] && $write_cache)
{
$this->delete_cache();
$this->appsession('phpgw_info_cache','phpgwapi',$this->user);
}
}
@ -722,7 +725,12 @@
session_register('phpgw_session');
$GLOBALS['HTTP_SESSION_VARS']['phpgw_session'] = $GLOBALS['phpgw_session'];
}
// This looks to be useless
// This will capture everything in the $GLOBALS['phpgw_info'] including server info,
// and store it in appsessions. This is really incompatible with any type of restoring
// from appsession as the saved user info is really in ['user'] rather than the root of
// the structure, which is what this class likes.
function save_repositories()
{
$phpgw_info_temp = $GLOBALS['phpgw_info'];

View File

@ -650,28 +650,26 @@
$GLOBALS['phpgw_info']['server'][$GLOBALS['phpgw']->db->f('config_name')] = stripslashes($GLOBALS['phpgw']->db->f('config_value'));
}
if(@isset($GLOBALS['phpgw_info']['server']['enforce_ssl']) && !$HTTPS)
{
Header('Location: https://' . $GLOBALS['phpgw_info']['server']['hostname'] . $GLOBALS['phpgw_info']['server']['webserver_url'] . $REQUEST_URI);
}
if(@isset($GLOBALS['phpgw_info']['server']['cache_phpgw_info']))
{
if($server_info_cache)
{
$cache_query = "UPDATE phpgw_app_sessions set content='".addslashes(serialize($GLOBALS['phpgw_info']['server']))."'"
." WHERE sessionid = '0' and loginid = '0' and app = 'phpgwapi' and location = 'config'";
}
else
{
$cache_query = 'INSERT INTO phpgw_app_sessions(sessionid,loginid,app,location,content) VALUES('
. "'0','0','phpgwapi','config','".addslashes(serialize($GLOBALS['phpgw_info']['server']))."')";
$cache_query = "DELETE FROM phpgw_app_sessions WHERE sessionid='0' and loginid='0' and app='phpgwapi' and location='config'";
$GLOBALS['phpgw']->db->query($cache_query,__LINE__,__FILE__);
}
$cache_query = 'INSERT INTO phpgw_app_sessions(sessionid,loginid,app,location,content) VALUES('
. "'0','0','phpgwapi','config','".addslashes(serialize($GLOBALS['phpgw_info']['server']))."')";
$GLOBALS['phpgw']->db->query($cache_query,__LINE__,__FILE__);
}
}
unset($cache_query);
unset($server_info_cache);
if(@isset($GLOBALS['phpgw_info']['server']['enforce_ssl']) && !$HTTPS)
{
Header('Location: https://' . $GLOBALS['phpgw_info']['server']['hostname'] . $GLOBALS['phpgw_info']['server']['webserver_url'] . $REQUEST_URI);
exit;
}
/************************************************************************\
* Required classes *
\************************************************************************/