name() public method

Return database name
public name ( ) : string
return string
Beispiel #1
0
 /**
  *	Instantiate class
  *	@param $db object
  *	@param $table string
  *	@param $force bool
  *	@param $onsuspect callback
  **/
 function __construct(\DB\SQL $db, $table = 'sessions', $force = TRUE, $onsuspect = NULL)
 {
     if ($force) {
         $eol = "\n";
         $tab = "\t";
         $db->exec((preg_match('/mssql|sqlsrv|sybase/', $db->driver()) ? 'IF NOT EXISTS (SELECT * FROM sysobjects WHERE ' . 'name=' . $db->quote($table) . ' AND xtype=\'U\') ' . 'CREATE TABLE dbo.' : 'CREATE TABLE IF NOT EXISTS ' . (($name = $db->name()) && $db->driver() != 'pgsql' ? $name . '.' : '')) . $table . ' (' . $eol . $tab . $db->quotekey('session_id') . ' VARCHAR(40),' . $eol . $tab . $db->quotekey('data') . ' TEXT,' . $eol . $tab . $db->quotekey('csrf') . ' TEXT,' . $eol . $tab . $db->quotekey('ip') . ' VARCHAR(40),' . $eol . $tab . $db->quotekey('agent') . ' VARCHAR(255),' . $eol . $tab . $db->quotekey('stamp') . ' INTEGER,' . $eol . $tab . 'PRIMARY KEY (' . $db->quotekey('session_id') . ')' . $eol . ');');
     }
     parent::__construct($db, $table);
     session_set_save_handler(array($this, 'open'), array($this, 'close'), array($this, 'read'), array($this, 'write'), array($this, 'destroy'), array($this, 'cleanup'));
     register_shutdown_function('session_commit');
     @session_start();
     $fw = \Base::instance();
     $headers = $fw->get('HEADERS');
     if (($ip = $this->ip()) && $ip != $fw->get('IP') || ($agent = $this->agent()) && (!isset($headers['User-Agent']) || $agent != $headers['User-Agent'])) {
         if (isset($onsuspect)) {
             $fw->call($onsuspect, array($this));
         } else {
             session_destroy();
             $fw->error(403);
         }
     }
     $csrf = $fw->hash($fw->get('ROOT') . $fw->get('BASE')) . '.' . $fw->hash(mt_rand());
     if ($this->load(array('session_id=?', $this->sid = session_id()))) {
         $this->set('csrf', $csrf);
         $this->save();
     }
 }
 /**
  *	Instantiate class
  *	@param $db object
  *	@param $table string
  **/
 function __construct(\DB\SQL $db, $table = 'sessions')
 {
     $db->exec((preg_match('/mssql|sqlsrv|sybase/', $db->driver()) ? 'IF NOT EXISTS (SELECT * FROM sysobjects WHERE ' . 'name=' . $db->quote($table) . ' AND xtype=\'U\') ' . 'CREATE TABLE dbo.' : 'CREATE TABLE IF NOT EXISTS ' . (($name = $db->name()) ? $name . '.' : '')) . $table . ' (' . 'session_id VARCHAR(40),' . 'data TEXT,' . 'csrf TEXT,' . 'ip VARCHAR(40),' . 'agent VARCHAR(255),' . 'stamp INTEGER,' . 'PRIMARY KEY(session_id)' . ');');
     parent::__construct($db, $table);
     session_set_save_handler(array($this, 'open'), array($this, 'close'), array($this, 'read'), array($this, 'write'), array($this, 'destroy'), array($this, 'cleanup'));
     register_shutdown_function('session_commit');
     @session_start();
     $fw = \Base::instance();
     $headers = $fw->get('HEADERS');
     if (($csrf = $this->csrf()) && (!isset($_COOKIE['_']) || $_COOKIE['_'] != $csrf || ($ip = $this->ip()) && $ip != $fw->get('IP') || ($agent = $this->agent()) && !isset($headers['User-Agent']) || $agent != $headers['User-Agent'])) {
         $jar = $fw->get('JAR');
         $jar['expire'] = strtotime('-1 year');
         call_user_func_array('setcookie', array_merge(array('_', ''), $jar));
         unset($_COOKIE['_']);
         session_destroy();
         \Base::instance()->error(403);
     }
     $csrf = $fw->hash($fw->get('ROOT') . $fw->get('BASE')) . '.' . $fw->hash(mt_rand());
     if ($this->load(array('session_id=?', session_id()))) {
         $this->set('csrf', $csrf);
         $this->save();
         call_user_func_array('setcookie', array('_', $csrf) + $fw->get('JAR'));
     }
 }
