| Current Path : /home/wuectly/www/03cbe/ |
| Current File : /home/wuectly/www/03cbe/Joomla.zip |
PK �"]����:\ :\ Session/Session.phpnu &1i� <?php
/**
* Part of the Joomla Framework Session Package
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Session;
use Joomla\Event\DispatcherInterface;
use Joomla\Input\Input;
/**
* Class for managing HTTP sessions
*
* Provides access to session-state values as well as session-level
* settings and lifetime management methods.
* Based on the standard PHP session handling mechanism it provides
* more advanced features such as expire timeouts.
*
* @since 1.0
*/
class Session implements \IteratorAggregate
{
/**
* Internal state.
* One of 'inactive'|'active'|'expired'|'destroyed'|'error'
*
* @var string
* @see getState()
* @since 1.0
*/
protected $state = 'inactive';
/**
* Maximum age of unused session in minutes
*
* @var string
* @since 1.0
*/
protected $expire = 15;
/**
* The session store object.
*
* @var Storage
* @since 1.0
*/
protected $store;
/**
* Security policy.
* List of checks that will be done.
*
* Default values:
* - fix_browser
* - fix_adress
*
* @var array
* @since 1.0
*/
protected $security = array('fix_browser');
/**
* Force cookies to be SSL only
* Default false
*
* @var boolean
* @since 1.0
*/
protected $force_ssl = false;
/**
* The domain to use when setting cookies.
*
* @var mixed
* @since 1.0
* @deprecated 2.0
*/
protected $cookie_domain;
/**
* The path to use when setting cookies.
*
* @var mixed
* @since 1.0
* @deprecated 2.0
*/
protected $cookie_path;
/**
* The configuration of the HttpOnly cookie.
*
* @var mixed
* @since 1.5.0
* @deprecated 2.0
*/
protected $cookie_httponly = true;
/**
* The configuration of the SameSite cookie.
*
* @var mixed
* @since 1.5.0
* @deprecated 2.0
*/
protected $cookie_samesite;
/**
* Session instances container.
*
* @var Session
* @since 1.0
* @deprecated 2.0
*/
protected static $instance;
/**
* The type of storage for the session.
*
* @var string
* @since 1.0
* @deprecated 2.0
*/
protected $storeName;
/**
* Holds the Input object
*
* @var Input
* @since 1.0
*/
private $input;
/**
* Holds the Dispatcher object
*
* @var DispatcherInterface
* @since 1.0
*/
private $dispatcher;
/**
* Constructor
*
* @param string $store The type of storage for the session.
* @param array $options Optional parameters
*
* @since 1.0
*/
public function __construct($store = 'none', array $options = array())
{
// Need to destroy any existing sessions started with session.auto_start
if (session_id())
{
session_unset();
session_destroy();
}
// Disable transparent sid support
ini_set('session.use_trans_sid', '0');
// Only allow the session ID to come from cookies and nothing else.
ini_set('session.use_only_cookies', '1');
// Create handler
$this->store = Storage::getInstance($store, $options);
$this->storeName = $store;
// Set options
$this->_setOptions($options);
$this->_setCookieParams();
$this->setState('inactive');
}
/**
* Magic method to get read-only access to properties.
*
* @param string $name Name of property to retrieve
*
* @return mixed The value of the property
*
* @since 1.0
* @deprecated 2.0 Use get methods for non-deprecated properties
*/
public function __get($name)
{
if ($name === 'storeName' || $name === 'state' || $name === 'expire')
{
return $this->$name;
}
}
/**
* Returns the global Session object, only creating it
* if it doesn't already exist.
*
* @param string $handler The type of session handler.
* @param array $options An array of configuration options (for new sessions only).
*
* @return Session The Session object.
*
* @since 1.0
* @deprecated 2.0 A singleton object store will no longer be supported
*/
public static function getInstance($handler, array $options = array())
{
if (!\is_object(self::$instance))
{
self::$instance = new self($handler, $options);
}
return self::$instance;
}
/**
* Get current state of session
*
* @return string The session state
*
* @since 1.0
*/
public function getState()
{
return $this->state;
}
/**
* Get expiration time in minutes
*
* @return integer The session expiration time in minutes
*
* @since 1.0
*/
public function getExpire()
{
return $this->expire;
}
/**
* Get a session token, if a token isn't set yet one will be generated.
*
* Tokens are used to secure forms from spamming attacks. Once a token
* has been generated the system will check the post request to see if
* it is present, if not it will invalidate the session.
*
* @param boolean $forceNew If true, force a new token to be created
*
* @return string The session token
*
* @since 1.0
*/
public function getToken($forceNew = false)
{
$token = $this->get('session.token');
// Create a token
if ($token === null || $forceNew)
{
$token = $this->_createToken();
$this->set('session.token', $token);
}
return $token;
}
/**
* Method to determine if a token exists in the session. If not the
* session will be set to expired
*
* @param string $tCheck Hashed token to be verified
* @param boolean $forceExpire If true, expires the session
*
* @return boolean
*
* @since 1.0
*/
public function hasToken($tCheck, $forceExpire = true)
{
// Check if a token exists in the session
$tStored = $this->get('session.token');
// Check token
if (($tStored !== $tCheck))
{
if ($forceExpire)
{
$this->setState('expired');
}
return false;
}
return true;
}
/**
* Retrieve an external iterator.
*
* @return \ArrayIterator Return an ArrayIterator of $_SESSION.
*
* @since 1.0
*/
public function getIterator()
{
return new \ArrayIterator($_SESSION);
}
/**
* Get session name
*
* @return string The session name
*
* @since 1.0
*/
public function getName()
{
if ($this->getState() === 'destroyed')
{
// @codingStandardsIgnoreLine
return;
}
return session_name();
}
/**
* Get session id
*
* @return string The session name
*
* @since 1.0
*/
public function getId()
{
if ($this->getState() === 'destroyed')
{
// @codingStandardsIgnoreLine
return;
}
return session_id();
}
/**
* Get the session handlers
*
* @return array An array of available session handlers
*
* @since 1.0
* @deprecated 2.0 The Storage class chain will be removed
*/
public static function getStores()
{
$connectors = array();
// Get an iterator and loop trough the driver classes.
$iterator = new \DirectoryIterator(__DIR__ . '/Storage');
foreach ($iterator as $file)
{
$fileName = $file->getFilename();
// Only load for php files.
if (!$file->isFile() || $file->getExtension() != 'php')
{
continue;
}
// Derive the class name from the type.
$class = str_ireplace('.php', '', '\\Joomla\\Session\\Storage\\' . ucfirst(trim($fileName)));
// If the class doesn't exist we have nothing left to do but look at the next type. We did our best.
if (!class_exists($class))
{
continue;
}
// Sweet! Our class exists, so now we just need to know if it passes its test method.
if ($class::isSupported())
{
// Connector names should not have file extensions.
$connectors[] = str_ireplace('.php', '', $fileName);
}
}
return $connectors;
}
/**
* Shorthand to check if the session is active
*
* @return boolean
*
* @since 1.0
*/
public function isActive()
{
return (bool) ($this->getState() == 'active');
}
/**
* Check whether this session is currently created
*
* @return boolean True on success.
*
* @since 1.0
*/
public function isNew()
{
$counter = $this->get('session.counter');
return (bool) ($counter === 1);
}
/**
* Check whether this session is currently created
*
* @param Input $input Input object for the session to use.
* @param DispatcherInterface $dispatcher Dispatcher object for the session to use.
*
* @return void
*
* @since 1.0
* @deprecated 2.0 In 2.0 the DispatcherInterface should be injected via the object constructor
*/
public function initialise(Input $input, DispatcherInterface $dispatcher = null)
{
$this->input = $input;
$this->dispatcher = $dispatcher;
}
/**
* Get data from the session store
*
* @param string $name Name of a variable
* @param mixed $default Default value of a variable if not set
* @param string $namespace Namespace to use, default to 'default' {@deprecated 2.0 Namespace support will be removed.}
*
* @return mixed Value of a variable
*
* @since 1.0
*/
public function get($name, $default = null, $namespace = 'default')
{
// Add prefix to namespace to avoid collisions
$namespace = '__' . $namespace;
if ($this->getState() !== 'active' && $this->getState() !== 'expired')
{
return;
}
if (isset($_SESSION[$namespace][$name]))
{
return $_SESSION[$namespace][$name];
}
return $default;
}
/**
* Set data into the session store.
*
* @param string $name Name of a variable.
* @param mixed $value Value of a variable.
* @param string $namespace Namespace to use, default to 'default' {@deprecated 2.0 Namespace support will be removed.}
*
* @return mixed Old value of a variable.
*
* @since 1.0
*/
public function set($name, $value = null, $namespace = 'default')
{
// Add prefix to namespace to avoid collisions
$namespace = '__' . $namespace;
if ($this->getState() !== 'active')
{
return;
}
$old = isset($_SESSION[$namespace][$name]) ? $_SESSION[$namespace][$name] : null;
if ($value === null)
{
unset($_SESSION[$namespace][$name]);
}
else
{
$_SESSION[$namespace][$name] = $value;
}
return $old;
}
/**
* Check whether data exists in the session store
*
* @param string $name Name of variable
* @param string $namespace Namespace to use, default to 'default' {@deprecated 2.0 Namespace support will be removed.}
*
* @return boolean True if the variable exists
*
* @since 1.0
*/
public function has($name, $namespace = 'default')
{
// Add prefix to namespace to avoid collisions.
$namespace = '__' . $namespace;
if ($this->getState() !== 'active')
{
// @codingStandardsIgnoreLine
return;
}
return isset($_SESSION[$namespace][$name]);
}
/**
* Unset data from the session store
*
* @param string $name Name of variable
* @param string $namespace Namespace to use, default to 'default' {@deprecated 2.0 Namespace support will be removed.}
*
* @return mixed The value from session or NULL if not set
*
* @since 1.0
*/
public function clear($name, $namespace = 'default')
{
// Add prefix to namespace to avoid collisions
$namespace = '__' . $namespace;
if ($this->getState() !== 'active')
{
// @TODO :: generated error here
return;
}
$value = null;
if (isset($_SESSION[$namespace][$name]))
{
$value = $_SESSION[$namespace][$name];
unset($_SESSION[$namespace][$name]);
}
return $value;
}
/**
* Start a session.
*
* @return void
*
* @since 1.0
*/
public function start()
{
if ($this->getState() === 'active')
{
return;
}
$this->_start();
$this->setState('active');
// Initialise the session
$this->_setCounter();
$this->_setTimers();
// Perform security checks
$this->_validate();
if ($this->dispatcher instanceof DispatcherInterface)
{
$this->dispatcher->triggerEvent('onAfterSessionStart');
}
}
/**
* Start a session.
*
* Creates a session (or resumes the current one based on the state of the session)
*
* @return boolean true on success
*
* @since 1.0
* @deprecated 2.0
*/
protected function _start()
{
// Start session if not started
if ($this->getState() === 'restart')
{
session_regenerate_id(true);
}
else
{
$session_name = session_name();
// Get the Joomla\Input\Cookie object
$cookie = $this->input->cookie;
if ($cookie->get($session_name) === null)
{
$session_clean = $this->input->get($session_name, false, 'string');
if ($session_clean)
{
session_id($session_clean);
$cookie->set($session_name, '', array('expires' => 1));
}
}
}
/**
* Write and Close handlers are called after destructing objects since PHP 5.0.5.
* Thus destructors can use sessions but session handler can't use objects.
* So we are moving session closure before destructing objects.
*
* Replace with session_register_shutdown() when dropping compatibility with PHP 5.3
*/
register_shutdown_function('session_write_close');
session_cache_limiter('none');
session_start();
return true;
}
/**
* Frees all session variables and destroys all data registered to a session
*
* This method resets the $_SESSION variable and destroys all of the data associated
* with the current session in its storage (file or DB). It forces new session to be
* started after this method is called. It does not unset the session cookie.
*
* @return boolean True on success
*
* @see session_destroy()
* @see session_unset()
* @since 1.0
*/
public function destroy()
{
// Session was already destroyed
if ($this->getState() === 'destroyed')
{
return true;
}
/*
* 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.
*/
$cookie = session_get_cookie_params();
$cookieOptions = array(
'expires' => 1,
'path' => $cookie['path'],
'domain' => $cookie['domain'],
'secure' => $cookie['secure'],
'httponly' => true,
);
if (isset($cookie['samesite']))
{
$cookieOptions['samesite'] = $cookie['samesite'];
}
$this->input->cookie->set($this->getName(), '', $cookieOptions);
session_unset();
session_destroy();
$this->setState('destroyed');
return true;
}
/**
* Restart an expired or locked session.
*
* @return boolean True on success
*
* @see destroy
* @since 1.0
*/
public function restart()
{
$this->destroy();
if ($this->getState() !== 'destroyed')
{
// @TODO :: generated error here
return false;
}
// Re-register the session handler after a session has been destroyed, to avoid PHP bug
$this->store->register();
$this->setState('restart');
// Regenerate session id
session_regenerate_id(true);
$this->_start();
$this->setState('active');
$this->_validate();
$this->_setCounter();
return true;
}
/**
* Create a new session and copy variables from the old one
*
* @return boolean $result true on success
*
* @since 1.0
*/
public function fork()
{
if ($this->getState() !== 'active')
{
// @TODO :: generated error here
return false;
}
// Keep session config
$cookie = session_get_cookie_params();
// Kill session
session_destroy();
// Re-register the session store after a session has been destroyed, to avoid PHP bug
$this->store->register();
// Restore config
if (version_compare(PHP_VERSION, '7.3', '>='))
{
session_set_cookie_params($cookie);
}
else
{
session_set_cookie_params($cookie['lifetime'], $cookie['path'], $cookie['domain'], $cookie['secure'], $cookie['httponly']);
}
// Restart session with new id
session_regenerate_id(true);
session_start();
return true;
}
/**
* Writes session data and ends session
*
* Session data is usually stored after your script terminated without the need
* to call JSession::close(), but as session data is locked to prevent concurrent
* writes only one script may operate on a session at any time. When using
* framesets together with sessions you will experience the frames loading one
* by one due to this locking. You can reduce the time needed to load all the
* frames by ending the session as soon as all changes to session variables are
* done.
*
* @return void
*
* @see session_write_close()
* @since 1.0
*/
public function close()
{
session_write_close();
}
/**
* Set the session expiration
*
* @param integer $expire Maximum age of unused session in minutes
*
* @return $this
*
* @since 1.3.0
*/
protected function setExpire($expire)
{
$this->expire = $expire;
return $this;
}
/**
* Set the session state
*
* @param string $state Internal state
*
* @return $this
*
* @since 1.3.0
*/
protected function setState($state)
{
$this->state = $state;
return $this;
}
/**
* Set session cookie parameters
*
* @return void
*
* @since 1.0
* @deprecated 2.0
*/
protected function _setCookieParams()
{
$cookie = session_get_cookie_params();
if ($this->force_ssl)
{
$cookie['secure'] = true;
}
if ($this->cookie_domain)
{
$cookie['domain'] = $this->cookie_domain;
}
if ($this->cookie_path)
{
$cookie['path'] = $this->cookie_path;
}
$cookie['httponly'] = $this->cookie_httponly;
if ($this->cookie_samesite)
{
$cookie['samesite'] = $this->cookie_samesite;
}
if (version_compare(PHP_VERSION, '7.3', '>='))
{
session_set_cookie_params($cookie);
}
else
{
session_set_cookie_params($cookie['lifetime'], $cookie['path'], $cookie['domain'], $cookie['secure'], $cookie['httponly']);
}
}
/**
* Create a token-string
*
* @param integer $length Length of string {@deprecated As of 2.0 the session token will be a fixed length}
*
* @return string Generated token
*
* @since 1.0
* @deprecated 2.0 Use createToken instead
*/
protected function _createToken($length = 32)
{
return $this->createToken($length);
}
/**
* Create a token-string
*
* @param integer $length Length of string {@deprecated As of 2.0 the session token will be a fixed length}
*
* @return string Generated token
*
* @since 1.3.1
*/
protected function createToken($length = 32)
{
return bin2hex(random_bytes($length));
}
/**
* Set counter of session usage
*
* @return boolean True on success
*
* @since 1.0
* @deprecated 2.0 Use setCounter instead
*/
protected function _setCounter()
{
return $this->setCounter();
}
/**
* Set counter of session usage
*
* @return boolean True on success
*
* @since 1.3.0
*/
protected function setCounter()
{
$counter = $this->get('session.counter', 0);
++$counter;
$this->set('session.counter', $counter);
return true;
}
/**
* Set the session timers
*
* @return boolean True on success
*
* @since 1.0
* @deprecated 2.0 Use setTimers instead
*/
protected function _setTimers()
{
return $this->setTimers();
}
/**
* Set the session timers
*
* @return boolean True on success
*
* @since 1.3.0
*/
protected function setTimers()
{
if (!$this->has('session.timer.start'))
{
$start = time();
$this->set('session.timer.start', $start);
$this->set('session.timer.last', $start);
$this->set('session.timer.now', $start);
}
$this->set('session.timer.last', $this->get('session.timer.now'));
$this->set('session.timer.now', time());
return true;
}
/**
* Set additional session options
*
* @param array $options List of parameter
*
* @return boolean True on success
*
* @since 1.0
* @deprecated 2.0 Use setOptions instead
*/
protected function _setOptions(array $options)
{
return $this->setOptions($options);
}
/**
* Set additional session options
*
* @param array $options List of parameter
*
* @return boolean True on success
*
* @since 1.3.0
*/
protected function setOptions(array $options)
{
// Set name
if (isset($options['name']))
{
session_name(md5($options['name']));
}
// Set id
if (isset($options['id']))
{
session_id($options['id']);
}
// Set expire time
if (isset($options['expire']))
{
$this->setExpire($options['expire']);
}
// Get security options
if (isset($options['security']))
{
$this->security = explode(',', $options['security']);
}
if (isset($options['force_ssl']))
{
$this->force_ssl = (bool) $options['force_ssl'];
}
if (isset($options['cookie_domain']))
{
$this->cookie_domain = $options['cookie_domain'];
}
if (isset($options['cookie_path']))
{
$this->cookie_path = $options['cookie_path'];
}
if (isset($options['cookie_httponly']))
{
$this->cookie_httponly = (bool) $options['cookie_httponly'];
}
if (isset($options['cookie_samesite']))
{
$this->cookie_samesite = $options['cookie_samesite'];
}
// Sync the session maxlifetime
if (!headers_sent())
{
ini_set('session.gc_maxlifetime', $this->getExpire());
}
return true;
}
/**
* Do some checks for security reason
*
* - timeout check (expire)
* - ip-fixiation
* - browser-fixiation
*
* If one check failed, session data has to be cleaned.
*
* @param boolean $restart Reactivate session
*
* @return boolean True on success
*
* @link http://shiflett.org/articles/the-truth-about-sessions
* @since 1.0
* @deprecated 2.0 Use validate instead
*/
protected function _validate($restart = false)
{
return $this->validate($restart);
}
/**
* Do some checks for security reason
*
* - timeout check (expire)
* - ip-fixiation
* - browser-fixiation
*
* If one check failed, session data has to be cleaned.
*
* @param boolean $restart Reactivate session
*
* @return boolean True on success
*
* @link http://shiflett.org/articles/the-truth-about-sessions
* @since 1.3.0
*/
protected function validate($restart = false)
{
// Allow to restart a session
if ($restart)
{
$this->setState('active');
$this->set('session.client.address', null);
$this->set('session.client.forwarded', null);
$this->set('session.token', null);
}
// Check if session has expired
if ($this->getExpire())
{
$curTime = $this->get('session.timer.now', 0);
$maxTime = $this->get('session.timer.last', 0) + $this->getExpire();
// Empty session variables
if ($maxTime < $curTime)
{
$this->setState('expired');
return false;
}
}
$remoteAddr = $this->input->server->getString('REMOTE_ADDR', '');
// Check for client address
if (\in_array('fix_adress', $this->security) && !empty($remoteAddr) && filter_var($remoteAddr, FILTER_VALIDATE_IP) !== false)
{
$ip = $this->get('session.client.address');
if ($ip === null)
{
$this->set('session.client.address', $remoteAddr);
}
elseif ($remoteAddr !== $ip)
{
$this->setState('error');
return false;
}
}
$xForwardedFor = $this->input->server->getString('HTTP_X_FORWARDED_FOR', '');
// Record proxy forwarded for in the session in case we need it later
if (!empty($xForwardedFor) && filter_var($xForwardedFor, FILTER_VALIDATE_IP) !== false)
{
$this->set('session.client.forwarded', $xForwardedFor);
}
return true;
}
}
PK �"]�P�E �E Session/LICENSEnu &1i� GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.
PK �"]d� � Session/Storage/Apcu.phpnu &1i� <?php
/**
* Part of the Joomla Framework Session Package
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Session\Storage;
use Joomla\Session\Storage;
/**
* APCU session storage handler for PHP
*
* @link https://www.php.net/manual/en/function.session-set-save-handler.php
* @since 1.4.0
* @deprecated 2.0 The Storage class chain will be removed.
*/
class Apcu extends Storage
{
/**
* Constructor
*
* @param array $options Optional parameters
*
* @since 1.4.0
* @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 1.4.0
*/
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 1.4.0
*/
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 1.4.0
*/
public function destroy($id)
{
$sess_id = 'sess_' . $id;
return apcu_delete($sess_id);
}
/**
* Test to see if the SessionHandler is available.
*
* @return boolean True on success, false otherwise.
*
* @since 1.4.0
*/
public static function isSupported()
{
return \extension_loaded('apcu');
}
}
PK �"]SC�� � Session/Storage/None.phpnu &1i� <?php
/**
* Part of the Joomla Framework Session Package
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Session\Storage;
use Joomla\Session\Storage;
/**
* Default PHP configured session handler for Joomla!
*
* @link https://www.php.net/manual/en/function.session-set-save-handler.php
* @since 1.0
* @deprecated 2.0 The Storage class chain will be removed
*/
class None extends Storage
{
/**
* Register the functions of this class with PHP's session handler
*
* @return void
*
* @since 1.0
* @deprecated 2.0
*/
public function register()
{
}
}
PK �"]�\�kl l Session/Storage/Memcache.phpnu &1i� <?php
/**
* Part of the Joomla Framework Session Package
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Session\Storage;
use Joomla\Session\Storage;
/**
* Memcache session storage handler for PHP
*
* @since 1.0
* @deprecated 2.0 The Storage class chain will be removed
*/
class Memcache extends Storage
{
/**
* Container for server data
*
* @var array
* @since 1.0
* @deprecated 2.0
*/
protected $_servers = array();
/**
* Constructor
*
* @param array $options Optional parameters.
*
* @since 1.0
* @throws \RuntimeException
* @deprecated 2.0
*/
public function __construct($options = array())
{
if (!self::isSupported())
{
throw new \RuntimeException('Memcache Extension is not available', 404);
}
// This will be an array of loveliness
// @todo: multiple servers
$this->_servers = array(
array(
'host' => isset($options['memcache_server_host']) ? $options['memcache_server_host'] : 'localhost',
'port' => isset($options['memcache_server_port']) ? $options['memcache_server_port'] : 11211,
),
);
parent::__construct($options);
}
/**
* Register the functions of this class with PHP's session handler
*
* @return void
*
* @since 1.0
* @deprecated 2.0
*/
public function register()
{
if (!headers_sent())
{
ini_set('session.save_path', $this->_servers[0]['host'] . ':' . $this->_servers[0]['port']);
ini_set('session.save_handler', 'memcache');
}
}
/**
* Test to see if the SessionHandler is available.
*
* @return boolean True on success, false otherwise.
*
* @since 1.0
* @deprecated 2.0
*/
public static function isSupported()
{
return \extension_loaded('memcache') && class_exists('Memcache');
}
}
PK �"]���r@ @ Session/Storage/Database.phpnu &1i� <?php
/**
* Part of the Joomla Framework Session Package
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Session\Storage;
use Joomla\Database\DatabaseDriver;
use Joomla\Session\Storage;
/**
* Database session storage handler for PHP
*
* @link https://www.php.net/manual/en/function.session-set-save-handler.php
* @since 1.0
* @deprecated 2.0 The Storage class chain will be removed
*/
class Database extends Storage
{
/**
* The DatabaseDriver to use when querying.
*
* @var DatabaseDriver
* @since 1.0
* @deprecated 2.0
*/
protected $db;
/**
* Constructor
*
* @param array $options Optional parameters. A `dbo` options is required.
*
* @since 1.0
* @throws \RuntimeException
* @deprecated 2.0
*/
public function __construct($options = array())
{
if (isset($options['db']) && ($options['db'] instanceof DatabaseDriver))
{
parent::__construct($options);
$this->db = $options['db'];
}
else
{
throw new \RuntimeException(
sprintf('The %s storage engine requires a `db` option that is an instance of Joomla\\Database\\DatabaseDriver.', __CLASS__)
);
}
}
/**
* 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.0
* @deprecated 2.0
*/
public function read($id)
{
try
{
// Get the session data from the database table.
$query = $this->db->getQuery(true);
$query->select($this->db->quoteName('data'))
->from($this->db->quoteName('#__session'))
->where($this->db->quoteName('session_id') . ' = ' . $this->db->quote($id));
$this->db->setQuery($query);
return (string) $this->db->loadResult();
}
catch (\Exception $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.0
* @deprecated 2.0
*/
public function write($id, $data)
{
try
{
$query = $this->db->getQuery(true);
$query->update($this->db->quoteName('#__session'))
->set($this->db->quoteName('data') . ' = ' . $this->db->quote($data))
->set($this->db->quoteName('time') . ' = ' . $this->db->quote((int) time()))
->where($this->db->quoteName('session_id') . ' = ' . $this->db->quote($id));
// Try to update the session data in the database table.
$this->db->setQuery($query);
if (!$this->db->execute())
{
return false;
}
// Since $this->db->execute did not throw an exception the query was successful.
// Either the data changed, or the data was identical. In either case we are done.
return true;
}
catch (\Exception $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.0
* @deprecated 2.0
*/
public function destroy($id)
{
try
{
$query = $this->db->getQuery(true);
$query->delete($this->db->quoteName('#__session'))
->where($this->db->quoteName('session_id') . ' = ' . $this->db->quote($id));
// Remove a session from the database.
$this->db->setQuery($query);
return (boolean) $this->db->execute();
}
catch (\Exception $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.0
* @deprecated 2.0
*/
public function gc($lifetime = 1440)
{
// Determine the timestamp threshold with which to purge old sessions.
$past = time() - $lifetime;
try
{
$query = $this->db->getQuery(true);
$query->delete($this->db->quoteName('#__session'))
->where($this->db->quoteName('time') . ' < ' . $this->db->quote((int) $past));
// Remove expired sessions from the database.
$this->db->setQuery($query);
return (boolean) $this->db->execute();
}
catch (\Exception $e)
{
return false;
}
}
}
PK �"]�fy�
Session/Storage/Xcache.phpnu &1i� <?php
/**
* Part of the Joomla Framework Session Package
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Session\Storage;
use Joomla\Session\Storage;
/**
* XCache session storage handler
*
* @since 1.0
* @deprecated 2.0 The Storage class chain will be removed
*/
class Xcache extends Storage
{
/**
* Constructor
*
* @param array $options Optional parameters.
*
* @since 1.0
* @throws \RuntimeException
* @deprecated 2.0
*/
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.0
* @deprecated 2.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.0
* @deprecated 2.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.0
* @deprecated 2.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 1.0
* @deprecated 2.0
*/
public static function isSupported()
{
return \extension_loaded('xcache');
}
}
PK �"]��Z� � Session/Storage/Apc.phpnu &1i� <?php
/**
* Part of the Joomla Framework Session Package
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Session\Storage;
use Joomla\Session\Storage;
/**
* APC session storage handler for PHP
*
* @link https://www.php.net/manual/en/function.session-set-save-handler.php
* @since 1.0
* @deprecated 2.0 The Storage class chain will be removed.
*/
class Apc extends Storage
{
/**
* Constructor
*
* @param array $options Optional parameters
*
* @since 1.0
* @throws \RuntimeException
* @deprecated 2.0
*/
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.0
* @deprecated 2.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.0
* @deprecated 2.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.0
* @deprecated 2.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 1.0
* @deprecated 2.0
*/
public static function isSupported()
{
return \extension_loaded('apc');
}
}
PK �"]I�Eg g Session/Storage/Memcached.phpnu &1i� <?php
/**
* Part of the Joomla Framework Session Package
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Session\Storage;
use Joomla\Session\Storage;
/**
* Memcached session storage handler for PHP
*
* @since 1.0
* @deprecated 2.0 The Storage class chain will be removed
*/
class Memcached extends Storage
{
/**
* Container for server data
*
* @var array
* @since 1.0
* @deprecated 2.0
*/
protected $_servers = array();
/**
* Constructor
*
* @param array $options Optional parameters.
*
* @since 1.0
* @throws \RuntimeException
* @deprecated 2.0
*/
public function __construct($options = array())
{
if (!self::isSupported())
{
throw new \RuntimeException('Memcached Extension is not available', 404);
}
// This will be an array of loveliness
// @todo: multiple servers
$this->_servers = array(
array(
'host' => isset($options['memcache_server_host']) ? $options['memcache_server_host'] : 'localhost',
'port' => isset($options['memcache_server_port']) ? $options['memcache_server_port'] : 11211,
),
);
// Only construct parent AFTER host and port are sent, otherwise when register is called this will fail.
parent::__construct($options);
}
/**
* Register the functions of this class with PHP's session handler
*
* @return void
*
* @since 1.0
* @deprecated 2.0
*/
public function register()
{
if (!headers_sent())
{
ini_set('session.save_path', $this->_servers[0]['host'] . ':' . $this->_servers[0]['port']);
ini_set('session.save_handler', 'memcached');
}
}
/**
* Test to see if the SessionHandler is available.
*
* @return boolean True on success, false otherwise.
*
* @since 1.0
* @deprecated 2.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 it works.
*/
return class_exists('Memcached');
}
}
PK �"]��� � Session/Storage/Wincache.phpnu &1i� <?php
/**
* Part of the Joomla Framework Session Package
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Session\Storage;
use Joomla\Session\Storage;
/**
* WINCACHE session storage handler for PHP
*
* @since 1.0
* @deprecated 2.0 The Storage class chain will be removed
*/
class Wincache extends Storage
{
/**
* Constructor
*
* @param array $options Optional parameters.
*
* @since 1.0
* @throws \RuntimeException
* @deprecated 2.0
*/
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 1.0
* @deprecated 2.0
*/
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 1.0
* @deprecated 2.0
*/
public static function isSupported()
{
return \extension_loaded('wincache') && \function_exists('wincache_ucache_get') && !strcmp(ini_get('wincache.ucenabled'), '1');
}
}
PK �"]�>){� � Session/Storage.phpnu &1i� <?php
/**
* Part of the Joomla Framework Session Package
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Session;
use Joomla\Filter\InputFilter;
/**
* Custom session storage handler for PHP
*
* @link https://www.php.net/manual/en/function.session-set-save-handler.php
* @since 1.0
* @deprecated 2.0 The Storage class chain will be removed.
*/
abstract class Storage
{
/**
* @var Storage[] Storage instances container.
* @since 1.0
* @deprecated 2.0
*/
protected static $instances = array();
/**
* Constructor
*
* @param array $options Optional parameters.
*
* @since 1.0
* @deprecated 2.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 Storage
*
* @since 1.0
* @deprecated 2.0
*/
public static function getInstance($name = 'none', $options = array())
{
$filter = new InputFilter;
$name = strtolower($filter->clean($name, 'word'));
if (empty(self::$instances[$name]))
{
$class = '\\Joomla\\Session\\Storage\\' . ucfirst($name);
if (!class_exists($class))
{
$path = __DIR__ . '/storage/' . $name . '.php';
if (file_exists($path))
{
require_once $path;
}
else
{
// No attempt to die gracefully here, as it tries to close the non-existing session
exit('Unable to load session storage class: ' . $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.0
* @deprecated 2.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.0
* @deprecated 2.0
*/
public function open($savePath, $sessionName)
{
return true;
}
/**
* Close the SessionHandler backend.
*
* @return boolean True on success, false otherwise.
*
* @since 1.0
* @deprecated 2.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.0
* @deprecated 2.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.0
* @deprecated 2.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.0
* @deprecated 2.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.0
* @deprecated 2.0
*/
public function gc($maxlifetime = null)
{
return true;
}
/**
* Test to see if the SessionHandler is available.
*
* @return boolean True on success, false otherwise.
*
* @since 1.0
* @deprecated 2.0
*/
public static function isSupported()
{
return true;
}
}
PK �E"]�~��e e Filesystem.phpnu &1i� <?php
/**
* @package FOF
* @copyright Copyright (c)2010-2020 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 2, or later
*/
namespace FOF30\Platform\Joomla;
defined('_JEXEC') || die;
use Exception;
use FOF30\Container\Container;
use FOF30\Platform\Base\Filesystem as BaseFilesystem;
use JLoader;
use Joomla\CMS\Filesystem\File;
use Joomla\CMS\Filesystem\Folder;
use Joomla\CMS\Filesystem\Path;
use UnexpectedValueException;
/**
* Abstraction for Joomla! filesystem API
*/
class Filesystem extends BaseFilesystem
{
/**
* Does the file exists?
*
* @param $path string Path to the file to test
*
* @return bool
*/
public function fileExists($path)
{
return File::exists($path);
}
/**
* Delete a file or array of files
*
* @param mixed $file The file name or an array of file names
*
* @return boolean True on success
*
*/
public function fileDelete($file)
{
return File::delete($file);
}
/**
* Copies a file
*
* @param string $src The path to the source file
* @param string $dest The path to the destination file
* @param string $path An optional base path to prefix to the file names
* @param boolean $use_streams True to use streams
*
* @return boolean True on success
*/
public function fileCopy($src, $dest, $path = null, $use_streams = false)
{
return File::copy($src, $dest, $path, $use_streams);
}
/**
* Write contents to a file
*
* @param string $file The full file path
* @param string &$buffer The buffer to write
* @param boolean $use_streams Use streams
*
* @return boolean True on success
*/
public function fileWrite($file, &$buffer, $use_streams = false)
{
return File::write($file, $buffer, $use_streams);
}
/**
* Checks for snooping outside of the file system root.
*
* @param string $path A file system path to check.
*
* @return string A cleaned version of the path or exit on error.
*
* @throws Exception
*/
public function pathCheck($path)
{
return Path::check($path);
}
/**
* Function to strip additional / or \ in a path name.
*
* @param string $path The path to clean.
* @param string $ds Directory separator (optional).
*
* @return string The cleaned path.
*
* @throws UnexpectedValueException
*/
public function pathClean($path, $ds = DIRECTORY_SEPARATOR)
{
return Path::clean($path, $ds);
}
/**
* Searches the directory paths for a given file.
*
* @param mixed $paths An path string or array of path strings to search in
* @param string $file The file name to look for.
*
* @return mixed The full path and file name for the target file, or boolean false if the file is not found in
* any of the paths.
*/
public function pathFind($paths, $file)
{
return Path::find($paths, $file);
}
/**
* Wrapper for the standard file_exists function
*
* @param string $path Folder name relative to installation dir
*
* @return boolean True if path is a folder
*/
public function folderExists($path)
{
try
{
return Folder::exists($path);
}
catch (Exception $e)
{
return false;
}
}
/**
* Utility function to read the files in a folder.
*
* @param string $path The path of the folder to read.
* @param string $filter A filter for file names.
* @param mixed $recurse True to recursively search into sub-folders, or an integer to specify the
* maximum depth.
* @param boolean $full True to return the full path to the file.
* @param array $exclude Array with names of files which should not be shown in the result.
* @param array $excludefilter Array of filter to exclude
* @param boolean $naturalSort False for asort, true for natsort
*
* @return array Files in the given folder.
*/
public function folderFiles($path, $filter = '.', $recurse = false, $full = false, $exclude = [
'.svn', 'CVS', '.DS_Store', '__MACOSX',
],
$excludefilter = ['^\..*', '.*~'], $naturalSort = false)
{
// JFolder throws nonsense errors if the path is not a folder
try
{
$path = Path::clean($path);
}
catch (Exception $e)
{
return [];
}
if (!@is_dir($path))
{
return [];
}
// Now call JFolder
return Folder::files($path, $filter, $recurse, $full, $exclude, $excludefilter, $naturalSort);
}
/**
* Utility function to read the folders in a folder.
*
* @param string $path The path of the folder to read.
* @param string $filter A filter for folder names.
* @param mixed $recurse True to recursively search into sub-folders, or an integer to specify the
* maximum depth.
* @param boolean $full True to return the full path to the folders.
* @param array $exclude Array with names of folders which should not be shown in the result.
* @param array $excludefilter Array with regular expressions matching folders which should not be shown in
* the result.
*
* @return array Folders in the given folder.
*/
public function folderFolders($path, $filter = '.', $recurse = false, $full = false, $exclude = [
'.svn', 'CVS', '.DS_Store', '__MACOSX',
],
$excludefilter = ['^\..*'])
{
// JFolder throws idiotic errors if the path is not a folder
try
{
$path = Path::clean($path);
}
catch (Exception $e)
{
return [];
}
if (!@is_dir($path))
{
return [];
}
// Now call JFolder
return Folder::folders($path, $filter, $recurse, $full, $exclude, $excludefilter);
}
/**
* Create a folder -- and all necessary parent folders.
*
* @param string $path A path to create from the base path.
* @param integer $mode Directory permissions to set for folders created. 0755 by default.
*
* @return boolean True if successful.
*/
public function folderCreate($path = '', $mode = 0755)
{
return Folder::create($path, $mode);
}
}
PK �E"]
{��ɏ ɏ Platform.phpnu &1i� <?php
/**
* @package FOF
* @copyright Copyright (c)2010-2020 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 2, or later
*/
namespace FOF30\Platform\Joomla;
defined('_JEXEC') || die;
use ActionlogsModelActionlog;
use Exception;
use FOF30\Container\Container;
use FOF30\Date\Date;
use FOF30\Date\DateDecorator;
use FOF30\Input\Input;
use FOF30\Platform\Base\Platform as BasePlatform;
use JDatabaseDriver;
use JEventDispatcher;
use Joomla\CMS\Application\ApplicationHelper;
use Joomla\CMS\Application\CliApplication as JApplicationCli;
use Joomla\CMS\Application\CMSApplication as JApplicationCms;
use Joomla\CMS\Application\ConsoleApplication;
use Joomla\CMS\Application\WebApplication as JApplicationWeb;
use Joomla\CMS\Authentication\Authentication as JAuthentication;
use Joomla\CMS\Authentication\AuthenticationResponse as JAuthenticationResponse;
use Joomla\CMS\Cache\Cache as JCache;
use Joomla\CMS\Document\Document;
use Joomla\CMS\Document\HtmlDocument;
use Joomla\CMS\Factory;
use Joomla\CMS\Factory as JFactory;
use Joomla\CMS\Language\Language;
use Joomla\CMS\Log\Log;
use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
use Joomla\CMS\MVC\Model\BaseDatabaseModel;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\CMS\Session\Session as JSession;
use Joomla\CMS\Uri\Uri as JUri;
use Joomla\CMS\User\User;
use Joomla\CMS\User\UserHelper;
use Joomla\CMS\Version;
use Joomla\Component\Actionlogs\Administrator\Model\ActionlogModel;
use Joomla\Registry\Registry;
/**
* Part of the FOF Platform Abstraction Layer.
*
* This implements the platform class for Joomla! 3
*
* @since 2.1
*/
class Platform extends BasePlatform
{
/**
* Is this a CLI application?
*
* @var bool
*/
protected static $isCLI = null;
/**
* Is this an administrator application?
*
* @var bool
*/
protected static $isAdmin = null;
/**
* Is this an API application?
*
* @var bool
*/
protected static $isApi = null;
/**
* A fake session storage for CLI apps. This is only used for legacy CLI applications which are not using the FOF
* Base CLI script.
*
* @var Registry
*/
protected static $fakeSession = null;
/**
* The table and table field cache object, used to speed up database access
*
* @var Registry|null
*/
private $_cache = null;
/**
* Public constructor.
*
* Overridden to cater for CLI applications not having access to a session object.
*
* @param Container $c The component container
*/
public function __construct(Container $c)
{
parent::__construct($c);
if ($this->isCli())
{
static::$fakeSession = new Registry();
}
}
/**
* Checks if the current script is run inside a valid CMS execution
*
* @return bool
* @see PlatformInterface::checkExecution()
*
*/
public function checkExecution()
{
return defined('_JEXEC');
}
/**
* Raises an error, using the logic requested by the CMS (PHP Exception or dedicated class)
*
* @param integer $code
* @param string $message
*
* @return void
*
* @throws Exception
*/
public function raiseError($code, $message)
{
$this->showErrorPage(new Exception($message, $code));
}
/**
* Returns absolute path to directories used by the CMS.
*
* @return array A hash array with keys root, public, admin, tmp and log.
* @see PlatformInterface::getPlatformBaseDirs()
*
*/
public function getPlatformBaseDirs()
{
return [
'root' => JPATH_ROOT,
'public' => JPATH_SITE,
'media' => JPATH_SITE . '/media',
'admin' => JPATH_ADMINISTRATOR,
'tmp' => JFactory::getConfig()->get('tmp_path'),
'log' => JFactory::getConfig()->get('log_path'),
];
}
/**
* Returns the base (root) directories for a given component.
*
* @param string $component The name of the component. For Joomla! this
* is something like "com_example"
*
* @return array A hash array with keys main, alt, site and admin.
* @see PlatformInterface::getComponentBaseDirs()
*
*/
public function getComponentBaseDirs($component)
{
if (!$this->isBackend())
{
$mainPath = JPATH_SITE . '/components/' . $component;
$altPath = JPATH_ADMINISTRATOR . '/components/' . $component;
}
else
{
$mainPath = JPATH_ADMINISTRATOR . '/components/' . $component;
$altPath = JPATH_SITE . '/components/' . $component;
}
return [
'main' => $mainPath,
'alt' => $altPath,
'site' => JPATH_SITE . '/components/' . $component,
'admin' => JPATH_ADMINISTRATOR . '/components/' . $component,
];
}
/**
* Returns the application's template name
*
* @param boolean|array $params An optional associative array of configuration settings
*
* @return string The template name. System is the fallback.
*/
public function getTemplate($params = false)
{
return JFactory::getApplication()->getTemplate($params);
}
/**
* Get application-specific suffixes to use with template paths. This allows
* you to look for view template overrides based on the application version.
*
* @return array A plain array of suffixes to try in template names
*/
public function getTemplateSuffixes()
{
$jversion = new Version;
$versionParts = explode('.', $jversion->getShortVersion());
$majorVersion = array_shift($versionParts);
$suffixes = [
'.j' . str_replace('.', '', $jversion->getHelpVersion()),
'.j' . $majorVersion,
];
return $suffixes;
}
/**
* Return the absolute path to the application's template overrides
* directory for a specific component. We will use it to look for template
* files instead of the regular component directories. If the application
* does not have such a thing as template overrides return an empty string.
*
* @param string $component The name of the component for which to fetch the overrides
* @param boolean $absolute Should I return an absolute or relative path?
*
* @return string The path to the template overrides directory
*/
public function getTemplateOverridePath($component, $absolute = true)
{
[$isCli, $isAdmin] = $this->isCliAdmin();
if (!$isCli)
{
if ($absolute)
{
$path = JPATH_THEMES . '/';
}
else
{
$path = $isAdmin ? 'administrator/templates/' : 'templates/';
}
if (substr($component, 0, 7) == 'media:/')
{
$directory = 'media/' . substr($component, 7);
}
else
{
$directory = 'html/' . $component;
}
$path .= $this->getTemplate() .
'/' . $directory;
}
else
{
$path = '';
}
return $path;
}
/**
* Load the translation files for a given component.
*
* @param string $component The name of the component. For Joomla! this
* is something like "com_example"
*
* @return void
* @see PlatformInterface::loadTranslations()
*
*/
public function loadTranslations($component)
{
if ($this->isBackend())
{
$paths = [JPATH_ROOT, JPATH_ADMINISTRATOR];
}
else
{
$paths = [JPATH_ADMINISTRATOR, JPATH_ROOT];
}
$jlang = $this->getLanguage();
$jlang->load($component, $paths[0], 'en-GB', true);
$jlang->load($component, $paths[0], null, true);
$jlang->load($component, $paths[1], 'en-GB', true);
$jlang->load($component, $paths[1], null, true);
}
/**
* Authorise access to the component in the back-end.
*
* @param string $component The name of the component.
*
* @return boolean True to allow loading the component, false to halt loading
* @see PlatformInterface::authorizeAdmin()
*
*/
public function authorizeAdmin($component)
{
if ($this->isBackend())
{
// Master access check for the back-end, Joomla! 1.6 style.
$user = $this->getUser();
if (!$user->authorise('core.manage', $component)
&& !$user->authorise('core.admin', $component)
)
{
return false;
}
}
return true;
}
/**
* Return a user object.
*
* @param integer $id The user ID to load. Skip or use null to retrieve
* the object for the currently logged in user.
*
* @return User The JUser object for the specified user
* @see PlatformInterface::getUser()
*/
public function getUser($id = null)
{
/**
* If I'm in CLI I need load the User directly, otherwise JFactory will check the session (which doesn't exist
* in CLI)
*/
if ($this->isCli())
{
if ($id)
{
return User::getInstance($id);
}
return new User();
}
return JFactory::getUser($id);
}
/**
* Returns the JDocument object which handles this component's response.
*
* @return Document
* @see PlatformInterface::getDocument()
*/
public function getDocument()
{
$document = null;
if (!$this->isCli())
{
try
{
$document = JFactory::getDocument();
}
catch (Exception $exc)
{
$document = null;
}
}
return $document;
}
/**
* Returns an object to handle dates
*
* @param mixed $time The initial time
* @param null $tzOffest The timezone offset
* @param bool $locale Should I try to load a specific class for current language?
*
* @return Date object
*/
public function getDate($time = 'now', $tzOffest = null, $locale = true)
{
if ($locale)
{
// Work around a bug in Joomla! 3.7.0.
if ($time == 'now')
{
$time = time();
}
$coreObject = JFactory::getDate($time, $tzOffest);
return new DateDecorator($coreObject);
}
else
{
return new Date($time, $tzOffest);
}
}
/**
* Return the \JLanguage instance of the CMS/application
*
* @return Language
*/
public function getLanguage()
{
return JFactory::getLanguage();
}
/**
* Returns the database driver object of the CMS/application
*
* @return JDatabaseDriver
*/
public function getDbo()
{
return JFactory::getDbo();
}
/**
* This method will try retrieving a variable from the request (input) data.
*
* @param string $key The user state key for the variable
* @param string $request The request variable name for the variable
* @param Input $input The Input object with the request (input) data
* @param mixed $default The default value. Default: null
* @param string $type The filter type for the variable data. Default: none (no filtering)
* @param boolean $setUserState Should I set the user state with the fetched value?
*
* @return mixed The value of the variable
* @see PlatformInterface::getUserStateFromRequest()
*
*/
public function getUserStateFromRequest($key, $request, $input, $default = null, $type = 'none', $setUserState = true)
{
[$isCLI, $isAdmin] = $this->isCliAdmin();
unset($isAdmin); // Just to make phpStorm happy
if ($isCLI)
{
$ret = $input->get($request, $default, $type);
if ($ret === $default)
{
$input->set($request, $ret);
}
return $ret;
}
$app = JFactory::getApplication();
if (method_exists($app, 'getUserState'))
{
$old_state = $app->getUserState($key, $default);
}
else
{
$old_state = null;
}
$cur_state = (!is_null($old_state)) ? $old_state : $default;
$new_state = $input->get($request, null, $type);
// Save the new value only if it was set in this request
if ($setUserState)
{
if ($new_state !== null)
{
$app->setUserState($key, $new_state);
}
else
{
$new_state = $cur_state;
}
}
elseif (is_null($new_state))
{
$new_state = $cur_state;
}
return $new_state;
}
/**
* Load plugins of a specific type. Obviously this seems to only be required
* in the Joomla! CMS.
*
* @param string $type The type of the plugins to be loaded
*
* @return void
*
* @codeCoverageIgnore
* @see PlatformInterface::importPlugin()
*
*/
public function importPlugin($type)
{
// Should I actually run the plugins?
$runPlugins = $this->isAllowPluginsInCli() || !$this->isCli();
if ($runPlugins)
{
PluginHelper::importPlugin($type);
}
}
/**
* Execute plugins (system-level triggers) and fetch back an array with
* their return values.
*
* @param string $event The event (trigger) name, e.g. onBeforeScratchMyEar
* @param array $data A hash array of data sent to the plugins as part of the trigger
*
* @return array A simple array containing the results of the plugins triggered
*
* @codeCoverageIgnore
* @see PlatformInterface::runPlugins()
*
*/
public function runPlugins($event, $data)
{
// Should I actually run the plugins?
$runPlugins = $this->isAllowPluginsInCli() || !$this->isCli();
if ($runPlugins)
{
// First, try with JEventDispatcher (Joomla 3.x)
if (class_exists('JEventDispatcher'))
{
return JEventDispatcher::getInstance()->trigger($event, $data);
}
// If there's no JEventDispatcher try getting JApplication
try
{
$app = JFactory::getApplication();
}
catch (Exception $e)
{
// If I can't get JApplication I cannot run the plugins.
return [];
}
return $app->triggerEvent($event, $data);
}
else
{
// I am not allowed to run plugins
return [];
}
}
/**
* Perform an ACL check.
*
* @param string $action The ACL privilege to check, e.g. core.edit
* @param string $assetname The asset name to check, typically the component's name
*
* @return boolean True if the user is allowed this action
* @see PlatformInterface::authorise()
*
*/
public function authorise($action, $assetname)
{
if ($this->isCli())
{
return true;
}
$ret = JFactory::getUser()->authorise($action, $assetname);
// Work around Joomla returning null instead of false in some cases.
return $ret ? true : false;
}
/**
* Is this the administrative section of the component?
*
* @return boolean
* @see PlatformInterface::isBackend()
*
*/
public function isBackend()
{
[$isCli, $isAdmin] = $this->isCliAdmin();
return $isAdmin && !$isCli;
}
/**
* Is this the public section of the component?
*
* @return boolean
* @see PlatformInterface::isFrontend()
*
*/
public function isFrontend()
{
[$isCli, $isAdmin] = $this->isCliAdmin();
return !$isAdmin && !$isCli && !$this->isApi();
}
/**
* Is this a component running in a CLI application?
*
* @return boolean
* @see PlatformInterface::isCli()
*
*/
public function isCli()
{
[$isCli, $isAdmin] = $this->isCliAdmin();
return !$isAdmin && $isCli;
}
public function isApi()
{
if (!is_null(static::$isApi))
{
return static::$isApi;
}
[$isCli, $isAdmin] = $this->isCliAdmin();
if (version_compare(JVERSION, '3.999.999', 'le') || $isCli || $isAdmin)
{
static::$isApi = false;
return static::$isApi;
}
try
{
$app = JFactory::getApplication();
static::$isApi = $app->isClient('api');
}
catch (Exception $e)
{
static::$isApi = false;
}
if (static::$isApi)
{
static::$isCLI = false;
static::$isAdmin = false;
}
return static::$isApi;
}
/**
* Is AJAX re-ordering supported? This is 100% Joomla!-CMS specific. All
* other platforms should return false and never ask why.
*
* @return boolean
*
* @codeCoverageIgnore
* @see PlatformInterface::supportsAjaxOrdering()
*
*/
public function supportsAjaxOrdering()
{
return true;
}
/**
* Is the global F0F cache enabled?
*
* @return boolean
*
* @codeCoverageIgnore
*/
public function isGlobalF0FCacheEnabled()
{
return !(defined('JDEBUG') && JDEBUG);
}
/**
* Retrieves data from the cache. This is supposed to be used for system-side
* F0F data, not application data.
*
* @param string $key The key of the data to retrieve
* @param string $default The default value to return if the key is not found or the cache is not populated
*
* @return string The cached value
*/
public function getCache($key, $default = null)
{
$registry = $this->getCacheObject();
return $registry->get($key, $default);
}
/**
* Saves something to the cache. This is supposed to be used for system-wide
* F0F data, not application data.
*
* @param string $key The key of the data to save
* @param string $content The actual data to save
*
* @return boolean True on success
*/
public function setCache($key, $content)
{
$registry = $this->getCacheObject();
$registry->set($key, $content);
return $this->saveCache();
}
/**
* Clears the cache of system-wide F0F data. You are supposed to call this in
* your components' installation script post-installation and post-upgrade
* methods or whenever you are modifying the structure of database tables
* accessed by F0F. Please note that F0F's cache never expires and is not
* purged by Joomla!. You MUST use this method to manually purge the cache.
*
* @return boolean True on success
*/
public function clearCache()
{
$false = false;
$cache = JFactory::getCache('fof', '');
$cache->store($false, 'cache', 'fof');
}
/**
* Returns an object that holds the configuration of the current site.
*
* @return Registry
*
* @codeCoverageIgnore
*/
public function getConfig()
{
return JFactory::getConfig();
}
/**
* logs in a user
*
* @param array $authInfo Authentication information
*
* @return boolean True on success
*/
public function loginUser($authInfo)
{
$options = ['remember' => false];
$response = new JAuthenticationResponse();
$response->type = 'fof';
$response->status = JAuthentication::STATUS_FAILURE;
if (isset($authInfo['username']))
{
$authenticate = JAuthentication::getInstance();
$response = $authenticate->authenticate($authInfo, $options);
}
// Use our own authentication handler, onFOFUserAuthenticate, as a fallback
if ($response->status != JAuthentication::STATUS_SUCCESS)
{
$this->container->platform->importPlugin('user');
$this->container->platform->importPlugin('fof');
$pluginResults = $this->container->platform->runPlugins('onFOFUserAuthenticate', [$authInfo, $options]);
/**
* Loop through all plugin results until we find a successful login. On failure we fall back to Joomla's
* previous authentication response.
*/
foreach ($pluginResults as $result)
{
if (empty($result))
{
continue;
}
if (!is_object($result) || !($result instanceof JAuthenticationResponse))
{
continue;
}
if ($result->status != JAuthentication::STATUS_SUCCESS)
{
continue;
}
$response = $result;
break;
}
}
// User failed to authenticate: maybe he enabled two factor authentication?
// Let's try again "manually", skipping the check vs two factor auth
// Due the big mess with encryption algorithms and libraries, we are doing this extra check only
// if we're in Joomla 2.5.18+ or 3.2.1+
if ($response->status != JAuthentication::STATUS_SUCCESS && method_exists('JUserHelper', 'verifyPassword') && isset($authInfo['username']))
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select($db->qn(['id', 'password']))
->from('#__users')
->where('username=' . $db->quote($authInfo['username']));
$result = $db->setQuery($query)->loadObject();
if ($result)
{
$match = UserHelper::verifyPassword($authInfo['password'], $result->password, $result->id);
if ($match === true)
{
// Bring this in line with the rest of the system
$user = User::getInstance($result->id);
$response->email = $user->email;
$response->fullname = $user->name;
[$isCli, $isAdmin] = $this->isCliAdmin();
if ($isAdmin)
{
$response->language = $user->getParam('admin_language');
}
else
{
$response->language = $user->getParam('language');
}
$response->status = JAuthentication::STATUS_SUCCESS;
$response->error_message = '';
}
}
}
if ($response->status == JAuthentication::STATUS_SUCCESS)
{
$this->importPlugin('user');
$results = $this->runPlugins('onLoginUser', [(array) $response, $options]);
unset($results); // Just to make phpStorm happy
$userid = UserHelper::getUserId($response->username);
$user = $this->getUser($userid);
$session = $this->container->session;
$session->set('user', $user);
return true;
}
return false;
}
/**
* logs out a user
*
* @return boolean True on success
*/
public function logoutUser()
{
$app = JFactory::getApplication();
$user = $this->getUser();
$options = ['remember' => false];
$parameters = [
'username' => $user->username,
'id' => $user->id,
];
// Set clientid in the options array if it hasn't been set already and shared sessions are not enabled.
if (!$app->get('shared_session', '0'))
{
$options['clientid'] = $app->getClientId();
}
$ret = $app->triggerEvent('onUserLogout', [$parameters, $options]);
return !in_array(false, $ret, true);
}
/**
* Add a log file for FOF
*
* @param string $file
*
* @return void
*
* @codeCoverageIgnore
*/
public function logAddLogger($file)
{
Log::addLogger(['text_file' => $file], Log::ALL, ['fof']);
}
/**
* Logs a deprecated practice. In Joomla! this results in the $message being output in the
* deprecated log file, found in your site's log directory.
*
* @param string $message The deprecated practice log message
*
* @return void
*
* @codeCoverageIgnore
*/
public function logDeprecated($message)
{
Log::add($message, Log::WARNING, 'deprecated');
}
/**
* Adds a message to the application's debug log
*
* @param string $message
*
* @return void
*
* @codeCoverageIgnore
*/
public function logDebug($message)
{
Log::add($message, Log::DEBUG, 'fof');
}
/**
* Adds a message
*
* @param string|array $title A title, or an array of additional fields to add to the log entry
* @param string $logText The translation key to the log text
* @param string $extension The name of the extension logging this entry
* @param User|null $user The user the action is being logged for
*
* @return void
*/
public function logUserAction($title, $logText, $extension, $user = null)
{
static $joomlaModelAdded = false;
// Find out which Joomla version I am running under
$isJoomla4 = version_compare(JVERSION, '3.999.999', 'gt');
$isJoomla3 = !$isJoomla4 && version_compare(JVERSION, '3.9.0', 'ge');
// I need Joomla! 3.9 or later
if (!$isJoomla4 && !$isJoomla3)
{
return;
}
/**
* Do not perform user actions logging under CLI and Joomla 3.
*
* In Joomla 3 the ActionlogsModelActionlog always goes through JFactory to get the current user. However, this
* goes through the session which is normally not initialized under CLI – that's why we needed to come up with
* our own CLI implementation to begin with.
*
* Joomla 4 doesn't have that problem. J4 CLI scripts use a CLI-aware session service provider.
*/
if ($isJoomla3 && $this->isCli())
{
return;
}
// Include required Joomla Model. Only applicable on Joomla 3.
if ($isJoomla3 && !$joomlaModelAdded)
{
BaseDatabaseModel::addIncludePath(JPATH_ROOT . '/administrator/components/com_actionlogs/models', 'ActionlogsModel');
$joomlaModelAdded = true;
}
if (is_null($user))
{
$user = $this->getUser();
}
// No log for guest users
if ($user->guest)
{
return;
}
$message = [
'title' => $title,
'username' => $user->username,
'accountlink' => 'index.php?option=com_users&task=user.edit&id=' . $user->id,
];
if (is_array($title))
{
unset ($message['title']);
$message = array_merge($message, $title);
}
if (version_compare(JVERSION, '3.999.999', 'le'))
{
/** @var ActionlogsModelActionlog $model * */
try
{
$model = BaseDatabaseModel::getInstance('Actionlog', 'ActionlogsModel');
}
catch (Exception $e)
{
return;
}
}
else
{
try
{
/** @var MVCFactoryInterface $factory */
$factory = JFactory::getApplication()->bootComponent('com_actionlogs')->getMVCFactory();
/** @var ActionlogModel $model */
$model = $factory->createModel('Actionlog', 'Administrator');
}
catch (Exception $e)
{
return;
}
}
try
{
$model->addLog([$message], $logText, $extension, $user->id);
}
catch (Exception $e)
{
return;
}
}
/**
* Returns the root URI for the request.
*
* @param boolean $pathonly If false, prepend the scheme, host and port information. Default is false.
* @param string $path The path
*
* @return string The root URI string.
*
* @codeCoverageIgnore
*/
public function URIroot($pathonly = false, $path = null)
{
return JUri::root($pathonly, $path);
}
/**
* Returns the base URI for the request.
*
* @param boolean $pathonly If false, prepend the scheme, host and port information. Default is false.
*
* @return string The base URI string
*
* @codeCoverageIgnore
*/
public function URIbase($pathonly = false)
{
return JUri::base($pathonly);
}
/**
* Method to set a response header. If the replace flag is set then all headers
* with the given name will be replaced by the new one (only if the current platform supports header caching)
*
* @param string $name The name of the header to set.
* @param string $value The value of the header to set.
* @param boolean $replace True to replace any headers with the same name.
*
* @return void
*
* @codeCoverageIgnore
*/
public function setHeader($name, $value, $replace = false)
{
JFactory::getApplication()->setHeader($name, $value, $replace);
}
/**
* In platforms that perform header caching, send all headers.
*
* @return void
*
* @codeCoverageIgnore
*/
public function sendHeaders()
{
JFactory::getApplication()->sendHeaders();
}
/**
* Immediately terminate the containing application's execution
*
* @param int $code The result code which should be returned by the application
*
* @return void
*/
public function closeApplication($code = 0)
{
// Necessary workaround for broken System - Page Cache plugin in Joomla! 3.7.0
$this->bugfixJoomlaCachePlugin();
JFactory::getApplication()->close($code);
}
/**
* Perform a redirection to a different page, optionally enqueuing a message for the user.
*
* @param string $url The URL to redirect to
* @param int $status (optional) The HTTP redirection status code, default 303 (See Other)
* @param string $msg (optional) A message to enqueue
* @param string $type (optional) The message type, e.g. 'message' (default), 'warning' or 'error'.
*
* @return void
*
* @throws Exception
*/
public function redirect($url, $status = 303, $msg = '', $type = 'message')
{
// Necessary workaround for broken System - Page Cache plugin in Joomla! 3.7.0
$this->bugfixJoomlaCachePlugin();
$app = JFactory::getApplication();
if (class_exists('JApplicationCms') && class_exists('JApplicationWeb')
&& ($app instanceof JApplicationCms)
&& ($app instanceof JApplicationWeb))
{
// In modern Joomla! versions we have versatility on setting the message and the redirection HTTP code
if (!empty($msg))
{
if (empty($type))
{
$type = 'message';
}
$app->enqueueMessage($msg, $type);
}
$app->redirect($url, $status);
}
/**
* If you're here, you have an ancient Joomla version and we have to use the legacy four parameter method...
* Note that we can't set a custom HTTP code, we can only tell it if it's a permanent redirection or not.
*/
$app->redirect($url, $msg, $type, $status == 301);
}
/**
* Handle an exception in a way that results to an error page. We use this under Joomla! to work around a bug in
* Joomla! 3.7 which results in error pages leading to white pages because Joomla's System - Page Cache plugin is
* broken.
*
* @param Exception $exception The exception to handle
*
* @throws Exception We rethrow the exception
*/
public function showErrorPage(Exception $exception)
{
// Necessary workaround for broken System - Page Cache plugin in Joomla! 3.7.0
$this->bugfixJoomlaCachePlugin();
throw $exception;
}
/**
* Set a variable in the user session
*
* @param string $name The name of the variable to set
* @param string $value (optional) The value to set it to, default is null
* @param string $namespace (optional) The variable's namespace e.g. the component name. Default: 'default'
*
* @return void
*/
public function setSessionVar($name, $value = null, $namespace = 'default')
{
// CLI
if ($this->isCli() && !class_exists('FOFApplicationCLI'))
{
static::$fakeSession->set("$namespace.$name", $value);
return;
}
// Joomla 3
if (version_compare(JVERSION, '3.9999.9999', 'le'))
{
$this->container->session->set($name, $value, $namespace);
}
// Joomla 4
if (empty($namespace))
{
$this->container->session->set($name, $value);
return;
}
$registry = $this->container->session->get('registry');
if (is_null($registry))
{
$registry = new Registry();
$this->container->session->set('registry', $registry);
}
$registry->set($namespace . '.' . $name, $value);
}
/**
* Get a variable from the user session
*
* @param string $name The name of the variable to set
* @param string $default (optional) The default value to return if the variable does not exit, default: null
* @param string $namespace (optional) The variable's namespace e.g. the component name. Default: 'default'
*
* @return mixed
*/
public function getSessionVar($name, $default = null, $namespace = 'default')
{
// CLI
if ($this->isCli() && !class_exists('FOFApplicationCLI'))
{
return static::$fakeSession->get("$namespace.$name", $default);
}
// Joomla 3
if (version_compare(JVERSION, '3.9999.9999', 'le'))
{
return $this->container->session->get($name, $default, $namespace);
}
// Joomla 4
if (empty($namespace))
{
return $this->container->session->get($name, $default);
}
$registry = $this->container->session->get('registry');
if (is_null($registry))
{
$registry = new Registry();
$this->container->session->set('registry', $registry);
}
return $registry->get($namespace . '.' . $name, $default);
}
/**
* Unset a variable from the user session
*
* @param string $name The name of the variable to unset
* @param string $namespace (optional) The variable's namespace e.g. the component name. Default: 'default'
*
* @return void
*/
public function unsetSessionVar($name, $namespace = 'default')
{
$this->setSessionVar($name, null, $namespace);
}
/**
* Return the session token. Two types of tokens can be returned:
*
* Session token ($formToken == false): Used for anti-spam protection of forms. This is specific to a session
* object.
*
* Form token ($formToken == true): A secure hash of the user ID with the session token. Both the session and the
* user are fetched from the application container. They are interpolated with the site's secret and passed
* through MD5, making this harder to spoof than the plain old session token.
*
* @param bool $formToken Should I return a form token?
* @param bool $forceNew Should I force the creation of a new token?
*
* @return mixed
*/
public function getToken($formToken = false, $forceNew = false)
{
// For CLI apps we implement our own fake token system
if ($this->isCli())
{
$token = $this->getSessionVar('session.token');
// Create a token
if (is_null($token) || $forceNew)
{
$token = UserHelper::genRandomPassword(32);
$this->setSessionVar('session.token', $token);
}
if (!$formToken)
{
return $token;
}
$user = $this->getUser();
return ApplicationHelper::getHash($user->id . $token);
}
// Web application, go through the regular Joomla! API.
if ($formToken)
{
return JSession::getFormToken($forceNew);
}
return $this->container->session->getToken($forceNew);
}
/** @inheritDoc */
public function addScriptOptions($key, $value, $merge = true)
{
/** @var HtmlDocument $document */
$document = $this->getDocument();
if (!method_exists($document, 'addScriptOptions'))
{
return;
}
$document->addScriptOptions($key, $value, $merge);
}
/** @inheritDoc */
public function getScriptOptions($key = null)
{
/** @var HtmlDocument $document */
$document = $this->getDocument();
if (!method_exists($document, 'getScriptOptions'))
{
return [];
}
return $document->getScriptOptions($key);
}
/**
* Main function to detect if we're running in a CLI environment and we're admin
*
* @return array isCLI and isAdmin. It's not an associative array, so we can use list().
*/
protected function isCliAdmin()
{
if (is_null(static::$isCLI) && is_null(static::$isAdmin))
{
static::$isCLI = false;
static::$isAdmin = false;
try
{
if (is_null(JFactory::$application))
{
static::$isCLI = true;
static::$isAdmin = false;
return [static::$isCLI, static::$isAdmin];
}
$app = JFactory::getApplication();
static::$isCLI = $app instanceof Exception;
if (class_exists('Joomla\CMS\Application\CliApplication'))
{
static::$isCLI = static::$isCLI || $app instanceof JApplicationCli;
}
if (class_exists('Joomla\CMS\Application\ConsoleApplication'))
{
static::$isCLI = static::$isCLI || ($app instanceof ConsoleApplication);
}
}
catch (Exception $e)
{
static::$isCLI = true;
}
if (static::$isCLI)
{
return [static::$isCLI, static::$isAdmin];
}
try
{
$app = JFactory::getApplication();
}
catch (Exception $e)
{
return [static::$isCLI, static::$isAdmin];
}
if (method_exists($app, 'isAdmin'))
{
static::$isAdmin = $app->isAdmin();
}
elseif (method_exists($app, 'isClient'))
{
static::$isAdmin = $app->isClient('administrator');
}
}
return [static::$isCLI, static::$isAdmin];
}
/**
* Gets a reference to the cache object, loading it from the disk if
* needed.
*
* @param boolean $force Should I forcibly reload the registry?
*
* @return Registry
*/
private function &getCacheObject($force = false)
{
// Check if we have to load the cache file or we are forced to do that
if (is_null($this->_cache) || $force)
{
// Try to get data from Joomla!'s cache
$cache = JFactory::getCache('fof', '');
$this->_cache = $cache->get('cache', 'fof');
$isRegistry = is_object($this->_cache);
if ($isRegistry)
{
$isRegistry = class_exists('JRegistry') ? ($this->_cache instanceof Registry) : ($this->_cache instanceof Registry);
}
if (!$isRegistry)
{
// Create a new Registry object
$this->_cache = class_exists('JRegistry') ? new Registry() : new Registry();
}
}
return $this->_cache;
}
/**
* Save the cache object back to disk
*
* @return boolean True on success
*/
private function saveCache()
{
// Get the Registry object of our cached data
$registry = $this->getCacheObject();
$cache = JFactory::getCache('fof', '');
return $cache->store($registry, 'cache', 'fof');
}
/**
* Joomla! 3.7 has a broken System - Page Cache plugin. When this plugin is enabled it FORCES the caching of all
* pages as soon as Joomla! starts loading, before the plugin has a chance to request to not be cached. Event worse,
* in case of a redirection, it doesn't try to remove the cache lock. This means that the next request will be
* treated as though the result of the page should be cached. Since there is NO cache content for the page Joomla!
* returns an empty response with a 200 OK header. This will, of course, get in the way of every single attempt to
* perform a redirection in the frontend of the site.
*/
private function bugfixJoomlaCachePlugin()
{
// Only Joomla! 3.7 and later is broken.
if (version_compare(JVERSION, '3.6.999', 'le'))
{
return;
}
// Only do something when the System - Cache plugin is activated
if (!class_exists('PlgSystemCache'))
{
return;
}
// Forcibly uncache the current request
$options = [
'defaultgroup' => 'page',
'browsercache' => false,
'caching' => false,
];
$cache_key = JUri::getInstance()->toString();
JCache::getInstance('page', $options)->cache->remove($cache_key, 'page');
}
}
PK �"]����:\ :\ Session/Session.phpnu &1i� PK �"]�P�E �E }\ Session/LICENSEnu &1i� PK �"]d� � T� Session/Storage/Apcu.phpnu &1i� PK �"]SC�� � � Session/Storage/None.phpnu &1i� PK �"]�\�kl l >� Session/Storage/Memcache.phpnu &1i� PK �"]���r@ @ �� Session/Storage/Database.phpnu &1i� PK �"]�fy�
�� Session/Storage/Xcache.phpnu &1i� PK �"]��Z� � �� Session/Storage/Apc.phpnu &1i� PK �"]I�Eg g �� Session/Storage/Memcached.phpnu &1i� PK �"]��� � �� Session/Storage/Wincache.phpnu &1i� PK �"]�>){� � {� Session/Storage.phpnu &1i� PK �E"]�~��e e v� Filesystem.phpnu &1i� PK �E"]
{��ɏ ɏ Platform.phpnu &1i� PK
a �