1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
|
<?php rcs_id('$Id: DbSession.php,v 1.35 2005/08/07 10:51:11 rurban Exp $');
/**
* Store sessions data in Pear DB / ADODB / dba / PDO, ....
*
* History
*
* Originally by Stanislav Shramko <stanis@movingmail.com>
* Minor rewrite by Reini Urban <rurban@x-ray.at> for Phpwiki.
* Quasi-major rewrite/decruft/fix by Jeff Dairiki <dairiki@dairiki.org>.
* ADODB, dba and PDO classes by Reini Urban.
*
* Warning: Enable USE_SAFE_DBSESSION if you get INSERT duplicate id warnings.
*/
class DbSession
{
/**
* Constructor
*
* @param mixed $dbh
* DB handle, or WikiDB object (from which the DB handle will
* be extracted.
*
* @param string $table
* Name of SQL table containing session data.
*/
function DbSession(&$dbh, $table = 'session') {
// Check for existing DbSession handler
$db_type = $dbh->getParam('dbtype');
if (isa($dbh, 'WikiDB')) {
// will fail with php4 and case-sensitive filesystem
//$db_type = substr(get_class($dbh),7);
// < 4.1.2 crash on dba sessions at session_write_close().
// (Tested with 4.1.1 and 4.1.2)
// Didn't try postgres sessions.
if (!check_php_version(4,1,2) and $db_type == 'dba')
return false;
@include_once("lib/DbSession/".$db_type.".php");
$class = "DbSession_".$db_type;
if (class_exists($class)) {
// dba has no ->_dbh, so this is used for the session link
$this->_backend = new $class($dbh->_backend->_dbh, $table);
return $this;
}
}
//Fixme: E_USER_WARNING ignored!
trigger_error(sprintf(_("Your WikiDB DB backend '%s' cannot be used for DbSession.")." ".
_("Set USE_DB_SESSION to false."),
$db_type), E_USER_WARNING);
return false;
}
function currentSessions() {
return $this->_backend->currentSessions();
}
function query($sql) {
return $this->_backend->query($sql);
}
function quote($string) { return $string; }
}
// $Log: DbSession.php,v $
// Revision 1.35 2005/08/07 10:51:11 rurban
// reformatting
//
// Revision 1.34 2005/08/07 10:08:33 rurban
// dba simplification: no _backend in the subclass
//
// Revision 1.33 2005/02/27 19:40:36 rurban
// fix for php4 and case-sensitive filesystems
//
// Revision 1.32 2005/02/11 14:41:57 rurban
// seperate DbSession classes: less memory, a bit slower
//
// Local Variables:
// mode: php
// tab-width: 8
// c-basic-offset: 4
// c-hanging-comment-ender-p: nil
// indent-tabs-mode: nil
// End:
?>
|