|
Description:
DB_eSession is a feature packed PHP class that stores session data in a MySQL database rather than flat files. It is powerful, designed with security in mind, and yet easy to utilize. The web site has a full package download containing example scripts too.
Source: Text Source
<?PHP
define('DB_ESESSION_LOADED', TRUE);
class DB_eSession
{
var $_ver = '1.0.0';
var $_REQ_VER = '4.2.0';
var $_mysql_ver = NULL;
var $_dbh;
var $_db = array();
var $_sess_opt = array();
var $_sess_name = NULL;
var $_sess_ID_len;
var $_DEFAULT_LANG;
var $_CURRENT_LANG;
var $_stop_on_warn;
var $_WRN_COLOR;
var $_WRN_SIZE;
var $_WRN_MSGS;
var $_warnings = NULL;
var $_stop_on_error;
var $_ERR_COLOR;
var $_ERR_SIZE;
var $_ERR_MSGS;
var $_errors = NULL;
var $_DETAIL_ERR_MSGS;
var $_MIN_SESS_ID_LEN = 12;
var $_MAX_SESS_ID_LEN = 32;
var $_SESS_LIFE;
var $_SESS_TIMEOUT;
var $_SEC_LEVEL;
var $_ENCRYPT;
var $_ENCRYPT_KEY;
var $_ENC_KEY_HASHED;
var $_MCRYPT;
var $_MCRYPT_LATEST;
var $_KEY_PREFIX;
var $_KEY_SUFFIX;
var $_CONF_PSWD;
var $_MAGIC_QUOTES_GPC;
var $_MAGIC_QUOTES_RUNTIME;
var $_ARG_SEP;
var $_SLASH_ANYWAY;
var $_STRIP_ANYWAY;
var $_GC_DEL_LOCKED;
function DB_eSession($_param = array())
{
define('STOP', TRUE);
if (strcmp($this->_REQ_VER, PHP_VERSION) > 0) {
$this->_errors = PHP_VERSION . ' < ' . $this->_REQ_VER . "\n";
$this->_handleErrors(STOP);
}
if (is_array($_param)) {
$_not_array = NULL;
} else {
$_not_array = 'NOT_ARRAY';
$_param = array();
}
$this->_DEFAULT_LANG = isSet($_param['default_lang']) ?
$_param['default_lang'] : 'en';
$this->_CURRENT_LANG = isSet($_param['current_lang']) ?
$_param['current_lang'] :
isSet($_SERVER['HTTP_ACCEPT_LANGUAGE']) ?
substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2) : 'en';
$this->_stop_on_error = (bool) isSet($_param['stop_on_error']) ?
$_param['stop_on_error'] : TRUE;
$this->_ERR_COLOR = isSet($_param['error_color']) ?
$_param['error_color'] : 'RED';
$this->_ERR_SIZE = isSet($_param['error_size']) ?
$_param['error_size'] : '+0';
$this->_stop_on_warn = (bool) isSet($_param['stop_on_warn']) ?
$_param['stop_on_warn'] : FALSE;
$this->_WRN_COLOR = isSet($_param['warn_color']) ?
$_param['warn_color'] : 'BLUE';
$this->_WRN_SIZE = isSet($_param['warn_size']) ?
$_param['warn_size'] : '+0';
$this->_DETAIL_ERR_MSGS = (bool) isSet($_param['detail_err_msgs']) ?
$_param['detail_err_msgs'] :
FALSE;
$_buffer = (bool) isSet($_param['buffer']) ? $_param['buffer'] : FALSE;
if ($_buffer)
ob_start();
$_errors_path = isSet($_param['errors_path']) ?
$_param['errors_path'] : './';
$_errors_file = isSet($_param['errors_file']) ?
$_param['errors_file'] : 'errors.DB_eSession';
$_filename = $_errors_path . $_errors_file . '.php';
if (($this->pregMatches('/^[a-z0-9_.]+$/i', $_errors_file)) &&
(file_exists($_filename))) {
$_loaded = require_once($_filename);
} else {
$this->_errors = "xxxx --> " . $_filename . " <-- xxxx\n";
$this->_handleErrors(STOP);
}
if ((0 === strcmp($_loaded, 'LOAD_OK')) &&
(isSet($_ERR)) &&
(isSet($_WRN))) {
$this->_ERR_MSGS = $_ERR;
$this->_WRN_MSGS = $_WRN;
unset($_ERR, $_WRN);
} else {
$this->_errors = '$_ERR $_WRN xxxx --> ' . $_filename .
" <-- xxxx\n";
$this->_handleErrors(STOP);
}
if (!empty($_not_array))
$this->_setWrnMsg($_not_array);
$this->_ENCRYPT = (bool) isSet($_param['encrypt']) ?
$_param['encrypt'] : FALSE;
$this->_ENCRYPT_KEY = isSet($_param['encrypt_key']) ?
$_param['encrypt_key'] :
"z1Mc6KRxAfNwZ0dGjY5qBXhtrPgJO7eCaUmHvQT3yW8nDsI2VkEpiS4blFoLu9";
$this->_MCRYPT = extension_loaded('mcrypt');
$this->_MCRYPT_LATEST = FALSE;
if ($this->_MCRYPT) {
if (defined('MCRYPT_TRIPLEDES'))
$this->_MCRYPT_LATEST = TRUE;
$this->_ENC_KEY_HASHED = md5($this->_ENCRYPT_KEY);
$this->_ENC_ALGO = isSet($_param['encrypt_cipher']) ?
$_param['encrypt_cipher'] : MCRYPT_GOST;
$_algo = mcrypt_list_algorithms();
if (!in_array($this->_ENC_ALGO, $_algo)) {
$this->_setErrMsg('BAD_ALGO', NULL, $this->_ENC_ALGO);
$this->_handleErrors();
$this->_ENC_ALGO = NULL;
}
$this->_ENC_MODE = isSet($_param['encrypt_mode']) ?
$_param['encrypt_mode'] : MCRYPT_MODE_CFB;
$_modes = mcrypt_list_modes();
if (!in_array($this->_ENC_MODE, $_modes)) {
$this->_setErrMsg('BAD_ENC_MODE', NULL, $this->_ENC_MODE);
$this->_handleErrors();
$this->_ENC_MODE = NULL;
} else
if (($this->_ENC_MODE != MCRYPT_MODE_ECB) &&
($this->_ENC_MODE != MCRYPT_MODE_CBC) &&
($this->_ENC_MODE != MCRYPT_MODE_CFB) &&
($this->_ENC_MODE != MCRYPT_MODE_OFB)) {
$this->_setErrMsg('BAD_MODE_SUPP', NULL, $this->_ENC_MODE,
'ECB, CBC, CFB, OFB.');
$this->_handleErrors();
$this->_ENC_MODE = NULL;
}
} else {
$this->_ENC_KEY_HASHED = NULL;
$this->_ENC_ALGO = NULL;
$this->_ENC_MODE = NULL;
}
mt_srand((double)microtime()*1000000);
srand((double)microtime()*1000000);
$this->_KEY_PREFIX = isSet($_param['key_prefix']) ?
$_param['key_prefix'] : 'O9R^3mp#i|34';
$this->_KEY_SUFFIX = isSet($_param['key_suffix']) ?
$_param['key_suffix'] : '+t97!u0K-2L5';
$this->_CONF_PSWD = isSet($_param['confirm_pswd']) ?
$_param['confirm_pswd'] : '!*CONFIRMED*!';
$this->_db['db_host'] =
isSet($_param['db_host']) ? $_param['db_host'] : 'localhost';
$this->_db['db_user'] =
isSet($_param['db_user']) ? $_param['db_user'] : 'sess_user';
$this->_db['db_pswd'] =
isSet($_param['db_pswd']) ? $_param['db_pswd'] : 'sess1234';
$this->_db['db_name'] =
isSet($_param['db_name']) ? $_param['db_name'] : 'db_esessions';
$this->_db['db_persistent'] =
isSet($_param['db_persistent']) ?
(bool) $_param['db_persistent'] : FALSE;
$this->_db['db_resource'] =
isSet($_param['db_resource']) ? $_param['db_resource'] : NULL;
if (is_resource($this->_db['db_resource']))
$this->_dbh = $this->_db['db_resource'];
else
$this->_dbh = NULL;
$this->_db['tb_name'] =
isSet($_param['tb_name']) ? $_param['tb_name'] : 'eSessions';
$this->_db['tb_id_col'] =
isSet($_param['tb_id_col']) ? $_param['tb_id_col'] : 'sess_id';
$this->_db['tb_sl_col'] =
isSet($_param['tb_sl_col']) ? $_param['tb_sl_col'] :
'sess_sec_level';
$this->_db['tb_cr_col'] =
isSet($_param['tb_cr_col']) ? $_param['tb_cr_col'] :
'sess_created';
$this->_db['tb_ex_col'] =
isSet($_param['tb_ex_col']) ? $_param['tb_ex_col'] : 'sess_expiry';
$this->_db['tb_to_col'] =
isSet($_param['tb_to_col']) ? $_param['tb_to_col'] :
'sess_timeout';
$this->_db['tb_lk_col'] =
isSet($_param['tb_lk_col']) ? $_param['tb_lk_col'] : 'sess_locked';
$this->_db['tb_vl_col'] =
isSet($_param['tb_vl_col']) ? $_param['tb_vl_col'] : 'sess_value';
$this->_db['tb_iv_col'] =
isSet($_param['tb_iv_col']) ? $_param['tb_iv_col'] : 'sess_enc_iv';
$this->_db['tb_si_col'] =
isSet($_param['tb_si_col']) ? $_param['tb_si_col'] : 'sess_sec_id';
$this->_db['tb_tr_col'] =
isSet($_param['tb_tr_col']) ? $_param['tb_tr_col'] : 'sess_trace';
$this->_sess_ID_len = (int)
isSet($_param['sess_id_len']) ? intval($_param['sess_id_len']) :
$this->_MAX_SESS_ID_LEN;
if ($this->_sess_ID_len < $this->_MIN_SESS_ID_LEN)
$this->_sess_ID_len = $this->_MIN_SESS_ID_LEN;
else
if ($this->_sess_ID_len > $this->_MAX_SESS_ID_LEN)
$this->_sess_ID_len = $this->_MAX_SESS_ID_LEN;
$_new_sess_ID = (bool)
isSet($_param['new_sid']) ? $_param['new_sid'] : FALSE;
$_sess_ID =
isSet($_param['sess_id']) ? $_param['sess_id'] : NULL;
if (!empty($_sess_ID)) {
if (strlen($_sess_ID) != $this->_sess_ID_len) {
$this->_setWrnMsg('SESS_LENGTH', NULL, $this->_sess_ID_len,
$_param['sess_id']);
$_sess_ID = NULL;
} else
if (!$this->pregMatches('/^[a-zA-Z0-9]+/', $_sess_ID)) {
$this->_setWrnMsg('SESS_INVALID', NULL, $_param['sess_id']);
$_sess_ID = NULL;
}
}
$_IE_fix = (bool)
isSet($_param['ie_fix']) ? $_param['ie_fix'] : TRUE;
$this->_GC_DEL_LOCKED = (bool)
isSet($_param['gc_del_locked']) ? $_param['gc_del_locked'] : FALSE;
$this->_sess_opt['save_path'] =
isSet($_param['save_path']) ? $_param['save_path'] : 'db_esessions';
if (isSet($_param['name'])) {
if (!$this->pregMatches('/^[a-zA-Z0-9]+/', $_param['name'])) {
$this->_setWrnMsg('NAME_INVALID', NULL, $_param['name']);
$this->_sess_opt['name'] = 'eSESSION';
} else {
$this->_sess_opt['name'] = $_param['name'];
}
} else {
$this->_sess_opt['name'] = 'eSESSION';
}
$this->_sess_opt['save_handler'] =
isSet($_param['save_handler']) ? $_param['save_handler'] : 'user';
if (isSet($_param['auto_start']))
$this->_sess_opt['auto_start'] = (bool) $_param['auto_start'];
if (isSet($_param['gc_probability']))
$this->_sess_opt['gc_probability'] = (int)
(0 == intval($_param['gc_probability'])) ?
10 : intval($_param['gc_probability']);
if (isSet($_param['gc_divisor']))
$this->_sess_opt['gc_divisor'] = (int)
(0 == intval($_param['gc_divisor'])) ?
100 : intval($_param['gc_divisor']);
if (isSet($_param['gc_maxlifetime']))
$this->_sess_opt['gc_maxlifetime'] =
intval($_param['gc_maxlifetime']);
if (isSet($_param['serialize_handler']))
$this->_sess_opt['serialize_handler'] =
$_param['serialize_handler'];
if (isSet($_param['cookie_lifetime']))
$this->_sess_opt['cookie_lifetime'] =
intval($_param['cookie_lifetime']);
if (isSet($_param['cookie_path']))
$this->_sess_opt['cookie_path'] = $_param['cookie_path'];
if (isSet($_param['cookie_domain']))
$this->_sess_opt['cookie_domain'] = $_param['cookie_domain'];
if (isSet($_param['cookie_secure'])) {
$this->_sess_opt['cookie_secure'] = $_param['cookie_secure'];
if ((0 === strcmp($this->_sess_opt['cookie_secure'], '1')) &&
(!$this->secureConnection())) {
$this->_setWrnMsg('NOT_SECURE');
}
}
if (isSet($_param['use_cookies']))
$this->_sess_opt['use_cookies'] = (bool) $_param['use_cookies'];
if ((isSet($_param['use_only_cookies'])) &&
(version_compare(PHP_VERSION, '4.3.0', '>=')))
$this->_sess_opt['use_only_cookies'] =
(bool) $_param['use_only_cookies'];
if (isSet($_param['referer_check']))
$this->_sess_opt['referer_check'] = $_param['referer_check'];
if (isSet($_param['entropy_file']))
$this->_sess_opt['entropy_file'] = $_param['entropy_file'];
if (isSet($_param['entropy_length']))
$this->_sess_opt['entropy_length'] =
intval($_param['entropy_length']);
if (isSet($_param['cache_limiter']))
$this->_sess_opt['cache_limiter'] = $_param['cache_limiter'];
if (isSet($_param['cache_expire']))
$this->_sess_opt['cache_expire'] = intval($_param['cache_expire']);
if (isSet($_param['bug_compat_42']))
$this->_sess_opt['bug_compat_42'] = (bool) $_param['bug_compat_42'];
if (isSet($_param['bug_compat_warn']))
$this->_sess_opt['bug_compat_warn'] = (bool)
$_param['bug_compat_warn'];
if (version_compare(PHP_VERSION, '5.0.0', '>=')) {
if (isSet($_param['use_trans_sid']))
$this->_sess_opt['use_trans_sid'] = $_param['use_trans_sid'];
if (isSet($_param['hash_function']))
$this->_sess_opt['hash_function'] = $_param['hash_function'];
if (isSet($_param['hash_bits_per_character']))
$this->_sess_opt['hash_bits_per_character'] =
$_param['hash_bits_per_character'];
}
foreach ($this->_sess_opt as $_key => $_value) {
if (FALSE === $this->_setSessOption($_key, $_value))
$this->_setWrnMsg('SESS_OPTION', NULL, $_key, $_value);
}
if (isSet($_param['tags'])) {
if (FALSE === $this->_setSessOption('url_rewriter.tags',
$_param['tags'],
FALSE))
$this->_setWrnMsg('URL_TAGS', NULL, $_param['tags']);
}
$this->_SEC_LEVEL = isSet($_param['security_level']) ?
intval($_param['security_level']) : 128;
$this->_SESS_LIFE = intval(ini_get('session.gc_maxlifetime'));
$this->_SESS_LIFE = (int) ($this->_SESS_LIFE < 1) ?
1440 : $this->_SESS_LIFE;
if (isSet($_param['timeout'])) {
$this->_SESS_TIMEOUT = (int)
(intval($_param['timeout']) < $this->_SESS_LIFE) ?
$this->_SESS_LIFE * 3 : intval($_param['timeout']);
} else {
$this->_SESS_TIMEOUT = (int) $this->_SESS_LIFE * 3;
}
if (!$_buffer) {
if (version_compare(PHP_VERSION, '4.3.0', '>=')) {
$_filename = '';
$_linenbr = (int) 0;
if (headers_sent($_filename, $_linenbr)) {
$this->_setWrnMsg('HEADER_SENT_1', NULL, $_filename,
$_linenbr);
}
} else
if (headers_sent()) {
$this->_setWrnMsg('HEADER_SENT_2');
}
}
if (!session_set_save_handler(array(&$this, '_sessDBOpen'),
array(&$this, '_sessDBClose'),
array(&$this, '_sessDBRead'),
array(&$this, '_sessDBWrite'),
array(&$this, '_sessDBDestroy'),
array(&$this, '_sessDBGC')
)) {
$this->_setErrMsg('HANDLER_FAIL');
$this->_handleErrors(STOP);
}
$this->_sess_name = session_name();
$this->_MAGIC_QUOTES_GPC = (bool) get_magic_quotes_gpc();
$this->_MAGIC_QUOTES_RUNTIME = (bool) get_magic_quotes_runtime();
$this->_ARG_SEP = ('' == ini_get('arg_separator.output')) ? '&' :
ini_get('arg_separator.output');
$this->_SLASH_ANYWAY = (bool) isSet($_param['slash_anyway']) ?
$_param['slash_anyway'] : TRUE;
$this->_STRIP_ANYWAY = (bool) isSet($_param['strip_anyway']) ?
$_param['strip_anyway'] : TRUE;
if (isSet($_COOKIE[$this->_sess_name]))
$_sess_id_set = $_COOKIE[$this->_sess_name];
else
if (isSet($GLOBALS[$this->_sess_name]))
$_sess_id_set = $GLOBALS[$this->_sess_name];
else
$_sess_id_set = NULL;
if (($_new_sess_ID) ||
(($this->_sess_ID_len < $this->_MAX_SESS_ID_LEN) &&
(!isSet($_COOKIE[$this->_sess_name])) &&
(!isSet($GLOBALS[$this->_sess_name])))) {
$this->_setNewSessID($_sess_ID);
}
$this->_handleErrors();
$_do_sess_start = (bool) isSet($_param['session_start']) ?
$_param['session_start'] : TRUE;
if (($_do_sess_start) &&
(!isSet($_SESSION)))
session_start();
else
if (!$_do_sess_start)
$this->_sessDBOpen($this->_sess_opt['save_path'], $this->_sess_name);
if (($_do_sess_start) &&
(!empty($_sess_id_set))) {
if (0 !== strcmp($_sess_id_set, session_id()))
$this->deleteSession($_sess_id_set);
}
if ($_IE_fix)
$this->sendCacheHeader('private');
}
function _formatFont($_text, $_color = 'BLACK', $_size = '+0')
{
if (empty($_color))
$_color = 'BLACK';
if (empty($_size))
$_size = '+0';
return '<FONT COLOR="' . $_color . '"' .
' SIZE="' . $_size . '">' .
$_text . '</FONT>';
}
function _setErrMsg ($_errMsgKey = '', $_SQL = NULL)
{
$_lang = $this->_CURRENT_LANG;
if (!isSet($this->_ERR_MSGS[$_errMsgKey][$_lang])) {
if (isSet($this->_ERR_MSGS[$_errMsgKey][$this->_DEFAULT_LANG])) {
$_lang = $this->_DEFAULT_LANG;
} else {
$this->_errors .= '$_ERR[\'' . $_errMsgKey . "']\n";
return FALSE;
}
}
if (@func_num_args() > 2) {
$_arg = @func_get_args();
array_shift($_arg);
array_shift($_arg);
$_cnt = count($_arg);
$_patterns = str_repeat('/%s/i,', $_cnt);
$_patterns = explode(',', $_patterns);
array_pop($_patterns);
for ($i = 0; $i < $_cnt; $i++) {
if ($this->_DETAIL_ERR_MSGS)
$_arg[$i] = str_replace('$', '\$', $_arg[$i]);
else
$_arg[$i] = '[xxx]';
}
$_err = @preg_replace($_patterns,
$_arg,
$this->_ERR_MSGS[$_errMsgKey][$_lang],
1
);
} else {
$_err = $this->_ERR_MSGS[$_errMsgKey][$_lang];
}
if (!empty($_SQL)) {
switch ($this->_DETAIL_ERR_MSGS) {
case TRUE:
$_err .= "SQL: $_SQL\nErr # " .
@mysql_errno($this->_dbh) . ': ' .
@mysql_error($this->_dbh) . "\n";
break;
default:
$_err .= "SQL Err # " .
@mysql_errno($this->_dbh) . ': ' .
@mysql_error($this->_dbh) . "\n";
}
}
$this->_errors .= $_err;
return TRUE;
}
function _setWrnMsg ($_wrnMsgKey = '', $_SQL = NULL)
{
$_lang = $this->_CURRENT_LANG;
if (!isSet($this->_WRN_MSGS[$_wrnMsgKey][$_lang])) {
if (isSet($this->_WRN_MSGS[$_wrnMsgKey][$this->_DEFAULT_LANG])) {
$_lang = $this->_DEFAULT_LANG;
} else {
$this->_warnings .= '$_WRN[\'' . $_wrnMsgKey . "']\n";
return FALSE;
}
}
if (@func_num_args() > 2) {
$_arg = @func_get_args();
array_shift($_arg);
array_shift($_arg);
$_cnt = count($_arg);
$_patterns = str_repeat('/%s/i,', $_cnt);
$_patterns = explode(',', $_patterns);
array_pop($_patterns);
for ($i = 0; $i < $_cnt; $i++) {
if ($this->_DETAIL_ERR_MSGS)
$_arg[$i] = str_replace('$', '\$', $_arg[$i]);
else
$_arg[$i] = '[xxx]';
}
$_wrn = @preg_replace($_patterns,
$_arg,
$this->_WRN_MSGS[$_wrnMsgKey][$_lang],
1
);
} else {
$_wrn = $this->_WRN_MSGS[$_wrnMsgKey][$_lang];
}
if (!empty($_SQL)) {
switch ($this->_DETAIL_ERR_MSGS) {
case TRUE:
$_wrn .= "SQL: $_SQL\nErr # " .
@mysql_errno($this->_dbh) . ': ' .
@mysql_error($this->_dbh) . "\n";
break;
default:
$_wrn .= "SQL Err # " .
@mysql_errno($this->_dbh) . ': ' .
@mysql_error($this->_dbh) . "\n";
}
}
$this->_warnings .= $_wrn;
return TRUE;
}
function _handleErrors($_stop = FALSE)
{
if (($this->warningsExist()) &&
($this->_stop_on_warn)) {
if ($this->errorsExist())
echo $this->getErrors($this->_ERR_COLOR, $this->_ERR_SIZE);
echo $this->getWarnings($this->_WRN_COLOR, $this->_WRN_SIZE);
exit;
}
if (($this->errorsExist()) &&
($this->_stop_on_error)) {
echo $this->getErrors($this->_ERR_COLOR, $this->_ERR_SIZE);
if ($this->warningsExist())
echo $this->getWarnings($this->_WRN_COLOR, $this->_WRN_SIZE);
exit;
}
if (!is_bool($_stop))
$_stop = FALSE;
if ($_stop) {
if ($this->errorsExist())
echo $this->getErrors($this->_ERR_COLOR, $this->_ERR_SIZE);
if ($this->warningsExist())
echo $this->getWarnings($this->_WRN_COLOR, $this->_WRN_SIZE);
exit;
}
return TRUE;
}
function _setSessOption($_config_option, $_value, $_check_sess = TRUE)
{
$_config_option = trim($_config_option);
if (empty($_config_option)) {
return FALSE;
} else {
if ($_check_sess) {
if (0 !== strpos(strtolower($_config_option), 'session.'))
$_config_option = 'session.' . $_config_option;
}
return ini_set($_config_option, $_value);
}
}
function _genString($_length = 0)
{
$_length = intval($_length);
if (($_length < 1) ||
($_length > $this->_MAX_SESS_ID_LEN))
$_length = $this->_MAX_SESS_ID_LEN;
$_string = md5(uniqid(mt_rand(), TRUE));
return substr($_string, 0, $_length);
}
function _setNewSessID($_sess_id = NULL)
{
global $HTTP_GET_VARS, $HTTP_POST_VARS, $HTTP_COOKIE_VARS;
$_continue = TRUE;
if (strlen($_sess_id) == $this->_sess_ID_len) {
if (!$this->pregMatches('/^[a-zA-Z0-9]+/', $_sess_id)) {
$this->_setWrnMsg('SESS_INVALID', NULL, $_sess_id);
$this->_handleErrors();
$this->_setWrnMsg('NEW_SESS_ID');
} else {
session_id($_sess_id);
$_continue = FALSE;
}
}
if (($_continue) &&
($this->_sess_ID_len == $this->_MAX_SESS_ID_LEN) &&
(version_compare(PHP_VERSION, '4.3.2', '>='))) {
if (session_regenerate_id()) {
$_sess_id = session_id();
$_continue = FALSE;
}
}
if ($_continue) {
$_sess_id = $this->_genString($this->_sess_ID_len);
session_id($_sess_id);
}
if (isSet($_REQUEST[$this->_sess_name]))
$_REQUEST[$this->_sess_name] = $_sess_id;
if (isSet($_GET[$this->_sess_name]))
$_GET[$this->_sess_name] = $_sess_id;
if (isSet($HTTP_GET_VARS[$this->_sess_name]))
$HTTP_GET_VARS[$this->_sess_name] = $_sess_id;
if (isSet($_POST[$this->_sess_name]))
$_POST[$this->_sess_name] = $_sess_id;
if (isSet($HTTP_POST_VARS[$this->_sess_name]))
$HTTP_POST_VARS[$this->_sess_name] = $_sess_id;
if (isSet($_COOKIE[$this->_sess_name]))
$_COOKIE[$this->_sess_name] = $_sess_id;
if (isSet($HTTP_COOKIE_VARS[$this->_sess_name]))
$HTTP_COOKIE_VARS[$this->_sess_name] = $_sess_id;
if (isSet($GLOBALS[$this->_sess_name]))
$GLOBALS[$this->_sess_name] = $_sess_id;
return $_sess_id;
}
function _getSecID()
{
$_type_used = NULL;
$_IP = $this->getIPAddr($_type_used);
$_agent = isSet($_SERVER['HTTP_USER_AGENT']) ?
$_SERVER['HTTP_USER_AGENT'] : 'NO USER AGENT';
return md5($this->_KEY_PREFIX .
$_IP .
$_type_used .
$_agent .
$this->_KEY_SUFFIX
|