Spade
Mini Shell
| Directory:~$ /home/lmsyaran/public_html/css/ |
| [Home] [System Details] [Kill Me] |
handler/interface.php000064400000005322151165414000010631 0ustar00<?php
/**
* @package Joomla.Platform
* @subpackage Session
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Interface for managing HTTP sessions
*
* @since 3.5
* @deprecated 4.0 The CMS' Session classes will be replaced with
the `joomla/session` package
*/
interface JSessionHandlerInterface
{
/**
* Starts the session.
*
* @return boolean True if started.
*
* @since 3.5
* @throws RuntimeException If something goes wrong starting the session.
*/
public function start();
/**
* Checks if the session is started.
*
* @return boolean True if started, false otherwise.
*
* @since 3.5
*/
public function isStarted();
/**
* Returns the session ID
*
* @return string The session ID
*
* @since 3.5
*/
public function getId();
/**
* Sets the session ID
*
* @param string $id The session ID
*
* @return void
*
* @since 3.5
*/
public function setId($id);
/**
* Returns the session name
*
* @return mixed The session name.
*
* @since 3.5
*/
public function getName();
/**
* Sets the session name
*
* @param string $name The name of the session
*
* @return void
*
* @since 3.5
*/
public function setName($name);
/**
* Regenerates ID that represents this storage.
*
* Note regenerate+destroy should not clear the session data in memory
only delete the session data from persistent storage.
*
* @param boolean $destroy Destroy session when regenerating?
* @param integer $lifetime Sets the cookie lifetime for the session
cookie. A null value will leave the system settings unchanged,
* 0 sets the cookie to expire with browser
session. Time is in seconds, and is not a Unix timestamp.
*
* @return boolean True if session regenerated, false if error
*
* @since 3.5
*/
public function regenerate($destroy = false, $lifetime = null);
/**
* Force the session to be saved and closed.
*
* This method must invoke session_write_close() unless this interface is
used for a storage object design for unit or functional testing where
* a real PHP session would interfere with testing, in which case it
should actually persist the session data if required.
*
* @return void
*
* @see session_write_close()
* @since 3.5
* @throws RuntimeException If the session is saved without being
started, or if the session is already closed.
*/
public function save();
/**
* Clear all session data in memory.
*
* @return void
*
* @since 3.5
*/
public function clear();
}
handler/joomla.php000064400000006637151165414000010164 0ustar00<?php
/**
* @package Joomla.Platform
* @subpackage Session
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Interface for managing HTTP sessions
*
* @since 3.5
* @deprecated 4.0 The CMS' Session classes will be replaced with
the `joomla/session` package
*/
class JSessionHandlerJoomla extends JSessionHandlerNative
{
/**
* The input object
*
* @var JInput
* @since 3.5
*/
public $input = null;
/**
* Force cookies to be SSL only
*
* @var boolean
* @since 3.5
*/
protected $force_ssl = false;
/**
* Public constructor
*
* @param array $options An array of configuration options
*
* @since 3.5
*/
public function __construct($options = array())
{
if (!headers_sent())
{
// Disable transparent sid support
ini_set('session.use_trans_sid', '0');
// Only allow the session ID to come from cookies and nothing else.
if ((int) ini_get('session.use_cookies') !== 1)
{
ini_set('session.use_only_cookies', 1);
}
}
// Set options
$this->setOptions($options);
$this->setCookieParams();
}
/**
* Starts the session
*
* @return boolean True if started
*
* @since 3.5
* @throws RuntimeException If something goes wrong starting the session.
*/
public function start()
{
$session_name = $this->getName();
// Get the JInputCookie object
$cookie = $this->input->cookie;
if (is_null($cookie->get($session_name)))
{
$session_clean = $this->input->get($session_name, false,
'string');
if ($session_clean)
{
$this->setId($session_clean);
$cookie->set($session_name, '', 1);
}
}
return parent::start();
}
/**
* Clear all session data in memory.
*
* @return void
*
* @since 3.5
*/
public function clear()
{
$sessionName = $this->getName();
/*
* In order to kill the session altogether, such as to log the user out,
the session id
* must also be unset. If a cookie is used to propagate the session id
(default behavior),
* then the session cookie must be deleted.
* We need to use setcookie here or we will get a warning in some session
handlers (ex: files).
*/
if (isset($_COOKIE[$sessionName]))
{
$cookie = session_get_cookie_params();
setcookie($sessionName, '', 1, $cookie['path'],
$cookie['domain'], $cookie['secure'], true);
}
parent::clear();
}
/**
* Set session cookie parameters
*
* @return void
*
* @since 3.5
*/
protected function setCookieParams()
{
if (headers_sent())
{
return;
}
$cookie = session_get_cookie_params();
if ($this->force_ssl)
{
$cookie['secure'] = true;
}
$config = JFactory::getConfig();
if ($config->get('cookie_domain', '') !=
'')
{
$cookie['domain'] =
$config->get('cookie_domain');
}
if ($config->get('cookie_path', '') !=
'')
{
$cookie['path'] = $config->get('cookie_path');
}
session_set_cookie_params($cookie['lifetime'],
$cookie['path'], $cookie['domain'],
$cookie['secure'], true);
}
/**
* Set additional session options
*
* @param array $options List of parameter
*
* @return boolean True on success
*
* @since 3.5
*/
protected function setOptions(array $options)
{
if (isset($options['force_ssl']))
{
$this->force_ssl = (bool) $options['force_ssl'];
}
return true;
}
}
handler/native.php000064400000013613151165414000010161 0ustar00<?php
/**
* @package Joomla.Platform
* @subpackage Session
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Interface for managing HTTP sessions
*
* @since 3.5
* @deprecated 4.0 The CMS' Session classes will be replaced with
the `joomla/session` package
*/
class JSessionHandlerNative implements JSessionHandlerInterface
{
/**
* Has the session been started
*
* @var boolean
* @since 3.5
*/
private $started = false;
/**
* Has the session been closed
*
* @var boolean
* @since 3.5
*/
private $closed = false;
/**
* Starts the session
*
* @return boolean True if started
*
* @since 3.5
*/
public function start()
{
if ($this->isStarted())
{
return true;
}
$this->doSessionStart();
return true;
}
/**
* Checks if the session is started.
*
* @return boolean True if started, false otherwise.
*
* @since 3.5
*/
public function isStarted()
{
return $this->started;
}
/**
* Returns the session ID
*
* @return string The session ID
*
* @since 3.5
*/
public function getId()
{
return session_id();
}
/**
* Sets the session ID
*
* @param string $id The session ID
*
* @return void
*
* @since 3.5
* @throws LogicException
*/
public function setId($id)
{
if ($this->isStarted())
{
throw new LogicException('Cannot change the ID of an active
session');
}
session_id($id);
}
/**
* Returns the session name
*
* @return mixed The session name
*
* @since 3.5
*/
public function getName()
{
return session_name();
}
/**
* Sets the session name
*
* @param string $name The name of the session
*
* @return void
*
* @since 3.5
* @throws LogicException
*/
public function setName($name)
{
if ($this->isStarted())
{
throw new LogicException('Cannot change the name of an active
session');
}
session_name($name);
}
/**
* Regenerates ID that represents this storage.
*
* Note regenerate+destroy should not clear the session data in memory
only delete the session data from persistent storage.
*
* @param boolean $destroy Destroy session when regenerating?
* @param integer $lifetime Sets the cookie lifetime for the session
cookie. A null value will leave the system settings unchanged,
* 0 sets the cookie to expire with browser
session. Time is in seconds, and is not a Unix timestamp.
*
* @return boolean True if session regenerated, false if error
*
* @since 3.5
*/
public function regenerate($destroy = false, $lifetime = null)
{
if (!headers_sent() && null !== $lifetime)
{
ini_set('session.cookie_lifetime', $lifetime);
}
$return = session_regenerate_id($destroy);
// Workaround for https://bugs.php.net/bug.php?id=61470 as suggested by
David Grudl
session_write_close();
$this->closed = true;
if (isset($_SESSION))
{
$backup = $_SESSION;
$this->doSessionStart();
$_SESSION = $backup;
}
else
{
$this->doSessionStart();
}
return $return;
}
/**
* Force the session to be saved and closed.
*
* This method must invoke session_write_close() unless this interface is
used for a storage object design for unit or functional testing where
* a real PHP session would interfere with testing, in which case it
should actually persist the session data if required.
*
* @return void
*
* @see session_write_close()
* @since 3.5
*/
public function save()
{
// Verify if the session is active
if ((version_compare(PHP_VERSION, '5.4', 'ge')
&& PHP_SESSION_ACTIVE === session_status())
|| (version_compare(PHP_VERSION, '5.4', 'lt')
&& $this->started && isset($_SESSION) &&
$this->getId()))
{
$session = JFactory::getSession();
$data = $session->getData();
// Before storing it, let's serialize and encode the Registry
object
$_SESSION['joomla'] = base64_encode(serialize($data));
session_write_close();
$this->closed = true;
$this->started = false;
}
}
/**
* Clear all session data in memory.
*
* @return void
*
* @since 3.5
*/
public function clear()
{
// Need to destroy any existing sessions started with session.auto_start
if ($this->getId())
{
session_unset();
session_destroy();
}
$this->closed = true;
$this->started = false;
}
/**
* Performs the session start mechanism
*
* @return void
*
* @since 3.5.1
* @throws RuntimeException If something goes wrong starting the session.
*/
private function doSessionStart()
{
// Register our function as shutdown method, so we can manipulate it
register_shutdown_function(array($this, 'save'));
// Disable the cache limiter
session_cache_limiter('none');
/*
* Extended checks to determine if the session has already been started
*/
// If running PHP 5.4, try to use the native API
if (version_compare(PHP_VERSION, '5.4', 'ge')
&& PHP_SESSION_ACTIVE === session_status())
{
throw new RuntimeException('Failed to start the session: already
started by PHP.');
}
// Fallback check for PHP 5.3
if (version_compare(PHP_VERSION, '5.4', 'lt')
&& !$this->closed && isset($_SESSION) &&
$this->getId())
{
throw new RuntimeException('Failed to start the session: already
started by PHP ($_SESSION is set).');
}
// If we are using cookies (default true) and headers have already been
started (early output),
if (ini_get('session.use_cookies') &&
headers_sent($file, $line))
{
throw new RuntimeException(sprintf('Failed to start the session
because headers have already been sent by "%s" at line %d.',
$file, $line));
}
// Ok to try and start the session
if (!session_start())
{
throw new RuntimeException('Failed to start the session');
}
// Mark ourselves as started
$this->started = true;
}
}
storage/apc.php000064400000004235151165414000007465 0ustar00<?php
/**
* @package Joomla.Platform
* @subpackage Session
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* APC session storage handler for PHP
*
* @link
https://www.php.net/manual/en/function.session-set-save-handler.php
* @since 1.7.0
* @deprecated 4.0 The CMS' Session classes will be replaced with
the `joomla/session` package
*/
class JSessionStorageApc extends JSessionStorage
{
/**
* Constructor
*
* @param array $options Optional parameters
*
* @since 1.7.0
* @throws RuntimeException
*/
public function __construct($options = array())
{
if (!self::isSupported())
{
throw new RuntimeException('APC Extension is not available',
404);
}
parent::__construct($options);
}
/**
* Read the data for a particular session identifier from the
* SessionHandler backend.
*
* @param string $id The session identifier.
*
* @return string The session data.
*
* @since 1.7.0
*/
public function read($id)
{
$sess_id = 'sess_' . $id;
return (string) apc_fetch($sess_id);
}
/**
* Write session data to the SessionHandler backend.
*
* @param string $id The session identifier.
* @param string $sessionData The session data.
*
* @return boolean True on success, false otherwise.
*
* @since 1.7.0
*/
public function write($id, $sessionData)
{
$sess_id = 'sess_' . $id;
return apc_store($sess_id, $sessionData,
ini_get('session.gc_maxlifetime'));
}
/**
* Destroy the data for a particular session identifier in the
SessionHandler backend.
*
* @param string $id The session identifier.
*
* @return boolean True on success, false otherwise.
*
* @since 1.7.0
*/
public function destroy($id)
{
$sess_id = 'sess_' . $id;
return apc_delete($sess_id);
}
/**
* Test to see if the SessionHandler is available.
*
* @return boolean True on success, false otherwise.
*
* @since 3.0.0
*/
public static function isSupported()
{
return extension_loaded('apc');
}
}
storage/apcu.php000064400000005006151165414000007647 0ustar00<?php
/**
* @package Joomla.Platform
* @subpackage Session
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* APC session storage handler for PHP
*
* @link
https://www.php.net/manual/en/function.session-set-save-handler.php
* @since 3.9
* @deprecated 4.0 The CMS' Session classes will be replaced with
the `joomla/session` package
*/
class JSessionStorageApcu extends JSessionStorage
{
/**
* Constructor
*
* @param array $options Optional parameters
*
* @since 3.9
* @throws RuntimeException
*/
public function __construct($options = array())
{
if (!self::isSupported())
{
throw new RuntimeException('APCu Extension is not available',
404);
}
parent::__construct($options);
}
/**
* Read the data for a particular session identifier from the
* SessionHandler backend.
*
* @param string $id The session identifier.
*
* @return string The session data.
*
* @since 3.9
*/
public function read($id)
{
$sess_id = 'sess_' . $id;
return (string) apcu_fetch($sess_id);
}
/**
* Write session data to the SessionHandler backend.
*
* @param string $id The session identifier.
* @param string $sessionData The session data.
*
* @return boolean True on success, false otherwise.
*
* @since 3.9
*/
public function write($id, $sessionData)
{
$sess_id = 'sess_' . $id;
return apcu_store($sess_id, $sessionData,
ini_get('session.gc_maxlifetime'));
}
/**
* Destroy the data for a particular session identifier in the
SessionHandler backend.
*
* @param string $id The session identifier.
*
* @return boolean True on success, false otherwise.
*
* @since 3.9
*/
public function destroy($id)
{
$sess_id = 'sess_' . $id;
// The apcu_delete function returns false if the id does not exist
return apcu_delete($sess_id = 'sess_' . $id) ||
!apcu_exists($sess_id = 'sess_' . $id);
}
/**
* Test to see if the SessionHandler is available.
*
* @return boolean True on success, false otherwise.
*
* @since 3.9
*/
public static function isSupported()
{
$supported = extension_loaded('apcu') &&
ini_get('apc.enabled');
// If on the CLI interface, the `apc.enable_cli` option must also be
enabled
if ($supported && php_sapi_name() === 'cli')
{
$supported = ini_get('apc.enable_cli');
}
return (bool) $supported;
}
}
storage/database.php000064400000007600151165414000010465 0ustar00<?php
/**
* @package Joomla.Platform
* @subpackage Session
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Database session storage handler for PHP
*
* @link
https://www.php.net/manual/en/function.session-set-save-handler.php
* @since 1.7.0
* @deprecated 4.0 The CMS' Session classes will be replaced with
the `joomla/session` package
*/
class JSessionStorageDatabase extends JSessionStorage
{
/**
* Read the data for a particular session identifier from the
SessionHandler backend.
*
* @param string $id The session identifier.
*
* @return string The session data.
*
* @since 1.7.0
*/
public function read($id)
{
// Get the database connection object and verify its connected.
$db = JFactory::getDbo();
try
{
// Get the session data from the database table.
$query = $db->getQuery(true)
->select($db->quoteName('data'))
->from($db->quoteName('#__session'))
->where($db->quoteName('session_id') . ' = ' .
$db->quoteBinary($id));
$db->setQuery($query);
$result = (string) $db->loadResult();
$result = str_replace('\0\0\0', chr(0) . '*' .
chr(0), $result);
return $result;
}
catch (RuntimeException $e)
{
return false;
}
}
/**
* Write session data to the SessionHandler backend.
*
* @param string $id The session identifier.
* @param string $data The session data.
*
* @return boolean True on success, false otherwise.
*
* @since 1.7.0
*/
public function write($id, $data)
{
// Get the database connection object and verify its connected.
$db = JFactory::getDbo();
$data = str_replace(chr(0) . '*' . chr(0), '\0\0\0',
$data);
try
{
$query = $db->getQuery(true)
->update($db->quoteName('#__session'))
->set($db->quoteName('data') . ' = ' .
$db->quote($data))
->set($db->quoteName('time') . ' = ' .
time())
->where($db->quoteName('session_id') . ' = '
. $db->quoteBinary($id));
// Try to update the session data in the database table.
$db->setQuery($query);
$db->execute();
/*
* Since $db->execute did not throw an exception, so the query was
successful.
* Either the data changed, or the data was identical.
* In either case we are done.
*/
return true;
}
catch (RuntimeException $e)
{
return false;
}
}
/**
* Destroy the data for a particular session identifier in the
SessionHandler backend.
*
* @param string $id The session identifier.
*
* @return boolean True on success, false otherwise.
*
* @since 1.7.0
*/
public function destroy($id)
{
// Get the database connection object and verify its connected.
$db = JFactory::getDbo();
try
{
$query = $db->getQuery(true)
->delete($db->quoteName('#__session'))
->where($db->quoteName('session_id') . ' = '
. $db->quoteBinary($id));
// Remove a session from the database.
$db->setQuery($query);
return (boolean) $db->execute();
}
catch (RuntimeException $e)
{
return false;
}
}
/**
* Garbage collect stale sessions from the SessionHandler backend.
*
* @param integer $lifetime The maximum age of a session.
*
* @return boolean True on success, false otherwise.
*
* @since 1.7.0
*/
public function gc($lifetime = 1440)
{
// Get the database connection object and verify its connected.
$db = JFactory::getDbo();
// Determine the timestamp threshold with which to purge old sessions.
$past = time() - $lifetime;
try
{
$query = $db->getQuery(true)
->delete($db->quoteName('#__session'))
->where($db->quoteName('time') . ' < ' .
(int) $past);
// Remove expired sessions from the database.
$db->setQuery($query);
return (boolean) $db->execute();
}
catch (RuntimeException $e)
{
return false;
}
}
}
storage/memcache.php000064400000003602151165414000010461 0ustar00<?php
/**
* @package Joomla.Platform
* @subpackage Session
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Memcache session storage handler for PHP
*
* @since 1.7.0
* @deprecated 4.0 The CMS' Session classes will be replaced with
the `joomla/session` package
*/
class JSessionStorageMemcache extends JSessionStorage
{
/**
* @var array Container for memcache server conf arrays
*/
private $_servers = array();
/**
* Constructor
*
* @param array $options Optional parameters.
*
* @since 1.7.0
* @throws RuntimeException
*/
public function __construct($options = array())
{
if (!self::isSupported())
{
throw new RuntimeException('Memcache Extension is not
available', 404);
}
$config = JFactory::getConfig();
// This will be an array of loveliness
// @todo: multiple servers
$this->_servers = array(
array(
'host' =>
$config->get('session_memcache_server_host',
'localhost'),
'port' =>
$config->get('session_memcache_server_port', 11211),
),
);
parent::__construct($options);
}
/**
* Register the functions of this class with PHP's session handler
*
* @return void
*
* @since 3.0.1
*/
public function register()
{
if (!empty($this->_servers) && isset($this->_servers[0]))
{
$serverConf = current($this->_servers);
if (!headers_sent())
{
ini_set('session.save_path',
"{$serverConf['host']}:{$serverConf['port']}");
ini_set('session.save_handler', 'memcache');
}
}
}
/**
* Test to see if the SessionHandler is available.
*
* @return boolean True on success, false otherwise.
*
* @since 3.0.0
*/
public static function isSupported()
{
return extension_loaded('memcache') &&
class_exists('Memcache');
}
}
storage/memcached.php000064400000003612151165414000010626 0ustar00<?php
/**
* @package Joomla.Platform
* @subpackage Session
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Memcached session storage handler for PHP
*
* @since 1.7.0
* @deprecated 4.0 The CMS' Session classes will be replaced with
the `joomla/session` package
*/
class JSessionStorageMemcached extends JSessionStorage
{
/**
* @var array Container for memcache server conf arrays
*/
private $_servers = array();
/**
* Constructor
*
* @param array $options Optional parameters.
*
* @since 1.7.0
* @throws RuntimeException
*/
public function __construct($options = array())
{
if (!self::isSupported())
{
throw new RuntimeException('Memcached Extension is not
available', 404);
}
$config = JFactory::getConfig();
// This will be an array of loveliness
// @todo: multiple servers
$this->_servers = array(
array(
'host' =>
$config->get('session_memcached_server_host',
'localhost'),
'port' =>
$config->get('session_memcached_server_port', 11211),
),
);
parent::__construct($options);
}
/**
* Register the functions of this class with PHP's session handler
*
* @return void
*
* @since 3.0.1
*/
public function register()
{
if (!empty($this->_servers) && isset($this->_servers[0]))
{
$serverConf = current($this->_servers);
if (!headers_sent())
{
ini_set('session.save_path',
"{$serverConf['host']}:{$serverConf['port']}");
ini_set('session.save_handler', 'memcached');
}
}
}
/**
* Test to see if the SessionHandler is available.
*
* @return boolean True on success, false otherwise.
*
* @since 3.0.0
*/
public static function isSupported()
{
return extension_loaded('memcached') &&
class_exists('Memcached');
}
}
storage/none.php000064400000001402151165414000007652 0ustar00<?php
/**
* @package Joomla.Platform
* @subpackage Session
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* File session handler for PHP
*
* @link
https://www.php.net/manual/en/function.session-set-save-handler.php
* @since 1.7.0
* @deprecated 4.0 The CMS' Session classes will be replaced with
the `joomla/session` package
*/
class JSessionStorageNone extends JSessionStorage
{
/**
* Register the functions of this class with PHP's session handler
*
* @return void
*
* @since 1.7.0
*/
public function register()
{
// Default session handler is `files`
}
}
storage/redis.php000064400000005045151165414000010030 0ustar00<?php
/**
* @package Joomla.Platform
* @subpackage Session
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Redis session storage handler for PHP
*
* @link
https://www.php.net/manual/en/function.session-set-save-handler.php
* @since 3.8.0
*/
class JSessionStorageRedis extends JSessionStorage
{
/**
* Constructor
*
* @param array $options Optional parameters.
*
* @since 3.8.0
*/
public function __construct($options = array())
{
if (!self::isSupported())
{
throw new RuntimeException('Redis Extension is not available',
404);
}
$config = JFactory::getConfig();
$this->_server = array(
'host' =>
$config->get('session_redis_server_host',
'localhost'),
'port' =>
$config->get('session_redis_server_port', 6379),
'persist' =>
$config->get('session_redis_persist', true),
'auth' =>
$config->get('session_redis_server_auth', null),
'db' => (int)
$config->get('session_redis_server_db', 0),
);
// If you are trying to connect to a socket file, ignore the supplied
port
if ($this->_server['host'][0] === '/')
{
$this->_server['port'] = 0;
}
parent::__construct($options);
}
/**
* Register the functions of this class with PHP's session handler
*
* @return void
*
* @since 3.8.0
*/
public function register()
{
if (!empty($this->_server) &&
isset($this->_server['host'],
$this->_server['port']))
{
if (!headers_sent())
{
if ($this->_server['port'] === 0)
{
$path = 'unix://' . $this->_server['host'];
}
else
{
$path = 'tcp://' . $this->_server['host'] .
":" . $this->_server['port'];
}
$persist = isset($this->_server['persist']) ?
$this->_server['persist'] : false;
$db = isset($this->_server['db']) ?
$this->_server['db'] : 0;
$path .= '?persistent=' . (int) $persist .
'&database=' . $db;
if (!empty($this->_server['auth']))
{
$path .= '&auth=' . $this->_server['auth'];
}
ini_set('session.save_path', $path);
ini_set('session.save_handler', 'redis');
}
// This is required if the configuration.php gzip is turned on
ini_set('zlib.output_compression', 'Off');
}
}
/**
* Test to see if the SessionHandler is available.
*
* @return boolean True on success, false otherwise.
*
* @since 3.8.0
*/
public static function isSupported()
{
return extension_loaded('redis') &&
class_exists('Redis');
}
}
storage/wincache.php000064400000002561151165414000010503 0ustar00<?php
/**
* @package Joomla.Platform
* @subpackage Session
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* WINCACHE session storage handler for PHP
*
* @since 1.7.0
* @deprecated 4.0 The CMS' Session classes will be replaced with
the `joomla/session` package
*/
class JSessionStorageWincache extends JSessionStorage
{
/**
* Constructor
*
* @param array $options Optional parameters.
*
* @since 1.7.0
* @throws RuntimeException
*/
public function __construct($options = array())
{
if (!self::isSupported())
{
throw new RuntimeException('Wincache Extension is not
available', 404);
}
parent::__construct($options);
}
/**
* Register the functions of this class with PHP's session handler
*
* @return void
*
* @since 3.0.1
*/
public function register()
{
if (!headers_sent())
{
ini_set('session.save_handler', 'wincache');
}
}
/**
* Test to see if the SessionHandler is available.
*
* @return boolean True on success, false otherwise.
*
* @since 3.0.0
*/
public static function isSupported()
{
return extension_loaded('wincache') &&
function_exists('wincache_ucache_get') &&
!strcmp(ini_get('wincache.ucenabled'), '1');
}
}
storage/xcache.php000064400000004321151165414000010151 0ustar00<?php
/**
* @package Joomla.Platform
* @subpackage Session
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* XCache session storage handler
*
* @since 1.7.0
* @deprecated 4.0 The CMS' Session classes will be replaced with
the `joomla/session` package
*/
class JSessionStorageXcache extends JSessionStorage
{
/**
* Constructor
*
* @param array $options Optional parameters.
*
* @since 1.7.0
* @throws RuntimeException
*/
public function __construct($options = array())
{
if (!self::isSupported())
{
throw new RuntimeException('XCache Extension is not
available', 404);
}
parent::__construct($options);
}
/**
* Read the data for a particular session identifier from the
SessionHandler backend.
*
* @param string $id The session identifier.
*
* @return string The session data.
*
* @since 1.7.0
*/
public function read($id)
{
$sess_id = 'sess_' . $id;
// Check if id exists
if (!xcache_isset($sess_id))
{
return;
}
return (string) xcache_get($sess_id);
}
/**
* Write session data to the SessionHandler backend.
*
* @param string $id The session identifier.
* @param string $sessionData The session data.
*
* @return boolean True on success, false otherwise.
*
* @since 1.7.0
*/
public function write($id, $sessionData)
{
$sess_id = 'sess_' . $id;
return xcache_set($sess_id, $sessionData,
ini_get('session.gc_maxlifetime'));
}
/**
* Destroy the data for a particular session identifier in the
SessionHandler backend.
*
* @param string $id The session identifier.
*
* @return boolean True on success, false otherwise.
*
* @since 1.7.0
*/
public function destroy($id)
{
$sess_id = 'sess_' . $id;
if (!xcache_isset($sess_id))
{
return true;
}
return xcache_unset($sess_id);
}
/**
* Test to see if the SessionHandler is available.
*
* @return boolean True on success, false otherwise.
*
* @since 3.0.0
*/
public static function isSupported()
{
return extension_loaded('xcache');
}
}
storage.php000064400000011506151165414000006721 0ustar00<?php
/**
* @package Joomla.Platform
* @subpackage Session
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Custom session storage handler for PHP
*
* @link
https://www.php.net/manual/en/function.session-set-save-handler.php
* @since 1.7.0
* @deprecated 4.0 The CMS' Session classes will be replaced with
the `joomla/session` package
*/
abstract class JSessionStorage
{
/**
* @var JSessionStorage[] JSessionStorage instances container.
* @since 1.7.3
*/
protected static $instances = array();
/**
* Constructor
*
* @param array $options Optional parameters.
*
* @since 1.7.0
*/
public function __construct($options = array())
{
$this->register($options);
}
/**
* Returns a session storage handler object, only creating it if it
doesn't already exist.
*
* @param string $name The session store to instantiate
* @param array $options Array of options
*
* @return JSessionStorage
*
* @since 1.7.0
* @throws JSessionExceptionUnsupported
*/
public static function getInstance($name = 'none', $options =
array())
{
$name = strtolower(JFilterInput::getInstance()->clean($name,
'word'));
if (empty(self::$instances[$name]))
{
/** @var JSessionStorage $class */
$class = 'JSessionStorage' . ucfirst($name);
if (!class_exists($class))
{
$path = __DIR__ . '/storage/' . $name . '.php';
if (!file_exists($path))
{
throw new JSessionExceptionUnsupported('Unable to load session
storage class: ' . $name);
}
JLoader::register($class, $path);
// The class should now be loaded
if (!class_exists($class))
{
throw new JSessionExceptionUnsupported('Unable to load session
storage class: ' . $name);
}
}
// Validate the session storage is supported on this platform
if (!$class::isSupported())
{
throw new JSessionExceptionUnsupported(sprintf('The %s Session
Storage is not supported on this platform.', $name));
}
self::$instances[$name] = new $class($options);
}
return self::$instances[$name];
}
/**
* Register the functions of this class with PHP's session handler
*
* @return void
*
* @since 1.7.0
*/
public function register()
{
if (!headers_sent())
{
session_set_save_handler(
array($this, 'open'),
array($this, 'close'),
array($this, 'read'),
array($this, 'write'),
array($this, 'destroy'),
array($this, 'gc')
);
}
}
/**
* Open the SessionHandler backend.
*
* @param string $savePath The path to the session object.
* @param string $sessionName The name of the session.
*
* @return boolean True on success, false otherwise.
*
* @since 1.7.0
*/
public function open($savePath, $sessionName)
{
return true;
}
/**
* Close the SessionHandler backend.
*
* @return boolean True on success, false otherwise.
*
* @since 1.7.0
*/
public function close()
{
return true;
}
/**
* Read the data for a particular session identifier from the
* SessionHandler backend.
*
* @param string $id The session identifier.
*
* @return string The session data.
*
* @since 1.7.0
*/
public function read($id)
{
return;
}
/**
* Write session data to the SessionHandler backend.
*
* @param string $id The session identifier.
* @param string $sessionData The session data.
*
* @return boolean True on success, false otherwise.
*
* @since 1.7.0
*/
public function write($id, $sessionData)
{
return true;
}
/**
* Destroy the data for a particular session identifier in the
* SessionHandler backend.
*
* @param string $id The session identifier.
*
* @return boolean True on success, false otherwise.
*
* @since 1.7.0
*/
public function destroy($id)
{
return true;
}
/**
* Garbage collect stale sessions from the SessionHandler backend.
*
* @param integer $maxlifetime The maximum age of a session.
*
* @return boolean True on success, false otherwise.
*
* @since 1.7.0
*/
public function gc($maxlifetime = null)
{
return true;
}
/**
* Test to see if the SessionHandler is available.
*
* @return boolean True on success, false otherwise.
*
* @since 3.0.0
*/
public static function isSupported()
{
return true;
}
/**
* Test to see if the SessionHandler is available.
*
* @return boolean True on success, false otherwise.
*
* @since 1.7.0
* @deprecated 4.0 - Use JSessionStorage::isSupported() instead.
*/
public static function test()
{
JLog::add('JSessionStorage::test() is deprecated. Use
JSessionStorage::isSupported() instead.', JLog::WARNING,
'deprecated');
return static::isSupported();
}
}