Exemple #1
0
 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();
     }
 }
$options['debug'] = 1;
$db = 'postgres';
#### CONNECTION
switch ($db) {
    case 'oci8':
        $options['table'] = 'adodb_sessions2';
        ADOdb_Session::config('oci8', 'mobydick', 'jdev', 'natsoft', 'mobydick', $options);
        break;
    case 'postgres':
        $options['table'] = 'sessions2';
        ADOdb_Session::config('postgres', 'localhost', 'postgres', 'natsoft', 'northwind', $options);
        break;
    case 'mysql':
    default:
        $options['table'] = 'sessions2';
        ADOdb_Session::config('mysql', 'localhost', 'root', '', 'xphplens_2', $options);
        break;
}
#### SETUP NOTIFICATION
$USER = '******' . rand();
$ADODB_SESSION_EXPIRE_NOTIFY = array('USER', 'NotifyExpire');
adodb_session_create_table();
session_start();
adodb_session_regenerate_id();
### SETUP SESSION VARIABLES
if (empty($_SESSION['MONKEY'])) {
    $_SESSION['MONKEY'] = array(1, 'abc', 44.41);
} else {
    $_SESSION['MONKEY'][0] += 1;
}
if (!isset($_GET['nochange'])) {
<?php

#
# Configuracion del conexion a la base de datos
#
include_once "adodb/adodb.inc.php";
#
# Tipo de Base de Datos. Solo implementadas MySQL y ADO MSSQL
#
$db = 'mysql';
//$driver = 'mysql'; $host = 'localhost'; $user = '******'; $pwd = 'asistencia'; $database = 'asistencia';
//ADOdb_Session::config($driver, $host, $user, $pwd, $database,$options=false);
if ($db == 'mysql') {
    $driver = $db;
    $host = 'localhost';
    $user = '******';
    $pwd = 'asistencia';
    $database = 'asistencia';
    ADOdb_Session::config($driver, $host, $user, $pwd, $database, $options = false);
}
if ($db == 'ado_mssql') {
    $driver = $db;
    $host = 'localhost';
    $user = '******';
    $pwd = '456789';
    $database = 'Asistencia';
    ADOdb_Session::config($driver, $host, $user, $pwd, $database, $options = false);
    //$myDSN="PROVIDER=MSDASQL;DRIVER={SQL Server};"
    //. "SERVER=APRYL_REAL;DATABASE=Asistencia;UID=sa;PWD=456789;"  ;
}
Exemple #4
0
// The following function (when called) includes FireBug Lite if true
define('FIREBUG', $use_firebug_lite);
define('ADODB_ASSOC_CASE', 2);
// needed to set proper upper/lower casing for mssql
##################################################################################
require_once $rootdir . '/classes/adodb/adodb.inc.php';
require_once $rootdir . '/classes/datetimeconverter/class.datetimeconverter.php';
require_once $rootdir . '/classes/phpmailer/class.phpmailer.php';
require_once $rootdir . '/classes/php-gettext/gettext.inc';
require_once $rootdir . '/classes/core/surveytranslator.php';
require_once $rootdir . '/classes/core/sanitize.php';
//  DB session handling
if ($sessionhandler == 'db') {
    require_once $rootdir . "/classes/adodb/session/adodb-session2.php";
    $sessionoptions['table'] = $dbprefix . 'sessions';
    ADOdb_Session::config($databasetype, $databaselocation, $databaseuser, $databasepass, $databasename, $sessionoptions);
}
$dbprefix = strtolower($dbprefix);
define("_PHPVERSION", phpversion());
// This is the same as the server defined 'PHP_VERSION'
// Deal with server systems having not set a default time zone
if (function_exists("date_default_timezone_set") and function_exists("date_default_timezone_get")) {
    @date_default_timezone_set(@date_default_timezone_get());
}
//Every 50th time clean up the temp directory of old files (older than 1 day)
//depending on the load the  probability might be set higher or lower
if (rand(1, 50) == 25) {
    cleanTempDirectory();
}
// Array of JS and CSS scripts to include in client header
$js_header_includes = array();
Exemple #5
0
<?php

/**
 * SUMO: Database sessions
 *
 * @version    0.4.0
 * @link       http://sumoam.sourceforge.net SUMO Access Manager
 * @author     Alberto Basso <*****@*****.**>
 * @copyright  Copyright &copy; 2003-2009, Alberto Basso
 * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
 * @package    SUMO
 * @category   Core
 */
$options['table'] = SUMO_TABLE_SESSIONS_STORE;
switch ($sumo_db['type']) {
    case 'mysql':
        ADOdb_Session::config($sumo_db['type'], $sumo_db['host'], $sumo_db['user'], $sumo_db['password'], $sumo_db['name'], $options);
        break;
    case 'postgres':
        ADOdb_Session::config($sumo_db['type'], $sumo_db['host'], $sumo_db['user'], $sumo_db['password'], $sumo_db['name'], $options);
        break;
    case 'sqlite':
        // NOT YET SUPPORTED BY ADODB
        break;
}
ADOdb_Session::Persist(false);
ADOdb_Session::filter(new ADODB_Encrypt_MD5());
// will compress and then encrypt the record in the database
//ADODB_Session::optimize(true);
adodb_sess_open(false, false, false);
Exemple #6
0
 /**
  * Returns an instance of the session manager
  *
  * @static
  * @return _DevblocksSessionManager
  */
 static function getInstance()
 {
     static $instance = null;
     if (null == $instance) {
         $db = DevblocksPlatform::getDatabaseService();
         if (is_null($db) || !$db->IsConnected()) {
             return null;
         }
         $prefix = APP_DB_PREFIX != '' ? APP_DB_PREFIX . '_' : '';
         // [TODO] Cleanup
         @session_destroy();
         include_once DEVBLOCKS_PATH . "libs/adodb5/session/adodb-session2.php";
         $options = array();
         $options['table'] = $prefix . 'session';
         ADOdb_Session::config(APP_DB_DRIVER, APP_DB_HOST, APP_DB_USER, APP_DB_PASS, APP_DB_DATABASE, $options);
         ADOdb_session::Persist($connectMode = false);
         ADOdb_session::lifetime($lifetime = 86400);
         session_name(APP_SESSION_NAME);
         session_set_cookie_params(0);
         session_start();
         $instance = new _DevblocksSessionManager();
         $instance->visit = isset($_SESSION['db_visit']) ? $_SESSION['db_visit'] : NULL;
         /* @var $visit DevblocksVisit */
     }
     return $instance;
 }
Exemple #7
0
 function __construct($session_handler, &$appserver, $cookie_scope, $cookie_time, $secret, $cookie_domain = "")
 {
     $this->handler = $session_handler;
     $this->appserver = $appserver;
     //$this->id = $appserver->request->parameters['sid'];
     $this->ip = $appserver->request->client_ip;
     $this->cookie_scope = $cookie_scope;
     $this->cookie_time = $cookie_time;
     $this->cookie_domain = $cookie_domain;
     $this->session_name = "sid";
     $this->secret = $secret;
     //ob_end_clean();
     // setup
     ini_set('session.use_cookies', 0);
     ini_set('session.use_trans_sid', 0);
     session_name($this->session_name);
     if (strlen($_POST['flashcookie']) > 1) {
         $fc = $_POST['flashcookie'];
         $this->appserver->error->raise("SESSION: client " . $this->ip . " passed flashcookie {$fc}", ERR_DEBUG);
         preg_match('/.*sid=([\\w]*).*/', $fc, $asMatch);
         $fvalue = $asMatch[1];
         $this->appserver->error->raise("SESSION: client " . $this->ip . " found {$fvalue} in flashcokkie", ERR_DEBUG);
         if (strlen($fvalue) > 0) {
             $this->appserver->error->raise("SESSION: client " . $this->ip . " overrides sid with {$fvalue} from flashcookie", ERR_NOTICE);
             $this->id = session_id($fvalue);
         }
     }
     if ($this->handler == "") {
         return;
     }
     if ($this->handler == "php") {
         $this->appserver->error->raise("SESSION: using php as session handler.", ERR_DEBUG);
     } else {
         if ($this->handler == "adodb") {
             $this->appserver->error->raise("SESSION: adodb php as session handler.", ERR_DEBUG);
             $dbcfg = $this->appserver->config->xmlobject->SESSION->DSN;
             $dbattrs = $dbcfg->attributes();
             $this->handler_driver = (string) $dbattrs["driver"];
             $this->handler_host = (string) $dbattrs["host"];
             $this->handler_user = (string) $dbattrs["user"];
             $this->handler_pw = (string) $dbattrs["password"];
             $this->handler_db = (string) $dbattrs["db"];
             $this->handler_table = (string) $dbattrs["table"];
             //				$ADODB_SESSION_DRIVER = $this->handler_driver;
             //				$ADODB_SESSION_CONNECT = $this->handler_host;
             //				$ADODB_SESSION_USER = $this->handler_user;
             //				$ADODB_SESSION_PWD = $this->handler_pw;
             //				$ADODB_SESSION_DB = $this->handler_db;
             //				$ADODB_SESSION_TBL = $this->handler_table;
             require_once getrealpath(dirname(__FILE__) . "/../../../../org/adodb/session/adodb-session2.php");
             $options['table'] = $this->handler_table;
             ADOdb_Session::lifetime($this->cookie_time);
             ADOdb_Session::config($this->handler_driver, $this->handler_host, $this->handler_user, $this->handler_pw, $this->handler_db, $options);
             ADOdb_session::Persist('P');
             //				ADOdb_Session::debug(true);
         }
     }
     if ($this->cookie_time == 0) {
         $ct = 0;
     } else {
         $ct = $this->cookie_time + time();
     }
     session_set_cookie_params($ct, $this->cookie_scope, $this->cookie_domain);
     ini_set('session.use_cookies', 0);
     $this->session_started = false;
     if ($_COOKIE[$this->session_name]) {
         $this->id = session_id($_COOKIE[$this->session_name]);
     } else {
         session_start();
         session_regenerate_id();
         $this->id = session_id();
     }
     //			setcookie ($this->session_name, $this->id, $ct, $this->cookie_scope, $this->cookie_domain);
     $_SESSION["nptn"] = true;
     $_SESSION["ts"] = time();
     if ($this->id != "") {
         // set session id to goven one
         $this->appserver->error->raise("SESSION: got session id {$this->id}", ERR_DEBUG);
     } else {
         // generate session id
         $this->id = session_id();
         if (!$this->id) {
             trigger_error("SESSION: could not generate session id", E_USER_ERROR);
         }
         $this->appserver->error->raise("SESSION: new session id: {$this->id}", ERR_DEBUG);
     }
     $this->appserver->error->setSessionId($this->id);
     // if session not empty
 }
Exemple #8
0
 * @author Adam Zammit <*****@*****.**>
 * @copyright Deakin University 2007,2008,2009
 * @package queXC
 * @subpackage configuration
 * @link http://www.deakin.edu.au/dcarf/ queXC was writen for DCARF - Deakin Computer Assisted Research Facility
 * @license http://opensource.org/licenses/agpl-v3.html The GNU Affero General Public License (AGPL) Version 3
 * 
 */
/**
 * Set locale
 */
include_once dirname(__FILE__) . '/lang.inc.php';
/**
 * Include ADODB
 */
if (!(include_once ADODB_PATH . 'adodb.inc.php')) {
    print "<p>ERROR: Please modify config.inc.php for ADODB_PATH to point to your ADODb installation</p>";
}
/**
 * Include ADODB session handling functions
 */
if (!(include_once ADODB_PATH . 'session/adodb-session2.php')) {
    print "<p>ERROR: Please modify config.inc.php for ADODB_PATH to point to your ADODb installation</p>";
}
//global database variable
$db = newADOConnection(DB_TYPE);
$db->Connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
$db->SetFetchMode(ADODB_FETCH_ASSOC);
//store session in database (see sessions2 table)
ADOdb_Session::config(DB_TYPE, DB_HOST, DB_USER, DB_PASS, DB_NAME, $options = false);
    # set the cookie domain so that the sessions are shared between subdomains
    # TODO: verify that this works; mixed results
    $cookie_domain = substr_count($_SERVER['HTTP_HOST'], '.') == 1 ? '.' . $_SERVER['HTTP_HOST'] : preg_replace('/^([^.])*/i', null, $_SERVER['HTTP_HOST']);
}
#set the PHP session id (PHPSESSID) cookie to a custom value
session_set_cookie_params($cookie_timeout, '/', $cookie_domain);
# timeout value for the garbage collector
ini_set('session.gc_maxlifetime', $cookie_timeout);
# set session handler
if ($memcache && $session_storage == 'memcache') {
    ini_set('session.save_handler', 'memcache');
    ini_set('session.save_path', $memcache_save_path);
} else {
    if ($db_name && $db_domain && $session_storage == 'db') {
        include_once 'lib/adodb/session/adodb-session2.php';
        ADOdb_Session::config($db_platform, $dbw_domain, $db_username, $db_password, $db_name, $options = false);
    }
}
# start the session
session_cache_limiter('none');
session_start();
# check if this is a multi domain session
if (!$multi_session_domain) {
    return;
}
# get the base domain name and subdomain name
foreach ($multi_session_domain as $domain) {
    $start = strpos($_SERVER['HTTP_HOST'], $domain);
    if ($start === false) {
        continue;
    }