本文整理汇总了PHP中ADODB_Session类的典型用法代码示例。如果您正苦于以下问题:PHP ADODB_Session类的具体用法?PHP ADODB_Session怎么用?PHP ADODB_Session使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ADODB_Session类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
function __construct($conn_options, $persist = TRUE, $debug = FALSE, $sess_table = 'sessao')
{
$ret = FALSE;
list($host, $database, $user, $password, $port) = array_values($conn_options);
$host .= ':' . $port;
$options['table'] = $sess_table;
$this->session_table = $sess_table;
ADOdb_Session::config('postgres', $host, $user, $password, $database, $options);
ADODB_Session::open(false, false, $connectMode = $persist);
if (isset($GLOBALS['ADODB_SESS_CONN']) && is_object($GLOBALS['ADODB_SESS_CONN'])) {
ADOdb_session::Persist($connectMode = $persist);
$GLOBALS['ADODB_SESS_CONN']->debug = $debug;
// limpa outras sessoes expiradas e inativas por mais de 15 minutos (padr�o)
$this->clear_expired_sessions();
@session_start();
}
}
示例2: init
public static function init()
{
if (!wbCore::isFuncDisabled('ini_set')) {
// PHP configuration variables
// Stop adding SID to URLs
ini_set('session.use_trans_sid', 0);
// User-defined save handler
ini_set('session.save_handler', 'user');
// How to store data
ini_set('session.serialize_handler', 'php');
// Use cookie to store the session ID
ini_set('session.use_cookies', 1);
// Name of our cookie
ini_set('session.name', 'WEBISID');
$path = wbServer::getBaseURI();
if (empty($path)) {
$path = '/';
}
// Lifetime of our cookie. Session lasts set number of days
$lifetime = wbConfig::get('Session.Duration') * 86400;
ini_set('session.cookie_lifetime', $lifetime);
// Cookie path
// this should be customized for multi-server setups wanting to share
// sessions
ini_set('session.cookie_path', $path);
// Garbage collection
ini_set('session.gc_probability', 1);
// Inactivity timeout for user sessions
ini_set('session.gc_maxlifetime', wbConfig::get('Session.InactivityTimeout') * 60);
// Auto-start session
ini_set('session.auto_start', 1);
}
include_once 'lib/adodb/session/adodb-session2.php';
$GLOBALS['ADODB_SESS_CONN'] =& wbDB::getConn();
ADODB_Session::table(wbConfig::get('DB.prefix') . '_sessions');
session_start();
}
示例3: adodb_session_regenerate_id
function adodb_session_regenerate_id()
{
$conn = ADODB_Session::_conn();
if (!$conn) {
return false;
}
$old_id = session_id();
if (function_exists('session_regenerate_id')) {
session_regenerate_id();
} else {
session_id(md5(uniqid(rand(), true)));
$ck = session_get_cookie_params();
setcookie(session_name(), session_id(), false, $ck['path'], $ck['domain'], $ck['secure']);
//@session_start();
}
$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);
if (empty($ck)) {
$ck = session_get_cookie_params();
}
setcookie(session_name(), session_id(), false, $ck['path'], $ck['domain'], $ck['secure']);
return false;
}
return true;
}
示例4: LogoutNotification
function LogoutNotification($SessionID)
{
global $CFG, $SESSION, $DB;
// Delete session of user using $SessionID
if (empty($CFG->dbsessions)) {
// File session
$dir = $CFG->dataroot . '/sessions';
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
// Read all session files
while (($file = readdir($dh)) !== false) {
// Check if it is a file
if (is_file($dir . '/' . $file)) {
$session_key = preg_replace('/sess_/', '', $file);
// Read session file data
$data = file($dir . '/' . $file);
if (isset($data[0])) {
$user_session = unserializesession($data[0]);
// Check if we have found session that shall be deleted
if (isset($user_session['SESSION']) && isset($user_session['SESSION']->shibboleth_session_id)) {
// If there is a match, delete file
if ($user_session['SESSION']->shibboleth_session_id == $SessionID) {
// Delete session file
if (!unlink($dir . '/' . $file)) {
return new SoapFault('LogoutError', 'Could not delete Moodle session file.');
}
}
}
}
}
}
closedir($dh);
}
}
} else {
// DB Session
//TODO: this needs to be rewritten to use new session stuff
if (!empty($CFG->sessiontimeout)) {
$ADODB_SESS_LIFE = $CFG->sessiontimeout;
}
if ($user_session_data = $DB->get_records_sql('SELECT sesskey, sessdata FROM {sessions2} WHERE expiry > NOW()')) {
foreach ($user_session_data as $session_data) {
// Get user session
$user_session = adodb_unserialize(urldecode($session_data->sessdata));
if (isset($user_session['SESSION']) && isset($user_session['SESSION']->shibboleth_session_id)) {
// If there is a match, delete file
if ($user_session['SESSION']->shibboleth_session_id == $SessionID) {
// Delete this session entry
if (ADODB_Session::destroy($session_data->sesskey) !== true) {
return new SoapFault('LogoutError', 'Could not delete Moodle session entry in database.');
}
}
}
}
}
}
// If now SoapFault was thrown the function will return OK as the SP assumes
}
示例5: define
*
* @author Organisation: Queen's University
* @author Unit: School of Medicine
* @author Developer: Matt Simpson <matt.simpson@queensu.ca>
* @copyright Copyright 2010 Queen's University. All Rights Reserved.
*
*/
$ADODB_QUOTE_FIELDNAMES = true;
// Whether or not you want ADOdb to backtick field names in AutoExecute, GetInsertSQL and GetUpdateSQL.
define("ADODB_QUOTE_FIELDNAMES", $ADODB_QUOTE_FIELDNAMES);
// Information required to start a new database connection.
$db = NewADOConnection(DATABASE_TYPE);
$db->Connect(DATABASE_HOST, DATABASE_USER, DATABASE_PASS, DATABASE_NAME);
$db->SetFetchMode(ADODB_FETCH_ASSOC);
if (defined("DEFAULT_CHARSET") && isset($ENTRADA_CHARSETS) && is_array($ENTRADA_CHARSETS) && array_key_exists(DEFAULT_CHARSET, $ENTRADA_CHARSETS)) {
$db->Execute("SET NAMES " . $db->qstr($ENTRADA_CHARSETS[DEFAULT_CHARSET]["mysql_names"]) . " COLLATE " . $db->qstr($ENTRADA_CHARSETS[DEFAULT_CHARSET]["mysql_collate"]));
}
$db->debug = isset($DEVELOPER_IPS) && is_array($DEVELOPER_IPS) && isset($_SERVER["REMOTE_ADDR"]) && in_array($_SERVER["REMOTE_ADDR"], $DEVELOPER_IPS) && isset($_GET["debug"]) ? true : false;
@ini_set("session.name", SESSION_NAME);
@ini_set("session.gc_maxlifetime", SESSION_EXPIRES);
if (defined("ADODB_SESSION") && defined("DATABASE_SESSIONS") && DATABASE_SESSIONS) {
require_once "Entrada/adodb/session/adodb-session2.php";
ADODB_Session::config(SESSION_DATABASE_TYPE, SESSION_DATABASE_HOST, SESSION_DATABASE_USER, SESSION_DATABASE_PASS, SESSION_DATABASE_NAME, array("table" => "sessions"));
ADODB_Session::encryptionKey(ENCRYPTION_KEY);
ADODB_Session::open(false, false, false);
ADODB_Session::optimize(true);
ADODB_Session::expireNotify(array("PROXY_ID", "expired_session"));
session_start();
} else {
session_start();
}
示例6: _sessionKey
function _sessionKey()
{
return crypt(ADODB_Session::encryptionKey(), session_id());
}
示例7: Lim
<?php
/*
V4.90 8 June 2006 (c) 2000-2006 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.
*/
/*
This file is provided for backwards compatibility purposes
*/
require_once dirname(__FILE__) . '/adodb-session.php';
ADODB_Session::clob('CLOB');
示例8: gc
static function gc($maxlifetime)
{
$conn = ADODB_Session::_conn();
$debug = ADODB_Session::debug();
$expire_notify = ADODB_Session::expireNotify();
$optimize = ADODB_Session::optimize();
$table = ADODB_Session::table();
if (!$conn) {
return false;
}
$debug = ADODB_Session::debug();
if ($debug) {
$conn->debug = 1;
$COMMITNUM = 2;
} else {
$COMMITNUM = 20;
}
//assert('$table');
$time = $conn->OffsetDate(-$maxlifetime / 24 / 3600, $conn->sysTimeStamp);
$binary = $conn->dataProvider === 'mysql' ? '/*! BINARY */' : '';
if ($expire_notify) {
reset($expire_notify);
$fn = next($expire_notify);
} 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);
if ($debug) {
ADODB_Session::_dumprs($rs);
}
$conn->SetFetchMode($savem);
if ($rs) {
$tr = $conn->hasTransactions;
if ($tr) {
$conn->BeginTrans();
}
$keys = array();
$ccnt = 0;
while (!$rs->EOF) {
$ref = $rs->fields[0];
$key = $rs->fields[1];
if ($fn) {
$fn($ref, $key);
}
$del = $conn->Execute("DELETE FROM {$table} WHERE sesskey=" . $conn->Param('0'), array($key));
$rs->MoveNext();
$ccnt += 1;
if ($tr && $ccnt % $COMMITNUM == 0) {
if ($debug) {
echo "Commit<br>\n";
}
$conn->CommitTrans();
$conn->BeginTrans();
}
}
$rs->Close();
if ($tr) {
$conn->CommitTrans();
}
}
// suggested by Cameron, "GaM3R" <gamr@outworld.cx>
if ($optimize) {
$driver = ADODB_Session::driver();
if (preg_match('/mysql/i', $driver)) {
$sql = "OPTIMIZE TABLE {$table}";
}
if (preg_match('/postgres/i', $driver)) {
$sql = "VACUUM {$table}";
}
if (!empty($sql)) {
$conn->Execute($sql);
}
}
return true;
}
示例9: array
</table></td>
<?php
$heading = array();
$contents = array();
if (isset($info)) {
$heading[] = array('text' => '<b>' . TABLE_HEADING_SHOPPING_CART . '</b><br />');
if (STORE_SESSIONS == '1') {
$sessionstable = $oostable['sessions'];
$session_data = $dbconn->Execute("SELECT data FROM $sessionstable WHERE sesskey = '" . $info . "'");
if (STORE_SESSIONS_CRYPT == '1') {
include_once '../includes/lib/adodb/session/crypt.inc.php';
$Crypt = new MD5Crypt;
$session_data = rawurldecode($Crypt->Decrypt(reset($session_data->fields), crypt(ADODB_Session::encryptionKey(), $info)));
} else {
$session_data = rawurldecode($session_data->fields['data']);
}
} else {
if ( (file_exists(oos_session_save_path() . '/sess_' . $info)) && (filesize(oos_session_save_path() . '/sess_' . $info) > 0) ) {
$session_data = file(oos_session_save_path() . '/sess_' . $info);
$session_data = trim(implode('', $session_data));
}
}
$currency = unserialize(oos_get_serialized_variable($session_data, 'currency', 'string'));
$cart = unserialize(oos_get_serialized_variable($session_data, 'cart', 'object'));
if (isset($cart) && is_object($cart)) {
示例10: error_reporting
error_reporting(E_ALL ^ E_NOTICE);
date_default_timezone_set('Europe/Kiev');
require_once _ROOT . 'vendor/autoload.php';
include_once _ROOT . "vendor/adodb/adodb-php/adodb-exceptions.inc.php";
//чтение конфигурации
$_config = parse_ini_file(_ROOT . 'config/config.ini', true);
// phpQuery::$debug = true;
// Подключение фреймворка
require_once _ZIPPY . 'zippy.inc.php';
//Параметры соединения с БД
\ZCL\DB\DB::config($_config['db']['host'], $_config['db']['name'], $_config['db']['user'], $_config['db']['pass']);
//Настройка сессии в БД
if ($_config["common"]["sessiondb"] == "1") {
include_once _ROOT . "vendor/adodb/adodb-php/session/adodb-session2.php";
\ADODB_Session::config('mysqli', $_config['db']['host'], $_config['db']['user'], $_config['db']['pass'], $_config['db']['name'], array('table' => 'system_session'));
\ADODB_Session::Persist($connectMode = false);
}
//подключение ядра системмы
require_once _ROOT . 'system/start.inc.php';
require_once _ROOT . 'erp/start.inc.php';
//загружаем модули
$modules = array();
/*
$modulespath = _ROOT . 'modules/';
if ($handle = @opendir($modulespath)) {
while (false !== ($file = readdir($handle))) {
if (is_dir($modulespath . $file) && strlen($file) > 2) {
$startfile = $modulespath . $file . '/start.inc.php';
if(file_exists($startfile)){
$modules[] = $file;
require_once $startfile;
示例11: calc
calc("Last Moderated Image", $sql);
$table[] = array("Parameter" => '', "Value" => '');
$sql = "SELECT COUNT(*) FROM gridimage WHERE submitted > DATE_SUB(NOW() , INTERVAL 24 HOUR)";
calc("Images Submitted in last 24 hours", $sql, 600);
$sql = "SELECT COUNT(DISTINCT user_id) FROM gridimage WHERE submitted > DATE_SUB(NOW() , INTERVAL 24 HOUR)";
calc("Image Contributors in last 24 hours", $sql, 3600);
$sql = "SELECT COUNT(DISTINCT moderator_id) FROM gridimage WHERE submitted > DATE_SUB(NOW() , INTERVAL 48 HOUR) and moderator_id > 0 and moderated > DATE_SUB(NOW() , INTERVAL 24 HOUR)";
calc("Active Moderators in last 24 hours", $sql, 3600);
$table[] = array("Parameter" => '', "Value" => '');
$sql = "SELECT COUNT(*) FROM gridimage WHERE submitted > DATE_SUB(NOW() , INTERVAL 7 DAY)";
calc("Images Submitted in last 7 days", $sql, 3600 * 3);
$sql = "SELECT COUNT(DISTINCT user_id) FROM gridimage WHERE submitted > DATE_SUB(NOW() , INTERVAL 7 DAY)";
calc("Image Contributors in last 7 days", $sql, 3600 * 3);
$table[] = array("Parameter" => '', "Value" => '');
$sql = "SELECT COUNT(DISTINCT ipaddr) FROM sessions WHERE EXPIRY > UNIX_TIMESTAMP(DATE_SUB(NOW(),INTERVAL 24 MINUTE))";
$db2 = ADODB_Session::_conn();
$table[] = array("Parameter" => "Approx Visitors in last 24 <u>minutes</u>", "Value" => $db2->getOne($sql));
$sql = "SELECT COUNT(DISTINCT user_id)-1 FROM autologin WHERE created > DATE_SUB(NOW(), INTERVAL 1 HOUR)";
calc("Approx Regular Users visited in last hour", $sql);
$table[] = array("Parameter" => '', "Value" => '');
$sql = "SELECT COUNT(*) FROM geobb_posts WHERE post_time > DATE_SUB(NOW() , INTERVAL 1 HOUR)";
calc("Forum Posts in last hour", $sql);
$sql = "SELECT COUNT(DISTINCT poster_id) FROM geobb_posts WHERE post_time > DATE_SUB(NOW() , INTERVAL 1 HOUR)";
calc("Forum Posters in last hour", $sql);
$table[] = array("Parameter" => '', "Value" => '');
$sql = "SELECT COUNT(*) FROM geobb_posts WHERE post_time > DATE_SUB(NOW() , INTERVAL 24 HOUR)";
calc("Forum Posts in last 24 hours", $sql);
$sql = "SELECT COUNT(DISTINCT poster_id) FROM geobb_posts WHERE post_time > DATE_SUB(NOW() , INTERVAL 24 HOUR)";
calc("Forum Posters in last 24 hours", $sql);
$sql = "SELECT COUNT(DISTINCT user_id) FROM geobb_lastviewed WHERE ts > DATE_SUB(NOW() , INTERVAL 24 HOUR)";
calc("Forum Viewers in last 24 hours", $sql);
示例12: NotifyExpire
function NotifyExpire($ref, $key)
{
print "<p><b>Notify Expiring={$ref}, sessionkey={$key}</b></p>";
}
$ADODB_SESSION_DRIVER = 'mysql';
$ADODB_SESSION_CONNECT = 'localhost';
$ADODB_SESSION_USER = 'root';
$ADODB_SESSION_PWD = '';
$ADODB_SESSION_DB = 'pos';
$ADODB_SESS_LIFE = 120;
//$ADODB_SESS_DEBUG = true;
$USER = 'h_izan@yahoo.com';
$ADODB_SESSION_EXPIRE_NOTIFY = array('USER', 'NotifyExpire');
error_reporting(E_ALL);
include 'session/adodb-cryptsession.php';
session_start();
print "session id <br>";
print session_id() . "<br>";
if (ADODB_Session::read(session_id()) == '') {
ADODB_Session::destroy(session_id());
//ADODB_Session::gc(160);
//unset($_COOKIE['PHPSESSID']);
//unset($_SESSION);
//session_destroy();
//session_unset();
print "session info is empty <br>";
}
print ADODB_Session::read(session_id()) . "<br>";
print date("F j, Y, g:i a s", 1095289294) . "<br>";
print date("F j, Y, g:i a s", 1095289337);
ob_end_flush();
示例13: ini_set
// No errors
ini_set('display_errors', '0');
// Don't show them
$db_logging = false;
// True gives an admin log entry for any SQL calls that update/insert/delete, and turns on adodb's sql logging. Only for use during development!This makes a huge amount of logs! You have been warned!!
}
ini_set('url_rewriter.tags', '');
// Ensure that the session id is *not* passed on the url - this is a possible security hole for logins - including admin.
global $ADODB_CRYPT_KEY;
global $ADODB_SESSION_CONNECT, $ADODB_SESSION_USER, $ADODB_SESSION_DB;
$ADODB_SESS_CONN = '';
$ADODB_SESSION_TBL = $db_prefix . "sessions";
// We explicitly use encrypted sessions, but this adds compression as well.
ADODB_Session::encryptionKey($ADODB_CRYPT_KEY);
// The data field name "data" violates SQL reserved words - switch it to SESSDATA
ADODB_Session::dataFieldName('SESSDATA');
global $db;
connectdb();
$db->prefix = $db_prefix;
$db->logging = $db_logging;
if ($db_logging) {
adodb_perf::table("{$db->prefix}adodb_logsql");
$db->LogSQL();
// Turn on adodb performance logging
}
if (!isset($index_page)) {
$index_page = false;
}
if (!$index_page) {
// Ensure that we do not set cookies on the index page, until the player chooses to allow them.
if (!isset($_SESSION)) {
示例14: elseif
}
// is session data stored in DB or in filesystem?
if ($gBitSystem->isFeatureActive('site_store_session_db') && !empty($gBitDbType)) {
if (file_exists(EXTERNAL_LIBS_PATH . 'adodb/session/adodb-session.php')) {
include_once EXTERNAL_LIBS_PATH . 'adodb/session/adodb-session.php';
} elseif (file_exists(UTIL_PKG_PATH . 'adodb/session/adodb-session.php')) {
include_once UTIL_PKG_PATH . 'adodb/session/adodb-session.php';
}
if (class_exists('ADODB_Session')) {
ADODB_Session::dataFieldName('session_data');
ADODB_Session::driver($gBitDbType);
ADODB_Session::host($gBitDbHost);
ADODB_Session::user($gBitDbUser);
ADODB_Session::password($gBitDbPassword);
ADODB_Session::database($gBitDbName);
ADODB_Session::table(BIT_DB_PREFIX . 'sessions');
ini_set('session.save_handler', 'user');
}
}
session_name(BIT_SESSION_NAME);
if ($gBitSystem->isFeatureActive('users_remember_me')) {
session_set_cookie_params($gBitSystem->getConfig('site_session_lifetime'), $gBitSystem->getConfig('cookie_path', BIT_ROOT_URL), $gBitSystem->getConfig('cookie_domain', ''));
} else {
session_set_cookie_params($gBitSystem->getConfig('site_session_lifetime'), BIT_ROOT_URL, '');
}
// just use a simple COOKIE (unique random string) that is linked to the users_cnxn table.
// This way, nuking rows in the users_cnxn table can log people out and is much more reliable than SESSIONS
global $gShellScript;
if (empty($gShellScript)) {
if (session_status() == PHP_SESSION_NONE) {
session_start();
示例15: db_op_result
// Since we now have the config values(including perf_logging), if the admin wants perf logging on - turn it on.
if (isset($perf_logging) && $perf_logging) {
$debug_query = $db->SelectLimit("SELECT * from {$db_prefix}adodb_logsql", 1);
if ($debug_query) {
adodb_perf::table("{$db_prefix}adodb_logsql");
$db->LogSQL();
}
}
}
// Ensure that the sessions table has been created, and if so, start a session.
// I bet there is a more elegant way to do this, but this works for all my testing scenarios, so its in for now.
$debug_query = $db->Execute("SHOW TABLES LIKE '{$db_prefix}sessions'");
db_op_result($debug_query, __LINE__, __FILE__);
$row = $debug_query->fields;
if ($debug_query) {
// We explicitly use encrypted sessions, but this adds compression as well.
$ADODB_SESSION_TBL = $db_prefix . "sessions";
ADODB_Session::filter(new ADODB_Compress_Gzip());
// The data field name "data" violates SQL reserved words - switch it to session_data.
ADODB_Session::dataFieldName('session_data');
session_start();
}
}
$smarty = new Smarty();
if (getenv("HTTP_X_FORWARDED_FOR")) {
$ip = getenv("HTTP_X_FORWARDED_FOR");
// Get Proxy IP address for user
} else {
$ip = getenv("REMOTE_ADDR");
// Get IP address for user
}