【php开源代码栏目提醒】:网学会员鉴于大家对php开源代码十分关注,论文会员在此为大家搜集整理了“adodb-session.php”一文,供大家参考学习
<?php
// $CVSHeader$
/*
V4.01 23 Oct 2003 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
Contributed by Ross Smith (adodb@netebb.com).
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 4 for best viewing.
*/
/*
You may want to rename the 'data' field to 'session_data' as
'data' appears to be a reserved word for one or more of the following:
ANSI SQL
IBM DB2
MS SQL Server
Postgres
SAP
If you do, then execute:
ADODB_Session::dataFieldName('session_data');
*/
if (!defined('_ADODB_LAYER')) {
require_once realpath(dirname(__FILE__) . '/../adodb.inc.php');
}
if (defined('ADODB_SESSION')) return 1;
define('ADODB_SESSION', dirname(__FILE__));
/*!
\static
*/
class ADODB_Session {
/////////////////////
// getter/setter methods
/////////////////////
/*!
*/
function driver($driver = null) {
static $_driver = '
mysql';
static $set = false;
if (!is_null($driver)) {
$_driver = trim($driver);
$set = true;
} elseif (!$set) {
// backwards compatibility
if (isset($GLOBALS['ADODB_SESSION_DRIVER'])) {
return $GLOBALS['ADODB_SESSION_DRIVER'];
}
}
return $_driver;
}
/*!
*/
function host($host = null) {
static $_host = 'localhost';
static $set = false;
if (!is_null($host)) {
$_host = trim($host);
$set = true;
} elseif (!$set) {
// backwards compatibility
if (isset($GLOBALS['ADODB_SESSION_CONNECT'])) {
return $GLOBALS['ADODB_SESSION_CONNECT'];
}
}
return $_host;
}
/*!
*/
function user($user = null) {
static $_user = 'root';
static $set = false;
if (!is_null($user)) {
$_user = trim($user);
$set = true;
} elseif (!$set) {
// backwards compatibility
if (isset($GLOBALS['ADODB_SESSION_USER'])) {
return $GLOBALS['ADODB_SESSION_USER'];
}
}
return $_user;
}
/*!
*/
function password($password = null) {
static $_password = '';
static $set = false;
if (!is_null($pass
word)) {
$_password = $password;
$set = true;
} elseif (!$set) {
// backwards compatibility
if (isset($GLOBALS['ADODB_SESSION_PWD'])) {
return $GLOBALS['ADODB_SESSION_PWD'];
}
}
return $_password;
}
/*!
*/
function database($database = null) {
static $_database = 'xphplens_2';
static $set = false;
if (!is_null($database)) {
$_database = trim($database);
$set = true;
} elseif (!$set) {
// backwards compatibility
if (isset($GLOBALS['ADODB_SESSION_DB'])) {
return $GLOBALS['ADODB_SESSION_DB'];
}
}
return $_database;
}
/*!
*/
function persist($persist = null) {
static $_persist = true;
if (!is_null($persist)) {
$_persist = trim($persist);
}
return $_persist;
}
/*!
*/
function lifetime($lifetime = null) {
static $_lifetime;
static $set = false;
if (!is_null($lifetime)) {
$_lifetime = (int) $lifetime;
$set = true;
} elseif (!$set) {
// backwards compatibility
if (isset($GLOBALS['ADODB_SESS_LIFE'])) {
return $GLOBALS['ADODB_SESS_LIFE'];
}
}
if (!$_lifetime) {
$_lifetime = ini_get('session.gc_maxlifetime');
if ($_lifetime <= 1) {
// bug in PHP 4.0.3 pl 1 -- how about other versions?
//print "<h3>Session Error:
PHP.INI setting <i>session.gc_maxlifetime</i>not set: $lifetime</h3>";
$_lifetime = 1440;
}
}
return $_lifetime;
}
/*!
*/
function debug($debug = null) {
static $_debug = false;
static $set = false;
if (!is_null($debug)) {
$_debug = (bool) $debug;
$conn = ADODB_Session::_conn();
if ($conn) {
$conn->debug = $_debug;
}
$set = true;
} elseif (!$set) {
// backwards compatibility
if (isset($GLOBALS['ADODB_SESS_DEBUG'])) {
return $GLOBALS['ADODB_SESS_DEBUG'];
}
}
return $_debug;
}
/*!
*/
function expireNotify($expire_notify = null) {
static $_expire_notify;
static $set = false;
if (!is_null($expire_notify)) {
$_expire_notify = $expire_notify;
$set = true;
} elseif (!$set) {
// backwards compatibility
if (isset($GLOBALS['ADODB_SESSION_EXPIRE_NOTIFY'])) {
return $GLOBALS['ADODB_SESSION_EXPIRE_NOTIFY'];
}
}
return $_expire_notify;
}
/*!
*/
function table($table = null) {
static $_table = 'sessions';
static $set = false;
if (!is_null($table)) {
$_table = trim($table);
$set = true;
} elseif (!$set) {
// backwards compatibility
if (isset($GLOBALS['ADODB_SESSION_TBL'])) {
return $GLOBALS['ADODB_SESSION_TBL'];
}