File manager - Edit - /home/opticamezl/www/newok/Handler.tar
Back
FilesystemHandler.php 0000644 00000004010 15176305263 0010702 0 ustar 00 <?php /** * Part of the Joomla Framework Session Package * * @copyright Copyright (C) 2005 - 2021 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE */ namespace Joomla\Session\Handler; use Joomla\Session\HandlerInterface; /** * Filesystem session storage handler * * @since 2.0.0 */ class FilesystemHandler extends \SessionHandler implements HandlerInterface { /** * Constructor * * @param string $path Path of directory to save session files. Leave null to use the PHP configured path. * * @since 2.0.0 * @throws \InvalidArgumentException * @throws \RuntimeException */ public function __construct(string $path = '') { $pathConfig = ini_get('session.save_path'); // If the paths are empty, then we can't use this handler if (empty($path) && empty($pathConfig)) { throw new \InvalidArgumentException('Invalid argument $path'); } // If path is empty or equal to the the PHP configured path, set only the handler and use the PHP path directly if (empty($path) || $path === $pathConfig) { if (!headers_sent()) { ini_set('session.save_handler', 'files'); } return; } $baseDir = $path; if ($count = substr_count($path, ';')) { if ($count > 2) { throw new \InvalidArgumentException(sprintf('Invalid argument $path "%s"', $path)); } // Characters after the last semi-colon are the path $baseDir = ltrim(strrchr($path, ';'), ';'); } // Create the directory if it doesn't exist if (!is_dir($baseDir)) { if (!mkdir($baseDir, 0755)) { throw new \RuntimeException(sprintf('Could not create session directory "%s"', $baseDir)); } } if (!headers_sent()) { ini_set('session.save_path', $path); ini_set('session.save_handler', 'files'); } } /** * Test to see if the HandlerInterface is available * * @return boolean True on success, false otherwise * * @since 2.0.0 */ public static function isSupported(): bool { return true; } } ApcuHandler.php 0000644 00000006262 15176305263 0007461 0 ustar 00 <?php /** * Part of the Joomla Framework Session Package * * @copyright Copyright (C) 2005 - 2021 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE */ namespace Joomla\Session\Handler; use Joomla\Session\HandlerInterface; /** * APCu session storage handler * * @since 2.0.0 */ class ApcuHandler implements HandlerInterface { /** * Session ID prefix to avoid naming conflicts * * @var string * @since 2.0.0 */ private $prefix; /** * Constructor * * @param array $options Associative array of options to configure the handler * * @since 2.0.0 */ public function __construct(array $options = []) { // Namespace our session IDs to avoid potential conflicts $this->prefix = $options['prefix'] ?? 'jfw'; } /** * Close the session * * @return boolean True on success, false otherwise * * @since 2.0.0 */ #[\ReturnTypeWillChange] public function close() { return true; } /** * Destroy a session * * @param integer $session_id The session ID being destroyed * * @return boolean True on success, false otherwise * * @since 2.0.0 */ public function destroy($session_id): bool { // The apcu_delete function returns false if the id does not exist return apcu_delete($this->prefix . $session_id) || !apcu_exists($this->prefix . $session_id); } /** * Cleanup old sessions * * @param integer $maxlifetime Sessions that have not updated for the last maxlifetime seconds will be removed * * @return boolean True on success, false otherwise * * @since 2.0.0 */ #[\ReturnTypeWillChange] public function gc($maxlifetime) { return true; } /** * Test to see if the HandlerInterface is available * * @return boolean True on success, false otherwise * * @since 2.0.0 */ public static function isSupported(): bool { $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 === 'cli') { $supported = ini_get('apc.enable_cli'); } return (bool) $supported; } /** * Initialize session * * @param string $save_path The path where to store/retrieve the session * @param string $session_id The session id * * @return boolean True on success, false otherwise * * @since 2.0.0 */ #[\ReturnTypeWillChange] public function open($save_path, $session_id) { return true; } /** * Read session data * * @param string $session_id The session id to read data for * * @return string The session data * * @since 2.0.0 */ #[\ReturnTypeWillChange] public function read($session_id) { return (string) apcu_fetch($this->prefix . $session_id); } /** * Write session data * * @param string $session_id The session id * @param string $session_data The encoded session data * * @return boolean True on success, false otherwise * * @since 2.0.0 */ #[\ReturnTypeWillChange] public function write($session_id, $session_data) { return apcu_store($this->prefix . $session_id, $session_data, ini_get('session.gc_maxlifetime')); } } WincacheHandler.php 0000644 00000001646 15176305263 0010313 0 ustar 00 <?php /** * Part of the Joomla Framework Session Package * * @copyright Copyright (C) 2005 - 2021 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE */ namespace Joomla\Session\Handler; use Joomla\Session\HandlerInterface; /** * Wincache session storage handler * * @since 2.0.0 */ class WincacheHandler extends \SessionHandler implements HandlerInterface { /** * Constructor * * @since 2.0.0 */ public function __construct() { if (!headers_sent()) { ini_set('session.save_handler', 'wincache'); } } /** * Test to see if the HandlerInterface is available * * @return boolean True on success, false otherwise * * @since 2.0.0 */ public static function isSupported(): bool { return \extension_loaded('wincache') && \function_exists('wincache_ucache_get') && !strcmp(ini_get('wincache.ucenabled'), '1'); } } RedisHandler.php 0000644 00000007154 15176305263 0007640 0 ustar 00 <?php /** * Part of the Joomla Framework Session Package * * @copyright Copyright (C) 2005 - 2021 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE */ namespace Joomla\Session\Handler; use Joomla\Session\HandlerInterface; /** * Redis session storage handler * * @since 2.0.0 */ class RedisHandler implements HandlerInterface { /** * Session ID prefix to avoid naming conflicts * * @var string * @since 2.0.0 */ private $prefix; /** * Redis driver * * @var \Redis * @since 2.0.0 */ private $redis; /** * Time to live in seconds * * @var integer * @since 2.0.0 */ private $ttl; /** * Constructor * * @param \Redis $redis A Redis instance * @param array $options Associative array of options to configure the handler * * @since 2.0.0 */ public function __construct(\Redis $redis, array $options = []) { $this->redis = $redis; // Set the default time-to-live based on the Session object's default configuration $this->ttl = isset($options['ttl']) ? (int) $options['ttl'] : 900; // Namespace our session IDs to avoid potential conflicts $this->prefix = $options['prefix'] ?? 'jfw'; } /** * Close the session * * @return boolean True on success, false otherwise * * @since 2.0.0 */ #[\ReturnTypeWillChange] public function close() { // No need to close the connection to Redis server manually. return true; } /** * Destroy a session, called automatically when running session_regenerate_id(). * * @param integer $session_id The session ID being destroyed * * @return boolean True on success, false otherwise * * @since 2.0.0 */ public function destroy($session_id): bool { $this->redis->del($this->prefix . $session_id); // Session callback must have a return value of type bool when session_regenerate_id() is called. return true; } /** * Cleanup old sessions * * @param integer $maxlifetime Sessions that have not updated for the last maxlifetime seconds will be removed * * @return boolean True on success, false otherwise * * @since 2.0.0 */ #[\ReturnTypeWillChange] public function gc($maxlifetime) { return true; } /** * Test to see if the HandlerInterface is available * * @return boolean True on success, false otherwise * * @since 2.0.0 */ public static function isSupported(): bool { return \extension_loaded('redis') && class_exists('Redis'); } /** * Initialize session * * @param string $save_path The path where to store/retrieve the session * @param string $session_id The session id * * @return boolean True on success, false otherwise * * @since 2.0.0 */ #[\ReturnTypeWillChange] public function open($save_path, $session_id) { return true; } /** * Read session data * * @param string $session_id The session id to read data for * * @return string The session data * * @since 2.0.0 */ #[\ReturnTypeWillChange] public function read($session_id) { return $this->redis->get($this->prefix . $session_id) ?: ''; } /** * Write session data * * @param string $session_id The session id * @param string $session_data The encoded session data * * @return boolean True on success, false otherwise * * @since 2.0.0 */ #[\ReturnTypeWillChange] public function write($session_id, $session_data) { if ($this->ttl > 0) { return $this->redis->setex($this->prefix . $session_id, $this->ttl, $session_data); } return $this->redis->set($this->prefix . $session_id, $session_data); } } MemcachedHandler.php 0000644 00000007055 15176305263 0010440 0 ustar 00 <?php /** * Part of the Joomla Framework Session Package * * @copyright Copyright (C) 2005 - 2021 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE */ namespace Joomla\Session\Handler; use Joomla\Session\HandlerInterface; /** * Memcached session storage handler * * @since 2.0.0 */ class MemcachedHandler implements HandlerInterface { /** * Memcached driver * * @var \Memcached * @since 2.0.0 */ private $memcached; /** * Session ID prefix to avoid naming conflicts * * @var string * @since 2.0.0 */ private $prefix; /** * Time to live in seconds * * @var integer * @since 2.0.0 */ private $ttl; /** * Constructor * * @param \Memcached $memcached A Memcached instance * @param array $options Associative array of options to configure the handler * * @since 2.0.0 */ public function __construct(\Memcached $memcached, array $options = []) { $this->memcached = $memcached; // Set the default time-to-live based on the Session object's default configuration $this->ttl = isset($options['ttl']) ? (int) $options['ttl'] : 900; // Namespace our session IDs to avoid potential conflicts $this->prefix = $options['prefix'] ?? 'jfw'; } /** * Close the session * * @return boolean True on success, false otherwise * * @since 2.0.0 */ #[\ReturnTypeWillChange] public function close() { return true; } /** * Destroy a session * * @param integer $session_id The session ID being destroyed * * @return boolean True on success, false otherwise * * @since 2.0.0 */ public function destroy($session_id): bool { return $this->memcached->delete($this->prefix . $session_id); } /** * Cleanup old sessions * * @param integer $maxlifetime Sessions that have not updated for the last maxlifetime seconds will be removed * * @return boolean True on success, false otherwise * * @since 2.0.0 */ #[\ReturnTypeWillChange] public function gc($maxlifetime) { // Memcached manages garbage collection on its own return true; } /** * Test to see if the HandlerInterface is available * * @return boolean True on success, false otherwise * * @since 2.0.0 */ public static function isSupported(): bool { /* * GAE and HHVM have both had instances where Memcached the class was defined but no extension was loaded. * If the class is there, we can assume it works. */ return class_exists('Memcached'); } /** * Initialize session * * @param string $save_path The path where to store/retrieve the session * @param string $session_id The session id * * @return boolean True on success, false otherwise * * @since 2.0.0 */ #[\ReturnTypeWillChange] public function open($save_path, $session_id) { return true; } /** * Read session data * * @param string $session_id The session id to read data for * * @return string The session data * * @since 2.0.0 */ #[\ReturnTypeWillChange] public function read($session_id) { return $this->memcached->get($this->prefix . $session_id) ?: ''; } /** * Write session data * * @param string $session_id The session id * @param string $session_data The encoded session data * * @return boolean True on success, false otherwise * * @since 2.0.0 */ #[\ReturnTypeWillChange] public function write($session_id, $session_data) { return $this->memcached->set($this->prefix . $session_id, $session_data, time() + $this->ttl); } } DatabaseHandler.php 0000644 00000015622 15176305263 0010275 0 ustar 00 <?php /** * Part of the Joomla Framework Session Package * * @copyright Copyright (C) 2005 - 2021 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE */ namespace Joomla\Session\Handler; use Joomla\Database\DatabaseDriver; use Joomla\Database\DatabaseInterface; use Joomla\Database\Exception\ExecutionFailureException; use Joomla\Database\ParameterType; use Joomla\Session\Exception\CreateSessionTableException; use Joomla\Session\Exception\UnsupportedDatabaseDriverException; use Joomla\Session\HandlerInterface; /** * Database session storage handler * * @since 2.0.0 */ class DatabaseHandler implements HandlerInterface { /** * Database connector * * @var DatabaseInterface * @since 2.0.0 */ private $db; /** * Flag whether gc() has been called * * @var boolean * @since 2.0.0 */ private $gcCalled = false; /** * Lifetime for garbage collection * * @var integer * @since 2.0.0 */ private $gcLifetime; /** * Constructor * * @param DatabaseInterface $db Database connector * * @since 2.0.0 */ public function __construct(DatabaseInterface $db) { $this->db = $db; } /** * Close the session * * @return boolean True on success, false otherwise * * @since 2.0.0 */ #[\ReturnTypeWillChange] public function close() { if ($this->gcCalled) { $query = $this->db->getQuery(true) ->delete($this->db->quoteName('#__session')) ->where($this->db->quoteName('time') . ' < ?') ->bind(1, $this->gcLifetime, ParameterType::INTEGER); // Remove expired sessions from the database. $this->db->setQuery($query)->execute(); $this->gcCalled = false; $this->gcLifetime = null; } $this->db->disconnect(); return true; } /** * Creates the session database table * * @return boolean * * @since 2.0.0 * @throws CreateSessionTableException * @throws UnsupportedDatabaseDriverException */ public function createDatabaseTable(): bool { switch ($this->db->getName()) { case 'mysql': case 'mysqli': $filename = 'mysql.sql'; break; case 'postgresql': $filename = 'pgsql.sql'; break; case 'sqlsrv': case 'sqlazure': $filename = 'sqlsrv.sql'; break; case 'sqlite': $filename = 'sqlite.sql'; break; default: throw new UnsupportedDatabaseDriverException(sprintf('The %s database driver is not supported.', $this->db->getName())); } $path = \dirname(__DIR__, 2) . '/meta/sql/' . $filename; if (!is_readable($path)) { throw new CreateSessionTableException( sprintf('Database schema could not be read from %s. Please ensure the file exists and is readable.', $path) ); } $queries = DatabaseDriver::splitSql(file_get_contents($path)); foreach ($queries as $query) { $query = trim($query); if ($query !== '') { try { $this->db->setQuery($query)->execute(); } catch (ExecutionFailureException $exception) { throw new CreateSessionTableException('Failed to create the session table.', 0, $exception); } } } return true; } /** * Destroy a session * * @param integer $session_id The session ID being destroyed * * @return boolean True on success, false otherwise * * @since 2.0.0 */ public function destroy($session_id): bool { try { $query = $this->db->getQuery(true) ->delete($this->db->quoteName('#__session')) ->where($this->db->quoteName('session_id') . ' = ' . $this->db->quote($session_id)); // Remove a session from the database. $this->db->setQuery($query)->execute(); return true; } catch (\Exception $e) { return false; } } /** * Cleanup old sessions * * @param integer $maxlifetime Sessions that have not updated for the last maxlifetime seconds will be removed * * @return boolean True on success, false otherwise * * @since 2.0.0 */ #[\ReturnTypeWillChange] public function gc($maxlifetime) { // We'll delay garbage collection until the session is closed to prevent potential issues mid-cycle $this->gcLifetime = time() - $maxlifetime; $this->gcCalled = true; return true; } /** * Test to see if the HandlerInterface is available * * @return boolean True on success, false otherwise * * @since 2.0.0 */ public static function isSupported(): bool { return interface_exists(DatabaseInterface::class); } /** * Initialize session * * @param string $save_path The path where to store/retrieve the session * @param string $session_id The session id * * @return boolean True on success, false otherwise * * @since 2.0.0 */ #[\ReturnTypeWillChange] public function open($save_path, $session_id) { $this->db->connect(); return true; } /** * Read session data * * @param string $session_id The session id to read data for * * @return string The session data * * @since 2.0.0 */ #[\ReturnTypeWillChange] public function read($session_id) { try { // Get the session data from the database table. $query = $this->db->getQuery(true) ->select($this->db->quoteName('data')) ->from($this->db->quoteName('#__session')) ->where($this->db->quoteName('session_id') . ' = ?') ->bind(1, $session_id); $this->db->setQuery($query); return (string) $this->db->loadResult(); } catch (\Exception $e) { return ''; } } /** * Write session data * * @param string $session_id The session id * @param string $session_data The encoded session data * * @return boolean True on success, false otherwise * * @since 2.0.0 */ #[\ReturnTypeWillChange] public function write($session_id, $session_data) { try { // Figure out if a row exists for the session ID $query = $this->db->getQuery(true) ->select($this->db->quoteName('session_id')) ->from($this->db->quoteName('#__session')) ->where($this->db->quoteName('session_id') . ' = ?') ->bind(1, $session_id); $idExists = $this->db->setQuery($query)->loadResult(); $query = $this->db->getQuery(true); $time = time(); if ($idExists) { $query->update($this->db->quoteName('#__session')) ->set($this->db->quoteName('data') . ' = ?') ->set($this->db->quoteName('time') . ' = ?') ->where($this->db->quoteName('session_id') . ' = ?') ->bind(1, $session_data) ->bind(2, $time, ParameterType::INTEGER) ->bind(3, $session_id); } else { $query->insert($this->db->quoteName('#__session')) ->columns([$this->db->quoteName('data'), $this->db->quoteName('time'), $this->db->quoteName('session_id')]) ->values('?, ?, ?') ->bind(1, $session_data) ->bind(2, $time, ParameterType::INTEGER) ->bind(3, $session_id); } // Try to insert the session data in the database table. $this->db->setQuery($query)->execute(); return true; } catch (\Exception $e) { return false; } } }
| ver. 1.4 |
Github
|
.
| PHP 8.3.23 | Generation time: 0 |
proxy
|
phpinfo
|
Settings