[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] api/sessions/class.sessions_php.php, 1.1.1.1.2.11
From: |
nomail |
Subject: |
[Phpgroupware-cvs] api/sessions/class.sessions_php.php, 1.1.1.1.2.11 |
Date: |
Thu, 20 May 2004 16:08:28 -0000 |
Update of /api/sessions
Modified Files:
Branch: proposal-branch
class.sessions_php.php
date: 2004/04/16 20:59:49; author: seek3r; state: Exp; lines: +74 -90
Log Message:
bringing savannah cvs back up to date with what we were doing on our private
cvs server. We will not be doing dev from this cvs tree
=====================================================================
No syntax errors detected in -
=====================================================================
Index: api/sessions/class.sessions_php.php
diff -u api/sessions/class.sessions_php.php:1.1.1.1.2.10
api/sessions/class.sessions_php.php:1.1.1.1.2.11
--- api/sessions/class.sessions_php.php:1.1.1.1.2.10 Tue Feb 24 10:51:02 2004
+++ api/sessions/class.sessions_php.php Fri Apr 16 20:59:49 2004
@@ -36,9 +36,9 @@
function api_sessions()
{
-
if(!empty($GLOBALS['phpgw_data']['server']['session_method']))
+
if(!empty($_SESSION['phpgw_data']['server']['session_method']))
{
- $this->method =
$GLOBALS['phpgw_data']['server']['session_method'];
+ $this->method =
$_SESSION['phpgw_data']['server']['session_method'];
}
else
{
@@ -50,7 +50,7 @@
session_start();
if(function_exists('session_regenerate_id'))
{
- session_regenerate_id();
+ //session_regenerate_id();
}
$this->sid = 'cookie';
}
@@ -71,27 +71,32 @@
session_start();
}
- if
(!empty($GLOBALS['phpgw_data']['server']['base_url']))
+ if (!empty($GLOBALS['phpgw_data']['server']['baseurl']))
{
- $this->baseurl =
$GLOBALS['phpgw_data']['server']['base_url'].'/index.php?sid='.$this->sid;
- $this->basepath =
$GLOBALS['phpgw_data']['server']['base_url'];
+ $this->basepath =
$GLOBALS['phpgw_data']['server']['baseurl'];
+ $this->baseurl =
$this->basepath.'/index.php?sid='.$this->sid;
+ }
+ elseif
(!empty($_SESSION['phpgw_data']['server']['baseurl']))
+ {
+ $this->basepath =
$_SESSION['phpgw_data']['server']['basepath'];
+ $this->baseurl =
$this->basepath.'/index.php?sid='.$this->sid;
}
else
- {
+ {
//$this->baseurl =
$GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'].'?sid='.$this->sid;
- $this->baseurl = 'index.php?sid='.$this->sid;
- $this->basepath = '';
+ $this->basepath = dirname($_SERVER['PHP_SELF']);
+ $this->baseurl =
$this->basepath.'/index.php?sid='.$this->sid;
}
$this->__read_data();
- if(!isset($GLOBALS['phpgw_session']['session_lid']))
+ if(!isset($_SESSION['phpgw_session']['session_lid']))
{
$this->create();
- $this->new_session = True;
+ $this->new_session = true;
}
else
{
- $this->new_session = False;
+ $this->new_session = false;
}
}
@@ -106,17 +111,16 @@
{
$args = new safe_args();
$args->set('login', 'anonymous');
- $args = $args->get(func_get_args(),__LINE__,__FILE__);
+ $args = $args->get(func_get_args());
- $GLOBALS['phpgw_session']['session_lid'] =
$args['login'];
- $GLOBALS['phpgw_session']['ip_address'] = get_ip();
- $GLOBALS['phpgw_session']['login_time'] = time();
+ $_SESSION['phpgw_session']['session_lid'] =
$args['login'];
+ $_SESSION['phpgw_session']['ip_address'] = get_ip();
+ $_SESSION['phpgw_session']['login_time'] = time();
}
function destroy()
{
- $GLOBALS['phpgw_session'] = array();
- $this->save_data();
+ $_SESSION['phpgw_session'] = array();
$this->create();
}
@@ -132,15 +136,9 @@
function __read_data()
{
- session_register('phpgw_session');
- $GLOBALS['phpgw_session'] =
$_SESSION['phpgw_session'];
+ // session_register('phpgw_session');
// Set this BEFORE preferences are loaded and timezone
specific crap is set
- $GLOBALS['phpgw_session']['session_dla'] = time();
- }
-
- function save_data()
- {
- $_SESSION['phpgw_session'] = $GLOBALS['phpgw_session'];
+ $_SESSION['phpgw_session']['session_dla'] = time();
}
function sid()
@@ -150,43 +148,37 @@
function is_anon()
{
- if($GLOBALS['phpgw_session']['session_lid'] ==
'anonymous')
- {
- return True;
- }
- else
- {
- return False;
- }
+ return $_SESSION['phpgw_session']['session_lid'] ==
'anonymous';
}
// This is ONLY intended for deleting OTHER user sessions, do
not use it otherwise
function delete()
{
$args = new safe_args();
- $args->set('sessionid','##REQUIRED##','string');
- $args = $args->get(func_get_args(),__LINE__,__FILE__);
+ $args->set('sessionid',REQUIRED,'string');
+ $args = $args->get(func_get_args());
return unlink(get_cfg_var('session.save_path') . SEP .
'sess_' . $args['sessionid']);
}
- // WARNING: It is possiable that this can create a large load
on systems with a lot of sessions open
+ // WARNING: It is possible that this can create a large load on
systems with a lot of sessions open
// For systems that have a lot of open sessions, either do NOT
use PHP sessions or don't
// use the current users screens. (Just disable them)
// We have to read the session data to make sure its actually
valid data and not from something else.
// Otherwise, it will mess up nextmatchs. (jengo)
function record_count()
{
- $i = 0;
- $dh = opendir(get_cfg_var('session.save_path'));
+ if (!$dh = opendir(get_cfg_var('session.save_path')))
+ {
+ return FALSE;
+ }
+ $i = 0;
while ($file = readdir($dh))
{
- if (ereg('sess_',$file) && strlen($file) == 37)
- {
- $sid =
ereg_replace('sess_','',$file);
- $session_values =
$this->read_other_session($sid);
-
- if (is_array($session_values))
+ if
(preg_match('/^sess_([a-f0-9]{32})$/',$file,$matches))
+ {
+ $sid = $matches[1];
+ if
(is_array($this->read_other_session($sid)))
{
$i++;
}
@@ -199,79 +191,71 @@
{
$args = new safe_args();
$args->set('start',0,'int');
- $args = $args->get(func_get_args(),__LINE__,__FILE__);
-
- $i = 0;
- $dh = opendir(get_cfg_var('session.save_path'));
+ $args = $args->get(func_get_args());
- if ($args['start'] == 0)
+ $i = 0;
+ if (!$dh = opendir(get_cfg_var('session.save_path')))
{
- $stop_point =
$GLOBALS['phpgw_data']['prefs']['api.maxmatchs'];
+ return FALSE;
}
- else
+
+ if ($args['start'] < 0)
{
- $stop_point = $args['start'] +
$GLOBALS['phpgw_data']['prefs']['api.maxmatchs'];
+ $args['start'] = 0;
}
+ $stop_point = $args['start'] +
$_SESSION['phpgw_data']['prefs']['api.maxmatchs'];
- while (! $done && $i != $stop_point)
+ $result = array();
+ while ($i < $stop_point)
{
- $file = readdir($dh);
-
- if (! $file)
+ if (!$file= readdir($dh))
{
- $done = True;
+ break;
}
- else
+
+ if
(preg_match('/^sess_([a-f0-9]{32})$/',$file,$matches))
{
- if (ereg('sess_',$file) &&
strlen($file) == 37)
- {
- $sid =
ereg_replace('sess_','',$file);
- $session_values =
$this->read_other_session($sid);
-
- if (is_array($session_values))
+ $sid = $matches[1];
+ if
(is_array($this->read_other_session($sid)))
+ {
+ if ($args['start'] <= $i)
{
- if ($args['start'] <=
$i)
- {
- $result[] =
array(
- 'lid'
=> $session_values['session_lid'],
-
'action' => $session_values['prevop'],
- 'ip'
=> $session_values['ip_address'],
-
'login_time' => $session_values['login_time'],
- 'dla'
=> $session_values['session_dla'],
- 'sid'
=> $sid
- );
- }
- $i++;
+ $result[] = array(
+ 'lid' =>
$session_values['session_lid'],
+ 'action' =>
$session_values['prevop'],
+ 'ip' =>
$session_values['ip_address'],
+ 'login_time' =>
$session_values['login_time'],
+ 'dla' =>
$session_values['session_dla'],
+ 'sid' =>
$sid
+ );
}
+ $i++;
}
}
- }
+ }
closedir($dh);
-
return $result;
}
function read_other_session()
{
$args = new safe_args();
- $args->set('sessionid','##REQUIRED##','string');
- $args = $args->get(func_get_args(),__LINE__,__FILE__);
+ $args->set('sessionid',REQUIRED,'string');
+ $args = $args->get(func_get_args());
- $fh = fopen(get_cfg_var('session.save_path') . SEP .
'sess_' . $args['sessionid'],'r');
- if (! $fh)
+ if(!$fh = fopen(get_cfg_var('session.save_path') . SEP
. 'sess_' . $args['sessionid'],'rb'))
{
- $GLOBALS['msgbox']->add(lang('Could not open
session file (%s)',get_cfg_var('session.save_path') . SEP . 'sess_' .
$args['sessionid']),__LINE__,__FILE__, 'error');
+ trigger_error(lang('Could not open session file
(%s)',get_cfg_var('session.save_path') . SEP . 'sess_' .
$args['sessionid']),E_USER_WARNING);
return;
}
- while (! feof($fh))
+ $raw_data = '';
+ while (!feof($fh))
{
$raw_data .= fgets($fh,4096);
}
fclose($fh);
- return
unserialize(ereg_replace('phpgw_session\|','',$raw_data));
+ return
unserialize(preg_replace('/^phpgw_session\|/','',$raw_data));
}
}
-
-
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] api/sessions/class.sessions_php.php, 1.1.1.1.2.11,
nomail <=