Beispiel #3
0
 /**
  *	Instantiate class
  *	@param $db \DB\SQL
  *	@param $table string
  *	@param $force bool
  *	@param $onsuspect callback
  *	@param $key string
  **/
 function __construct(\DB\SQL $db, $table = 'sessions', $force = TRUE, $onsuspect = NULL, $key = NULL)
 {
     if ($force) {
         $eol = "\n";
         $tab = "\t";
         $db->exec((preg_match('/mssql|sqlsrv|sybase/', $db->driver()) ? 'IF NOT EXISTS (SELECT * FROM sysobjects WHERE ' . 'name=' . $db->quote($table) . ' AND xtype=\'U\') ' . 'CREATE TABLE dbo.' : 'CREATE TABLE IF NOT EXISTS ' . (($name = $db->name()) && $db->driver() != 'pgsql' ? $name . '.' : '')) . $table . ' (' . $eol . $tab . $db->quotekey('session_id') . ' VARCHAR(255),' . $eol . $tab . $db->quotekey('data') . ' TEXT,' . $eol . $tab . $db->quotekey('ip') . ' VARCHAR(45),' . $eol . $tab . $db->quotekey('agent') . ' VARCHAR(300),' . $eol . $tab . $db->quotekey('stamp') . ' INTEGER,' . $eol . $tab . 'PRIMARY KEY (' . $db->quotekey('session_id') . ')' . $eol . ');');
     }
     parent::__construct($db, $table);
     $this->onsuspect = $onsuspect;
     session_set_save_handler([$this, 'open'], [$this, 'close'], [$this, 'read'], [$this, 'write'], [$this, 'destroy'], [$this, 'cleanup']);
     register_shutdown_function('session_commit');
     $fw = \Base::instance();
     $headers = $fw->get('HEADERS');
     $this->_csrf = $fw->hash($fw->get('ROOT') . $fw->get('BASE')) . '.' . $fw->hash(mt_rand());
     if ($key) {
         $fw->set($key, $this->_csrf);
     }
     $this->_agent = isset($headers['User-Agent']) ? $headers['User-Agent'] : '';
     $this->_ip = $fw->get('IP');
 }
Beispiel #4
0
 /**
  *	Instantiate class
  *	@param $db object
  *	@param $table string
  **/
 function __construct(\DB\SQL $db, $table = 'sessions')
 {
     $db->exec('CREATE TABLE IF NOT EXISTS ' . (($name = $db->name()) ? $name . '.' : '') . $table . ' (' . 'session_id VARCHAR(40),' . 'data TEXT,' . 'ip VARCHAR(40),' . 'agent VARCHAR(255),' . 'stamp INTEGER,' . 'PRIMARY KEY(session_id)' . ');');
     parent::__construct($db, $table);
     session_set_save_handler(array($this, 'open'), array($this, 'close'), array($this, 'read'), array($this, 'write'), array($this, 'destroy'), array($this, 'cleanup'));
     register_shutdown_function('session_commit');
 }
Beispiel #5
0
 /**
  *	Instantiate class
  *	@param $db object
  *	@param $table string
  **/
 function __construct(\DB\SQL $db, $table = 'sessions')
 {
     $db->exec((preg_match('/mssql|sqlsrv|sybase/', $db->driver()) ? 'IF NOT EXISTS (SELECT * FROM sysobjects WHERE ' . 'name=' . $db->quote($table) . ' AND xtype=\'U\') ' . 'CREATE TABLE dbo.' : 'CREATE TABLE IF NOT EXISTS ' . (($name = $db->name()) ? $name . '.' : '')) . $table . ' (' . 'session_id VARCHAR(40),' . 'data TEXT,' . 'ip VARCHAR(40),' . 'agent VARCHAR(255),' . 'stamp INTEGER,' . 'PRIMARY KEY(session_id)' . ');');
     parent::__construct($db, $table);
     session_set_save_handler(array($this, 'open'), array($this, 'close'), array($this, 'read'), array($this, 'write'), array($this, 'destroy'), array($this, 'cleanup'));
     register_shutdown_function('session_commit');
 }