adodb 최신버전으로 변경
<? 를 <?php 로 변경
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
V5.09 25 June 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
Contributed by Ross Smith (adodb@netebb.com).
|
||||
@version v5.20.9 21-Dec-2016
|
||||
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
|
||||
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.
|
||||
@@ -73,7 +75,7 @@ class ADODB_Compress_Bzip2 {
|
||||
|
||||
/**
|
||||
*/
|
||||
function ADODB_Compress_Bzip2($block_size = null, $work_level = null, $min_length = null) {
|
||||
function __construct($block_size = null, $work_level = null, $min_length = null) {
|
||||
if (!is_null($block_size)) {
|
||||
$this->setBlockSize($block_size);
|
||||
}
|
||||
@@ -114,5 +116,3 @@ class ADODB_Compress_Bzip2 {
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
||||
?>
|
||||
|
||||
@@ -2,8 +2,10 @@
|
||||
|
||||
|
||||
/*
|
||||
V5.09 25 June 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
Contributed by Ross Smith (adodb@netebb.com).
|
||||
@version v5.20.9 21-Dec-2016
|
||||
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
|
||||
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.
|
||||
@@ -56,7 +58,7 @@ class ADODB_Compress_Gzip {
|
||||
|
||||
/**
|
||||
*/
|
||||
function ADODB_Compress_Gzip($level = null, $min_length = null) {
|
||||
function __construct($level = null, $min_length = null) {
|
||||
if (!is_null($level)) {
|
||||
$this->setLevel($level);
|
||||
}
|
||||
@@ -89,5 +91,3 @@ class ADODB_Compress_Gzip {
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
||||
?>
|
||||
|
||||
@@ -2,8 +2,10 @@
|
||||
|
||||
|
||||
/*
|
||||
V5.09 25 June 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
Contributed by Ross Smith (adodb@netebb.com).
|
||||
@version v5.20.9 21-Dec-2016
|
||||
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
|
||||
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.
|
||||
@@ -23,5 +25,3 @@ if (!defined('ADODB_SESSION')) {
|
||||
require_once ADODB_SESSION . '/adodb-encrypt-md5.php';
|
||||
|
||||
ADODB_Session::filter(new ADODB_Encrypt_MD5());
|
||||
|
||||
?>
|
||||
|
||||
@@ -2,8 +2,10 @@
|
||||
|
||||
|
||||
/*
|
||||
V5.09 25 June 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
Contributed by Ross Smith (adodb@netebb.com).
|
||||
@version v5.20.9 21-Dec-2016
|
||||
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
|
||||
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.
|
||||
@@ -23,5 +25,3 @@ if (!defined('ADODB_SESSION')) {
|
||||
require_once ADODB_SESSION . '/adodb-encrypt-md5.php';
|
||||
|
||||
ADODB_Session::filter(new ADODB_Encrypt_MD5());
|
||||
|
||||
?>
|
||||
|
||||
@@ -2,8 +2,10 @@
|
||||
|
||||
|
||||
/*
|
||||
V5.09 25 June 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
Contributed by Ross Smith (adodb@netebb.com).
|
||||
@version v5.20.9 21-Dec-2016
|
||||
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
|
||||
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.
|
||||
@@ -69,7 +71,7 @@ class ADODB_Encrypt_MCrypt {
|
||||
|
||||
/**
|
||||
*/
|
||||
function ADODB_Encrypt_MCrypt($cipher = null, $mode = null, $source = null) {
|
||||
function __construct($cipher = null, $mode = null, $source = null) {
|
||||
if (!$cipher) {
|
||||
$cipher = MCRYPT_RIJNDAEL_256;
|
||||
}
|
||||
@@ -105,5 +107,3 @@ class ADODB_Encrypt_MCrypt {
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
||||
?>
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
V5.09 25 June 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
Contributed by Ross Smith (adodb@netebb.com).
|
||||
@version v5.20.9 21-Dec-2016
|
||||
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
|
||||
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.
|
||||
@@ -35,5 +37,3 @@ class ADODB_Encrypt_MD5 {
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
||||
?>
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
V5.09 25 June 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
Contributed by Ross Smith (adodb@netebb.com).
|
||||
@version v5.20.9 21-Dec-2016
|
||||
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
|
||||
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.
|
||||
@@ -44,5 +46,3 @@ class ADODB_Encrypt_Secret {
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
||||
?>
|
||||
|
||||
@@ -10,7 +10,7 @@ include_once ADODB_SESSION . '/crypt.inc.php';
|
||||
|
||||
class ADODB_Encrypt_SHA1 {
|
||||
|
||||
function write($data, $key)
|
||||
function write($data, $key)
|
||||
{
|
||||
$sha1crypt = new SHA1Crypt();
|
||||
return $sha1crypt->encrypt($data, $key);
|
||||
@@ -18,7 +18,7 @@ class ADODB_Encrypt_SHA1 {
|
||||
}
|
||||
|
||||
|
||||
function read($data, $key)
|
||||
function read($data, $key)
|
||||
{
|
||||
$sha1crypt = new SHA1Crypt();
|
||||
return $sha1crypt->decrypt($data, $key);
|
||||
@@ -29,4 +29,3 @@ class ADODB_Encrypt_SHA1 {
|
||||
|
||||
|
||||
return 1;
|
||||
?>
|
||||
|
||||
@@ -2,8 +2,10 @@
|
||||
|
||||
|
||||
/*
|
||||
V5.09 25 June 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
Contributed by Ross Smith (adodb@netebb.com).
|
||||
@version v5.20.9 21-Dec-2016
|
||||
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
|
||||
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.
|
||||
@@ -20,5 +22,3 @@ if (!defined('ADODB_SESSION')) {
|
||||
require_once dirname(__FILE__) . '/adodb-session.php';
|
||||
}
|
||||
ADODB_Session::clob('CLOB');
|
||||
|
||||
?>
|
||||
|
||||
@@ -2,8 +2,10 @@
|
||||
|
||||
|
||||
/*
|
||||
V5.09 25 June 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
Contributed by Ross Smith (adodb@netebb.com).
|
||||
@version v5.20.9 21-Dec-2016
|
||||
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
|
||||
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.
|
||||
@@ -20,5 +22,3 @@ if (!defined('ADODB_SESSION')) {
|
||||
require_once dirname(__FILE__) . '/adodb-session2.php';
|
||||
}
|
||||
ADODB_Session::clob('CLOB');
|
||||
|
||||
?>
|
||||
|
||||
@@ -2,8 +2,10 @@
|
||||
|
||||
|
||||
/*
|
||||
V5.09 25 June 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
Contributed by Ross Smith (adodb@netebb.com).
|
||||
@version v5.20.9 21-Dec-2016
|
||||
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
|
||||
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.
|
||||
@@ -34,16 +36,16 @@ if (defined('ADODB_SESSION')) return 1;
|
||||
define('ADODB_SESSION', dirname(__FILE__));
|
||||
|
||||
|
||||
/*
|
||||
Unserialize session data manually. See http://phplens.com/lens/lensforum/msgs.php?id=9821
|
||||
|
||||
From Kerr Schere, to unserialize session data stored via ADOdb.
|
||||
1. Pull the session data from the db and loop through it.
|
||||
2. Inside the loop, you will need to urldecode the data column.
|
||||
/*
|
||||
Unserialize session data manually. See http://phplens.com/lens/lensforum/msgs.php?id=9821
|
||||
|
||||
From Kerr Schere, to unserialize session data stored via ADOdb.
|
||||
1. Pull the session data from the db and loop through it.
|
||||
2. Inside the loop, you will need to urldecode the data column.
|
||||
3. After urldecode, run the serialized string through this function:
|
||||
|
||||
*/
|
||||
function adodb_unserialize( $serialized_string )
|
||||
function adodb_unserialize( $serialized_string )
|
||||
{
|
||||
$variables = array( );
|
||||
$a = preg_split( "/(\w+)\|/", $serialized_string, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE );
|
||||
@@ -57,7 +59,7 @@ function adodb_unserialize( $serialized_string )
|
||||
Thanks Joe Li. See http://phplens.com/lens/lensforum/msgs.php?id=11487&x=1
|
||||
Since adodb 4.61.
|
||||
*/
|
||||
function adodb_session_regenerate_id()
|
||||
function adodb_session_regenerate_id()
|
||||
{
|
||||
$conn = ADODB_Session::_conn();
|
||||
if (!$conn) return false;
|
||||
@@ -73,7 +75,7 @@ function adodb_session_regenerate_id()
|
||||
}
|
||||
$new_id = session_id();
|
||||
$ok = $conn->Execute('UPDATE '. ADODB_Session::table(). ' SET sesskey='. $conn->qstr($new_id). ' WHERE sesskey='.$conn->qstr($old_id));
|
||||
|
||||
|
||||
/* it is possible that the update statement fails due to a collision */
|
||||
if (!$ok) {
|
||||
session_id($old_id);
|
||||
@@ -81,7 +83,7 @@ function adodb_session_regenerate_id()
|
||||
setcookie(session_name(), session_id(), false, $ck['path'], $ck['domain'], $ck['secure']);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -111,13 +113,13 @@ class ADODB_Session {
|
||||
/////////////////////
|
||||
// getter/setter methods
|
||||
/////////////////////
|
||||
|
||||
|
||||
/*
|
||||
|
||||
|
||||
function Lock($lock=null)
|
||||
{
|
||||
static $_lock = false;
|
||||
|
||||
|
||||
if (!is_null($lock)) $_lock = $lock;
|
||||
return $lock;
|
||||
}
|
||||
@@ -219,7 +221,7 @@ class ADODB_Session {
|
||||
|
||||
/*!
|
||||
*/
|
||||
function persist($persist = null)
|
||||
function persist($persist = null)
|
||||
{
|
||||
static $_persist = true;
|
||||
|
||||
@@ -492,7 +494,7 @@ class ADODB_Session {
|
||||
/////////////////////
|
||||
// public methods
|
||||
/////////////////////
|
||||
|
||||
|
||||
function config($driver, $host, $user, $password, $database=false,$options=false)
|
||||
{
|
||||
ADODB_Session::driver($driver);
|
||||
@@ -500,9 +502,9 @@ class ADODB_Session {
|
||||
ADODB_Session::user($user);
|
||||
ADODB_Session::password($password);
|
||||
ADODB_Session::database($database);
|
||||
|
||||
|
||||
if ($driver == 'oci8' || $driver == 'oci8po') $options['lob'] = 'CLOB';
|
||||
|
||||
|
||||
if (isset($options['table'])) ADODB_Session::table($options['table']);
|
||||
if (isset($options['lob'])) ADODB_Session::clob($options['lob']);
|
||||
if (isset($options['debug'])) ADODB_Session::debug($options['debug']);
|
||||
@@ -513,7 +515,7 @@ class ADODB_Session {
|
||||
|
||||
If $conn already exists, reuse that connection
|
||||
*/
|
||||
function open($save_path, $session_name, $persist = null)
|
||||
function open($save_path, $session_name, $persist = null)
|
||||
{
|
||||
$conn = ADODB_Session::_conn();
|
||||
|
||||
@@ -560,7 +562,7 @@ class ADODB_Session {
|
||||
if ($ok) $GLOBALS['ADODB_SESS_CONN'] = $conn;
|
||||
else
|
||||
ADOConnection::outp('<p>Session: connection failed</p>', false);
|
||||
|
||||
|
||||
|
||||
return $ok;
|
||||
}
|
||||
@@ -568,7 +570,7 @@ class ADODB_Session {
|
||||
/*!
|
||||
Close the connection
|
||||
*/
|
||||
function close()
|
||||
function close()
|
||||
{
|
||||
/*
|
||||
$conn = ADODB_Session::_conn();
|
||||
@@ -580,7 +582,7 @@ class ADODB_Session {
|
||||
/*
|
||||
Slurp in the session variables and return the serialized string
|
||||
*/
|
||||
function read($key)
|
||||
function read($key)
|
||||
{
|
||||
$conn = ADODB_Session::_conn();
|
||||
$data = ADODB_Session::dataFieldName();
|
||||
@@ -595,15 +597,15 @@ class ADODB_Session {
|
||||
|
||||
$qkey = $conn->quote($key);
|
||||
$binary = $conn->dataProvider === 'mysql' ? '/*! BINARY */' : '';
|
||||
|
||||
|
||||
$sql = "SELECT $data FROM $table WHERE sesskey = $binary $qkey AND expiry >= " . time();
|
||||
/* Lock code does not work as it needs to hold transaction within whole page, and we don't know if
|
||||
/* Lock code does not work as it needs to hold transaction within whole page, and we don't know if
|
||||
developer has commited elsewhere... :(
|
||||
*/
|
||||
#if (ADODB_Session::Lock())
|
||||
# $rs = $conn->RowLock($table, "$binary sesskey = $qkey AND expiry >= " . time(), $data);
|
||||
#else
|
||||
|
||||
|
||||
$rs = $conn->Execute($sql);
|
||||
//ADODB_Session::_dumprs($rs);
|
||||
if ($rs) {
|
||||
@@ -634,12 +636,12 @@ class ADODB_Session {
|
||||
|
||||
If the data has not been modified since the last read(), we do not write.
|
||||
*/
|
||||
function write($key, $val)
|
||||
function write($key, $val)
|
||||
{
|
||||
global $ADODB_SESSION_READONLY;
|
||||
|
||||
|
||||
if (!empty($ADODB_SESSION_READONLY)) return;
|
||||
|
||||
|
||||
$clob = ADODB_Session::clob();
|
||||
$conn = ADODB_Session::_conn();
|
||||
$crc = ADODB_Session::_crc();
|
||||
@@ -650,12 +652,12 @@ class ADODB_Session {
|
||||
$filter = ADODB_Session::filter();
|
||||
$lifetime = ADODB_Session::lifetime();
|
||||
$table = ADODB_Session::table();
|
||||
|
||||
|
||||
if (!$conn) {
|
||||
return false;
|
||||
}
|
||||
$qkey = $conn->qstr($key);
|
||||
|
||||
|
||||
//assert('$table');
|
||||
|
||||
$expiry = time() + $lifetime;
|
||||
@@ -668,7 +670,7 @@ class ADODB_Session {
|
||||
if ($debug) {
|
||||
ADOConnection::outp( '<p>Session: Only updating date - crc32 not changed</p>');
|
||||
}
|
||||
|
||||
|
||||
$expirevar = '';
|
||||
if ($expire_notify) {
|
||||
$var = reset($expire_notify);
|
||||
@@ -677,8 +679,8 @@ class ADODB_Session {
|
||||
$expirevar = $$var;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$sql = "UPDATE $table SET expiry = ".$conn->Param('0').",expireref=".$conn->Param('1')." WHERE $binary sesskey = ".$conn->Param('2')." AND expiry >= ".$conn->Param('3');
|
||||
$rs = $conn->Execute($sql,array($expiry,$expirevar,$key,time()));
|
||||
return true;
|
||||
@@ -702,7 +704,7 @@ class ADODB_Session {
|
||||
if (!$clob) { // no lobs, simply use replace()
|
||||
$arr[$data] = $val;
|
||||
$rs = $conn->Replace($table, $arr, 'sesskey', $autoQuote = true);
|
||||
|
||||
|
||||
} else {
|
||||
// what value shall we insert/update for lob row?
|
||||
switch ($driver) {
|
||||
@@ -719,7 +721,7 @@ class ADODB_Session {
|
||||
$lob_value = 'null';
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
$conn->StartTrans();
|
||||
$expiryref = $conn->qstr($arr['expireref']);
|
||||
// do we insert or update? => as for sesskey
|
||||
@@ -730,15 +732,15 @@ class ADODB_Session {
|
||||
$sql = "INSERT INTO $table (expiry, $data, sesskey,expireref) VALUES ($expiry, $lob_value, $qkey,$expiryref)";
|
||||
}
|
||||
if ($rs)$rs->Close();
|
||||
|
||||
|
||||
|
||||
$err = '';
|
||||
$rs1 = $conn->Execute($sql);
|
||||
if (!$rs1) $err = $conn->ErrorMsg()."\n";
|
||||
|
||||
|
||||
$rs2 = $conn->UpdateBlob($table, $data, $val, " sesskey=$qkey", strtoupper($clob));
|
||||
if (!$rs2) $err .= $conn->ErrorMsg()."\n";
|
||||
|
||||
|
||||
$rs = ($rs && $rs2) ? true : false;
|
||||
$conn->CompleteTrans();
|
||||
}
|
||||
@@ -810,7 +812,7 @@ class ADODB_Session {
|
||||
|
||||
/*!
|
||||
*/
|
||||
function gc($maxlifetime)
|
||||
function gc($maxlifetime)
|
||||
{
|
||||
$conn = ADODB_Session::_conn();
|
||||
$debug = ADODB_Session::debug();
|
||||
@@ -846,11 +848,11 @@ class ADODB_Session {
|
||||
$rs->MoveNext();
|
||||
}
|
||||
$rs->Close();
|
||||
|
||||
|
||||
$conn->CompleteTrans();
|
||||
}
|
||||
} else {
|
||||
|
||||
|
||||
if (1) {
|
||||
$sql = "SELECT sesskey FROM $table WHERE expiry < $time";
|
||||
$arr = $conn->GetAll($sql);
|
||||
@@ -927,8 +929,6 @@ function adodb_sess_open($save_path, $session_name, $persist = true) {
|
||||
|
||||
// for backwards compatability only
|
||||
function adodb_sess_gc($t)
|
||||
{
|
||||
{
|
||||
return ADODB_Session::gc($t);
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -2,13 +2,15 @@
|
||||
|
||||
|
||||
/*
|
||||
V5.09 25 June 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
Contributed by Ross Smith (adodb@netebb.com).
|
||||
@version v5.20.9 21-Dec-2016
|
||||
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
|
||||
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.
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
@@ -36,10 +38,10 @@ CREATE UNIQUE INDEX SESS2_PK ON SESSIONS2(SESSKEY);
|
||||
CREATE INDEX SESS2_EXP_REF ON SESSIONS2(EXPIREREF);
|
||||
|
||||
|
||||
|
||||
|
||||
MySQL
|
||||
=====
|
||||
|
||||
|
||||
CREATE TABLE sessions2(
|
||||
sesskey VARCHAR( 64 ) NOT NULL DEFAULT '',
|
||||
expiry TIMESTAMP NOT NULL ,
|
||||
@@ -64,16 +66,16 @@ if (defined('ADODB_SESSION')) return 1;
|
||||
define('ADODB_SESSION', dirname(__FILE__));
|
||||
define('ADODB_SESSION2', ADODB_SESSION);
|
||||
|
||||
/*
|
||||
Unserialize session data manually. See http://phplens.com/lens/lensforum/msgs.php?id=9821
|
||||
|
||||
From Kerr Schere, to unserialize session data stored via ADOdb.
|
||||
1. Pull the session data from the db and loop through it.
|
||||
2. Inside the loop, you will need to urldecode the data column.
|
||||
/*
|
||||
Unserialize session data manually. See http://phplens.com/lens/lensforum/msgs.php?id=9821
|
||||
|
||||
From Kerr Schere, to unserialize session data stored via ADOdb.
|
||||
1. Pull the session data from the db and loop through it.
|
||||
2. Inside the loop, you will need to urldecode the data column.
|
||||
3. After urldecode, run the serialized string through this function:
|
||||
|
||||
*/
|
||||
function adodb_unserialize( $serialized_string )
|
||||
function adodb_unserialize( $serialized_string )
|
||||
{
|
||||
$variables = array( );
|
||||
$a = preg_split( "/(\w+)\|/", $serialized_string, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE );
|
||||
@@ -87,7 +89,7 @@ function adodb_unserialize( $serialized_string )
|
||||
Thanks Joe Li. See http://phplens.com/lens/lensforum/msgs.php?id=11487&x=1
|
||||
Since adodb 4.61.
|
||||
*/
|
||||
function adodb_session_regenerate_id()
|
||||
function adodb_session_regenerate_id()
|
||||
{
|
||||
$conn = ADODB_Session::_conn();
|
||||
if (!$conn) return false;
|
||||
@@ -103,7 +105,7 @@ function adodb_session_regenerate_id()
|
||||
}
|
||||
$new_id = session_id();
|
||||
$ok = $conn->Execute('UPDATE '. ADODB_Session::table(). ' SET sesskey='. $conn->qstr($new_id). ' WHERE sesskey='.$conn->qstr($old_id));
|
||||
|
||||
|
||||
/* it is possible that the update statement fails due to a collision */
|
||||
if (!$ok) {
|
||||
session_id($old_id);
|
||||
@@ -111,7 +113,7 @@ function adodb_session_regenerate_id()
|
||||
setcookie(session_name(), session_id(), false, $ck['path'], $ck['domain'], $ck['secure']);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -141,20 +143,20 @@ class ADODB_Session {
|
||||
/////////////////////
|
||||
// getter/setter methods
|
||||
/////////////////////
|
||||
|
||||
|
||||
/*
|
||||
|
||||
|
||||
function Lock($lock=null)
|
||||
{
|
||||
static $_lock = false;
|
||||
|
||||
|
||||
if (!is_null($lock)) $_lock = $lock;
|
||||
return $lock;
|
||||
}
|
||||
*/
|
||||
/*!
|
||||
*/
|
||||
static function driver($driver = null)
|
||||
static function driver($driver = null)
|
||||
{
|
||||
static $_driver = 'mysql';
|
||||
static $set = false;
|
||||
@@ -193,7 +195,7 @@ class ADODB_Session {
|
||||
|
||||
/*!
|
||||
*/
|
||||
static function user($user = null)
|
||||
static function user($user = null)
|
||||
{
|
||||
static $_user = 'root';
|
||||
static $set = false;
|
||||
@@ -213,7 +215,7 @@ class ADODB_Session {
|
||||
|
||||
/*!
|
||||
*/
|
||||
static function password($password = null)
|
||||
static function password($password = null)
|
||||
{
|
||||
static $_password = '';
|
||||
static $set = false;
|
||||
@@ -233,11 +235,11 @@ class ADODB_Session {
|
||||
|
||||
/*!
|
||||
*/
|
||||
static function database($database = null)
|
||||
static function database($database = null)
|
||||
{
|
||||
static $_database = '';
|
||||
static $set = false;
|
||||
|
||||
|
||||
if (!is_null($database)) {
|
||||
$_database = trim($database);
|
||||
$set = true;
|
||||
@@ -252,7 +254,7 @@ class ADODB_Session {
|
||||
|
||||
/*!
|
||||
*/
|
||||
static function persist($persist = null)
|
||||
static function persist($persist = null)
|
||||
{
|
||||
static $_persist = true;
|
||||
|
||||
@@ -265,7 +267,7 @@ class ADODB_Session {
|
||||
|
||||
/*!
|
||||
*/
|
||||
static function lifetime($lifetime = null)
|
||||
static function lifetime($lifetime = null)
|
||||
{
|
||||
static $_lifetime;
|
||||
static $set = false;
|
||||
@@ -293,7 +295,7 @@ class ADODB_Session {
|
||||
|
||||
/*!
|
||||
*/
|
||||
static function debug($debug = null)
|
||||
static function debug($debug = null)
|
||||
{
|
||||
static $_debug = false;
|
||||
static $set = false;
|
||||
@@ -318,7 +320,7 @@ class ADODB_Session {
|
||||
|
||||
/*!
|
||||
*/
|
||||
static function expireNotify($expire_notify = null)
|
||||
static function expireNotify($expire_notify = null)
|
||||
{
|
||||
static $_expire_notify;
|
||||
static $set = false;
|
||||
@@ -338,7 +340,7 @@ class ADODB_Session {
|
||||
|
||||
/*!
|
||||
*/
|
||||
static function table($table = null)
|
||||
static function table($table = null)
|
||||
{
|
||||
static $_table = 'sessions2';
|
||||
static $set = false;
|
||||
@@ -358,7 +360,7 @@ class ADODB_Session {
|
||||
|
||||
/*!
|
||||
*/
|
||||
static function optimize($optimize = null)
|
||||
static function optimize($optimize = null)
|
||||
{
|
||||
static $_optimize = false;
|
||||
static $set = false;
|
||||
@@ -380,7 +382,7 @@ class ADODB_Session {
|
||||
*/
|
||||
static function syncSeconds($sync_seconds = null) {
|
||||
//echo ("<p>WARNING: ADODB_SESSION::syncSeconds is longer used, please remove this function for your code</p>");
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -507,7 +509,7 @@ class ADODB_Session {
|
||||
return;
|
||||
}
|
||||
$rs = $conn->_rs2rs($rs);
|
||||
|
||||
|
||||
require_once ADODB_SESSION.'/../tohtml.inc.php';
|
||||
rs2html($rs);
|
||||
$rs->MoveFirst();
|
||||
@@ -516,7 +518,7 @@ class ADODB_Session {
|
||||
/////////////////////
|
||||
// public methods
|
||||
/////////////////////
|
||||
|
||||
|
||||
static function config($driver, $host, $user, $password, $database=false,$options=false)
|
||||
{
|
||||
ADODB_Session::driver($driver);
|
||||
@@ -524,9 +526,9 @@ class ADODB_Session {
|
||||
ADODB_Session::user($user);
|
||||
ADODB_Session::password($password);
|
||||
ADODB_Session::database($database);
|
||||
|
||||
if ($driver == 'oci8' || $driver == 'oci8po') $options['lob'] = 'CLOB';
|
||||
|
||||
|
||||
if (strncmp($driver, 'oci8', 4) == 0) $options['lob'] = 'CLOB';
|
||||
|
||||
if (isset($options['table'])) ADODB_Session::table($options['table']);
|
||||
if (isset($options['lob'])) ADODB_Session::clob($options['lob']);
|
||||
if (isset($options['debug'])) ADODB_Session::debug($options['debug']);
|
||||
@@ -537,7 +539,7 @@ class ADODB_Session {
|
||||
|
||||
If $conn already exists, reuse that connection
|
||||
*/
|
||||
static function open($save_path, $session_name, $persist = null)
|
||||
static function open($save_path, $session_name, $persist = null)
|
||||
{
|
||||
$conn = ADODB_Session::_conn();
|
||||
|
||||
@@ -566,25 +568,29 @@ class ADODB_Session {
|
||||
$conn = ADONewConnection($driver);
|
||||
|
||||
if ($debug) {
|
||||
$conn->debug = true;
|
||||
$conn->debug = true;
|
||||
ADOConnection::outp( " driver=$driver user=$user db=$database ");
|
||||
}
|
||||
|
||||
if ($persist) {
|
||||
switch($persist) {
|
||||
default:
|
||||
case 'P': $ok = $conn->PConnect($host, $user, $password, $database); break;
|
||||
case 'C': $ok = $conn->Connect($host, $user, $password, $database); break;
|
||||
case 'N': $ok = $conn->NConnect($host, $user, $password, $database); break;
|
||||
|
||||
if (empty($conn->_connectionID)) { // not dsn
|
||||
if ($persist) {
|
||||
switch($persist) {
|
||||
default:
|
||||
case 'P': $ok = $conn->PConnect($host, $user, $password, $database); break;
|
||||
case 'C': $ok = $conn->Connect($host, $user, $password, $database); break;
|
||||
case 'N': $ok = $conn->NConnect($host, $user, $password, $database); break;
|
||||
}
|
||||
} else {
|
||||
$ok = $conn->Connect($host, $user, $password, $database);
|
||||
}
|
||||
} else {
|
||||
$ok = $conn->Connect($host, $user, $password, $database);
|
||||
$ok = true; // $conn->_connectionID is set after call to ADONewConnection
|
||||
}
|
||||
|
||||
if ($ok) $GLOBALS['ADODB_SESS_CONN'] = $conn;
|
||||
else
|
||||
ADOConnection::outp('<p>Session: connection failed</p>', false);
|
||||
|
||||
|
||||
|
||||
return $ok;
|
||||
}
|
||||
@@ -592,7 +598,7 @@ class ADODB_Session {
|
||||
/*!
|
||||
Close the connection
|
||||
*/
|
||||
static function close()
|
||||
static function close()
|
||||
{
|
||||
/*
|
||||
$conn = ADODB_Session::_conn();
|
||||
@@ -604,7 +610,7 @@ class ADODB_Session {
|
||||
/*
|
||||
Slurp in the session variables and return the serialized string
|
||||
*/
|
||||
static function read($key)
|
||||
static function read($key)
|
||||
{
|
||||
$conn = ADODB_Session::_conn();
|
||||
$filter = ADODB_Session::filter();
|
||||
@@ -617,9 +623,12 @@ class ADODB_Session {
|
||||
//assert('$table');
|
||||
|
||||
$binary = $conn->dataProvider === 'mysql' ? '/*! BINARY */' : '';
|
||||
|
||||
$sql = "SELECT sessdata FROM $table WHERE sesskey = $binary ".$conn->Param(0)." AND expiry >= " . $conn->sysTimeStamp;
|
||||
/* Lock code does not work as it needs to hold transaction within whole page, and we don't know if
|
||||
|
||||
global $ADODB_SESSION_SELECT_FIELDS;
|
||||
if (!isset($ADODB_SESSION_SELECT_FIELDS)) $ADODB_SESSION_SELECT_FIELDS = 'sessdata';
|
||||
$sql = "SELECT $ADODB_SESSION_SELECT_FIELDS FROM $table WHERE sesskey = $binary ".$conn->Param(0)." AND expiry >= " . $conn->sysTimeStamp;
|
||||
|
||||
/* Lock code does not work as it needs to hold transaction within whole page, and we don't know if
|
||||
developer has commited elsewhere... :(
|
||||
*/
|
||||
#if (ADODB_Session::Lock())
|
||||
@@ -655,12 +664,12 @@ class ADODB_Session {
|
||||
|
||||
If the data has not been modified since the last read(), we do not write.
|
||||
*/
|
||||
static function write($key, $oval)
|
||||
static function write($key, $oval)
|
||||
{
|
||||
global $ADODB_SESSION_READONLY;
|
||||
|
||||
|
||||
if (!empty($ADODB_SESSION_READONLY)) return;
|
||||
|
||||
|
||||
$clob = ADODB_Session::clob();
|
||||
$conn = ADODB_Session::_conn();
|
||||
$crc = ADODB_Session::_crc();
|
||||
@@ -670,13 +679,13 @@ class ADODB_Session {
|
||||
$filter = ADODB_Session::filter();
|
||||
$lifetime = ADODB_Session::lifetime();
|
||||
$table = ADODB_Session::table();
|
||||
|
||||
|
||||
if (!$conn) {
|
||||
return false;
|
||||
}
|
||||
if ($debug) $conn->debug = 1;
|
||||
$sysTimeStamp = $conn->sysTimeStamp;
|
||||
|
||||
|
||||
//assert('$table');
|
||||
|
||||
$expiry = $conn->OffsetDate($lifetime/(24*3600),$sysTimeStamp);
|
||||
@@ -685,11 +694,11 @@ class ADODB_Session {
|
||||
|
||||
// crc32 optimization since adodb 2.1
|
||||
// now we only update expiry date, thx to sebastian thom in adodb 2.32
|
||||
if ($crc !== false && $crc == (strlen($oval) . crc32($oval))) {
|
||||
if ($crc !== '00' && $crc !== false && $crc == (strlen($oval) . crc32($oval))) {
|
||||
if ($debug) {
|
||||
echo '<p>Session: Only updating date - crc32 not changed</p>';
|
||||
}
|
||||
|
||||
|
||||
$expirevar = '';
|
||||
if ($expire_notify) {
|
||||
$var = reset($expire_notify);
|
||||
@@ -698,8 +707,8 @@ class ADODB_Session {
|
||||
$expirevar = $$var;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$sql = "UPDATE $table SET expiry = $expiry ,expireref=".$conn->Param('0').", modified = $sysTimeStamp WHERE $binary sesskey = ".$conn->Param('1')." AND expiry >= $sysTimeStamp";
|
||||
$rs = $conn->Execute($sql,array($expirevar,$key));
|
||||
return true;
|
||||
@@ -718,61 +727,48 @@ class ADODB_Session {
|
||||
if (isset($$var)) {
|
||||
$expireref = $$var;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$clob) { // no lobs, simply use replace()
|
||||
$rs = $conn->Execute("SELECT COUNT(*) AS cnt FROM $table WHERE $binary sesskey = ".$conn->Param(0),array($key));
|
||||
if ($rs) $rs->Close();
|
||||
|
||||
|
||||
if ($rs && reset($rs->fields) > 0) {
|
||||
$sql = "UPDATE $table SET expiry=$expiry, sessdata=".$conn->Param(0).", expireref= ".$conn->Param(1).",modified=$sysTimeStamp WHERE sesskey = ".$conn->Param('2');
|
||||
|
||||
$sql = "UPDATE $table SET expiry=$expiry, sessdata=".$conn->Param(0).", expireref= ".$conn->Param(1).",modified=$sysTimeStamp WHERE sesskey = ".$conn->Param(2);
|
||||
|
||||
} else {
|
||||
$sql = "INSERT INTO $table (expiry, sessdata, expireref, sesskey, created, modified)
|
||||
$sql = "INSERT INTO $table (expiry, sessdata, expireref, sesskey, created, modified)
|
||||
VALUES ($expiry,".$conn->Param('0').", ". $conn->Param('1').", ".$conn->Param('2').", $sysTimeStamp, $sysTimeStamp)";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$rs = $conn->Execute($sql,array($val,$expireref,$key));
|
||||
|
||||
|
||||
} else {
|
||||
// what value shall we insert/update for lob row?
|
||||
switch ($driver) {
|
||||
// empty_clob or empty_lob for oracle dbs
|
||||
case 'oracle':
|
||||
case 'oci8':
|
||||
case 'oci8po':
|
||||
case 'oci805':
|
||||
$lob_value = sprintf('empty_%s()', strtolower($clob));
|
||||
break;
|
||||
if (strncmp($driver, 'oci8', 4) == 0) $lob_value = sprintf('empty_%s()', strtolower($clob));
|
||||
else $lob_value = 'null';
|
||||
|
||||
// null for all other
|
||||
default:
|
||||
$lob_value = 'null';
|
||||
break;
|
||||
}
|
||||
|
||||
$conn->StartTrans();
|
||||
|
||||
|
||||
$rs = $conn->Execute("SELECT COUNT(*) AS cnt FROM $table WHERE $binary sesskey = ".$conn->Param(0),array($key));
|
||||
if ($rs) $rs->Close();
|
||||
|
||||
|
||||
if ($rs && reset($rs->fields) > 0) {
|
||||
$sql = "UPDATE $table SET expiry=$expiry, sessdata=$lob_value, expireref= ".$conn->Param(0).",modified=$sysTimeStamp WHERE sesskey = ".$conn->Param('1');
|
||||
|
||||
|
||||
} else {
|
||||
$sql = "INSERT INTO $table (expiry, sessdata, expireref, sesskey, created, modified)
|
||||
$sql = "INSERT INTO $table (expiry, sessdata, expireref, sesskey, created, modified)
|
||||
VALUES ($expiry,$lob_value, ". $conn->Param('0').", ".$conn->Param('1').", $sysTimeStamp, $sysTimeStamp)";
|
||||
}
|
||||
|
||||
|
||||
$rs = $conn->Execute($sql,array($expireref,$key));
|
||||
|
||||
|
||||
$qkey = $conn->qstr($key);
|
||||
$rs2 = $conn->UpdateBlob($table, 'sessdata', $val, " sesskey=$qkey", strtoupper($clob));
|
||||
if ($debug) echo "<hr>",htmlspecialchars($oval), "<hr>";
|
||||
$rs = @$conn->CompleteTrans();
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (!$rs) {
|
||||
@@ -845,7 +841,7 @@ class ADODB_Session {
|
||||
|
||||
/*!
|
||||
*/
|
||||
static function gc($maxlifetime)
|
||||
static function gc($maxlifetime)
|
||||
{
|
||||
$conn = ADODB_Session::_conn();
|
||||
$debug = ADODB_Session::debug();
|
||||
@@ -865,7 +861,7 @@ class ADODB_Session {
|
||||
} else {
|
||||
$COMMITNUM = 20;
|
||||
}
|
||||
|
||||
|
||||
//assert('$table');
|
||||
|
||||
$time = $conn->OffsetDate(-$maxlifetime/24/3600,$conn->sysTimeStamp);
|
||||
@@ -877,12 +873,12 @@ class ADODB_Session {
|
||||
} else {
|
||||
$fn = false;
|
||||
}
|
||||
|
||||
|
||||
$savem = $conn->SetFetchMode(ADODB_FETCH_NUM);
|
||||
$sql = "SELECT expireref, sesskey FROM $table WHERE expiry < $time ORDER BY 2"; # add order by to prevent deadlock
|
||||
$rs = $conn->SelectLimit($sql,1000);
|
||||
ADODB_Session::_dumprs($rs);
|
||||
if ($debug) $conn->SetFetchMode($savem);
|
||||
if ($debug) ADODB_Session::_dumprs($rs);
|
||||
$conn->SetFetchMode($savem);
|
||||
if ($rs) {
|
||||
$tr = $conn->hasTransactions;
|
||||
if ($tr) $conn->BeginTrans();
|
||||
@@ -902,10 +898,10 @@ class ADODB_Session {
|
||||
}
|
||||
}
|
||||
$rs->Close();
|
||||
|
||||
|
||||
if ($tr) $conn->CommitTrans();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// suggested by Cameron, "GaM3R" <gamr@outworld.cx>
|
||||
if ($optimize) {
|
||||
@@ -922,7 +918,7 @@ class ADODB_Session {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -938,8 +934,6 @@ function adodb_sess_open($save_path, $session_name, $persist = true) {
|
||||
|
||||
// for backwards compatability only
|
||||
function adodb_sess_gc($t)
|
||||
{
|
||||
{
|
||||
return ADODB_Session::gc($t);
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
-- $CVSHeader$
|
||||
|
||||
CREATE DATABASE /*! IF NOT EXISTS */ adodb_sessions;
|
||||
|
||||
USE adodb_sessions;
|
||||
|
||||
DROP TABLE /*! IF EXISTS */ sessions;
|
||||
|
||||
CREATE TABLE /*! IF NOT EXISTS */ sessions (
|
||||
sesskey CHAR(32) /*! BINARY */ NOT NULL DEFAULT '',
|
||||
expiry INT(11) /*! UNSIGNED */ NOT NULL DEFAULT 0,
|
||||
expireref VARCHAR(64) DEFAULT '',
|
||||
data LONGTEXT DEFAULT '',
|
||||
PRIMARY KEY (sesskey),
|
||||
INDEX expiry (expiry)
|
||||
);
|
||||
@@ -1,15 +0,0 @@
|
||||
-- $CVSHeader$
|
||||
|
||||
DROP TABLE adodb_sessions;
|
||||
|
||||
CREATE TABLE sessions (
|
||||
sesskey CHAR(32) DEFAULT '' NOT NULL,
|
||||
expiry INT DEFAULT 0 NOT NULL,
|
||||
expireref VARCHAR(64) DEFAULT '',
|
||||
data CLOB DEFAULT '',
|
||||
PRIMARY KEY (sesskey)
|
||||
);
|
||||
|
||||
CREATE INDEX ix_expiry ON sessions (expiry);
|
||||
|
||||
QUIT;
|
||||
@@ -1,16 +0,0 @@
|
||||
-- $CVSHeader$
|
||||
|
||||
DROP TABLE adodb_sessions;
|
||||
|
||||
CREATE TABLE sessions (
|
||||
sesskey CHAR(32) DEFAULT '' NOT NULL,
|
||||
expiry INT DEFAULT 0 NOT NULL,
|
||||
expireref VARCHAR(64) DEFAULT '',
|
||||
data VARCHAR(4000) DEFAULT '',
|
||||
PRIMARY KEY (sesskey),
|
||||
INDEX expiry (expiry)
|
||||
);
|
||||
|
||||
CREATE INDEX ix_expiry ON sessions (expiry);
|
||||
|
||||
QUIT;
|
||||
@@ -64,7 +64,6 @@ class MD5Crypt{
|
||||
|
||||
|
||||
class SHA1Crypt{
|
||||
|
||||
function keyED($txt,$encrypt_key)
|
||||
{
|
||||
|
||||
@@ -81,8 +80,6 @@ class SHA1Crypt{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function Encrypt($txt,$key)
|
||||
{
|
||||
|
||||
@@ -158,4 +155,3 @@ class SHA1Crypt{
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -1,26 +1,28 @@
|
||||
<?php
|
||||
/*
|
||||
V5.09 25 June 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
Released under both BSD license and Lesser GPL library license.
|
||||
Whenever there is any discrepancy between the two licenses,
|
||||
@version v5.20.9 21-Dec-2016
|
||||
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
|
||||
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.
|
||||
Made table name configurable - by David Johnson djohnson@inpro.net
|
||||
Encryption by Ari Kuorikoski <ari.kuorikoski@finebyte.com>
|
||||
|
||||
|
||||
Set tabs to 4 for best viewing.
|
||||
|
||||
|
||||
Latest version of ADODB is available at http://php.weblogs.com/adodb
|
||||
======================================================================
|
||||
|
||||
|
||||
This file provides PHP4 session management using the ADODB database
|
||||
wrapper library.
|
||||
|
||||
|
||||
Example
|
||||
=======
|
||||
|
||||
|
||||
include('adodb.inc.php');
|
||||
#---------------------------------#
|
||||
include('adodb-cryptsession.php');
|
||||
include('adodb-cryptsession.php');
|
||||
#---------------------------------#
|
||||
session_start();
|
||||
session_register('AVAR');
|
||||
@@ -28,12 +30,12 @@ wrapper library.
|
||||
print "
|
||||
-- \$_SESSION['AVAR']={$_SESSION['AVAR']}</p>";
|
||||
|
||||
|
||||
|
||||
Installation
|
||||
============
|
||||
1. Create a new database in MySQL or Access "sessions" like
|
||||
so:
|
||||
|
||||
|
||||
create table sessions (
|
||||
SESSKEY char(32) not null,
|
||||
EXPIRY int(11) unsigned not null,
|
||||
@@ -41,17 +43,17 @@ so:
|
||||
DATA CLOB,
|
||||
primary key (sesskey)
|
||||
);
|
||||
|
||||
|
||||
2. Then define the following parameters. You can either modify
|
||||
this file, or define them before this file is included:
|
||||
|
||||
|
||||
$ADODB_SESSION_DRIVER='database driver, eg. mysql or ibase';
|
||||
$ADODB_SESSION_CONNECT='server to connect to';
|
||||
$ADODB_SESSION_USER ='user';
|
||||
$ADODB_SESSION_PWD ='password';
|
||||
$ADODB_SESSION_DB ='database';
|
||||
$ADODB_SESSION_TBL = 'sessions'
|
||||
|
||||
|
||||
3. Recommended is PHP 4.0.2 or later. There are documented
|
||||
session bugs in earlier versions of PHP.
|
||||
|
||||
@@ -65,13 +67,13 @@ if (!defined('_ADODB_LAYER')) {
|
||||
}
|
||||
|
||||
/* if database time and system time is difference is greater than this, then give warning */
|
||||
define('ADODB_SESSION_SYNCH_SECS',60);
|
||||
define('ADODB_SESSION_SYNCH_SECS',60);
|
||||
|
||||
if (!defined('ADODB_SESSION')) {
|
||||
|
||||
define('ADODB_SESSION',1);
|
||||
|
||||
GLOBAL $ADODB_SESSION_CONNECT,
|
||||
|
||||
GLOBAL $ADODB_SESSION_CONNECT,
|
||||
$ADODB_SESSION_DRIVER,
|
||||
$ADODB_SESSION_USER,
|
||||
$ADODB_SESSION_PWD,
|
||||
@@ -81,10 +83,10 @@ GLOBAL $ADODB_SESSION_CONNECT,
|
||||
$ADODB_SESS_DEBUG,
|
||||
$ADODB_SESS_INSERT,
|
||||
$ADODB_SESSION_EXPIRE_NOTIFY,
|
||||
$ADODB_SESSION_TBL;
|
||||
$ADODB_SESSION_TBL;
|
||||
|
||||
//$ADODB_SESS_DEBUG = true;
|
||||
|
||||
|
||||
/* SET THE FOLLOWING PARAMETERS */
|
||||
if (empty($ADODB_SESSION_DRIVER)) {
|
||||
$ADODB_SESSION_DRIVER='mysql';
|
||||
@@ -102,7 +104,7 @@ if (empty($ADODB_SESSION_EXPIRE_NOTIFY)) {
|
||||
$ADODB_SESSION_EXPIRE_NOTIFY = false;
|
||||
}
|
||||
|
||||
function ADODB_Session_Key()
|
||||
function ADODB_Session_Key()
|
||||
{
|
||||
$ADODB_CRYPT_KEY = 'CRYPTED ADODB SESSIONS ROCK!';
|
||||
|
||||
@@ -118,20 +120,20 @@ if ($ADODB_SESS_LIFE <= 1) {
|
||||
$ADODB_SESS_LIFE=1440;
|
||||
}
|
||||
|
||||
function adodb_sess_open($save_path, $session_name)
|
||||
function adodb_sess_open($save_path, $session_name)
|
||||
{
|
||||
GLOBAL $ADODB_SESSION_CONNECT,
|
||||
GLOBAL $ADODB_SESSION_CONNECT,
|
||||
$ADODB_SESSION_DRIVER,
|
||||
$ADODB_SESSION_USER,
|
||||
$ADODB_SESSION_PWD,
|
||||
$ADODB_SESSION_DB,
|
||||
$ADODB_SESS_CONN,
|
||||
$ADODB_SESS_DEBUG;
|
||||
|
||||
|
||||
$ADODB_SESS_INSERT = false;
|
||||
|
||||
|
||||
if (isset($ADODB_SESS_CONN)) return true;
|
||||
|
||||
|
||||
$ADODB_SESS_CONN = ADONewConnection($ADODB_SESSION_DRIVER);
|
||||
if (!empty($ADODB_SESS_DEBUG)) {
|
||||
$ADODB_SESS_CONN->debug = true;
|
||||
@@ -139,10 +141,10 @@ GLOBAL $ADODB_SESSION_CONNECT,
|
||||
}
|
||||
return $ADODB_SESS_CONN->PConnect($ADODB_SESSION_CONNECT,
|
||||
$ADODB_SESSION_USER,$ADODB_SESSION_PWD,$ADODB_SESSION_DB);
|
||||
|
||||
|
||||
}
|
||||
|
||||
function adodb_sess_close()
|
||||
function adodb_sess_close()
|
||||
{
|
||||
global $ADODB_SESS_CONN;
|
||||
|
||||
@@ -150,7 +152,7 @@ global $ADODB_SESS_CONN;
|
||||
return true;
|
||||
}
|
||||
|
||||
function adodb_sess_read($key)
|
||||
function adodb_sess_read($key)
|
||||
{
|
||||
$Crypt = new MD5Crypt;
|
||||
global $ADODB_SESS_CONN,$ADODB_SESS_INSERT,$ADODB_SESSION_TBL;
|
||||
@@ -167,20 +169,20 @@ global $ADODB_SESS_CONN,$ADODB_SESS_INSERT,$ADODB_SESSION_TBL;
|
||||
return $v;
|
||||
}
|
||||
else $ADODB_SESS_INSERT = true;
|
||||
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
function adodb_sess_write($key, $val)
|
||||
function adodb_sess_write($key, $val)
|
||||
{
|
||||
$Crypt = new MD5Crypt;
|
||||
global $ADODB_SESS_INSERT,$ADODB_SESS_CONN, $ADODB_SESS_LIFE, $ADODB_SESSION_TBL,$ADODB_SESSION_EXPIRE_NOTIFY;
|
||||
|
||||
$expiry = time() + $ADODB_SESS_LIFE;
|
||||
|
||||
// encrypt session data..
|
||||
// encrypt session data..
|
||||
$val = $Crypt->Encrypt(rawurlencode($val), ADODB_Session_Key());
|
||||
|
||||
|
||||
$arr = array('sesskey' => $key, 'expiry' => $expiry, 'data' => $val);
|
||||
if ($ADODB_SESSION_EXPIRE_NOTIFY) {
|
||||
$var = reset($ADODB_SESSION_EXPIRE_NOTIFY);
|
||||
@@ -197,16 +199,16 @@ $Crypt = new MD5Crypt;
|
||||
} else {
|
||||
// bug in access driver (could be odbc?) means that info is not commited
|
||||
// properly unless select statement executed in Win2000
|
||||
|
||||
|
||||
if ($ADODB_SESS_CONN->databaseType == 'access') $rs = $ADODB_SESS_CONN->Execute("select sesskey from $ADODB_SESSION_TBL WHERE sesskey='$key'");
|
||||
}
|
||||
return isset($rs);
|
||||
}
|
||||
|
||||
function adodb_sess_destroy($key)
|
||||
function adodb_sess_destroy($key)
|
||||
{
|
||||
global $ADODB_SESS_CONN, $ADODB_SESSION_TBL,$ADODB_SESSION_EXPIRE_NOTIFY;
|
||||
|
||||
|
||||
if ($ADODB_SESSION_EXPIRE_NOTIFY) {
|
||||
reset($ADODB_SESSION_EXPIRE_NOTIFY);
|
||||
$fn = next($ADODB_SESSION_EXPIRE_NOTIFY);
|
||||
@@ -252,7 +254,7 @@ function adodb_sess_gc($maxlifetime) {
|
||||
$rs->MoveNext();
|
||||
}
|
||||
$rs->Close();
|
||||
|
||||
|
||||
$ADODB_SESS_CONN->Execute("DELETE FROM $ADODB_SESSION_TBL WHERE expiry < $t");
|
||||
$ADODB_SESS_CONN->CommitTrans();
|
||||
}
|
||||
@@ -260,12 +262,12 @@ function adodb_sess_gc($maxlifetime) {
|
||||
$qry = "DELETE FROM $ADODB_SESSION_TBL WHERE expiry < " . time();
|
||||
$ADODB_SESS_CONN->Execute($qry);
|
||||
}
|
||||
|
||||
|
||||
// suggested by Cameron, "GaM3R" <gamr@outworld.cx>
|
||||
if (defined('ADODB_SESSION_OPTIMIZE'))
|
||||
{
|
||||
global $ADODB_SESSION_DRIVER;
|
||||
|
||||
|
||||
switch( $ADODB_SESSION_DRIVER ) {
|
||||
case 'mysql':
|
||||
case 'mysqlt':
|
||||
@@ -273,34 +275,34 @@ function adodb_sess_gc($maxlifetime) {
|
||||
break;
|
||||
case 'postgresql':
|
||||
case 'postgresql7':
|
||||
$opt_qry = 'VACUUM '.$ADODB_SESSION_TBL;
|
||||
$opt_qry = 'VACUUM '.$ADODB_SESSION_TBL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($ADODB_SESS_CONN->dataProvider === 'oci8') $sql = 'select TO_CHAR('.($ADODB_SESS_CONN->sysTimeStamp).', \'RRRR-MM-DD HH24:MI:SS\') from '. $ADODB_SESSION_TBL;
|
||||
else $sql = 'select '.$ADODB_SESS_CONN->sysTimeStamp.' from '. $ADODB_SESSION_TBL;
|
||||
|
||||
|
||||
$rs = $ADODB_SESS_CONN->SelectLimit($sql,1);
|
||||
if ($rs && !$rs->EOF) {
|
||||
|
||||
|
||||
$dbts = reset($rs->fields);
|
||||
$rs->Close();
|
||||
$dbt = $ADODB_SESS_CONN->UnixTimeStamp($dbts);
|
||||
$t = time();
|
||||
if (abs($dbt - $t) >= ADODB_SESSION_SYNCH_SECS) {
|
||||
$msg =
|
||||
$msg =
|
||||
__FILE__.": Server time for webserver {$_SERVER['HTTP_HOST']} not in synch with database: database=$dbt ($dbts), webserver=$t (diff=".(abs($dbt-$t)/3600)." hrs)";
|
||||
error_log($msg);
|
||||
if ($ADODB_SESS_DEBUG) ADOConnection::outp("
|
||||
-- $msg</p>");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
session_module_name('user');
|
||||
session_module_name('user');
|
||||
session_set_save_handler(
|
||||
"adodb_sess_open",
|
||||
"adodb_sess_close",
|
||||
@@ -321,4 +323,3 @@ if (0) {
|
||||
-- \$_SESSION['AVAR']={$_SESSION['AVAR']}</p>";
|
||||
}
|
||||
*/
|
||||
?>
|
||||
|
||||
@@ -1,20 +1,22 @@
|
||||
<?php
|
||||
/*
|
||||
V4.93 10 Oct 2006 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
Released under both BSD license and Lesser GPL library license.
|
||||
Whenever there is any discrepancy between the two licenses,
|
||||
@version v5.20.9 21-Dec-2016
|
||||
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
|
||||
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.
|
||||
|
||||
|
||||
Latest version of ADODB is available at http://php.weblogs.com/adodb
|
||||
======================================================================
|
||||
|
||||
|
||||
This file provides PHP4 session management using the ADODB database
|
||||
wrapper library, using Oracle CLOB's to store data. Contributed by achim.gosse@ddd.de.
|
||||
|
||||
Example
|
||||
=======
|
||||
|
||||
|
||||
include('adodb.inc.php');
|
||||
include('adodb-session.php');
|
||||
session_start();
|
||||
@@ -22,7 +24,7 @@
|
||||
$_SESSION['AVAR'] += 1;
|
||||
print "
|
||||
-- \$_SESSION['AVAR']={$_SESSION['AVAR']}</p>";
|
||||
|
||||
|
||||
To force non-persistent connections, call adodb_session_open first before session_start():
|
||||
|
||||
include('adodb.inc.php');
|
||||
@@ -34,11 +36,11 @@ To force non-persistent connections, call adodb_session_open first before sessio
|
||||
print "
|
||||
-- \$_SESSION['AVAR']={$_SESSION['AVAR']}</p>";
|
||||
|
||||
|
||||
|
||||
Installation
|
||||
============
|
||||
1. Create this table in your database (syntax might vary depending on your db):
|
||||
|
||||
|
||||
create table sessions (
|
||||
SESSKEY char(32) not null,
|
||||
EXPIRY int(11) unsigned not null,
|
||||
@@ -56,7 +58,7 @@ To force non-persistent connections, call adodb_session_open first before sessio
|
||||
$ADODB_SESSION_DB ='database';
|
||||
$ADODB_SESSION_TBL = 'sessions'
|
||||
$ADODB_SESSION_USE_LOBS = false; (or, if you wanna use CLOBS (= 'CLOB') or ( = 'BLOB')
|
||||
|
||||
|
||||
3. Recommended is PHP 4.1.0 or later. There are documented
|
||||
session bugs in earlier versions of PHP.
|
||||
|
||||
@@ -64,24 +66,24 @@ To force non-persistent connections, call adodb_session_open first before sessio
|
||||
you can tag a session with an EXPIREREF, and before the session
|
||||
record is deleted, we can call a function that will pass the EXPIREREF
|
||||
as the first parameter, and the session key as the second parameter.
|
||||
|
||||
|
||||
To do this, define a notification function, say NotifyFn:
|
||||
|
||||
|
||||
function NotifyFn($expireref, $sesskey)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Then you need to define a global variable $ADODB_SESSION_EXPIRE_NOTIFY.
|
||||
This is an array with 2 elements, the first being the name of the variable
|
||||
you would like to store in the EXPIREREF field, and the 2nd is the
|
||||
you would like to store in the EXPIREREF field, and the 2nd is the
|
||||
notification function's name.
|
||||
|
||||
In this example, we want to be notified when a user's session
|
||||
has expired, so we store the user id in the global variable $USERID,
|
||||
|
||||
In this example, we want to be notified when a user's session
|
||||
has expired, so we store the user id in the global variable $USERID,
|
||||
store this value in the EXPIREREF field:
|
||||
|
||||
|
||||
$ADODB_SESSION_EXPIRE_NOTIFY = array('USERID','NotifyFn');
|
||||
|
||||
|
||||
Then when the NotifyFn is called, we are passed the $USERID as the first
|
||||
parameter, eg. NotifyFn($userid, $sesskey).
|
||||
*/
|
||||
@@ -93,14 +95,14 @@ if (!defined('_ADODB_LAYER')) {
|
||||
if (!defined('ADODB_SESSION')) {
|
||||
|
||||
define('ADODB_SESSION',1);
|
||||
|
||||
|
||||
/* if database time and system time is difference is greater than this, then give warning */
|
||||
define('ADODB_SESSION_SYNCH_SECS',60);
|
||||
define('ADODB_SESSION_SYNCH_SECS',60);
|
||||
|
||||
/****************************************************************************************\
|
||||
Global definitions
|
||||
\****************************************************************************************/
|
||||
GLOBAL $ADODB_SESSION_CONNECT,
|
||||
GLOBAL $ADODB_SESSION_CONNECT,
|
||||
$ADODB_SESSION_DRIVER,
|
||||
$ADODB_SESSION_USER,
|
||||
$ADODB_SESSION_PWD,
|
||||
@@ -112,9 +114,9 @@ GLOBAL $ADODB_SESSION_CONNECT,
|
||||
$ADODB_SESSION_CRC,
|
||||
$ADODB_SESSION_USE_LOBS,
|
||||
$ADODB_SESSION_TBL;
|
||||
|
||||
|
||||
if (!isset($ADODB_SESSION_USE_LOBS)) $ADODB_SESSION_USE_LOBS = 'CLOB';
|
||||
|
||||
|
||||
$ADODB_SESS_LIFE = ini_get('session.gc_maxlifetime');
|
||||
if ($ADODB_SESS_LIFE <= 1) {
|
||||
// bug in PHP 4.0.3 pl 1 -- how about other versions?
|
||||
@@ -123,11 +125,11 @@ GLOBAL $ADODB_SESSION_CONNECT,
|
||||
}
|
||||
$ADODB_SESSION_CRC = false;
|
||||
//$ADODB_SESS_DEBUG = true;
|
||||
|
||||
|
||||
//////////////////////////////////
|
||||
/* SET THE FOLLOWING PARAMETERS */
|
||||
//////////////////////////////////
|
||||
|
||||
|
||||
if (empty($ADODB_SESSION_DRIVER)) {
|
||||
$ADODB_SESSION_DRIVER='mysql';
|
||||
$ADODB_SESSION_CONNECT='localhost';
|
||||
@@ -135,7 +137,7 @@ GLOBAL $ADODB_SESSION_CONNECT,
|
||||
$ADODB_SESSION_PWD ='';
|
||||
$ADODB_SESSION_DB ='xphplens_2';
|
||||
}
|
||||
|
||||
|
||||
if (empty($ADODB_SESSION_EXPIRE_NOTIFY)) {
|
||||
$ADODB_SESSION_EXPIRE_NOTIFY = false;
|
||||
}
|
||||
@@ -143,7 +145,7 @@ GLOBAL $ADODB_SESSION_CONNECT,
|
||||
if (empty($ADODB_SESSION_TBL)){
|
||||
$ADODB_SESSION_TBL = 'sessions';
|
||||
}
|
||||
|
||||
|
||||
|
||||
// defaulting $ADODB_SESSION_USE_LOBS
|
||||
if (!isset($ADODB_SESSION_USE_LOBS) || empty($ADODB_SESSION_USE_LOBS)) {
|
||||
@@ -158,28 +160,28 @@ GLOBAL $ADODB_SESSION_CONNECT,
|
||||
$ADODB_SESS['db'] = $ADODB_SESSION_DB;
|
||||
$ADODB_SESS['life'] = $ADODB_SESS_LIFE;
|
||||
$ADODB_SESS['debug'] = $ADODB_SESS_DEBUG;
|
||||
|
||||
|
||||
$ADODB_SESS['debug'] = $ADODB_SESS_DEBUG;
|
||||
$ADODB_SESS['table'] = $ADODB_SESS_TBL;
|
||||
*/
|
||||
|
||||
|
||||
/****************************************************************************************\
|
||||
Create the connection to the database.
|
||||
|
||||
Create the connection to the database.
|
||||
|
||||
If $ADODB_SESS_CONN already exists, reuse that connection
|
||||
\****************************************************************************************/
|
||||
function adodb_sess_open($save_path, $session_name,$persist=true)
|
||||
function adodb_sess_open($save_path, $session_name,$persist=true)
|
||||
{
|
||||
GLOBAL $ADODB_SESS_CONN;
|
||||
if (isset($ADODB_SESS_CONN)) return true;
|
||||
|
||||
GLOBAL $ADODB_SESSION_CONNECT,
|
||||
|
||||
GLOBAL $ADODB_SESSION_CONNECT,
|
||||
$ADODB_SESSION_DRIVER,
|
||||
$ADODB_SESSION_USER,
|
||||
$ADODB_SESSION_PWD,
|
||||
$ADODB_SESSION_DB,
|
||||
$ADODB_SESS_DEBUG;
|
||||
|
||||
|
||||
// cannot use & below - do not know why...
|
||||
$ADODB_SESS_CONN = ADONewConnection($ADODB_SESSION_DRIVER);
|
||||
if (!empty($ADODB_SESS_DEBUG)) {
|
||||
@@ -190,7 +192,7 @@ GLOBAL $ADODB_SESSION_CONNECT,
|
||||
$ADODB_SESSION_USER,$ADODB_SESSION_PWD,$ADODB_SESSION_DB);
|
||||
else $ok = $ADODB_SESS_CONN->Connect($ADODB_SESSION_CONNECT,
|
||||
$ADODB_SESSION_USER,$ADODB_SESSION_PWD,$ADODB_SESSION_DB);
|
||||
|
||||
|
||||
if (!$ok) ADOConnection::outp( "
|
||||
-- Session: connection failed</p>",false);
|
||||
}
|
||||
@@ -198,7 +200,7 @@ GLOBAL $ADODB_SESSION_CONNECT,
|
||||
/****************************************************************************************\
|
||||
Close the connection
|
||||
\****************************************************************************************/
|
||||
function adodb_sess_close()
|
||||
function adodb_sess_close()
|
||||
{
|
||||
global $ADODB_SESS_CONN;
|
||||
|
||||
@@ -209,7 +211,7 @@ global $ADODB_SESS_CONN;
|
||||
/****************************************************************************************\
|
||||
Slurp in the session variables and return the serialized string
|
||||
\****************************************************************************************/
|
||||
function adodb_sess_read($key)
|
||||
function adodb_sess_read($key)
|
||||
{
|
||||
global $ADODB_SESS_CONN,$ADODB_SESSION_TBL,$ADODB_SESSION_CRC;
|
||||
|
||||
@@ -217,50 +219,50 @@ global $ADODB_SESS_CONN,$ADODB_SESSION_TBL,$ADODB_SESSION_CRC;
|
||||
if ($rs) {
|
||||
if ($rs->EOF) {
|
||||
$v = '';
|
||||
} else
|
||||
} else
|
||||
$v = rawurldecode(reset($rs->fields));
|
||||
|
||||
|
||||
$rs->Close();
|
||||
|
||||
|
||||
// new optimization adodb 2.1
|
||||
$ADODB_SESSION_CRC = strlen($v).crc32($v);
|
||||
|
||||
|
||||
return $v;
|
||||
}
|
||||
|
||||
|
||||
return ''; // thx to Jorma Tuomainen, webmaster#wizactive.com
|
||||
}
|
||||
|
||||
/****************************************************************************************\
|
||||
Write the serialized data to a database.
|
||||
|
||||
|
||||
If the data has not been modified since adodb_sess_read(), we do not write.
|
||||
\****************************************************************************************/
|
||||
function adodb_sess_write($key, $val)
|
||||
function adodb_sess_write($key, $val)
|
||||
{
|
||||
global
|
||||
$ADODB_SESS_CONN,
|
||||
$ADODB_SESS_LIFE,
|
||||
$ADODB_SESS_CONN,
|
||||
$ADODB_SESS_LIFE,
|
||||
$ADODB_SESSION_TBL,
|
||||
$ADODB_SESS_DEBUG,
|
||||
$ADODB_SESS_DEBUG,
|
||||
$ADODB_SESSION_CRC,
|
||||
$ADODB_SESSION_EXPIRE_NOTIFY,
|
||||
$ADODB_SESSION_DRIVER, // added
|
||||
$ADODB_SESSION_USE_LOBS; // added
|
||||
|
||||
$expiry = time() + $ADODB_SESS_LIFE;
|
||||
|
||||
|
||||
// crc32 optimization since adodb 2.1
|
||||
// now we only update expiry date, thx to sebastian thom in adodb 2.32
|
||||
if ($ADODB_SESSION_CRC !== false && $ADODB_SESSION_CRC == strlen($val).crc32($val)) {
|
||||
if ($ADODB_SESS_DEBUG) echo "
|
||||
-- Session: Only updating date - crc32 not changed</p>";
|
||||
$qry = "UPDATE $ADODB_SESSION_TBL SET expiry=$expiry WHERE sesskey='$key' AND expiry >= " . time();
|
||||
$rs = $ADODB_SESS_CONN->Execute($qry);
|
||||
$rs = $ADODB_SESS_CONN->Execute($qry);
|
||||
return true;
|
||||
}
|
||||
$val = rawurlencode($val);
|
||||
|
||||
|
||||
$arr = array('sesskey' => $key, 'expiry' => $expiry, 'data' => $val);
|
||||
if ($ADODB_SESSION_EXPIRE_NOTIFY) {
|
||||
$var = reset($ADODB_SESSION_EXPIRE_NOTIFY);
|
||||
@@ -268,7 +270,7 @@ function adodb_sess_write($key, $val)
|
||||
$arr['expireref'] = $$var;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ($ADODB_SESSION_USE_LOBS === false) { // no lobs, simply use replace()
|
||||
$rs = $ADODB_SESS_CONN->Replace($ADODB_SESSION_TBL,$arr, 'sesskey',$autoQuote = true);
|
||||
if (!$rs) {
|
||||
@@ -318,16 +320,16 @@ function adodb_sess_write($key, $val)
|
||||
} else {
|
||||
// bug in access driver (could be odbc?) means that info is not commited
|
||||
// properly unless select statement executed in Win2000
|
||||
if ($ADODB_SESS_CONN->databaseType == 'access')
|
||||
if ($ADODB_SESS_CONN->databaseType == 'access')
|
||||
$rs = $ADODB_SESS_CONN->Execute("select sesskey from $ADODB_SESSION_TBL WHERE sesskey='$key'");
|
||||
}
|
||||
return !empty($rs);
|
||||
}
|
||||
|
||||
function adodb_sess_destroy($key)
|
||||
function adodb_sess_destroy($key)
|
||||
{
|
||||
global $ADODB_SESS_CONN, $ADODB_SESSION_TBL,$ADODB_SESSION_EXPIRE_NOTIFY;
|
||||
|
||||
|
||||
if ($ADODB_SESSION_EXPIRE_NOTIFY) {
|
||||
reset($ADODB_SESSION_EXPIRE_NOTIFY);
|
||||
$fn = next($ADODB_SESSION_EXPIRE_NOTIFY);
|
||||
@@ -352,10 +354,10 @@ function adodb_sess_destroy($key)
|
||||
return $rs ? true : false;
|
||||
}
|
||||
|
||||
function adodb_sess_gc($maxlifetime)
|
||||
function adodb_sess_gc($maxlifetime)
|
||||
{
|
||||
global $ADODB_SESS_DEBUG, $ADODB_SESS_CONN, $ADODB_SESSION_TBL,$ADODB_SESSION_EXPIRE_NOTIFY;
|
||||
|
||||
|
||||
if ($ADODB_SESSION_EXPIRE_NOTIFY) {
|
||||
reset($ADODB_SESSION_EXPIRE_NOTIFY);
|
||||
$fn = next($ADODB_SESSION_EXPIRE_NOTIFY);
|
||||
@@ -373,21 +375,21 @@ function adodb_sess_gc($maxlifetime)
|
||||
$rs->MoveNext();
|
||||
}
|
||||
$rs->Close();
|
||||
|
||||
|
||||
//$ADODB_SESS_CONN->Execute("DELETE FROM $ADODB_SESSION_TBL WHERE expiry < $t");
|
||||
$ADODB_SESS_CONN->CommitTrans();
|
||||
|
||||
|
||||
}
|
||||
} else {
|
||||
$ADODB_SESS_CONN->Execute("DELETE FROM $ADODB_SESSION_TBL WHERE expiry < " . time());
|
||||
|
||||
|
||||
if ($ADODB_SESS_DEBUG) ADOConnection::outp("
|
||||
-- <b>Garbage Collection</b>: $qry</p>");
|
||||
}
|
||||
// suggested by Cameron, "GaM3R" <gamr@outworld.cx>
|
||||
if (defined('ADODB_SESSION_OPTIMIZE')) {
|
||||
global $ADODB_SESSION_DRIVER;
|
||||
|
||||
|
||||
switch( $ADODB_SESSION_DRIVER ) {
|
||||
case 'mysql':
|
||||
case 'mysqlt':
|
||||
@@ -395,7 +397,7 @@ function adodb_sess_gc($maxlifetime)
|
||||
break;
|
||||
case 'postgresql':
|
||||
case 'postgresql7':
|
||||
$opt_qry = 'VACUUM '.$ADODB_SESSION_TBL;
|
||||
$opt_qry = 'VACUUM '.$ADODB_SESSION_TBL;
|
||||
break;
|
||||
}
|
||||
if (!empty($opt_qry)) {
|
||||
@@ -404,27 +406,27 @@ function adodb_sess_gc($maxlifetime)
|
||||
}
|
||||
if ($ADODB_SESS_CONN->dataProvider === 'oci8') $sql = 'select TO_CHAR('.($ADODB_SESS_CONN->sysTimeStamp).', \'RRRR-MM-DD HH24:MI:SS\') from '. $ADODB_SESSION_TBL;
|
||||
else $sql = 'select '.$ADODB_SESS_CONN->sysTimeStamp.' from '. $ADODB_SESSION_TBL;
|
||||
|
||||
|
||||
$rs = $ADODB_SESS_CONN->SelectLimit($sql,1);
|
||||
if ($rs && !$rs->EOF) {
|
||||
|
||||
|
||||
$dbts = reset($rs->fields);
|
||||
$rs->Close();
|
||||
$dbt = $ADODB_SESS_CONN->UnixTimeStamp($dbts);
|
||||
$t = time();
|
||||
if (abs($dbt - $t) >= ADODB_SESSION_SYNCH_SECS) {
|
||||
$msg =
|
||||
$msg =
|
||||
__FILE__.": Server time for webserver {$_SERVER['HTTP_HOST']} not in synch with database: database=$dbt ($dbts), webserver=$t (diff=".(abs($dbt-$t)/3600)." hrs)";
|
||||
error_log($msg);
|
||||
if ($ADODB_SESS_DEBUG) ADOConnection::outp("
|
||||
-- $msg</p>");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
session_module_name('user');
|
||||
session_module_name('user');
|
||||
session_set_save_handler(
|
||||
"adodb_sess_open",
|
||||
"adodb_sess_close",
|
||||
@@ -444,5 +446,3 @@ if (0) {
|
||||
ADOConnection::outp( "
|
||||
-- \$_SESSION['AVAR']={$_SESSION['AVAR']}</p>",false);
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -1,20 +1,22 @@
|
||||
<?php
|
||||
/*
|
||||
V4.93 10 Oct 2006 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
Released under both BSD license and Lesser GPL library license.
|
||||
Whenever there is any discrepancy between the two licenses,
|
||||
@version v5.20.9 21-Dec-2016
|
||||
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
|
||||
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.
|
||||
|
||||
|
||||
Latest version of ADODB is available at http://php.weblogs.com/adodb
|
||||
======================================================================
|
||||
|
||||
|
||||
This file provides PHP4 session management using the ADODB database
|
||||
wrapper library.
|
||||
|
||||
|
||||
Example
|
||||
=======
|
||||
|
||||
|
||||
include('adodb.inc.php');
|
||||
include('adodb-session.php');
|
||||
session_start();
|
||||
@@ -22,7 +24,7 @@ wrapper library.
|
||||
$_SESSION['AVAR'] += 1;
|
||||
print "
|
||||
-- \$_SESSION['AVAR']={$_SESSION['AVAR']}</p>";
|
||||
|
||||
|
||||
To force non-persistent connections, call adodb_session_open first before session_start():
|
||||
|
||||
include('adodb.inc.php');
|
||||
@@ -34,11 +36,11 @@ To force non-persistent connections, call adodb_session_open first before sessio
|
||||
print "
|
||||
-- \$_SESSION['AVAR']={$_SESSION['AVAR']}</p>";
|
||||
|
||||
|
||||
|
||||
Installation
|
||||
============
|
||||
1. Create this table in your database (syntax might vary depending on your db):
|
||||
|
||||
|
||||
create table sessions (
|
||||
SESSKEY char(32) not null,
|
||||
EXPIRY int(11) unsigned not null,
|
||||
@@ -46,7 +48,7 @@ To force non-persistent connections, call adodb_session_open first before sessio
|
||||
DATA text not null,
|
||||
primary key (sesskey)
|
||||
);
|
||||
|
||||
|
||||
For oracle:
|
||||
create table sessions (
|
||||
SESSKEY char(32) not null,
|
||||
@@ -59,14 +61,14 @@ To force non-persistent connections, call adodb_session_open first before sessio
|
||||
|
||||
2. Then define the following parameters. You can either modify
|
||||
this file, or define them before this file is included:
|
||||
|
||||
|
||||
$ADODB_SESSION_DRIVER='database driver, eg. mysql or ibase';
|
||||
$ADODB_SESSION_CONNECT='server to connect to';
|
||||
$ADODB_SESSION_USER ='user';
|
||||
$ADODB_SESSION_PWD ='password';
|
||||
$ADODB_SESSION_DB ='database';
|
||||
$ADODB_SESSION_TBL = 'sessions'
|
||||
|
||||
|
||||
3. Recommended is PHP 4.1.0 or later. There are documented
|
||||
session bugs in earlier versions of PHP.
|
||||
|
||||
@@ -74,24 +76,24 @@ To force non-persistent connections, call adodb_session_open first before sessio
|
||||
you can tag a session with an EXPIREREF, and before the session
|
||||
record is deleted, we can call a function that will pass the EXPIREREF
|
||||
as the first parameter, and the session key as the second parameter.
|
||||
|
||||
|
||||
To do this, define a notification function, say NotifyFn:
|
||||
|
||||
|
||||
function NotifyFn($expireref, $sesskey)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Then you need to define a global variable $ADODB_SESSION_EXPIRE_NOTIFY.
|
||||
This is an array with 2 elements, the first being the name of the variable
|
||||
you would like to store in the EXPIREREF field, and the 2nd is the
|
||||
you would like to store in the EXPIREREF field, and the 2nd is the
|
||||
notification function's name.
|
||||
|
||||
In this example, we want to be notified when a user's session
|
||||
has expired, so we store the user id in the global variable $USERID,
|
||||
|
||||
In this example, we want to be notified when a user's session
|
||||
has expired, so we store the user id in the global variable $USERID,
|
||||
store this value in the EXPIREREF field:
|
||||
|
||||
|
||||
$ADODB_SESSION_EXPIRE_NOTIFY = array('USERID','NotifyFn');
|
||||
|
||||
|
||||
Then when the NotifyFn is called, we are passed the $USERID as the first
|
||||
parameter, eg. NotifyFn($userid, $sesskey).
|
||||
*/
|
||||
@@ -103,14 +105,14 @@ if (!defined('_ADODB_LAYER')) {
|
||||
if (!defined('ADODB_SESSION')) {
|
||||
|
||||
define('ADODB_SESSION',1);
|
||||
|
||||
|
||||
/* if database time and system time is difference is greater than this, then give warning */
|
||||
define('ADODB_SESSION_SYNCH_SECS',60);
|
||||
define('ADODB_SESSION_SYNCH_SECS',60);
|
||||
|
||||
/*
|
||||
Thanks Joe Li. See http://phplens.com/lens/lensforum/msgs.php?id=11487&x=1
|
||||
*/
|
||||
function adodb_session_regenerate_id()
|
||||
function adodb_session_regenerate_id()
|
||||
{
|
||||
$conn = ADODB_Session::_conn();
|
||||
if (!$conn) return false;
|
||||
@@ -126,7 +128,7 @@ function adodb_session_regenerate_id()
|
||||
}
|
||||
$new_id = session_id();
|
||||
$ok = $conn->Execute('UPDATE '. ADODB_Session::table(). ' SET sesskey='. $conn->qstr($new_id). ' WHERE sesskey='.$conn->qstr($old_id));
|
||||
|
||||
|
||||
/* it is possible that the update statement fails due to a collision */
|
||||
if (!$ok) {
|
||||
session_id($old_id);
|
||||
@@ -134,14 +136,14 @@ function adodb_session_regenerate_id()
|
||||
setcookie(session_name(), session_id(), false, $ck['path'], $ck['domain'], $ck['secure']);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/****************************************************************************************\
|
||||
Global definitions
|
||||
\****************************************************************************************/
|
||||
GLOBAL $ADODB_SESSION_CONNECT,
|
||||
GLOBAL $ADODB_SESSION_CONNECT,
|
||||
$ADODB_SESSION_DRIVER,
|
||||
$ADODB_SESSION_USER,
|
||||
$ADODB_SESSION_PWD,
|
||||
@@ -152,8 +154,8 @@ GLOBAL $ADODB_SESSION_CONNECT,
|
||||
$ADODB_SESSION_EXPIRE_NOTIFY,
|
||||
$ADODB_SESSION_CRC,
|
||||
$ADODB_SESSION_TBL;
|
||||
|
||||
|
||||
|
||||
|
||||
$ADODB_SESS_LIFE = ini_get('session.gc_maxlifetime');
|
||||
if ($ADODB_SESS_LIFE <= 1) {
|
||||
// bug in PHP 4.0.3 pl 1 -- how about other versions?
|
||||
@@ -162,11 +164,11 @@ GLOBAL $ADODB_SESSION_CONNECT,
|
||||
}
|
||||
$ADODB_SESSION_CRC = false;
|
||||
//$ADODB_SESS_DEBUG = true;
|
||||
|
||||
|
||||
//////////////////////////////////
|
||||
/* SET THE FOLLOWING PARAMETERS */
|
||||
//////////////////////////////////
|
||||
|
||||
|
||||
if (empty($ADODB_SESSION_DRIVER)) {
|
||||
$ADODB_SESSION_DRIVER='mysql';
|
||||
$ADODB_SESSION_CONNECT='localhost';
|
||||
@@ -174,7 +176,7 @@ GLOBAL $ADODB_SESSION_CONNECT,
|
||||
$ADODB_SESSION_PWD ='';
|
||||
$ADODB_SESSION_DB ='xphplens_2';
|
||||
}
|
||||
|
||||
|
||||
if (empty($ADODB_SESSION_EXPIRE_NOTIFY)) {
|
||||
$ADODB_SESSION_EXPIRE_NOTIFY = false;
|
||||
}
|
||||
@@ -182,7 +184,7 @@ GLOBAL $ADODB_SESSION_CONNECT,
|
||||
if (empty($ADODB_SESSION_TBL)){
|
||||
$ADODB_SESSION_TBL = 'sessions';
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
$ADODB_SESS['driver'] = $ADODB_SESSION_DRIVER;
|
||||
$ADODB_SESS['connect'] = $ADODB_SESSION_CONNECT;
|
||||
@@ -191,28 +193,28 @@ GLOBAL $ADODB_SESSION_CONNECT,
|
||||
$ADODB_SESS['db'] = $ADODB_SESSION_DB;
|
||||
$ADODB_SESS['life'] = $ADODB_SESS_LIFE;
|
||||
$ADODB_SESS['debug'] = $ADODB_SESS_DEBUG;
|
||||
|
||||
|
||||
$ADODB_SESS['debug'] = $ADODB_SESS_DEBUG;
|
||||
$ADODB_SESS['table'] = $ADODB_SESS_TBL;
|
||||
*/
|
||||
|
||||
|
||||
/****************************************************************************************\
|
||||
Create the connection to the database.
|
||||
|
||||
Create the connection to the database.
|
||||
|
||||
If $ADODB_SESS_CONN already exists, reuse that connection
|
||||
\****************************************************************************************/
|
||||
function adodb_sess_open($save_path, $session_name,$persist=true)
|
||||
function adodb_sess_open($save_path, $session_name,$persist=true)
|
||||
{
|
||||
GLOBAL $ADODB_SESS_CONN;
|
||||
if (isset($ADODB_SESS_CONN)) return true;
|
||||
|
||||
GLOBAL $ADODB_SESSION_CONNECT,
|
||||
|
||||
GLOBAL $ADODB_SESSION_CONNECT,
|
||||
$ADODB_SESSION_DRIVER,
|
||||
$ADODB_SESSION_USER,
|
||||
$ADODB_SESSION_PWD,
|
||||
$ADODB_SESSION_DB,
|
||||
$ADODB_SESS_DEBUG;
|
||||
|
||||
|
||||
// cannot use & below - do not know why...
|
||||
$ADODB_SESS_CONN = ADONewConnection($ADODB_SESSION_DRIVER);
|
||||
if (!empty($ADODB_SESS_DEBUG)) {
|
||||
@@ -223,7 +225,7 @@ GLOBAL $ADODB_SESSION_CONNECT,
|
||||
$ADODB_SESSION_USER,$ADODB_SESSION_PWD,$ADODB_SESSION_DB);
|
||||
else $ok = $ADODB_SESS_CONN->Connect($ADODB_SESSION_CONNECT,
|
||||
$ADODB_SESSION_USER,$ADODB_SESSION_PWD,$ADODB_SESSION_DB);
|
||||
|
||||
|
||||
if (!$ok) ADOConnection::outp( "
|
||||
-- Session: connection failed</p>",false);
|
||||
}
|
||||
@@ -231,7 +233,7 @@ GLOBAL $ADODB_SESSION_CONNECT,
|
||||
/****************************************************************************************\
|
||||
Close the connection
|
||||
\****************************************************************************************/
|
||||
function adodb_sess_close()
|
||||
function adodb_sess_close()
|
||||
{
|
||||
global $ADODB_SESS_CONN;
|
||||
|
||||
@@ -242,7 +244,7 @@ global $ADODB_SESS_CONN;
|
||||
/****************************************************************************************\
|
||||
Slurp in the session variables and return the serialized string
|
||||
\****************************************************************************************/
|
||||
function adodb_sess_read($key)
|
||||
function adodb_sess_read($key)
|
||||
{
|
||||
global $ADODB_SESS_CONN,$ADODB_SESSION_TBL,$ADODB_SESSION_CRC;
|
||||
|
||||
@@ -250,48 +252,48 @@ global $ADODB_SESS_CONN,$ADODB_SESSION_TBL,$ADODB_SESSION_CRC;
|
||||
if ($rs) {
|
||||
if ($rs->EOF) {
|
||||
$v = '';
|
||||
} else
|
||||
} else
|
||||
$v = rawurldecode(reset($rs->fields));
|
||||
|
||||
|
||||
$rs->Close();
|
||||
|
||||
|
||||
// new optimization adodb 2.1
|
||||
$ADODB_SESSION_CRC = strlen($v).crc32($v);
|
||||
|
||||
|
||||
return $v;
|
||||
}
|
||||
|
||||
|
||||
return ''; // thx to Jorma Tuomainen, webmaster#wizactive.com
|
||||
}
|
||||
|
||||
/****************************************************************************************\
|
||||
Write the serialized data to a database.
|
||||
|
||||
|
||||
If the data has not been modified since adodb_sess_read(), we do not write.
|
||||
\****************************************************************************************/
|
||||
function adodb_sess_write($key, $val)
|
||||
function adodb_sess_write($key, $val)
|
||||
{
|
||||
global
|
||||
$ADODB_SESS_CONN,
|
||||
$ADODB_SESS_LIFE,
|
||||
$ADODB_SESS_CONN,
|
||||
$ADODB_SESS_LIFE,
|
||||
$ADODB_SESSION_TBL,
|
||||
$ADODB_SESS_DEBUG,
|
||||
$ADODB_SESS_DEBUG,
|
||||
$ADODB_SESSION_CRC,
|
||||
$ADODB_SESSION_EXPIRE_NOTIFY;
|
||||
|
||||
$expiry = time() + $ADODB_SESS_LIFE;
|
||||
|
||||
|
||||
// crc32 optimization since adodb 2.1
|
||||
// now we only update expiry date, thx to sebastian thom in adodb 2.32
|
||||
if ($ADODB_SESSION_CRC !== false && $ADODB_SESSION_CRC == strlen($val).crc32($val)) {
|
||||
if ($ADODB_SESS_DEBUG) echo "
|
||||
-- Session: Only updating date - crc32 not changed</p>";
|
||||
$qry = "UPDATE $ADODB_SESSION_TBL SET expiry=$expiry WHERE sesskey='$key' AND expiry >= " . time();
|
||||
$rs = $ADODB_SESS_CONN->Execute($qry);
|
||||
$rs = $ADODB_SESS_CONN->Execute($qry);
|
||||
return true;
|
||||
}
|
||||
$val = rawurlencode($val);
|
||||
|
||||
|
||||
$arr = array('sesskey' => $key, 'expiry' => $expiry, 'data' => $val);
|
||||
if ($ADODB_SESSION_EXPIRE_NOTIFY) {
|
||||
$var = reset($ADODB_SESSION_EXPIRE_NOTIFY);
|
||||
@@ -300,23 +302,23 @@ function adodb_sess_write($key, $val)
|
||||
}
|
||||
$rs = $ADODB_SESS_CONN->Replace($ADODB_SESSION_TBL,$arr,
|
||||
'sesskey',$autoQuote = true);
|
||||
|
||||
|
||||
if (!$rs) {
|
||||
ADOConnection::outp( '
|
||||
-- Session Replace: '.$ADODB_SESS_CONN->ErrorMsg().'</p>',false);
|
||||
} else {
|
||||
// bug in access driver (could be odbc?) means that info is not commited
|
||||
// properly unless select statement executed in Win2000
|
||||
if ($ADODB_SESS_CONN->databaseType == 'access')
|
||||
if ($ADODB_SESS_CONN->databaseType == 'access')
|
||||
$rs = $ADODB_SESS_CONN->Execute("select sesskey from $ADODB_SESSION_TBL WHERE sesskey='$key'");
|
||||
}
|
||||
return !empty($rs);
|
||||
}
|
||||
|
||||
function adodb_sess_destroy($key)
|
||||
function adodb_sess_destroy($key)
|
||||
{
|
||||
global $ADODB_SESS_CONN, $ADODB_SESSION_TBL,$ADODB_SESSION_EXPIRE_NOTIFY;
|
||||
|
||||
|
||||
if ($ADODB_SESSION_EXPIRE_NOTIFY) {
|
||||
reset($ADODB_SESSION_EXPIRE_NOTIFY);
|
||||
$fn = next($ADODB_SESSION_EXPIRE_NOTIFY);
|
||||
@@ -341,10 +343,10 @@ function adodb_sess_destroy($key)
|
||||
return $rs ? true : false;
|
||||
}
|
||||
|
||||
function adodb_sess_gc($maxlifetime)
|
||||
function adodb_sess_gc($maxlifetime)
|
||||
{
|
||||
global $ADODB_SESS_DEBUG, $ADODB_SESS_CONN, $ADODB_SESSION_TBL,$ADODB_SESSION_EXPIRE_NOTIFY;
|
||||
|
||||
|
||||
if ($ADODB_SESSION_EXPIRE_NOTIFY) {
|
||||
reset($ADODB_SESSION_EXPIRE_NOTIFY);
|
||||
$fn = next($ADODB_SESSION_EXPIRE_NOTIFY);
|
||||
@@ -362,21 +364,21 @@ function adodb_sess_gc($maxlifetime)
|
||||
$rs->MoveNext();
|
||||
}
|
||||
$rs->Close();
|
||||
|
||||
|
||||
$ADODB_SESS_CONN->CommitTrans();
|
||||
|
||||
|
||||
}
|
||||
} else {
|
||||
$qry = "DELETE FROM $ADODB_SESSION_TBL WHERE expiry < " . time();
|
||||
$ADODB_SESS_CONN->Execute($qry);
|
||||
|
||||
|
||||
if ($ADODB_SESS_DEBUG) ADOConnection::outp("
|
||||
-- <b>Garbage Collection</b>: $qry</p>");
|
||||
}
|
||||
// suggested by Cameron, "GaM3R" <gamr@outworld.cx>
|
||||
if (defined('ADODB_SESSION_OPTIMIZE')) {
|
||||
global $ADODB_SESSION_DRIVER;
|
||||
|
||||
|
||||
switch( $ADODB_SESSION_DRIVER ) {
|
||||
case 'mysql':
|
||||
case 'mysqlt':
|
||||
@@ -384,7 +386,7 @@ function adodb_sess_gc($maxlifetime)
|
||||
break;
|
||||
case 'postgresql':
|
||||
case 'postgresql7':
|
||||
$opt_qry = 'VACUUM '.$ADODB_SESSION_TBL;
|
||||
$opt_qry = 'VACUUM '.$ADODB_SESSION_TBL;
|
||||
break;
|
||||
}
|
||||
if (!empty($opt_qry)) {
|
||||
@@ -393,29 +395,29 @@ function adodb_sess_gc($maxlifetime)
|
||||
}
|
||||
if ($ADODB_SESS_CONN->dataProvider === 'oci8') $sql = 'select TO_CHAR('.($ADODB_SESS_CONN->sysTimeStamp).', \'RRRR-MM-DD HH24:MI:SS\') from '. $ADODB_SESSION_TBL;
|
||||
else $sql = 'select '.$ADODB_SESS_CONN->sysTimeStamp.' from '. $ADODB_SESSION_TBL;
|
||||
|
||||
|
||||
$rs = $ADODB_SESS_CONN->SelectLimit($sql,1);
|
||||
if ($rs && !$rs->EOF) {
|
||||
|
||||
|
||||
$dbts = reset($rs->fields);
|
||||
$rs->Close();
|
||||
$dbt = $ADODB_SESS_CONN->UnixTimeStamp($dbts);
|
||||
$t = time();
|
||||
|
||||
|
||||
if (abs($dbt - $t) >= ADODB_SESSION_SYNCH_SECS) {
|
||||
|
||||
$msg =
|
||||
|
||||
$msg =
|
||||
__FILE__.": Server time for webserver {$_SERVER['HTTP_HOST']} not in synch with database: database=$dbt ($dbts), webserver=$t (diff=".(abs($dbt-$t)/3600)." hrs)";
|
||||
error_log($msg);
|
||||
if ($ADODB_SESS_DEBUG) ADOConnection::outp("
|
||||
-- $msg</p>");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
session_module_name('user');
|
||||
session_module_name('user');
|
||||
session_set_save_handler(
|
||||
"adodb_sess_open",
|
||||
"adodb_sess_close",
|
||||
@@ -435,5 +437,3 @@ if (0) {
|
||||
ADOConnection::outp( "
|
||||
-- \$_SESSION['AVAR']={$_SESSION['AVAR']}</p>",false);
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -61,4 +61,3 @@ class MD5Crypt{
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<KEY/>
|
||||
<NOTNULL/>
|
||||
</field>
|
||||
|
||||
|
||||
<field name="EXPIRY" type="I" size="11">
|
||||
<descr></descr>
|
||||
<NOTNULL/>
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<schema version="0.2">
|
||||
<table name="sessions">
|
||||
<desc>table for ADOdb session-management</desc>
|
||||
|
||||
<field name="SESSKEY" type="C" size="32">
|
||||
<descr>session key</descr>
|
||||
<KEY/>
|
||||
<NOTNULL/>
|
||||
</field>
|
||||
|
||||
<field name="EXPIRY" type="I" size="11">
|
||||
<descr></descr>
|
||||
<NOTNULL/>
|
||||
</field>
|
||||
|
||||
<field name="EXPIREREF" type="C" size="64">
|
||||
<descr></descr>
|
||||
</field>
|
||||
|
||||
<field name="DATA" type="XL">
|
||||
<descr></descr>
|
||||
<NOTNULL/>
|
||||
</field>
|
||||
</table>
|
||||
</schema>
|
||||
@@ -8,19 +8,19 @@
|
||||
<KEY/>
|
||||
<NOTNULL/>
|
||||
</field>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<field name="EXPIRY" type="T">
|
||||
<descr></descr>
|
||||
<NOTNULL/>
|
||||
</field>
|
||||
|
||||
|
||||
<field name="CREATED" type="T">
|
||||
<descr></descr>
|
||||
<NOTNULL/>
|
||||
</field>
|
||||
|
||||
|
||||
<field name="MODIFIED" type="T">
|
||||
<descr></descr>
|
||||
<NOTNULL/>
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<schema version="0.3">
|
||||
<table name="sessions2">
|
||||
<desc>table for ADOdb session-management</desc>
|
||||
|
||||
<field name="SESSKEY" type="C" size="64">
|
||||
<descr>session key</descr>
|
||||
<KEY/>
|
||||
<NOTNULL/>
|
||||
</field>
|
||||
|
||||
|
||||
|
||||
<field name="EXPIRY" type="T">
|
||||
<descr></descr>
|
||||
<NOTNULL/>
|
||||
</field>
|
||||
|
||||
<field name="CREATED" type="T">
|
||||
<descr></descr>
|
||||
<NOTNULL/>
|
||||
</field>
|
||||
|
||||
<field name="MODIFIED" type="T">
|
||||
<descr></descr>
|
||||
<NOTNULL/>
|
||||
</field>
|
||||
|
||||
<field name="EXPIREREF" type="C" size="250">
|
||||
<descr></descr>
|
||||
</field>
|
||||
|
||||
<field name="SESSDATA" type="XL">
|
||||
<descr></descr>
|
||||
<NOTNULL/>
|
||||
</field>
|
||||
</table>
|
||||
</schema>
|
||||
Reference in New Issue
Block a user