File manager - Edit - /home/opticamezl/www/newok/Storage.zip
Back
PK e#�\OE�� � JoomlaStorage.phpnu �[��� <?php /** * Joomla! Content Management System * * @copyright (C) 2005 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\CMS\Session\Storage; use Joomla\CMS\Factory; use Joomla\Input\Input; use Joomla\Registry\Registry; use Joomla\Session\Storage\NativeStorage; // phpcs:disable PSR1.Files.SideEffects \defined('JPATH_PLATFORM') or die; // phpcs:enable PSR1.Files.SideEffects /** * Service provider for the application's session dependency * * @since 4.0.0 */ class JoomlaStorage extends NativeStorage { /** * Internal data store for the session data * * @var Registry * @since 4.0.0 */ private $data; /** * Force cookies to be SSL only * * @var boolean * @since 4.0.0 */ private $forceSSL = false; /** * Input object * * @var Input * @since 4.0.0 */ private $input; /** * Constructor * * @param Input $input Input object * @param \SessionHandlerInterface $handler Session save handler * @param array $options Session options * * @since 4.0.0 */ public function __construct(Input $input, \SessionHandlerInterface $handler = null, array $options = []) { // Disable transparent sid support and default use cookies $options += [ 'use_cookies' => 1, 'use_trans_sid' => 0, ]; if (!headers_sent() && !$this->isActive()) { session_cache_limiter('none'); } $this->setOptions($options); $this->setHandler($handler); $this->setCookieParams(); $this->data = new Registry(); $this->input = $input; // Register our function as shutdown method, so we can manipulate it register_shutdown_function([$this, 'close']); } /** * Retrieves all variables from the session store * * @return array * * @since 4.0.0 */ public function all(): array { return $this->data->toArray(); } /** * Clears all variables from the session store * * @return void * * @since 4.0.0 */ public function clear(): void { $session_name = $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. */ if (isset($_COOKIE[$session_name])) { $app = Factory::getApplication(); $cookie_domain = $app->get('cookie_domain', ''); $cookie_path = $app->get('cookie_path', '/'); $cookie = session_get_cookie_params(); setcookie($session_name, '', time() - 42000, $cookie_path, $cookie_domain, $cookie['secure'], true); } $this->data = new Registry(); } /** * Writes session data and ends session * * @return void * * @see session_write_close() * @since 4.0.0 */ public function close(): void { // Before storing data to the session, we serialize and encode the Registry $_SESSION['joomla'] = base64_encode(serialize(clone $this->data)); parent::close(); } /** * Get data from the session store * * @param string $name Name of a variable * @param mixed $default Default value of a variable if not set * * @return mixed Value of a variable * * @since 4.0.0 */ public function get(string $name, $default) { if (!$this->isStarted()) { $this->start(); } return $this->data->get($name, $default); } /** * Check whether data exists in the session store * * @param string $name Name of variable * * @return boolean True if the variable exists * * @since 4.0.0 */ public function has(string $name): bool { if (!$this->isStarted()) { $this->start(); } return $this->data->exists($name); } /** * Unset a variable from the session store * * @param string $name Name of variable * * @return mixed The value from session or NULL if not set * * @since 4.0.0 */ public function remove(string $name) { if (!$this->isStarted()) { $this->start(); } $old = $this->data->get($name); unset($this->data[$name]); return $old; } /** * Set data into the session store * * @param string $name Name of a variable. * @param mixed $value Value of a variable. * * @return mixed Old value of a variable. * * @since 4.0.0 */ public function set(string $name, $value = null) { if (!$this->isStarted()) { $this->start(); } $old = $this->data->get($name); $this->data->set($name, $value); return $old; } /** * Set session cookie parameters * * @return void * * @since 4.0.0 */ protected function setCookieParams(): void { if (headers_sent() || $this->isActive()) { return; } $cookie = session_get_cookie_params(); if ($this->forceSSL) { $cookie['secure'] = true; } $app = Factory::getApplication(); if ($app->get('cookie_domain', '') != '') { $cookie['domain'] = $app->get('cookie_domain'); } if ($app->get('cookie_path', '') != '') { $cookie['path'] = $app->get('cookie_path'); } session_set_cookie_params($cookie['lifetime'], $cookie['path'], $cookie['domain'], $cookie['secure'], true); } /** * Sets session options * * @param array $options Session ini directives array(key => value). * * @return $this * * @see http://php.net/session.configuration * @since 4.0.0 */ public function setOptions(array $options): NativeStorage { if (isset($options['force_ssl'])) { $this->forceSSL = (bool) $options['force_ssl']; } return parent::setOptions($options); } /** * Start a session * * @return void * * @since 4.0.0 */ public function start(): void { $session_name = $this->getName(); // Get the cookie object $cookie = $this->input->cookie; if (\is_null($cookie->get($session_name))) { $session_clean = $this->input->getString($session_name); if ($session_clean) { $this->setId($session_clean); $cookie->set($session_name, '', time() - 3600); } } parent::start(); // Try loading data from the session if (isset($_SESSION['joomla']) && !empty($_SESSION['joomla'])) { $this->data = unserialize(base64_decode($_SESSION['joomla'])); } } } PK �]�\��+� � CacheStorageHelper.phpnu �[��� <?php /** * Joomla! Content Management System * * @copyright (C) 2010 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\CMS\Cache\Storage; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; // phpcs:enable PSR1.Files.SideEffects /** * Cache storage helper functions. * * @since 1.7.0 */ class CacheStorageHelper { /** * Cache data group * * @var string * @since 1.7.0 */ public $group = ''; /** * Cached item size * * @var string * @since 1.7.0 */ public $size = 0; /** * Counter * * @var integer * @since 1.7.0 */ public $count = 0; /** * Constructor * * @param string $group The cache data group * * @since 1.7.0 */ public function __construct($group) { $this->group = $group; } /** * Increase cache items count. * * @param string $size Cached item size * * @return void * * @since 1.7.0 */ public function updateSize($size) { $this->size += $size; $this->count++; } } PK �]�\� �Gk k RedisStorage.phpnu �[��� <?php /** * Joomla! Content Management System * * @copyright (C) 2014 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\CMS\Cache\Storage; use Joomla\CMS\Cache\CacheStorage; use Joomla\CMS\Cache\Exception\CacheConnectingException; use Joomla\CMS\Factory; use Joomla\CMS\Log\Log; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; // phpcs:enable PSR1.Files.SideEffects /** * Redis cache storage handler for PECL * * @since 3.4 */ class RedisStorage extends CacheStorage { /** * Redis connection object * * @var \Redis * @since 3.4 */ protected static $_redis = null; /** * Persistent session flag * * @var boolean * @since 3.4 */ protected $_persistent = false; /** * Constructor * * @param array $options Optional parameters. * * @since 3.4 */ public function __construct($options = []) { parent::__construct($options); if (static::$_redis === null) { $this->getConnection(); } } /** * Create the Redis connection * * @return \Redis|boolean Redis connection object on success, boolean on failure * * @since 3.4 * @note As of 4.0 this method will throw a JCacheExceptionConnecting object on connection failure */ protected function getConnection() { if (static::isSupported() == false) { return false; } $app = Factory::getApplication(); $this->_persistent = $app->get('redis_persist', true); $server = [ 'host' => $app->get('redis_server_host', 'localhost'), 'port' => $app->get('redis_server_port', 6379), 'auth' => $app->get('redis_server_auth', null), 'db' => (int) $app->get('redis_server_db', null), ]; // If you are trying to connect to a socket file, ignore the supplied port if ($server['host'][0] === '/') { $server['port'] = 0; } static::$_redis = new \Redis(); try { if ($this->_persistent) { $connection = static::$_redis->pconnect($server['host'], $server['port']); } else { $connection = static::$_redis->connect($server['host'], $server['port']); } } catch (\RedisException $e) { $connection = false; Log::add($e->getMessage(), Log::DEBUG); } if ($connection == false) { static::$_redis = null; throw new CacheConnectingException('Redis connection failed', 500); } try { $auth = $server['auth'] ? static::$_redis->auth($server['auth']) : true; } catch (\RedisException $e) { $auth = false; Log::add($e->getMessage(), Log::DEBUG); } if ($auth === false) { static::$_redis = null; throw new CacheConnectingException('Redis authentication failed', 500); } $select = static::$_redis->select($server['db']); if ($select == false) { static::$_redis = null; throw new CacheConnectingException('Redis failed to select database', 500); } try { static::$_redis->ping(); } catch (\RedisException $e) { static::$_redis = null; throw new CacheConnectingException('Redis ping failed', 500); } return static::$_redis; } /** * Check if the cache contains data stored by ID and group * * @param string $id The cache data ID * @param string $group The cache data group * * @return boolean * * @since 3.7.0 */ public function contains($id, $group) { if (static::isConnected() == false) { return false; } // Redis exists returns integer values lets convert that to boolean see: https://redis.io/commands/exists return (bool) static::$_redis->exists($this->_getCacheId($id, $group)); } /** * Get cached data by ID and group * * @param string $id The cache data ID * @param string $group The cache data group * @param boolean $checkTime True to verify cache time expiration threshold * * @return mixed Boolean false on failure or a cached data object * * @since 3.4 */ public function get($id, $group, $checkTime = true) { if (static::isConnected() == false) { return false; } return static::$_redis->get($this->_getCacheId($id, $group)); } /** * Get all cached data * * @return mixed Boolean false on failure or a cached data object * * @since 3.4 */ public function getAll() { if (static::isConnected() == false) { return false; } $allKeys = static::$_redis->keys('*'); $data = []; $secret = $this->_hash; if (!empty($allKeys)) { foreach ($allKeys as $key) { $namearr = explode('-', $key); if ($namearr !== false && $namearr[0] == $secret && $namearr[1] === 'cache') { $group = $namearr[2]; if (!isset($data[$group])) { $item = new CacheStorageHelper($group); } else { $item = $data[$group]; } $item->updateSize(\strlen($key) * 8); $data[$group] = $item; } } } return $data; } /** * Store the data to cache by ID and group * * @param string $id The cache data ID * @param string $group The cache data group * @param string $data The data to store in cache * * @return boolean * * @since 3.4 */ public function store($id, $group, $data) { if (static::isConnected() == false) { return false; } static::$_redis->setex($this->_getCacheId($id, $group), $this->_lifetime, $data); return true; } /** * Remove a cached data entry by ID and group * * @param string $id The cache data ID * @param string $group The cache data group * * @return boolean * * @since 3.4 */ public function remove($id, $group) { if (static::isConnected() == false) { return false; } return (bool) static::$_redis->del($this->_getCacheId($id, $group)); } /** * Clean cache for a group given a mode. * * group mode : cleans all cache in the group * notgroup mode : cleans all cache not in the group * * @param string $group The cache data group * @param string $mode The mode for cleaning cache [group|notgroup] * * @return boolean * * @since 3.4 */ public function clean($group, $mode = null) { if (static::isConnected() == false) { return false; } $allKeys = static::$_redis->keys('*'); if ($allKeys === false) { $allKeys = []; } $secret = $this->_hash; foreach ($allKeys as $key) { if (strpos($key, $secret . '-cache-' . $group . '-') === 0 && $mode === 'group') { static::$_redis->del($key); } if (strpos($key, $secret . '-cache-' . $group . '-') !== 0 && $mode !== 'group') { static::$_redis->del($key); } } return true; } /** * Test to see if the storage handler is available. * * @return boolean * * @since 3.4 */ public static function isSupported() { return class_exists('\\Redis'); } /** * Test to see if the Redis connection is available. * * @return boolean * * @since 3.4 */ public static function isConnected() { return static::$_redis instanceof \Redis; } } PK �]�\ 'S�\. \. MemcachedStorage.phpnu �[��� <?php /** * Joomla! Content Management System * * @copyright (C) 2012 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\CMS\Cache\Storage; use Joomla\CMS\Cache\Cache; use Joomla\CMS\Cache\CacheStorage; use Joomla\CMS\Cache\Exception\CacheConnectingException; use Joomla\CMS\Factory; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; // phpcs:enable PSR1.Files.SideEffects /** * Memcached cache storage handler * * @link https://www.php.net/manual/en/book.memcached.php * @since 3.0.0 */ class MemcachedStorage extends CacheStorage { /** * Memcached connection object * * @var \Memcached * @since 3.0.0 */ protected static $_db = null; /** * Payload compression level * * @var integer * @since 3.0.0 */ protected $_compress = 0; /** * Constructor * * @param array $options Optional parameters. * * @since 3.0.0 */ public function __construct($options = []) { parent::__construct($options); $this->_compress = Factory::getApplication()->get('memcached_compress', false) ? \Memcached::OPT_COMPRESSION : 0; if (static::$_db === null) { $this->getConnection(); } } /** * Create the Memcached connection * * @return void * * @since 3.0.0 * @throws \RuntimeException */ protected function getConnection() { if (!static::isSupported()) { throw new \RuntimeException('Memcached Extension is not available'); } $app = Factory::getApplication(); $host = $app->get('memcached_server_host', 'localhost'); $port = $app->get('memcached_server_port', 11211); // Create the memcached connection if ($app->get('memcached_persist', true)) { static::$_db = new \Memcached($this->_hash); $servers = static::$_db->getServerList(); if ($servers && ($servers[0]['host'] != $host || $servers[0]['port'] != $port)) { static::$_db->resetServerList(); $servers = []; } if (!$servers) { static::$_db->addServer($host, $port); } } else { static::$_db = new \Memcached(); static::$_db->addServer($host, $port); } static::$_db->setOption(\Memcached::OPT_COMPRESSION, $this->_compress); $stats = static::$_db->getStats(); $result = !empty($stats["$host:$port"]) && $stats["$host:$port"]['pid'] > 0; if (!$result) { // Null out the connection to inform the constructor it will need to attempt to connect if this class is instantiated again static::$_db = null; throw new CacheConnectingException('Could not connect to memcached server'); } } /** * Get a cache_id string from an id/group pair * * @param string $id The cache data id * @param string $group The cache data group * * @return string The cache_id string * * @since 1.7.0 */ protected function _getCacheId($id, $group) { $prefix = Cache::getPlatformPrefix(); $length = \strlen($prefix); $cache_id = parent::_getCacheId($id, $group); if ($length) { // Memcached use suffix instead of prefix $cache_id = substr($cache_id, $length) . strrev($prefix); } return $cache_id; } /** * Check if the cache contains data stored by ID and group * * @param string $id The cache data ID * @param string $group The cache data group * * @return boolean * * @since 3.7.0 */ public function contains($id, $group) { static::$_db->get($this->_getCacheId($id, $group)); return static::$_db->getResultCode() !== \Memcached::RES_NOTFOUND; } /** * Get cached data by ID and group * * @param string $id The cache data ID * @param string $group The cache data group * @param boolean $checkTime True to verify cache time expiration threshold * * @return mixed Boolean false on failure or a cached data object * * @since 3.0.0 */ public function get($id, $group, $checkTime = true) { return static::$_db->get($this->_getCacheId($id, $group)); } /** * Get all cached data * * @return mixed Boolean false on failure or a cached data object * * @since 3.0.0 */ public function getAll() { $keys = static::$_db->get($this->_hash . '-index'); $secret = $this->_hash; $data = []; if (\is_array($keys)) { foreach ($keys as $key) { if (empty($key)) { continue; } $namearr = explode('-', $key->name); if ($namearr !== false && $namearr[0] == $secret && $namearr[1] === 'cache') { $group = $namearr[2]; if (!isset($data[$group])) { $item = new CacheStorageHelper($group); } else { $item = $data[$group]; } $item->updateSize($key->size); $data[$group] = $item; } } } return $data; } /** * Store the data to cache by ID and group * * @param string $id The cache data ID * @param string $group The cache data group * @param string $data The data to store in cache * * @return boolean * * @since 3.0.0 */ public function store($id, $group, $data) { $cache_id = $this->_getCacheId($id, $group); if (!$this->lockindex()) { return false; } $index = static::$_db->get($this->_hash . '-index'); if (!\is_array($index)) { $index = []; } $tmparr = new \stdClass(); $tmparr->name = $cache_id; $tmparr->size = \strlen($data); $index[] = $tmparr; static::$_db->set($this->_hash . '-index', $index, 0); $this->unlockindex(); static::$_db->set($cache_id, $data, $this->_lifetime); return true; } /** * Remove a cached data entry by ID and group * * @param string $id The cache data ID * @param string $group The cache data group * * @return boolean * * @since 3.0.0 */ public function remove($id, $group) { $cache_id = $this->_getCacheId($id, $group); if (!$this->lockindex()) { return false; } $index = static::$_db->get($this->_hash . '-index'); if (\is_array($index)) { foreach ($index as $key => $value) { if ($value->name == $cache_id) { unset($index[$key]); static::$_db->set($this->_hash . '-index', $index, 0); break; } } } $this->unlockindex(); return static::$_db->delete($cache_id); } /** * Clean cache for a group given a mode. * * group mode : cleans all cache in the group * notgroup mode : cleans all cache not in the group * * @param string $group The cache data group * @param string $mode The mode for cleaning cache [group|notgroup] * * @return boolean * * @since 3.0.0 */ public function clean($group, $mode = null) { if (!$this->lockindex()) { return false; } $index = static::$_db->get($this->_hash . '-index'); if (\is_array($index)) { $prefix = $this->_hash . '-cache-' . $group . '-'; foreach ($index as $key => $value) { if (strpos($value->name, $prefix) === 0 xor $mode !== 'group') { static::$_db->delete($value->name); unset($index[$key]); } } static::$_db->set($this->_hash . '-index', $index, 0); } $this->unlockindex(); return true; } /** * Flush all existing items in storage. * * @return boolean * * @since 3.6.3 */ public function flush() { if (!$this->lockindex()) { return false; } return static::$_db->flush(); } /** * Test to see if the storage handler is available. * * @return boolean * * @since 3.0.0 */ public static function isSupported() { /* * 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 support. */ return class_exists('Memcached'); } /** * Lock cached item * * @param string $id The cache data ID * @param string $group The cache data group * @param integer $locktime Cached item max lock time * * @return mixed Boolean false if locking failed or an object containing properties lock and locklooped * * @since 3.0.0 */ public function lock($id, $group, $locktime) { $returning = new \stdClass(); $returning->locklooped = false; $looptime = $locktime * 10; $cache_id = $this->_getCacheId($id, $group); $data_lock = static::$_db->add($cache_id . '_lock', 1, $locktime); if ($data_lock === false) { $lock_counter = 0; // Loop until you find that the lock has been released. // That implies that data get from other thread has finished. while ($data_lock === false) { if ($lock_counter > $looptime) { break; } usleep(100); $data_lock = static::$_db->add($cache_id . '_lock', 1, $locktime); $lock_counter++; } $returning->locklooped = true; } $returning->locked = $data_lock; return $returning; } /** * Unlock cached item * * @param string $id The cache data ID * @param string $group The cache data group * * @return boolean * * @since 3.0.0 */ public function unlock($id, $group = null) { $cache_id = $this->_getCacheId($id, $group) . '_lock'; return static::$_db->delete($cache_id); } /** * Lock cache index * * @return boolean * * @since 3.0.0 */ protected function lockindex() { $looptime = 300; $data_lock = static::$_db->add($this->_hash . '-index_lock', 1, 30); if ($data_lock === false) { $lock_counter = 0; // Loop until you find that the lock has been released. that implies that data get from other thread has finished while ($data_lock === false) { if ($lock_counter > $looptime) { return false; } usleep(100); $data_lock = static::$_db->add($this->_hash . '-index_lock', 1, 30); $lock_counter++; } } return true; } /** * Unlock cache index * * @return boolean * * @since 3.0.0 */ protected function unlockindex() { return static::$_db->delete($this->_hash . '-index_lock'); } } PK �]�\Z$Xc c ApcuStorage.phpnu �[��� <?php /** * Joomla! Content Management System * * @copyright (C) 2016 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\CMS\Cache\Storage; use Joomla\CMS\Cache\CacheStorage; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; // phpcs:enable PSR1.Files.SideEffects /** * APCu cache storage handler * * @link https://www.php.net/manual/en/ref.apcu.php * @since 3.5 */ class ApcuStorage extends CacheStorage { /** * Check if the cache contains data stored by ID and group * * @param string $id The cache data ID * @param string $group The cache data group * * @return boolean * * @since 3.7.0 */ public function contains($id, $group) { return apcu_exists($this->_getCacheId($id, $group)); } /** * Get cached data by ID and group * * @param string $id The cache data ID * @param string $group The cache data group * @param boolean $checkTime True to verify cache time expiration threshold * * @return mixed Boolean false on failure or a cached data object * * @since 3.5 */ public function get($id, $group, $checkTime = true) { return apcu_fetch($this->_getCacheId($id, $group)); } /** * Get all cached data * * @return mixed Boolean false on failure or a cached data object * * @since 3.5 */ public function getAll() { $allinfo = apcu_cache_info(); $keys = $allinfo['cache_list']; $secret = $this->_hash; $data = []; foreach ($keys as $key) { if (isset($key['info'])) { // The internal key name changed with APCu 4.0.7 from key to info $name = $key['info']; } elseif (isset($key['entry_name'])) { // Some APCu modules changed the internal key name from key to entry_name $name = $key['entry_name']; } else { // A fall back for the old internal key name $name = $key['key']; } $namearr = explode('-', $name); if ($namearr !== false && $namearr[0] == $secret && $namearr[1] === 'cache') { $group = $namearr[2]; if (!isset($data[$group])) { $item = new CacheStorageHelper($group); } else { $item = $data[$group]; } $item->updateSize($key['mem_size']); $data[$group] = $item; } } return $data; } /** * Store the data to cache by ID and group * * @param string $id The cache data ID * @param string $group The cache data group * @param string $data The data to store in cache * * @return boolean * * @since 3.5 */ public function store($id, $group, $data) { return apcu_store($this->_getCacheId($id, $group), $data, $this->_lifetime); } /** * Remove a cached data entry by ID and group * * @param string $id The cache data ID * @param string $group The cache data group * * @return boolean * * @since 3.5 */ public function remove($id, $group) { $cache_id = $this->_getCacheId($id, $group); // The apcu_delete function returns false if the ID does not exist if (apcu_exists($cache_id)) { return apcu_delete($cache_id); } return true; } /** * Clean cache for a group given a mode. * * group mode : cleans all cache in the group * notgroup mode : cleans all cache not in the group * * @param string $group The cache data group * @param string $mode The mode for cleaning cache [group|notgroup] * * @return boolean * * @since 3.5 */ public function clean($group, $mode = null) { $allinfo = apcu_cache_info(); $keys = $allinfo['cache_list']; $secret = $this->_hash; foreach ($keys as $key) { if (isset($key['info'])) { // The internal key name changed with APCu 4.0.7 from key to info $internalKey = $key['info']; } elseif (isset($key['entry_name'])) { // Some APCu modules changed the internal key name from key to entry_name $internalKey = $key['entry_name']; } else { // A fall back for the old internal key name $internalKey = $key['key']; } if (strpos($internalKey, $secret . '-cache-' . $group . '-') === 0 xor $mode !== 'group') { apcu_delete($internalKey); } } return true; } /** * Garbage collect expired cache data * * @return boolean * * @since 3.5 */ public function gc() { $allinfo = apcu_cache_info(); $keys = $allinfo['cache_list']; $secret = $this->_hash; foreach ($keys as $key) { if (isset($key['info'])) { // The internal key name changed with APCu 4.0.7 from key to info $internalKey = $key['info']; } elseif (isset($key['entry_name'])) { // Some APCu modules changed the internal key name from key to entry_name $internalKey = $key['entry_name']; } else { // A fall back for the old internal key name $internalKey = $key['key']; } if (strpos($internalKey, $secret . '-cache-')) { apcu_fetch($internalKey); } } return true; } /** * Test to see if the storage handler is available. * * @return boolean * * @since 3.5 */ 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 === 'cli') { $supported = ini_get('apc.enable_cli'); } return (bool) $supported; } /** * Lock cached item * * @param string $id The cache data ID * @param string $group The cache data group * @param integer $locktime Cached item max lock time * * @return mixed Boolean false if locking failed or an object containing properties lock and locklooped * * @since 3.5 */ public function lock($id, $group, $locktime) { $returning = new \stdClass(); $returning->locklooped = false; $looptime = $locktime * 10; $cache_id = $this->_getCacheId($id, $group) . '_lock'; $data_lock = apcu_add($cache_id, 1, $locktime); if ($data_lock === false) { $lock_counter = 0; // Loop until you find that the lock has been released. // That implies that data get from other thread has finished while ($data_lock === false) { if ($lock_counter > $looptime) { $returning->locked = false; $returning->locklooped = true; break; } usleep(100); $data_lock = apcu_add($cache_id, 1, $locktime); $lock_counter++; } } $returning->locked = $data_lock; return $returning; } /** * Unlock cached item * * @param string $id The cache data ID * @param string $group The cache data group * * @return boolean * * @since 3.5 */ public function unlock($id, $group = null) { $cache_id = $this->_getCacheId($id, $group) . '_lock'; // The apcu_delete function returns false if the ID does not exist if (apcu_exists($cache_id)) { return apcu_delete($cache_id); } return true; } } PK �]�\��� � WincacheStorage.phpnu �[��� <?php /** * Joomla! Content Management System * * @copyright (C) 2010 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\CMS\Cache\Storage; use Joomla\CMS\Cache\CacheStorage; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; // phpcs:enable PSR1.Files.SideEffects /** * WinCache cache storage handler * * @link https://www.php.net/manual/en/book.wincache.php * @since 1.7.0 * @deprecated 4.3 will be removed in 6.0 * WinCache is abandoned and not supported from PHP 8 onwards * Will be removed without replacement */ class WincacheStorage extends CacheStorage { /** * Check if the cache contains data stored by ID and group * * @param string $id The cache data ID * @param string $group The cache data group * * @return boolean * * @since 3.7.0 * * @deprecated 4.3 will be removed in 6.0 * Will be removed without replacement */ public function contains($id, $group) { return wincache_ucache_exists($this->_getCacheId($id, $group)); } /** * Get cached data by ID and group * * @param string $id The cache data ID * @param string $group The cache data group * @param boolean $checkTime True to verify cache time expiration threshold * * @return mixed Boolean false on failure or a cached data object * * @since 1.7.0 * * @deprecated 4.3 will be removed in 6.0 * Will be removed without replacement */ public function get($id, $group, $checkTime = true) { return wincache_ucache_get($this->_getCacheId($id, $group)); } /** * Get all cached data * * @return mixed Boolean false on failure or a cached data object * * @since 1.7.0 * * @deprecated 4.3 will be removed in 6.0 * Will be removed without replacement */ public function getAll() { $allinfo = wincache_ucache_info(); $keys = $allinfo['ucache_entries']; $secret = $this->_hash; $data = []; foreach ($keys as $key) { $name = $key['key_name']; $namearr = explode('-', $name); if ($namearr !== false && $namearr[0] == $secret && $namearr[1] === 'cache') { $group = $namearr[2]; if (!isset($data[$group])) { $item = new CacheStorageHelper($group); } else { $item = $data[$group]; } if (isset($key['value_size'])) { $item->updateSize($key['value_size']); } else { // Dummy, WINCACHE version is too low. $item->updateSize(1); } $data[$group] = $item; } } return $data; } /** * Store the data to cache by ID and group * * @param string $id The cache data ID * @param string $group The cache data group * @param string $data The data to store in cache * * @return boolean * * @since 1.7.0 * * @deprecated 4.3 will be removed in 6.0 * Will be removed without replacement */ public function store($id, $group, $data) { return wincache_ucache_set($this->_getCacheId($id, $group), $data, $this->_lifetime); } /** * Remove a cached data entry by ID and group * * @param string $id The cache data ID * @param string $group The cache data group * * @return boolean * * @since 1.7.0 * * @deprecated 4.3 will be removed in 6.0 * Will be removed without replacement */ public function remove($id, $group) { return wincache_ucache_delete($this->_getCacheId($id, $group)); } /** * Clean cache for a group given a mode. * * group mode : cleans all cache in the group * notgroup mode : cleans all cache not in the group * * @param string $group The cache data group * @param string $mode The mode for cleaning cache [group|notgroup] * * @return boolean * * @since 1.7.0 * * @deprecated 4.3 will be removed in 6.0 * Will be removed without replacement */ public function clean($group, $mode = null) { $allinfo = wincache_ucache_info(); $keys = $allinfo['ucache_entries']; $secret = $this->_hash; foreach ($keys as $key) { if (strpos($key['key_name'], $secret . '-cache-' . $group . '-') === 0 xor $mode !== 'group') { wincache_ucache_delete($key['key_name']); } } return true; } /** * Garbage collect expired cache data * * @return boolean * * @since 1.7.0 * * @deprecated 4.3 will be removed in 6.0 * Will be removed without replacement */ public function gc() { $allinfo = wincache_ucache_info(); $keys = $allinfo['ucache_entries']; $secret = $this->_hash; foreach ($keys as $key) { if (strpos($key['key_name'], $secret . '-cache-')) { wincache_ucache_get($key['key_name']); } } return true; } /** * Test to see if the storage handler is available. * * @return boolean * * @since 3.0.0 * * @deprecated 4.3 will be removed in 6.0 * Will be removed without replacement */ public static function isSupported() { return \extension_loaded('wincache') && \function_exists('wincache_ucache_get') && !strcmp(ini_get('wincache.ucenabled'), '1'); } } PK �]�\���v� � FileStorage.phpnu �[��� <?php /** * @package Joomla.Plugin * @subpackage System.Debug * * @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\Plugin\System\Debug\Storage; use Joomla\CMS\Factory; use Joomla\CMS\Filesystem\Folder; use Joomla\CMS\User\UserFactoryInterface; use Joomla\Filesystem\File; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; // phpcs:enable PSR1.Files.SideEffects /** * Stores collected data into files * * @since 4.0.0 */ class FileStorage extends \DebugBar\Storage\FileStorage { /** * Saves collected data * * @param string $id The log id * @param string $data The log data * * @return void * * @since 4.0.0 */ public function save($id, $data) { if (!file_exists($this->dirname)) { Folder::create($this->dirname); } $dataStr = '<?php die(); ?>#(^-^)#' . json_encode($data); File::write($this->makeFilename($id), $dataStr); } /** * Returns collected data with the specified id * * @param string $id The log id * * @return array * * @since 4.0.0 */ public function get($id) { $dataStr = file_get_contents($this->makeFilename($id)); $dataStr = str_replace('<?php die(); ?>#(^-^)#', '', $dataStr); return json_decode($dataStr, true) ?: []; } /** * Returns a metadata about collected data * * @param array $filters Filtering options * @param integer $max The limit, items per page * @param integer $offset The offset * * @return array * * @since 4.0.0 */ public function find(array $filters = [], $max = 20, $offset = 0) { // Loop through all .php files and remember the modified time and id. $files = []; foreach (new \DirectoryIterator($this->dirname) as $file) { if ($file->getExtension() == 'php') { $files[] = [ 'time' => $file->getMTime(), 'id' => $file->getBasename('.php'), ]; } } // Sort the files, newest first usort( $files, function ($a, $b) { if ($a['time'] === $b['time']) { return 0; } return $a['time'] < $b['time'] ? 1 : -1; } ); // Load the metadata and filter the results. $results = []; $i = 0; foreach ($files as $file) { // When filter is empty, skip loading the offset if ($i++ < $offset && empty($filters)) { $results[] = null; continue; } $data = $this->get($file['id']); if (!$this->isSecureToReturnData($data)) { continue; } $meta = $data['__meta']; unset($data); if ($this->filter($meta, $filters)) { $results[] = $meta; } if (\count($results) >= ($max + $offset)) { break; } } return \array_slice($results, $offset, $max); } /** * Get a full path to the file * * @param string $id The log id * * @return string * * @since 4.0.0 */ public function makeFilename($id) { return $this->dirname . basename($id) . '.php'; } /** * Check if the user is allowed to view the request. Users can only see their own requests. * * @param array $data The data item to process * * @return boolean * * @since 4.2.4 */ private function isSecureToReturnData($data): bool { /** * We only started this collector in Joomla 4.2.4 - any older files we have to assume are insecure. */ if (!array_key_exists('juser', $data)) { return false; } $currentUser = Factory::getUser(); $currentUserId = $currentUser->id; $currentUserSuperAdmin = $currentUser->authorise('core.admin'); /** * Guests aren't allowed to look at other requests because there's no guarantee it's the same guest. Potentially * in the future this could be refined to check the session ID to show some requests. But it's unlikely we want * guests to be using the debug bar anyhow */ if ($currentUserId === 0) { return false; } /** @var \Joomla\CMS\User\User $user */ $user = Factory::getContainer()->get(UserFactoryInterface::class) ->loadUserById($data['juser']['user_id']); // Super users are allowed to look at other users requests. Otherwise users can only see their own requests. if ($currentUserSuperAdmin || $user->id === $currentUserId) { return true; } return false; } } PK e#�\OE�� � JoomlaStorage.phpnu �[��� PK �]�\��+� � � CacheStorageHelper.phpnu �[��� PK �]�\� �Gk k "