⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 adodb-session2.php

📁 asterisk 計費模塊
💻 PHP
📖 第 1 页 / 共 2 页
字号:
<?php/*V4.94 23 Jan 2007  (c) 2000-2007 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.	  *//*CREATE Table SCriptsOracle======CREATE TABLE SESSIONS2(  SESSKEY    VARCHAR2(48 BYTE)                  NOT NULL,  EXPIRY     DATE                               NOT NULL,  EXPIREREF  VARCHAR2(200 BYTE),  CREATED    DATE                               NOT NULL,  MODIFIED   DATE                               NOT NULL,  SESSDATA   CLOB,  PRIMARY KEY(SESSKEY));CREATE INDEX SESS2_EXPIRY ON SESSIONS2(EXPIRY);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 ,	expireref VARCHAR( 250 ) DEFAULT '',	created TIMESTAMP NOT NULL ,	modified TIMESTAMP NOT NULL ,	sessdata LONGTEXT DEFAULT '',	PRIMARY KEY ( sesskey ) ,	INDEX sess2_expiry( expiry ),	INDEX sess2_expireref( expireref ))*/if (!defined('_ADODB_LAYER')) {	require realpath(dirname(__FILE__) . '/../adodb.inc.php');}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. 	3. After urldecode, run the serialized string through this function:*/function adodb_unserialize( $serialized_string ) {	$variables = array( );	$a = preg_split( "/(\w+)\|/", $serialized_string, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE );	for( $i = 0; $i < count( $a ); $i = $i+2 ) {		$variables[$a[$i]] = unserialize( $a[$i+1] );	}	return( $variables );}/*	Thanks Joe Li. See http://phplens.com/lens/lensforum/msgs.php?id=11487&x=1	Since adodb 4.61.*/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;}/*    Generate database table for session data    @see http://phplens.com/lens/lensforum/msgs.php?id=12280    @return 0 if failure, 1 if errors, 2 if successful.	@author Markus Staab http://www.public-4u.de*/function adodb_session_create_table($schemaFile=null,$conn = null){    // set default values    if ($schemaFile===null) $schemaFile = ADODB_SESSION . '/session_schema2.xml';    if ($conn===null) $conn =& ADODB_Session::_conn();	if (!$conn) return 0;    $schema = new adoSchema($conn);    $schema->ParseSchema($schemaFile);    return $schema->ExecuteSchema();}/*!	\static*/class ADODB_Session {	/////////////////////	// getter/setter methods	/////////////////////		/*		function Lock($lock=null)	{	static $_lock = false;			if (!is_null($lock)) $_lock = $lock;		return $lock;	}	*/	/*!	*/	function driver($driver = null) 	{		static $_driver = 'mysql';		static $set = false;		if (!is_null($driver)) {			$_driver = trim($driver);			$set = true;		} elseif (!$set) {			// backwards compatibility			if (isset($GLOBALS['ADODB_SESSION_DRIVER'])) {				return $GLOBALS['ADODB_SESSION_DRIVER'];			}		}		return $_driver;	}	/*!	*/	function host($host = null) {		static $_host = 'localhost';		static $set = false;		if (!is_null($host)) {			$_host = trim($host);			$set = true;		} elseif (!$set) {			// backwards compatibility			if (isset($GLOBALS['ADODB_SESSION_CONNECT'])) {				return $GLOBALS['ADODB_SESSION_CONNECT'];			}		}		return $_host;	}	/*!	*/	function user($user = null) 	{		static $_user = 'root';		static $set = false;		if (!is_null($user)) {			$_user = trim($user);			$set = true;		} elseif (!$set) {			// backwards compatibility			if (isset($GLOBALS['ADODB_SESSION_USER'])) {				return $GLOBALS['ADODB_SESSION_USER'];			}		}		return $_user;	}	/*!	*/	function password($password = null) 	{		static $_password = '';		static $set = false;		if (!is_null($password)) {			$_password = $password;			$set = true;		} elseif (!$set) {			// backwards compatibility			if (isset($GLOBALS['ADODB_SESSION_PWD'])) {				return $GLOBALS['ADODB_SESSION_PWD'];			}		}		return $_password;	}	/*!	*/	function database($database = null) 	{		static $_database = '';		static $set = false;				if (!is_null($database)) {			$_database = trim($database);			$set = true;		} elseif (!$set) {			// backwards compatibility			if (isset($GLOBALS['ADODB_SESSION_DB'])) {				return $GLOBALS['ADODB_SESSION_DB'];			}		}		return $_database;	}	/*!	*/	function persist($persist = null) 	{		static $_persist = true;		if (!is_null($persist)) {			$_persist = trim($persist);		}		return $_persist;	}	/*!	*/	function lifetime($lifetime = null) 	{		static $_lifetime;		static $set = false;		if (!is_null($lifetime)) {			$_lifetime = (int) $lifetime;			$set = true;		} elseif (!$set) {			// backwards compatibility			if (isset($GLOBALS['ADODB_SESS_LIFE'])) {				return $GLOBALS['ADODB_SESS_LIFE'];			}		}		if (!$_lifetime) {			$_lifetime = ini_get('session.gc_maxlifetime');			if ($_lifetime <= 1) {				// bug in PHP 4.0.3 pl 1  -- how about other versions?				//print "<h3>Session Error: PHP.INI setting <i>session.gc_maxlifetime</i>not set: $lifetime</h3>";				$_lifetime = 1440;			}		}		return $_lifetime;	}	/*!	*/	function debug($debug = null) 	{		static $_debug = false;		static $set = false;		if (!is_null($debug)) {			$_debug = (bool) $debug;			$conn = ADODB_Session::_conn();			if ($conn) {				$conn->debug = $_debug;			}			$set = true;		} elseif (!$set) {			// backwards compatibility			if (isset($GLOBALS['ADODB_SESS_DEBUG'])) {				return $GLOBALS['ADODB_SESS_DEBUG'];			}		}		return $_debug;	}	/*!	*/	function expireNotify($expire_notify = null) 	{		static $_expire_notify;		static $set = false;		if (!is_null($expire_notify)) {			$_expire_notify = $expire_notify;			$set = true;		} elseif (!$set) {			// backwards compatibility			if (isset($GLOBALS['ADODB_SESSION_EXPIRE_NOTIFY'])) {				return $GLOBALS['ADODB_SESSION_EXPIRE_NOTIFY'];			}		}		return $_expire_notify;	}	/*!	*/	function table($table = null) 	{		static $_table = 'sessions2';		static $set = false;		if (!is_null($table)) {			$_table = trim($table);			$set = true;		} elseif (!$set) {			// backwards compatibility			if (isset($GLOBALS['ADODB_SESSION_TBL'])) {				return $GLOBALS['ADODB_SESSION_TBL'];			}		}		return $_table;	}	/*!	*/	function optimize($optimize = null) 	{		static $_optimize = false;		static $set = false;		if (!is_null($optimize)) {			$_optimize = (bool) $optimize;			$set = true;		} elseif (!$set) {			// backwards compatibility			if (defined('ADODB_SESSION_OPTIMIZE')) {				return true;			}		}		return $_optimize;	}	/*!	*/	function syncSeconds($sync_seconds = null) {		//echo ("<p>WARNING: ADODB_SESSION::syncSeconds is longer used, please remove this function for your code</p>");				return 0;	}	/*!	*/	function clob($clob = null) {		static $_clob = false;		static $set = false;		if (!is_null($clob)) {			$_clob = strtolower(trim($clob));			$set = true;		} elseif (!$set) {			// backwards compatibility			if (isset($GLOBALS['ADODB_SESSION_USE_LOBS'])) {				return $GLOBALS['ADODB_SESSION_USE_LOBS'];			}		}		return $_clob;	}	/*!	*/	function dataFieldName($data_field_name = null) {		//echo ("<p>WARNING: ADODB_SESSION::dataFieldName() is longer used, please remove this function for your code</p>");		return '';	}	/*!	*/	function filter($filter = null) {		static $_filter = array();		if (!is_null($filter)) {			if (!is_array($filter)) {				$filter = array($filter);			}			$_filter = $filter;		}		return $_filter;	}	/*!	*/	function encryptionKey($encryption_key = null) {		static $_encryption_key = 'CRYPTED ADODB SESSIONS ROCK!';		if (!is_null($encryption_key)) {			$_encryption_key = $encryption_key;		}		return $_encryption_key;	}	/////////////////////	// private methods	/////////////////////	/*!	*/	function &_conn($conn=null) {		return $GLOBALS['ADODB_SESS_CONN'];	}	/*!	*/	function _crc($crc = null) {		static $_crc = false;		if (!is_null($crc)) {			$_crc = $crc;		}		return $_crc;	}	/*!	*/	function _init() {		session_module_name('user');		session_set_save_handler(			array('ADODB_Session', 'open'),			array('ADODB_Session', 'close'),			array('ADODB_Session', 'read'),			array('ADODB_Session', 'write'),			array('ADODB_Session', 'destroy'),

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -