コード例 #1
0
ファイル: session.php プロジェクト: fraancisneiluiz/ciaweb
 public static function resume()
 {
     if (isset($GLOBALS['ADODB_SESS_CONN']) && is_object($GLOBALS['ADODB_SESS_CONN'])) {
         ADOdb_session::Persist($connectMode = $persist);
         $GLOBALS['ADODB_SESS_CONN']->debug = $debug;
         @session_start();
     }
 }
コード例 #2
0
 /**
  * Abre a conexao com o banco de dados
  */
 public function open()
 {
     $this->adodb = $GLOBALS['ADODB_SESS_CONN'];
     // reaproveita a conexao da sessao, caso exista uma e seja identica a conexao sendo criada
     if (is_object($this->adodb) && $this->adodb->host == $this->host && $this->adodb->port == $this->port && $this->adodb->database == $this->database && $this->adodb->user == $this->user && $this->adodb->password == $this->passowrd) {
         ADOdb_session::Persist($connectMode = $this->conn_persistent);
     } else {
         $conn_data = "host={$this->host} port={$this->port} dbname={$this->database} user={$this->user} password={$this->password}";
         $this->adodb = ADONewConnection("postgres");
         if ($this->conn_persistent) {
             // Conexao persistente
             if (!$this->adodb->PConnect($conn_data)) {
                 $this->show_error($this->adodb->ErrorMsg());
             }
         } else {
             // Conexao nao persistente
             if (!$this->adodb->Connect($conn_data)) {
                 $this->show_error($this->adodb->ErrorMsg());
             }
         }
     }
     $this->adodb->debug = $this->debug;
 }
コード例 #3
0
ファイル: Engine.php プロジェクト: sluther/portsensor
 /**
  * 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;
 }
コード例 #4
0
ファイル: handler.php プロジェクト: nrueckmann/yeager
 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
 }